From 0911027c09cf3f734f39f0d3b1bfe4119b73b100 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 9 Oct 2017 02:48:33 +0200 Subject: routingtable: only use device's mutex, not a special rt one --- src/selftest/routingtable.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/selftest') diff --git a/src/selftest/routingtable.h b/src/selftest/routingtable.h index 951eb59..4e30b98 100644 --- a/src/selftest/routingtable.h +++ b/src/selftest/routingtable.h @@ -349,7 +349,7 @@ static __init inline struct in6_addr *ip6(u32 a, u32 b, u32 c, u32 d) } while (0) #define insert(version, mem, ipa, ipb, ipc, ipd, cidr) \ - routing_table_insert_v##version(&t, ip##version(ipa, ipb, ipc, ipd), cidr, mem) + routing_table_insert_v##version(&t, ip##version(ipa, ipb, ipc, ipd), cidr, mem, &mutex) #define maybe_fail \ ++i; \ @@ -370,6 +370,7 @@ static __init inline struct in6_addr *ip6(u32 a, u32 b, u32 c, u32 d) bool __init routing_table_selftest(void) { + DEFINE_MUTEX(mutex); struct routing_table t; struct wireguard_peer *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL, *f = NULL, *g = NULL, *h = NULL; size_t i = 0; @@ -377,6 +378,8 @@ bool __init routing_table_selftest(void) struct in6_addr ip; __be64 part; + mutex_lock(&mutex); + routing_table_init(&t); init_peer(a); init_peer(b); @@ -452,18 +455,18 @@ bool __init routing_table_selftest(void) insert(4, a, 128, 0, 0, 0, 32); insert(4, a, 192, 0, 0, 0, 32); insert(4, a, 255, 0, 0, 0, 32); - routing_table_remove_by_peer(&t, a); + routing_table_remove_by_peer(&t, a, &mutex); test_negative(4, a, 1, 0, 0, 0); test_negative(4, a, 64, 0, 0, 0); test_negative(4, a, 128, 0, 0, 0); test_negative(4, a, 192, 0, 0, 0); test_negative(4, a, 255, 0, 0, 0); - routing_table_free(&t); + routing_table_free(&t, &mutex); routing_table_init(&t); insert(4, a, 192, 168, 0, 0, 16); insert(4, a, 192, 168, 0, 0, 24); - routing_table_remove_by_peer(&t, a); + routing_table_remove_by_peer(&t, a, &mutex); test_negative(4, a, 192, 168, 0, 1); /* These will hit the BUG_ON(len >= 128) in free_node if something goes wrong. */ @@ -471,7 +474,7 @@ bool __init routing_table_selftest(void) part = cpu_to_be64(~(1LLU << (i % 64))); memset(&ip, 0xff, 16); memcpy((u8 *)&ip + (i < 64) * 8, &part, 8); - routing_table_insert_v6(&t, &ip, 128, a); + routing_table_insert_v6(&t, &ip, 128, a, &mutex); } #ifdef DEBUG_RANDOM_TRIE @@ -483,7 +486,7 @@ bool __init routing_table_selftest(void) pr_info("routing table self-tests: pass\n"); free: - routing_table_free(&t); + routing_table_free(&t, &mutex); kfree(a); kfree(b); kfree(c); @@ -492,6 +495,7 @@ free: kfree(f); kfree(g); kfree(h); + mutex_unlock(&mutex); return success; } -- cgit v1.2.3-59-g8ed1b