aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-18 13:38:16 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-18 13:48:17 +0200
commitfbea8fe2e0ac0f46d5a64a2291a2926109163001 (patch)
tree84feafae215c775fc347f3f1b90b63f8206bb529
parentwg-quick: darwin: simpler inclusion check (diff)
downloadwireguard-monolithic-historical-fbea8fe2e0ac0f46d5a64a2291a2926109163001.tar.xz
wireguard-monolithic-historical-fbea8fe2e0ac0f46d5a64a2291a2926109163001.zip
device: remove allowedips before individual peers
This avoids an O(n^2) traversal in favor of an O(n) one.
-rw-r--r--src/device.c2
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);