git: 7e2781fdcfdb - main - pfsync: handle large MTU pfsync interfaces

Kristof Provost <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm
Message-ID <[email protected]>
The branch main has been updated by kp:

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

commit 7e2781fdcfdbe489cc07572d33dc36bca06a342d
Author:     Kristof Provost <[email protected]>
AuthorDate: 2026-08-07 14:07:09 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-08-08 09:02:50 +0000

    pfsync: handle large MTU pfsync interfaces
    
    pfsync packets were allocated with m_get2(), which can't return packets
    larger than MJUMPAGESIZE. As a result 9k MTU pfsync interfaces simply didn't work.
    
    Use m_get3(), which can allocate sufficiently large mbufs.
    
    Extend the pfsync:bulk test case to provoke this problem.
    
    PR:             297307
    MFC after:      2 weeks
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netpfil/pf/if_pfsync.c     |  2 +-
 tests/sys/netpfil/pf/pfsync.sh | 11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index a64d0ef64a61..db7db987197b 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -2039,7 +2039,7 @@ pfsync_sendout(int schedswi, int c)
 		return;
 	}
 
-	m = m_get2(max_linkhdr + b->b_len, M_NOWAIT, MT_DATA, M_PKTHDR);
+	m = m_get3(max_linkhdr + b->b_len, M_NOWAIT, MT_DATA, M_PKTHDR);
 	if (m == NULL) {
 		if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1);
 		V_pfsyncstats.pfsyncs_onomem++;
diff --git a/tests/sys/netpfil/pf/pfsync.sh b/tests/sys/netpfil/pf/pfsync.sh
index 9843c470c06f..8e639ca7c988 100644
--- a/tests/sys/netpfil/pf/pfsync.sh
+++ b/tests/sys/netpfil/pf/pfsync.sh
@@ -212,13 +212,14 @@ bulk_body()
 
 	# pfsync interface
 	jexec one ifconfig ${epair_sync}a 192.0.2.1/24 up
+	jexec one ifconfig ${epair_sync}a mtu 9000
 	jexec one ifconfig ${epair_one}a 198.51.100.1/24 up
 	jexec one ifconfig pfsync0 \
 		syncdev ${epair_sync}a \
-		maxupd 1\
-		up
+		up mtu 9000
 	jexec two ifconfig ${epair_two}a 198.51.100.2/24 up
 	jexec two ifconfig ${epair_sync}b 192.0.2.2/24 up
+	jexec two ifconfig ${epair_sync}b mtu 9000
 
 	# Enable pf
 	jexec one pfctl -e
@@ -232,7 +233,11 @@ bulk_body()
 
 	ifconfig ${epair_one}b 198.51.100.254/24 up
 
-	# Create state prior to setting up pfsync
+	# Create states prior to setting up pfsync
+	${common_dir}/pft_synflood.py \
+		--sendif ${epair_one}b \
+		--to 198.51.100.1 \
+		--count 2500
 	ping -c 1 -S 198.51.100.254 198.51.100.1
 
 	# Wait before setting up pfsync on two, so we don't accidentally catch
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.