Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wireguard: receive: reset last_under_load to zero

This is a small optimization that prevents more expensive comparisons
from happening when they are no longer necessary, by clearing the
last_under_load variable whenever we wind up in a state where we were
under load but we no longer are.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Suggested-by: Matt Dunwoodie <ncon@noconroy.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jason A. Donenfeld and committed by
David S. Miller
2a8a4df3 04ddf120

+5 -2
+5 -2
drivers/net/wireguard/receive.c
··· 118 118 119 119 under_load = skb_queue_len(&wg->incoming_handshakes) >= 120 120 MAX_QUEUED_INCOMING_HANDSHAKES / 8; 121 - if (under_load) 121 + if (under_load) { 122 122 last_under_load = ktime_get_coarse_boottime_ns(); 123 - else if (last_under_load) 123 + } else if (last_under_load) { 124 124 under_load = !wg_birthdate_has_expired(last_under_load, 1); 125 + if (!under_load) 126 + last_under_load = 0; 127 + } 125 128 mac_state = wg_cookie_validate_packet(&wg->cookie_checker, skb, 126 129 under_load); 127 130 if ((under_load && mac_state == VALID_MAC_WITH_COOKIE) ||