main: allow disabling of digests

This commit is contained in:
Thomas Schoebel-Theuer 2019-07-23 09:41:42 +02:00 committed by Thomas Schoebel-Theuer
parent e938add256
commit 2d35812d50
3 changed files with 14 additions and 2 deletions

View File

@ -367,7 +367,7 @@ bool log_finalize(struct log_status *logst, int len, void (*endio)(void *private
unsigned char checksum[MARS_DIGEST_SIZE];
check_flags |=
mars_digest(usable_digest_mask,
mars_digest(usable_digest_mask & ~disabled_log_digests,
&used_log_digest,
checksum,
data + logst->payload_offset, len);

View File

@ -384,7 +384,7 @@ __u32 _make_flags(bool verify_mode, bool is_local)
if (is_local)
return available_digest_mask | MREF_NODATA;
return usable_digest_mask | MREF_NODATA;
return (usable_digest_mask & ~disabled_net_digests) | MREF_NODATA;
}

View File

@ -81,6 +81,9 @@
int usable_features_version = 0;
int usable_strategy_version = 0;
__u32 disabled_log_digests = 0;
__u32 disabled_net_digests = 0;
static int _tmp_features_version = OPTIONAL_FEATURES_VERSION;
static int _tmp_strategy_version = OPTIONAL_STRATEGY_VERSION;
@ -5642,6 +5645,15 @@ int make_defaults(void *buf, struct mars_dent *dent)
if (!strcmp(dent->d_name, "sync-limit")) {
sscanf(dent->new_link, "%d", &global_sync_limit);
} else if (!strcmp(dent->d_name, "disabled-log-digests")) {
sscanf(dent->new_link, "0x%x", &disabled_log_digests);
} else if (!strcmp(dent->d_name, "disabled-net-digests")) {
__u32 tmp = 0;
sscanf(dent->new_link, "0x%x", &tmp);
/* at least one digest must remain usable */
tmp &= ~MREF_CHKSUM_MD5_OLD;
disabled_net_digests = tmp;
} else {
MARS_DBG("unimplemented default '%s'\n", dent->d_name);
}