summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-03-16 09:30:55 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-03-16 09:30:55 +0000
commit200129b8df5e0d9beb3f24b4fb1efb587526c0ec (patch)
treee9229eb774ac1011139635ecd72e69233b304b91
parent0ce5abbfb99a9d143eeb935c70dfc5da2320220a (diff)
Switch tun(4) from encapsualting packets into a long mbuf chain over to use
mbuf clusters if the packet is big enough. This should speed up tun(4) and may help in other cases where long mbuf chains hurt. Additionally switch the default tun(4) MTU to a more sane 1500 bytes. TUNMTU is kept because it is used in userland. Input and OK from brad@ and djm@
-rw-r--r--sys/net/if_tun.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index aacce07d36c..e2bddf1183a 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.76 2006/03/05 02:35:38 brad Exp $ */
+/* $OpenBSD: if_tun.c,v 1.77 2006/03/16 09:30:54 claudio Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -200,7 +200,7 @@ tun_create(struct if_clone *ifc, int unit, int flags)
IFQ_SET_READY(&ifp->if_snd);
if ((flags & TUN_LAYER2) == 0) {
tp->tun_flags &= ~TUN_LAYER2;
- ifp->if_mtu = TUNMTU;
+ ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_POINTOPOINT;
ifp->if_type = IFT_TUNNEL;
ifp->if_hdrlen = sizeof(u_int32_t);
@@ -828,6 +828,14 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag)
if (m == NULL)
return (ENOBUFS);
mlen = MHLEN;
+ if (uio->uio_resid >= MINCLSIZE) {
+ MCLGET(m, M_DONTWAIT);
+ if (!(m->m_flags & M_EXT)) {
+ m_freem(m);
+ return (ENOBUFS);
+ }
+ mlen = MCLBYTES;
+ }
top = NULL;
mp = &top;
@@ -851,6 +859,14 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag)
break;
}
mlen = MLEN;
+ if (uio->uio_resid >= MINCLSIZE) {
+ MCLGET(m, M_DONTWAIT);
+ if (!(m->m_flags & M_EXT)) {
+ error = ENOBUFS;
+ break;
+ }
+ mlen = MCLBYTES;
+ }
}
}
if (error) {