diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-06 15:55:47 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-06 16:02:38 +0200 |
commit | 66e170cfb511dea0162a97629967487fed4fbe3d (patch) | |
tree | ffca4c22dacd495eb12aa96a6d34fe212610c9b6 /src | |
parent | c1a12c572bf90c9e1ecbe2291517741b4823d855 (diff) |
receive: do not consider 0 jiffies as being set
This causes tests to fail if run within the first 5 minutes.
We also move to jiffies 64, so that there's low chance of wrapping in
case handshakes are spread far apart.
Reported-by: René van Dorst <opensource@vdorst.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/receive.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/receive.c b/src/receive.c index b3ad9c3..ca87476 100644 --- a/src/receive.c +++ b/src/receive.c @@ -83,7 +83,7 @@ static inline int skb_prepare_header(struct sk_buff *skb, struct wireguard_devic static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff *skb) { - static unsigned long last_under_load = 0; /* Yes this is global, so that our load calculation applies to the whole system. */ + static u64 last_under_load = 0; /* Yes this is global, so that our load calculation applies to the whole system. */ struct wireguard_peer *peer = NULL; bool under_load; enum cookie_mac_state mac_state; @@ -97,9 +97,9 @@ static void receive_handshake_packet(struct wireguard_device *wg, struct sk_buff under_load = skb_queue_len(&wg->incoming_handshakes) >= MAX_QUEUED_INCOMING_HANDSHAKES / 8; if (under_load) - last_under_load = jiffies; - else - under_load = time_is_after_jiffies(last_under_load + HZ); + last_under_load = get_jiffies_64(); + else if (last_under_load) + under_load = time_is_after_jiffies64(last_under_load + HZ); mac_state = cookie_validate_packet(&wg->cookie_checker, skb, under_load); if ((under_load && mac_state == VALID_MAC_WITH_COOKIE) || (!under_load && mac_state == VALID_MAC_BUT_NO_COOKIE)) packet_needs_cookie = false; |