diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-11-13 16:08:24 +0900 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-11-13 16:10:37 +0900 |
commit | e302a662e2106d3292609d76886b145960e584e5 (patch) | |
tree | 15c3615d240fce290b53069d2ee2ef7a7839bc3f /src/selftest/allowedips.h | |
parent | e90a1ba20cbbe3d7ed4f6573048569b6b8034934 (diff) |
selftest: allowedips: randomized test mutex update
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/selftest/allowedips.h')
-rw-r--r-- | src/selftest/allowedips.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/selftest/allowedips.h b/src/selftest/allowedips.h index 78b019d..8a568c8 100644 --- a/src/selftest/allowedips.h +++ b/src/selftest/allowedips.h @@ -188,6 +188,7 @@ static __init void *horrible_allowedips_lookup_v6(struct horrible_allowedips *ta static __init bool randomized_test(void) { + DEFINE_MUTEX(mutex); bool ret = false; unsigned int i, j, k, mutate_amount, cidr; struct wireguard_peer **peers, *peer; @@ -216,7 +217,7 @@ static __init bool randomized_test(void) prandom_bytes(ip, 4); cidr = prandom_u32_max(32) + 1; peer = peers[prandom_u32_max(NUM_PEERS)]; - if (allowedips_insert_v4(&t, (struct in_addr *)ip, cidr, peer) < 0) { + if (allowedips_insert_v4(&t, (struct in_addr *)ip, cidr, peer, &mutex) < 0) { pr_info("allowedips random self-test: out of memory\n"); goto free; } @@ -237,7 +238,7 @@ static __init bool randomized_test(void) mutated[k] = (mutated[k] & mutate_mask[k]) | (~mutate_mask[k] & prandom_u32_max(256)); cidr = prandom_u32_max(32) + 1; peer = peers[prandom_u32_max(NUM_PEERS)]; - if (allowedips_insert_v4(&t, (struct in_addr *)mutated, cidr, peer) < 0) { + if (allowedips_insert_v4(&t, (struct in_addr *)mutated, cidr, peer, &mutex) < 0) { pr_info("allowedips random self-test: out of memory\n"); goto free; } @@ -252,7 +253,7 @@ static __init bool randomized_test(void) prandom_bytes(ip, 16); cidr = prandom_u32_max(128) + 1; peer = peers[prandom_u32_max(NUM_PEERS)]; - if (allowedips_insert_v6(&t, (struct in6_addr *)ip, cidr, peer) < 0) { + if (allowedips_insert_v6(&t, (struct in6_addr *)ip, cidr, peer, &mutex) < 0) { pr_info("allowedips random self-test: out of memory\n"); goto free; } @@ -273,7 +274,7 @@ static __init bool randomized_test(void) mutated[k] = (mutated[k] & mutate_mask[k]) | (~mutate_mask[k] & prandom_u32_max(256)); cidr = prandom_u32_max(128) + 1; peer = peers[prandom_u32_max(NUM_PEERS)]; - if (allowedips_insert_v6(&t, (struct in6_addr *)mutated, cidr, peer) < 0) { + if (allowedips_insert_v6(&t, (struct in6_addr *)mutated, cidr, peer, &mutex) < 0) { pr_info("allowedips random self-test: out of memory\n"); goto free; } @@ -307,7 +308,7 @@ static __init bool randomized_test(void) ret = true; free: - allowedips_free(&t); + allowedips_free(&t, &mutex); horrible_allowedips_free(&h); if (peers) { for (i = 0; i < NUM_PEERS; ++i) |