summaryrefslogtreecommitdiffhomepage
path: root/src/device.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-25 17:01:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 17:25:23 +0100
commit2a221ee32e7fa17b1dd983f520768ff455603912 (patch)
tree7fae52acd90b0fcb15bb6211617838ec79eaad8a /src/device.h
parentbd6692ea74658bc084ba8fa1979549beda104be7 (diff)
peer: store total number of peers instead of iterating
This is faster, since it means adding a new peer is O(1) instead of O(n). It's also safe to do because we're holding the device_update_lock on both the ++ and the --. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/device.h')
-rw-r--r--src/device.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/device.h b/src/device.h
index 4932477..a74f58b 100644
--- a/src/device.h
+++ b/src/device.h
@@ -49,7 +49,7 @@ struct wireguard_device {
struct routing_table peer_routing_table;
struct mutex device_update_lock, socket_update_lock;
struct list_head device_list, peer_list;
- unsigned int device_update_gen;
+ unsigned int num_peers, device_update_gen;
u32 fwmark;
u16 incoming_port;
};