diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-18 13:38:16 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-18 13:48:17 +0200 |
commit | 66ca1c23ae8bba13c72cac96d9641a58dac2aaf6 (patch) | |
tree | 8e09bf4a18718a2aee207f7783e800ce800bc4c8 /src/device.c | |
parent | 42354178cd0bb963dcfd325b2d407c627617959d (diff) |
device: remove allowedips before individual peers
This avoids an O(n^2) traversal in favor of an O(n) one.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/device.c')
-rw-r--r-- | src/device.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c index d64653d..88790d6 100644 --- a/src/device.c +++ b/src/device.c @@ -219,6 +219,7 @@ static void destruct(struct net_device *dev) mutex_lock(&wg->device_update_lock); wg->incoming_port = 0; socket_reinit(wg, NULL, NULL); + allowedips_free(&wg->peer_allowedips, &wg->device_update_lock); peer_remove_all(wg); /* The final references are cleared in the below calls to destroy_workqueue. */ destroy_workqueue(wg->handshake_receive_wq); destroy_workqueue(wg->handshake_send_wq); @@ -226,7 +227,6 @@ static void destruct(struct net_device *dev) packet_queue_free(&wg->encrypt_queue, true); destroy_workqueue(wg->packet_crypt_wq); rcu_barrier_bh(); /* Wait for all the peers to be actually freed. */ - allowedips_free(&wg->peer_allowedips, &wg->device_update_lock); ratelimiter_uninit(); memzero_explicit(&wg->static_identity, sizeof(struct noise_static_identity)); skb_queue_purge(&wg->incoming_handshakes); |