aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/peer.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-04 02:50:51 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-04 05:14:15 +0200
commitf1ccce3fccbf21422c18fdc45fc89cc5af46b290 (patch)
tree9d64d51f821c712aaf21795aa2652fa054b18de9 /src/peer.c
parentversion: bump snapshot (diff)
downloadwireguard-linux-compat-f1ccce3fccbf21422c18fdc45fc89cc5af46b290.tar.xz
wireguard-linux-compat-f1ccce3fccbf21422c18fdc45fc89cc5af46b290.zip
send: switch handshake stamp to an atomic
Rather than abusing the handshake lock, we're much better off just using a boring atomic64 for this. It's simpler and performs better. Also, while we're at it, we set the handshake stamp both before and after the calculations, in case the calculations block for a really long time waiting for the RNG to initialize. Otherwise it's possible that when the RNG finally initializes, two handshakes are sent back to back, which isn't sensible. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/peer.c b/src/peer.c
index 97a472a..b9703d5 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -50,7 +50,7 @@ struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_
rwlock_init(&peer->endpoint_lock);
kref_init(&peer->refcount);
skb_queue_head_init(&peer->staged_packet_queue);
- peer->last_sent_handshake = ktime_get_boot_fast_ns() - (u64)(REKEY_TIMEOUT + 1) * NSEC_PER_SEC;
+ atomic64_set(&peer->last_sent_handshake, ktime_get_boot_fast_ns() - (u64)(REKEY_TIMEOUT + 1) * NSEC_PER_SEC);
set_bit(NAPI_STATE_NO_BUSY_POLL, &peer->napi.state);
netif_napi_add(wg->dev, &peer->napi, packet_rx_poll, NAPI_POLL_WEIGHT);
napi_enable(&peer->napi);