summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 15:57:59 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 16:35:54 +0200
commit4879a1dbeeaf75bd0d13899b21276afd45ead6db (patch)
tree54b4a74ee4dfa2aa5bd4a5f9bf1f65d56e458b8d /src
parent59ddd348959aa2d52976397e0f0e81335bc502ec (diff)
global: style nits
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/receive.c2
-rw-r--r--src/selftest/allowedips.c49
-rw-r--r--src/selftest/counter.c4
-rw-r--r--src/selftest/ratelimiter.c2
-rw-r--r--src/send.c5
5 files changed, 30 insertions, 32 deletions
diff --git a/src/receive.c b/src/receive.c
index c38a274..95c888d 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -481,7 +481,7 @@ int wg_packet_rx_poll(struct napi_struct *napi, int budget)
packet_consume_data_done(peer, skb, &endpoint);
free = false;
- next:
+next:
wg_noise_keypair_put(keypair, false);
wg_peer_put(peer);
if (unlikely(free))
diff --git a/src/selftest/allowedips.c b/src/selftest/allowedips.c
index 3b095d0..335a93f 100644
--- a/src/selftest/allowedips.c
+++ b/src/selftest/allowedips.c
@@ -282,13 +282,13 @@ static __init bool randomized_test(void)
peers = kcalloc(NUM_PEERS, sizeof(*peers), GFP_KERNEL);
if (unlikely(!peers)) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
for (i = 0; i < NUM_PEERS; ++i) {
peers[i] = kzalloc(sizeof(*peers[i]), GFP_KERNEL);
if (unlikely(!peers[i])) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
kref_init(&peers[i]->refcount);
@@ -302,12 +302,12 @@ static __init bool randomized_test(void)
peer = peers[prandom_u32_max(NUM_PEERS)];
if (wg_allowedips_insert_v4(&t, (struct in_addr *)ip, cidr,
peer, &mutex) < 0) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
if (horrible_allowedips_insert_v4(&h, (struct in_addr *)ip,
cidr, peer) < 0) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
for (j = 0; j < NUM_MUTATED_ROUTES; ++j) {
@@ -329,12 +329,12 @@ static __init bool randomized_test(void)
if (wg_allowedips_insert_v4(&t,
(struct in_addr *)mutated,
cidr, peer, &mutex) < 0) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random malloc: FAIL\n");
goto free;
}
if (horrible_allowedips_insert_v4(&h,
(struct in_addr *)mutated, cidr, peer)) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
}
@@ -346,12 +346,12 @@ static __init bool randomized_test(void)
peer = peers[prandom_u32_max(NUM_PEERS)];
if (wg_allowedips_insert_v6(&t, (struct in6_addr *)ip, cidr,
peer, &mutex) < 0) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
if (horrible_allowedips_insert_v6(&h, (struct in6_addr *)ip,
cidr, peer) < 0) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
for (j = 0; j < NUM_MUTATED_ROUTES; ++j) {
@@ -373,13 +373,13 @@ static __init bool randomized_test(void)
if (wg_allowedips_insert_v6(&t,
(struct in6_addr *)mutated,
cidr, peer, &mutex) < 0) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
if (horrible_allowedips_insert_v6(
&h, (struct in6_addr *)mutated, cidr,
peer)) {
- pr_info("allowedips random self-test: out of memory\n");
+ pr_err("allowedips random self-test malloc: FAIL\n");
goto free;
}
}
@@ -396,7 +396,7 @@ static __init bool randomized_test(void)
prandom_bytes(ip, 4);
if (lookup(t.root4, 32, ip) !=
horrible_allowedips_lookup_v4(&h, (struct in_addr *)ip)) {
- pr_info("allowedips random self-test: FAIL\n");
+ pr_err("allowedips random self-test: FAIL\n");
goto free;
}
}
@@ -405,7 +405,7 @@ static __init bool randomized_test(void)
prandom_bytes(ip, 16);
if (lookup(t.root6, 128, ip) !=
horrible_allowedips_lookup_v6(&h, (struct in6_addr *)ip)) {
- pr_info("allowedips random self-test: FAIL\n");
+ pr_err("allowedips random self-test: FAIL\n");
goto free;
}
}
@@ -481,13 +481,10 @@ static __init int walk_callback(void *ctx, const u8 *ip, u8 cidr, int family)
return 0;
}
-#define init_peer(name) do { \
- name = kzalloc(sizeof(*name), GFP_KERNEL); \
- if (unlikely(!name)) { \
- pr_info("allowedips self-test: out of memory\n"); \
- goto free; \
- } \
- kref_init(&name->refcount); \
+#define init_peer(name) do { \
+ name = kzalloc(sizeof(*name), GFP_KERNEL); \
+ if (name) \
+ kref_init(&name->refcount); \
} while (0)
#define insert(version, mem, ipa, ipb, ipc, ipd, cidr) \
@@ -523,7 +520,7 @@ bool __init wg_allowedips_selftest(void)
{
struct wireguard_peer *a = NULL, *b = NULL, *c = NULL, *d = NULL,
*e = NULL, *f = NULL, *g = NULL, *h = NULL;
- struct allowedips_cursor *cursor;
+ struct allowedips_cursor *cursor = NULL;
struct walk_ctx wctx = { 0 };
bool success = false;
struct allowedips t;
@@ -532,12 +529,6 @@ bool __init wg_allowedips_selftest(void)
size_t i = 0;
__be64 part;
- cursor = kzalloc(sizeof(*cursor), GFP_KERNEL);
- if (!cursor) {
- pr_info("allowedips self-test malloc: FAIL\n");
- return false;
- }
-
mutex_init(&mutex);
mutex_lock(&mutex);
@@ -550,6 +541,12 @@ bool __init wg_allowedips_selftest(void)
init_peer(f);
init_peer(g);
init_peer(h);
+ cursor = kzalloc(sizeof(*cursor), GFP_KERNEL);
+
+ if (!cursor || !a || !b || !c || !d || !e || !f || !g || !h) {
+ pr_err("allowedips self-test malloc: FAIL\n");
+ goto free;
+ }
insert(4, a, 192, 168, 4, 0, 24);
insert(4, b, 192, 168, 4, 4, 32);
diff --git a/src/selftest/counter.c b/src/selftest/counter.c
index 5cb41d1..7e14eeb 100644
--- a/src/selftest/counter.c
+++ b/src/selftest/counter.c
@@ -18,8 +18,8 @@ bool __init wg_packet_counter_selftest(void)
#define T(n, v) do { \
++test_num; \
if (counter_validate(&counter, n) != v) { \
- pr_info("nonce counter self-test %u: FAIL\n", \
- test_num); \
+ pr_err("nonce counter self-test %u: FAIL\n", \
+ test_num); \
success = false; \
} \
} while (0)
diff --git a/src/selftest/ratelimiter.c b/src/selftest/ratelimiter.c
index 2ea7489..0d956e0 100644
--- a/src/selftest/ratelimiter.c
+++ b/src/selftest/ratelimiter.c
@@ -171,7 +171,7 @@ out:
if (ret)
pr_info("ratelimiter self-tests: pass\n");
else
- pr_info("ratelimiter self-test %d: fail\n", test);
+ pr_err("ratelimiter self-test %d: FAIL\n", test);
return ret;
}
diff --git a/src/send.c b/src/send.c
index d4bf1a0..707efbe 100644
--- a/src/send.c
+++ b/src/send.c
@@ -380,8 +380,9 @@ void wg_packet_send_staged_packets(struct wireguard_peer *peer)
* handshake.
*/
skb_queue_walk (&packets, skb) {
- /* 0 for no outer TOS: no leak. TODO: should we use flowi->tos
- * as outer? */
+ /* 0 for no outer TOS: no leak. TODO: at some later point, we
+ * might consider using flowi->tos as outer instead.
+ */
PACKET_CB(skb)->ds = ip_tunnel_ecn_encap(0, ip_hdr(skb), skb);
PACKET_CB(skb)->nonce =
atomic64_inc_return(&key->counter.counter) - 1;