aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-06 15:55:47 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-06 16:02:38 +0200
commit64669564122e5112a01536cbe28e8c2159eb056b (patch)
tree7dcded6d0e73c761ad00602cc9df61adc489fda8
parentversion: bump snapshot (diff)
downloadwireguard-monolithic-historical-64669564122e5112a01536cbe28e8c2159eb056b.tar.xz
wireguard-monolithic-historical-64669564122e5112a01536cbe28e8c2159eb056b.zip
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>
-rw-r--r--src/receive.c8
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;