diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2019-09-12 01:27:03 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2019-09-12 01:27:03 +0000 |
commit | f12391556302ab6d63daed00e514b6cef394ced3 (patch) | |
tree | 5e79c967eb8e1b09d700eb41434e12dfa46e8357 | |
parent | ef6a9df6d7c24b153651f4f7eb2080102c789a24 (diff) |
let userland write up to hardmtu bytes, not just mtu bytes.
this brings tun in line with pretty much every other driver we have
where we let interfaces rx whatever they can.
while here make sure userland provides enough bytes for the link
header, which is the 4 byte address family for tun(4), and an
ethernet header for tap(4).
-rw-r--r-- | sys/net/if_tun.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 8fa1bfb874b..a405633de5f 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.187 2019/06/10 21:55:16 dlg Exp $ */ +/* $OpenBSD: if_tun.c,v 1.188 2019/09/12 01:27:02 dlg Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -838,8 +838,8 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) ifp = &tp->tun_if; TUNDEBUG(("%s: tunwrite\n", ifp->if_xname)); - if (uio->uio_resid == 0 || uio->uio_resid > ifp->if_mtu + - (tp->tun_flags & TUN_LAYER2 ? ETHER_HDR_LEN : sizeof(*th))) { + if (uio->uio_resid < ifp->if_hdrlen || + uio->uio_resid > (ifp->if_hdrlen + ifp->if_hardmtu)) { TUNDEBUG(("%s: len=%d!\n", ifp->if_xname, uio->uio_resid)); return (EMSGSIZE); } |