summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvs <mvs@openbsd.org>2020-08-09 14:33:49 +0000
committermvs <mvs@openbsd.org>2020-08-09 14:33:49 +0000
commitd8baefb339f6d903de2c3fad88094e5899f9cd26 (patch)
treef96bd4a7b7db2090d6ff2a27fd92e8a6f60b4784
parentShuffle functions and declarations around to more logical grouping. Nuke some (diff)
downloadwireguard-openbsd-d8baefb339f6d903de2c3fad88094e5899f9cd26.tar.xz
wireguard-openbsd-d8baefb339f6d903de2c3fad88094e5899f9cd26.zip
vether(4) is pretty dummy. It contains nothing requires to be protected.
So set `IFXF_MPSAFE' bit. This allows to discard outgoing packets without kernel lock. ok kn@
-rw-r--r--sys/net/if_vether.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/sys/net/if_vether.c b/sys/net/if_vether.c
index bff5058c892..0364488b299 100644
--- a/sys/net/if_vether.c
+++ b/sys/net/if_vether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vether.c,v 1.33 2020/07/28 09:52:32 mvs Exp $ */
+/* $OpenBSD: if_vether.c,v 1.34 2020/08/09 14:33:49 mvs Exp $ */
/*
* Copyright (c) 2009 Theo de Raadt
@@ -36,7 +36,7 @@
void vetherattach(int);
int vetherioctl(struct ifnet *, u_long, caddr_t);
-void vetherstart(struct ifnet *);
+void vetherqstart(struct ifqueue *);
int vether_clone_create(struct if_clone *, int);
int vether_clone_destroy(struct ifnet *);
int vether_media_change(struct ifnet *);
@@ -83,12 +83,12 @@ vether_clone_create(struct if_clone *ifc, int unit)
ifp->if_softc = sc;
ifp->if_ioctl = vetherioctl;
- ifp->if_start = vetherstart;
+ ifp->if_qstart = vetherqstart;
ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
ifp->if_hardmtu = ETHER_MAX_HARDMTU_LEN;
ifp->if_capabilities = IFCAP_VLAN_MTU;
- ifp->if_xflags = IFXF_CLONED;
+ ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE;
ifmedia_init(&sc->sc_media, 0, vether_media_change,
vether_media_status);
@@ -117,15 +117,12 @@ vether_clone_destroy(struct ifnet *ifp)
* and we only need to discard the packets.
*/
void
-vetherstart(struct ifnet *ifp)
+vetherqstart(struct ifqueue *ifq)
{
+ struct ifnet *ifp = ifq->ifq_if;
struct mbuf *m;
- for (;;) {
- m = ifq_dequeue(&ifp->if_snd);
- if (m == NULL)
- return;
-
+ while ((m = ifq_dequeue(ifq)) != NULL) {
#if NBPFILTER > 0
if (ifp->if_bpf)
bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);