summaryrefslogtreecommitdiff
path: root/proto/wireguard
diff options
context:
space:
mode:
Diffstat (limited to 'proto/wireguard')
-rw-r--r--proto/wireguard/wireguard.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c
index 3cb80ed6..e9cb9cf2 100644
--- a/proto/wireguard/wireguard.c
+++ b/proto/wireguard/wireguard.c
@@ -217,9 +217,7 @@ wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n,
debug("WG: found ip\n");
- struct wg_allowedip *next = ip->next_allowedip;
-
- if (peer->first_allowedip == ip) {
+ if (!previp) {
debug("WG: remove first\n");
peer->first_allowedip = ip->next_allowedip;
if (peer->last_allowedip == ip)
@@ -227,23 +225,14 @@ wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n,
} else {
debug("WG: remove middle\n");
// Remove
- struct wg_allowedip *cur = NULL;
- wg_for_each_allowedip(peer, cur) {
- if (cur->next_allowedip != ip)
- continue;
-
- debug("WG: remove next\n");
- if (peer->last_allowedip == ip)
- peer->last_allowedip = cur;
-
- cur->next_allowedip = ip->next_allowedip;
- break;
- }
+ if (peer->last_allowedip == ip)
+ peer->last_allowedip = previp;
+
+ previp->next_allowedip = ip->next_allowedip;
}
free(ip);
break;
- /* ip = next; */
}
peer->flags |= WGPEER_REPLACE_ALLOWEDIPS;