summaryrefslogtreecommitdiffhomepage
path: root/src/selftest/ratelimiter.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-28 03:05:22 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-02 03:41:49 +0200
commita8af31524ad8fb036b03a67823d8372e509b41d9 (patch)
treec89c0b1bf07deda487ac37717969743777236771 /src/selftest/ratelimiter.h
parent09e85633a7c689f8e605f5ae544b83b7940a1437 (diff)
global: prefix all functions with wg_
I understand why this must be done, though I'm not so happy about having to do it. In some places, it puts us over 80 chars and we have to break lines up in further ugly ways. And in general, I think this makes things harder to read. Yet another thing we must do to please upstream. Maybe this can be replaced in the future by some kind of automatic module namespacing logic in the linker, or even combined with LTO and aggressive symbol stripping. Suggested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/selftest/ratelimiter.h')
-rw-r--r--src/selftest/ratelimiter.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/selftest/ratelimiter.h b/src/selftest/ratelimiter.h
index e0c65ea..cf94407 100644
--- a/src/selftest/ratelimiter.h
+++ b/src/selftest/ratelimiter.h
@@ -30,7 +30,7 @@ static __init unsigned int maximum_jiffies_at_index(int index)
return msecs_to_jiffies(total_msecs);
}
-bool __init ratelimiter_selftest(void)
+bool __init wg_ratelimiter_selftest(void)
{
int i, test = 0, tries = 0, ret = false;
unsigned long loop_start_time;
@@ -47,17 +47,17 @@ bool __init ratelimiter_selftest(void)
BUILD_BUG_ON(MSEC_PER_SEC % PACKETS_PER_SECOND != 0);
- if (ratelimiter_init())
+ if (wg_ratelimiter_init())
goto out;
++test;
- if (ratelimiter_init()) {
- ratelimiter_uninit();
+ if (wg_ratelimiter_init()) {
+ wg_ratelimiter_uninit();
goto out;
}
++test;
- if (ratelimiter_init()) {
- ratelimiter_uninit();
- ratelimiter_uninit();
+ if (wg_ratelimiter_init()) {
+ wg_ratelimiter_uninit();
+ wg_ratelimiter_uninit();
goto out;
}
++test;
@@ -104,13 +104,13 @@ restart:
msleep(expected_results[i].msec_to_sleep_before);
ensure_time;
- if (ratelimiter_allow(skb4, &init_net) !=
+ if (wg_ratelimiter_allow(skb4, &init_net) !=
expected_results[i].result)
goto err;
++test;
hdr4->saddr = htonl(ntohl(hdr4->saddr) + i + 1);
ensure_time;
- if (!ratelimiter_allow(skb4, &init_net))
+ if (!wg_ratelimiter_allow(skb4, &init_net))
goto err;
++test;
hdr4->saddr = htonl(ntohl(hdr4->saddr) - i - 1);
@@ -119,14 +119,14 @@ restart:
hdr6->saddr.in6_u.u6_addr32[2] =
hdr6->saddr.in6_u.u6_addr32[3] = htonl(i);
ensure_time;
- if (ratelimiter_allow(skb6, &init_net) !=
+ if (wg_ratelimiter_allow(skb6, &init_net) !=
expected_results[i].result)
goto err;
++test;
hdr6->saddr.in6_u.u6_addr32[0] =
htonl(ntohl(hdr6->saddr.in6_u.u6_addr32[0]) + i + 1);
ensure_time;
- if (!ratelimiter_allow(skb6, &init_net))
+ if (!wg_ratelimiter_allow(skb6, &init_net))
goto err;
++test;
hdr6->saddr.in6_u.u6_addr32[0] =
@@ -146,7 +146,8 @@ restart2:
for (i = 0; i <= max_entries; ++i) {
hdr4->saddr = htonl(i);
- if (ratelimiter_allow(skb4, &init_net) != (i != max_entries)) {
+ if (wg_ratelimiter_allow(skb4, &init_net) !=
+ (i != max_entries)) {
if (++tries < 5000)
goto restart2;
goto err;
@@ -162,11 +163,11 @@ err:
kfree_skb(skb6);
#endif
err_nofree:
- ratelimiter_uninit();
- ratelimiter_uninit();
- ratelimiter_uninit();
+ wg_ratelimiter_uninit();
+ wg_ratelimiter_uninit();
+ wg_ratelimiter_uninit();
/* Uninit one extra time to check underflow detection. */
- ratelimiter_uninit();
+ wg_ratelimiter_uninit();
out:
if (ret)
pr_info("ratelimiter self-tests: pass\n");