git: c31d86d329fb - main - tests/net/bpf: run the bpf:inject test with RSS again

From: R. Christian McDonald <rcm_at_FreeBSD.org>
Date: Thu, 26 Nov 2026 20:10:27 UTC
The branch main has been updated by rcm:

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

commit c31d86d329fb9c80b5e39376c871ded06fc50a07
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-11-26 20:09:37 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-11-26 20:09:37 +0000

    tests/net/bpf: run the bpf:inject test with RSS again
    
    1abb62867f2a skipped the test on RSS kernels because epair(4) delivered
    the injected frames out of order.  The reordering within a flow is fixed
    in if_epair, but the test still failed in about one run in seven: the
    first capture starts with the ARP request from ping(8), which is not an
    IP packet and goes to the first epair queue, while the ICMP flow goes to
    the queue its hash selects.  Written back to back by the inject step,
    the two may arrive in either order.
    
    Add static ARP entries on both ends so that the captures hold only the
    ICMP flow, and remove the skip.  On an 8-CPU RSS kernel the test then
    passed 250 of 250 runs with the if_epair fix and failed 26 of 150
    without it.
    
    While here, use the -j option of ifconfig(8), netstat(1) and arp(8)
    instead of jexec(8).
    
    Reviewed by:            glebius, pouria
    Sponsored by:           Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D61726
---
 tests/sys/net/bpf/bpf.sh | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tests/sys/net/bpf/bpf.sh b/tests/sys/net/bpf/bpf.sh
index a721c3327b19..a11feddb2b8b 100644
--- a/tests/sys/net/bpf/bpf.sh
+++ b/tests/sys/net/bpf/bpf.sh
@@ -40,7 +40,7 @@ multi_read_body()
 	ifconfig ${epair}a inet 192.0.2.1/24 up
 
 	vnet_mkjail alcatraz ${epair}b
-	jexec alcatraz ifconfig ${epair}b inet 192.0.2.2/24 up
+	ifconfig -j alcatraz ${epair}b inet 192.0.2.2/24 up
 
 	atf_check -s exit:0 -o ignore \
 	    ping -c 1 192.0.2.2
@@ -69,14 +69,17 @@ inject_body()
 {
 	vnet_init
 
-	if sysctl -q kern.features.rss >/dev/null; then
-		atf_skip "This test is flaky with RSS"
-	fi
-
 	epair=$(vnet_mkepair)
 	ifconfig ${epair}a inet 192.0.2.1/24 up
 	vnet_mkjail alcatraz ${epair}b
-	jexec alcatraz ifconfig ${epair}b inet 192.0.2.2/24 up
+	ifconfig -j alcatraz ${epair}b inet 192.0.2.2/24 up
+	# Static ARP entries keep ARP out of the captures.  With RSS the
+	# epair queues ARP frames apart from the IP flow and may deliver
+	# them out of order with it.
+	arp -s 192.0.2.2 $(ifconfig -j alcatraz ${epair}b ether | \
+	    awk '/ether/{print $2}')
+	arp -j alcatraz -s 192.0.2.1 $(ifconfig ${epair}a ether | \
+	    awk '/ether/{print $2}')
 
 	in=$(pwd)/$(mktemp in.pcap.XXXXXXXXXX)
 	in2=$(pwd)/$(mktemp in2.pcap.XXXXXXXXXX)
@@ -85,7 +88,7 @@ inject_body()
 	# write dump on jail side, with "in" direction
 	jexec alcatraz $(atf_get_srcdir)/pcap-test \
 	    capture epair0b $in 3 in > out & pid=$!
-	while ! jexec alcatraz netstat -B | grep -q epair0b.*pcap-test; do
+	while ! netstat -j alcatraz -B | grep -q epair0b.*pcap-test; do
 		sleep 0.01;
 	done
 	atf_check -s exit:0 -o ignore ping -c 3 -i 0.1 192.0.2.2
@@ -95,7 +98,7 @@ inject_body()
 	# inject dump on host side, recording on both sides
 	jexec alcatraz $(atf_get_srcdir)/pcap-test \
 	    capture epair0b $in2 3 in > jout & jpid=$!
-	while ! jexec alcatraz netstat -B | grep -q epair0b.*pcap-test; do
+	while ! netstat -j alcatraz -B | grep -q epair0b.*pcap-test; do
 		sleep 0.01;
 	done
 	$(atf_get_srcdir)/pcap-test \