if_tuntap: Enable MEXTPG support

Fix tunread() to use m_mbuftouio() instead of manually copying (which
doesn't work for unmapped mbufs).

Reviewed by:	jhb, gallatin
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D47295

(cherry picked from commit 01c738cd5c3938374cce8293c82753d977966154)
This commit is contained in:
Mark Johnston 2024-10-28 13:52:14 +00:00 committed by Franco Fichtner
parent 7a96546625
commit 98d8d839c7

View file

@ -976,11 +976,11 @@ tuncreate(struct cdev *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;
@ -1760,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);
}