aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_tuntap.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net/if_tuntap.c')
-rw-r--r--sys/net/if_tuntap.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index 4cb219dc92b6..a0275a7471e5 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -253,14 +253,14 @@ static int tunkqread(struct knote *, long);
static int tunkqwrite(struct knote *, long);
static void tunkqdetach(struct knote *);
-static struct filterops tun_read_filterops = {
+static const struct filterops tun_read_filterops = {
.f_isfd = 1,
.f_attach = NULL,
.f_detach = tunkqdetach,
.f_event = tunkqread,
};
-static struct filterops tun_write_filterops = {
+static const struct filterops tun_write_filterops = {
.f_isfd = 1,
.f_attach = NULL,
.f_detach = tunkqdetach,
@@ -971,19 +971,16 @@ tuncreate(struct cdev *dev)
iflags |= IFF_POINTOPOINT;
}
ifp = tp->tun_ifp = if_alloc(type);
- if (ifp == NULL)
- panic("%s%d: failed to if_alloc() interface.\n",
- drv->cdevsw.d_name, dev2unit(dev));
ifp->if_softc = tp;
if_initname(ifp, drv->cdevsw.d_name, dev2unit(dev));
ifp->if_ioctl = tunifioctl;
ifp->if_flags = iflags;
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
- ifp->if_capabilities |= IFCAP_LINKSTATE;
+ ifp->if_capabilities |= IFCAP_LINKSTATE | IFCAP_MEXTPG;
if ((tp->tun_flags & TUN_L2) != 0)
ifp->if_capabilities |=
IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_LRO;
- ifp->if_capenable |= IFCAP_LINKSTATE;
+ ifp->if_capenable |= IFCAP_LINKSTATE | IFCAP_MEXTPG;
if ((tp->tun_flags & TUN_L2) != 0) {
ifp->if_init = tunifinit;
@@ -1442,7 +1439,7 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
}
/* BPF writes need to be handled specially. */
- if (dst->sa_family == AF_UNSPEC)
+ if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT)
bcopy(dst->sa_data, &af, sizeof(af));
else
af = RO_GET_FAMILY(ro, dst);
@@ -1763,18 +1760,9 @@ tunread(struct cdev *dev, struct uio *uio, int flag)
vhdr.hdr.csum_offset);
error = uiomove(&vhdr, len, uio);
}
-
- while (m && uio->uio_resid > 0 && error == 0) {
- len = min(uio->uio_resid, m->m_len);
- if (len != 0)
- error = uiomove(mtod(m, void *), len, uio);
- m = m_free(m);
- }
-
- if (m) {
- TUNDEBUG(ifp, "Dropping mbuf\n");
- m_freem(m);
- }
+ if (error == 0)
+ error = m_mbuftouio(uio, m, 0);
+ m_freem(m);
return (error);
}