Skip to content

Commit

Permalink
pool: check also signatures during syncing
Browse files Browse the repository at this point in the history
Check also signatures during syncing the poolset,
because it happened that the checksum was correct,
but the signature was invalid.
  • Loading branch information
ldorau committed Apr 9, 2018
1 parent 96a973d commit 4a6cc44
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/libpmempool/replica.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,13 @@ unmap_all_headers(struct pool_set *set)
}

/*
* check_checksums -- (internal) check if checksums are correct for parts in
* a given replica
* check_checksums_and_signatures -- (internal) check if checksums
* and signatures are correct for parts
* in a given replica
*/
static int
check_checksums(struct pool_set *set, struct poolset_health_status *set_hs)
check_checksums_and_signatures(struct pool_set *set,
struct poolset_health_status *set_hs)
{
LOG(3, "set %p, set_hs %p", set, set_hs);
for (unsigned r = 0; r < set->nreplicas; ++r) {
Expand All @@ -524,13 +526,20 @@ check_checksums(struct pool_set *set, struct poolset_health_status *set_hs)
} else {
hdr = HDR(rep, p);
}

if (!util_checksum(hdr, sizeof(*hdr), &hdr->checksum, 0,
POOL_HDR_CSUM_END_OFF)) {
ERR("invalid checksum of pool header");
rep_hs->part[p] |= IS_BROKEN;
} else if (util_is_zeroed(hdr, sizeof(*hdr))) {
rep_hs->part[p] |= IS_BROKEN;
}

enum pool_type type = pool_hdr_get_type(hdr);
if (type == POOL_TYPE_UNKNOWN) {
ERR("invalid signature");
rep_hs->part[p] |= IS_BROKEN;
}
}
}
return 0;
Expand Down Expand Up @@ -1071,8 +1080,11 @@ replica_check_poolset_health(struct pool_set *set,
/* map all headers */
map_all_unbroken_headers(set, set_hs);

/* check if checksums are correct for parts in all replicas */
check_checksums(set, set_hs);
/*
* Check if checksums and signatures are correct for all parts
* in all replicas.
*/
check_checksums_and_signatures(set, set_hs);

/* check if option flags are consistent */
if (check_options(set, set_hs)) {
Expand Down

0 comments on commit 4a6cc44

Please sign in to comment.