tun_dev_write currently checks if the packet being written into the
kernel is less than the current if_mtu of the interface. we don't really
have a conflation of the mtu with the mru in any other driver, so i'd
like to remove it from tun(4).
we can also avoid a check at runtime about what type of interface
it is by using the if_hdrlen value. tun needs the 4 byte af shim,
and tap should have a whole ethernet header before ether_input gets
to look at it.
ok?
Index: if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.187
diff -u -p -r1.187 if_tun.c
--- if_tun.c 10 Jun 2019 21:55:16 -0000 1.187
+++ if_tun.c 29 Aug 2019 02:53:35 -0000
@@ -838,8 +838,7 @@ tun_dev_write(struct tun_softc *tp, stru
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) {
TUNDEBUG(("%s: len=%d!\n", ifp->if_xname, uio->uio_resid));
return (EMSGSIZE);
}