From 85a2dd8b6347233bd9f0056448d35fd2b9d03c40 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 25 Feb 2019 22:35:28 +0100 Subject: netlink: don't remove allowed ips for new peers This causes needless traversal of the trie. --- src/netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/netlink.c b/src/netlink.c index 9a33192..f44f211 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -375,6 +375,9 @@ static int set_peer(struct wg_device *wg, struct nlattr **attrs) if (flags & WGPEER_F_REMOVE_ME) goto out; /* Tried to remove a non-existing peer. */ + /* The peer is new, so there aren't allowed IPs to remove. */ + flags &= ~WGPEER_F_REPLACE_ALLOWEDIPS; + down_read(&wg->static_identity.lock); if (wg->static_identity.has_identity && !memcmp(nla_data(attrs[WGPEER_A_PUBLIC_KEY]), -- cgit v1.2.3-59-g8ed1b