git: c38abd64dbc1 - main - if_epair: support IFCAP_MEXTPG

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Wed, 08 Jul 2026 07:52:12 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=c38abd64dbc18ec10a4f80e74ae4a304c075aa5c

commit c38abd64dbc18ec10a4f80e74ae4a304c075aa5c
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-07-06 09:16:41 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-07-08 07:23:17 +0000

    if_epair: support IFCAP_MEXTPG
    
    Enable IFCAP_MEXTPG by default, which may bring performance benefits.
    Allow it to be disabled, and when disabled assert that we do not receive
    any mbufs with M_EXTPG set. This is useful for testing.
    Default the tests to disabling MEXTPG support.
    
    Reviewed by:    zlei
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D58054
---
 sys/net/if_epair.c         | 7 ++++++-
 tests/sys/common/vnet.subr | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c
index 60849ca1d4f2..5addd43b6190 100644
--- a/sys/net/if_epair.c
+++ b/sys/net/if_epair.c
@@ -351,6 +351,10 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m)
 		return (E2BIG);
 	}
 
+	if ((ifp->if_capenable & IFCAP_MEXTPG) == 0) {
+		M_ASSERTMAPPED(m);
+	}
+
 	/*
 	 * We are not going to use the interface en/dequeue mechanism
 	 * on the TX side. We are called from ether_output_frame()
@@ -632,7 +636,8 @@ epair_setup_ifp(struct epair_softc *sc, char *name, int unit)
 	ifp->if_capabilities =
 	    IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING |
 	    IFCAP_TXCSUM | IFCAP_RXCSUM |
-	    IFCAP_TXCSUM_IPV6 | IFCAP_RXCSUM_IPV6;
+	    IFCAP_TXCSUM_IPV6 | IFCAP_RXCSUM_IPV6 |
+	    IFCAP_MEXTPG;
 	ifp->if_capenable = ifp->if_capabilities;
 	epair_caps_changed(ifp);
 	ifp->if_transmit = epair_transmit;
diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr
index 245dbaea517a..781bde4943fa 100644
--- a/tests/sys/common/vnet.subr
+++ b/tests/sys/common/vnet.subr
@@ -46,7 +46,9 @@ vnet_mkepair()
 	# compute checksums, it just marks packets that this computation still
 	# needs to be done. However, some test cases verify the checksum.
 	# Therefore disable this for IPv4 and IPv6.
-	ifconfig ${ifname} -txcsum -txcsum6
+	# Also disable MEXTPG support, so the tests can verify that the network
+	# stack don't pass MEXTPG mbufs to interfaces that don't support it.
+	ifconfig ${ifname} -txcsum -txcsum6 -mextpg
 	list_interface $ifname
 	list_interface ${ifname%a}b
 	echo ${ifname%a}