summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2021-01-25 09:11:37 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2021-01-25 09:11:37 +0000
commit7752b3a5bd8cb1467d9b5e24d68c73f8ad0b7e84 (patch)
tree8706a2a793635c21a99a97fee1b3d841276ce5e2 /sys/net
parent7ce8f11a523435cda8793aec2ef8d2ba8e24d09b (diff)
Fix wg(4) ioctl to be able to handle multiple wgpeers.
Diff from Yuichiro NAITO. ok procter
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_wg.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c
index c534f966363..23557126787 100644
--- a/sys/net/if_wg.c
+++ b/sys/net/if_wg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wg.c,v 1.14 2020/09/01 19:06:59 tb Exp $ */
+/* $OpenBSD: if_wg.c,v 1.15 2021/01/25 09:11:36 yasuoka Exp $ */
/*
* Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
@@ -2270,7 +2270,7 @@ wg_ioctl_set(struct wg_softc *sc, struct wg_data_io *data)
/* Peer must have public key */
if (!(peer_o.p_flags & WG_PEER_HAS_PUBLIC))
- continue;
+ goto next_peer;
/* 0 = latest protocol, 1 = this protocol */
if (peer_o.p_protocol_version != 0) {
@@ -2283,7 +2283,7 @@ wg_ioctl_set(struct wg_softc *sc, struct wg_data_io *data)
/* Get local public and check that peer key doesn't match */
if (noise_local_keys(&sc->sc_local, public, NULL) == 0 &&
bcmp(public, peer_o.p_public, WG_KEY_SIZE) == 0)
- continue;
+ goto next_peer;
/* Lookup peer, or create if it doesn't exist */
if ((peer = wg_peer_lookup(sc, peer_o.p_public)) == NULL) {
@@ -2291,7 +2291,7 @@ wg_ioctl_set(struct wg_softc *sc, struct wg_data_io *data)
* Also, don't create a new one if we only want to
* update. */
if (peer_o.p_flags & (WG_PEER_REMOVE|WG_PEER_UPDATE))
- continue;
+ goto next_peer;
if ((peer = wg_peer_create(sc,
peer_o.p_public)) == NULL) {
@@ -2303,7 +2303,7 @@ wg_ioctl_set(struct wg_softc *sc, struct wg_data_io *data)
/* Remove peer and continue if specified */
if (peer_o.p_flags & WG_PEER_REMOVE) {
wg_peer_destroy(peer);
- continue;
+ goto next_peer;
}
if (peer_o.p_flags & WG_PEER_HAS_ENDPOINT)
@@ -2333,6 +2333,11 @@ wg_ioctl_set(struct wg_softc *sc, struct wg_data_io *data)
}
peer_p = (struct wg_peer_io *)aip_p;
+ continue;
+next_peer:
+ aip_p = &peer_p->p_aips[0];
+ aip_p += peer_o.p_aips_count;
+ peer_p = (struct wg_peer_io *)aip_p;
}
error: