summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2019-09-13 01:31:25 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2019-09-13 01:31:25 +0000
commit2a7637872b5a9aa6aa7aa1b90a5e520db53aebd8 (patch)
tree250fbcd628a879dd19395d13850b96c20b5e4567 /sys/net
parent4def774fb8ddb67f5cffca20dcb5146454aaf8f1 (diff)
tweak tun/tap kn_data to be more consistent with everything else.
for EVFILT_READ, kn_data is now like FIONREAD and reports how many bytes there are to read. previously it would report how many packets were available to read, which is not something i've seen anywhere else. for EVFILT_WRITE, report the max number of bytes a write can do. previously it was if_mtu bytes, now it is if_hdrlen + if_hardmtu bytes, which is the same as what the write path uses as it's maximum message size. discussed with and ok visa@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_tun.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index d59916970e2..07491393b98 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.189 2019/09/12 01:28:29 dlg Exp $ */
+/* $OpenBSD: if_tun.c,v 1.190 2019/09/13 01:31:24 dlg Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -1008,9 +1008,6 @@ tun_dev_poll(struct tun_softc *tp, int events, struct proc *p)
*
* The tun driver uses an array of tun_softc's based on the minor number
* of the device. kn->kn_hook gets set to the specific tun_softc.
- *
- * filt_tunread() sets kn->kn_data to the iface qsize
- * filt_tunwrite() sets kn->kn_data to the MTU size
*/
int
tunkqfilter(dev_t dev, struct knote *kn)
@@ -1082,7 +1079,6 @@ filt_tunread(struct knote *kn, long hint)
{
struct tun_softc *tp;
struct ifnet *ifp;
- unsigned int len;
if (kn->kn_status & KN_DETACHED) {
kn->kn_data = 0;
@@ -1092,16 +1088,9 @@ filt_tunread(struct knote *kn, long hint)
tp = (struct tun_softc *)kn->kn_hook;
ifp = &tp->tun_if;
- len = IFQ_LEN(&ifp->if_snd);
- if (len > 0) {
- kn->kn_data = len;
+ kn->kn_data = ifq_hdatalen(&ifp->if_snd);
- TUNDEBUG(("%s: tunkqread q=%d\n", ifp->if_xname,
- IFQ_LEN(&ifp->if_snd)));
- return (1);
- }
- TUNDEBUG(("%s: tunkqread waiting\n", ifp->if_xname));
- return (0);
+ return (kn->kn_data > 0);
}
void
@@ -1131,7 +1120,7 @@ filt_tunwrite(struct knote *kn, long hint)
tp = (struct tun_softc *)kn->kn_hook;
ifp = &tp->tun_if;
- kn->kn_data = ifp->if_mtu;
+ kn->kn_data = ifp->if_hdrlen + ifp->if_hardmtu;
return (1);
}