summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2020-01-24 01:45:32 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2020-01-24 01:45:32 +0000
commite1411d6894467afbb3265f51cd8b426b0005e93d (patch)
treef53d2f1cba3856d2eae96845e9d90aa03f980c98 /sys
parentb82a46ba522d7ffa04b9979e000d395240395646 (diff)
move to if_vinput() in tun_dev_write.
this means tun doesn't queue the packet on input for the network stack to process, it's pushed through as part of the write into the kernel. discussed at length with claudio@ who agrees that avoiding a queue, and charging the writing process with the work associated with the packet, are both reasonable (good) things to do.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_tun.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 9ea301df771..bcfe1d1226e 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.208 2020/01/24 01:36:22 dlg Exp $ */
+/* $OpenBSD: if_tun.c,v 1.209 2020/01/24 01:45:31 dlg Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -227,6 +227,8 @@ tun_create(struct if_clone *ifc, int unit, int flags)
ifp->if_link_state = LINK_STATE_DOWN;
IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
+ if_counters_alloc(ifp);
+
if ((flags & TUN_LAYER2) == 0) {
if (tun_list_insert(&tun_softc_list, sc) != 0)
goto exists;
@@ -823,7 +825,6 @@ tun_dev_write(struct tun_softc *sc, struct uio *uio, int ioflag, int align)
struct mbuf *m0;
int error = 0;
size_t mlen;
- struct mbuf_list ml = MBUF_LIST_INITIALIZER();
ifp = &sc->sc_if;
TUNDEBUG(("%s: tunwrite\n", ifp->if_xname));
@@ -856,8 +857,10 @@ tun_dev_write(struct tun_softc *sc, struct uio *uio, int ioflag, int align)
if (error != 0)
goto drop;
- ml_enqueue(&ml, m0);
- if_input(ifp, &ml);
+ NET_RLOCK();
+ if_vinput(ifp, m0);
+ NET_RUNLOCK();
+
return (0);
drop: