summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2020-01-23 23:30:42 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2020-01-23 23:30:42 +0000
commitabfdccb05581f39f9052057c9c57680c38e6728c (patch)
tree0fb3300fbc17091a61e7d193fb891ad72e46b718 /sys
parent546b0f2b30ab7d8723a35bdd2a5bd4b9e656b58c (diff)
provide a custom if_enqueue handler.
tun and tap now queue a packet on output (for userland to read) on the if send queue, and then directly call tun_wakeup to tell userland about it. this bypasses calling the ifq serialiser machinery which then calls tun_start, which then calls tun_wakeup.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_tun.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 72101cc43c9..90a27344708 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.203 2020/01/23 23:22:47 dlg Exp $ */
+/* $OpenBSD: if_tun.c,v 1.204 2020/01/23 23:30:41 dlg Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -111,6 +111,7 @@ int tun_dev_kqfilter(struct tun_softc *, struct knote *);
int tun_ioctl(struct ifnet *, u_long, caddr_t);
int tun_output(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
+int tun_enqueue(struct ifnet *, struct mbuf *);
int tun_clone_create(struct if_clone *, int);
int tap_clone_create(struct if_clone *, int);
int tun_create(struct if_clone *, int, int);
@@ -219,6 +220,7 @@ tun_create(struct if_clone *ifc, int unit, int flags)
ifp->if_softc = sc;
ifp->if_ioctl = tun_ioctl;
+ ifp->if_enqueue = tun_enqueue;
ifp->if_start = tun_start;
ifp->if_hardmtu = TUNMRU;
ifp->if_link_state = LINK_STATE_DOWN;
@@ -558,6 +560,21 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
return (if_enqueue(ifp, m0));
}
+int
+tun_enqueue(struct ifnet *ifp, struct mbuf *m0)
+{
+ struct tun_softc *sc = ifp->if_softc;
+ int error;
+
+ error = ifq_enqueue(&ifp->if_snd, m0);
+ if (error != 0)
+ return (error);
+
+ tun_wakeup(sc);
+
+ return (0);
+}
+
void
tun_wakeup(struct tun_softc *sc)
{