Skip to contentSkip to conversation

selftests: netfilter: Add bridge_fastpath.sh

RFC PATCH Superseded Eric Woudstra 2 participants 4 messages Sep 25, 2025 – Oct 4, 2025

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v3 1/1 selftests: netfilter: Add bridge_fastpath.sh

Add a script to test various scenarios where a bridge is involved in the fastpath. It runs tests in the forward path, and also in a bridged path.

The setup is similar to a basic home router with multiple lan ports.

It uses 3 pairs of veth-devices. Each or all pairs can be replaced by a pair of real interfaces, interconnected by wire. This is necessary to test the behavior when dealing with dsa ports, foreign (dsa) ports and switchdev userports that support SWITCHDEV_OBJ_ID_PORT_VLAN.

See the head of the script for a detailed description.

Run without arguments to perform all tests on veth-devices.

---

This test script is written first for the proposed bridge-fastpath patch-sets, but it's use is more general and can easily be expanded.

Changes in v3:

- Removed all warnings reported by shellcheck -x -e SC2317
- Improved del_pppoe(), check if interfaces are removed
- Added is_known_issue() to warn instead of error for known issues
- Link down and (hardware) interfaces to default netns at end of script
- Removed matching ip(v6) address

Changes in v2:

- Moved test-series to functions
- Moved code to set_pair_link() up/down
- Added conntrack zone to bridged traffic
- Test bridge chain prerouting in test without fastpath and bridge chain forward in tests with fastpath

Some example outputs of this last version of patches from different hardware, without and with patches:

ALL VETH:
=========

./bridge_fastpath.sh -t
Setup:
CLIENT 0
veth0cl
|
veth0rt
WAN
ROUTER
LAN1 LAN2
veth1rt veth2rt
| |
veth1cl veth2cl
CLIENT 1 CLIENT 2

Without patches:

PASS:  unaware bridge, without encaps,             without fastpath
PASS:  unaware bridge, with single vlan encap,     without fastpath
WARN:  unaware bridge, with double q vlan encaps,  without fastpath: ipv4/6: established bytes 0 < 4194304
WARN:  unaware bridge, with 802.1ad vlan encaps,   without fastpath: ipv4/6: established bytes 0 < 4194304
WARN:  unaware bridge, with pppoe encap,           without fastpath: ipv4/6: established bytes 0 < 4194304
WARN:  unaware bridge, with pppoe-in-q encaps,     without fastpath: ipv4/6: established bytes 0 < 4194304
PASS:  aware bridge,   without/without vlan encap, without fastpath
PASS:  aware bridge,   with/without vlan encap,    without fastpath
PASS:  aware bridge,   with/with vlan encap,       without fastpath
PASS:  aware bridge,   without/with vlan encap,    without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, without fastpath
WARN:  forward,        without vlan-device, with vlan encap,    client1, with fastpath: ipv4/6: tcp broken
PASS:  forward,        with vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, without fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, with fastpath
PASS:  all tests passed

With patches:

PASS:  unaware bridge, without encaps,             without fastpath
PASS:  unaware bridge, without encaps,             with fastpath
PASS:  unaware bridge, with single vlan encap,     without fastpath
PASS:  unaware bridge, with single vlan encap,     with fastpath
PASS:  unaware bridge, with double q vlan encaps,  without fastpath
PASS:  unaware bridge, with double q vlan encaps,  with fastpath
PASS:  unaware bridge, with 802.1ad vlan encaps,   without fastpath
PASS:  unaware bridge, with 802.1ad vlan encaps,   with fastpath
PASS:  unaware bridge, with pppoe encap,           without fastpath
PASS:  unaware bridge, with pppoe encap,           with fastpath
PASS:  unaware bridge, with pppoe-in-q encaps,     without fastpath
PASS:  unaware bridge, with pppoe-in-q encaps,     with fastpath
PASS:  aware bridge,   without/without vlan encap, without fastpath
PASS:  aware bridge,   without/without vlan encap, with fastpath
PASS:  aware bridge,   with/without vlan encap,    without fastpath
PASS:  aware bridge,   with/without vlan encap,    with fastpath
PASS:  aware bridge,   with/with vlan encap,       without fastpath
PASS:  aware bridge,   with/with vlan encap,       with fastpath
PASS:  aware bridge,   without/with vlan encap,    without fastpath
PASS:  aware bridge,   without/with vlan encap,    with fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, without fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, with fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, without fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, with fastpath
PASS:  all tests passed

BANANAPI-R3 (lan1 & lan2 are dsa):
============

Without patches:

./bridge_fastpath.sh -t -0 enu1u2,lan2 -1 enu1u1,lan1 -2 lan4,eth1 Setup:

            CLIENT 0
              enu1u2
                |
              lan2
               WAN
              ROUTER
          LAN1      LAN2
          lan1      eth1
           |          |
        enu1u1      lan4
      CLIENT 1      CLIENT 2
PASS:  unaware bridge, without encaps,             without fastpath
PASS:  unaware bridge, with single vlan encap,     without fastpath
WARN:  unaware bridge, with pppoe encap,           without fastpath: ipv4/6: established bytes 0 < 4194304
WARN:  unaware bridge, with pppoe-in-q encaps,     without fastpath: ipv4/6: established bytes 0 < 4194304
PASS:  aware bridge,   without/without vlan encap, without fastpath
PASS:  aware bridge,   with/without vlan encap,    without fastpath
PASS:  aware bridge,   with/with vlan encap,       without fastpath
PASS:  aware bridge,   without/with vlan encap,    without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, without fastpath
WARN:  forward,        without vlan-device, without vlan encap, client1, with fastpath: ipv4: counted bytes 2110480 > 2097152
WARN:  forward,        without vlan-device, without vlan encap, client1, with fastpath: ipv6: counted bytes 2116104 > 2097152
PASS:  forward,        without vlan-device, without vlan encap, client1, with hw_fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, with fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, with hw_fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, without fastpath
WARN:  forward,        without vlan-device, with vlan encap,    client1, with fastpath: ipv4/6: tcp broken
WARN:  forward,        without vlan-device, with vlan encap,    client1, with hw_fastpath: ipv4/6: tcp broken
PASS:  forward,        without vlan-device, with vlan encap,    client2, without fastpath
WARN:  forward,        without vlan-device, with vlan encap,    client2, with fastpath: ipv4/6: tcp broken
WARN:  forward,        without vlan-device, with vlan encap,    client2, with hw_fastpath: ipv4/6: tcp broken
PASS:  forward,        with vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, with hw_fastpath
PASS:  forward,        with vlan-device, without vlan encap, client2, without fastpath
WARN:  forward,        with vlan-device, without vlan encap, client2, with fastpath: ipv4: counted bytes 2122388 > 2097152
WARN:  forward,        with vlan-device, without vlan encap, client2, with fastpath: ipv6: counted bytes 2129280 > 2097152
WARN:  forward,        with vlan-device, without vlan encap, client2, with hw_fastpath: ipv4: counted bytes 2110428 > 2097152
WARN:  forward,        with vlan-device, without vlan encap, client2, with hw_fastpath: ipv6: counted bytes 2140144 > 2097152
PASS:  forward,        with vlan-device, with vlan encap,    client1, without fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, with fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, with hw_fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client2, without fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client2, with fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client2, with hw_fastpath
PASS:  all tests passed

With patches:

PASS:  unaware bridge, without encaps,             without fastpath
PASS:  unaware bridge, without encaps,             with fastpath
PASS:  unaware bridge, without encaps,             with hw_fastpath
PASS:  unaware bridge, with single vlan encap,     without fastpath
PASS:  unaware bridge, with single vlan encap,     with fastpath
PASS:  unaware bridge, with single vlan encap,     with hw_fastpath
PASS:  unaware bridge, with pppoe encap,           without fastpath
PASS:  unaware bridge, with pppoe encap,           with fastpath
PASS:  unaware bridge, with pppoe encap,           with hw_fastpath
PASS:  unaware bridge, with pppoe-in-q encaps,     without fastpath
PASS:  unaware bridge, with pppoe-in-q encaps,     with fastpath
PASS:  unaware bridge, with pppoe-in-q encaps,     with hw_fastpath
PASS:  aware bridge,   without/without vlan encap, without fastpath
PASS:  aware bridge,   without/without vlan encap, with fastpath
PASS:  aware bridge,   without/without vlan encap, with hw_fastpath
PASS:  aware bridge,   with/without vlan encap,    without fastpath
PASS:  aware bridge,   with/without vlan encap,    with fastpath
PASS:  aware bridge,   with/without vlan encap,    with hw_fastpath
PASS:  aware bridge,   with/with vlan encap,       without fastpath
PASS:  aware bridge,   with/with vlan encap,       with fastpath
PASS:  aware bridge,   with/with vlan encap,       with hw_fastpath
PASS:  aware bridge,   without/with vlan encap,    without fastpath
PASS:  aware bridge,   without/with vlan encap,    with fastpath
PASS:  aware bridge,   without/with vlan encap,    with hw_fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        without vlan-device, without vlan encap, client1, with hw_fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, with fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, with hw_fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, without fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, with fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client1, with hw_fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client2, without fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client2, with fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client2, with hw_fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, without fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, with fastpath
PASS:  forward,        with vlan-device, without vlan encap, client1, with hw_fastpath
PASS:  forward,        with vlan-device, without vlan encap, client2, without fastpath
PASS:  forward,        with vlan-device, without vlan encap, client2, with fastpath
PASS:  forward,        with vlan-device, without vlan encap, client2, with hw_fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, without fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, with fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client1, with hw_fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client2, without fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client2, with fastpath
PASS:  forward,        with vlan-device, with vlan encap,    client2, with hw_fastpath
PASS:  all tests passed
 .../testing/selftests/net/netfilter/Makefile  |    1 +
 .../net/netfilter/bridge_fastpath.sh          | 1055 +++++++++++++++++
 2 files changed, 1056 insertions(+)
 create mode 100755 tools/testing/selftests/net/netfilter/bridge_fastpath.sh
tools/testing/selftests/net/netfilter/Makefile +1 -0
index a98ed892f55f..e0de04333a3f 100644
@@ -8,6 +8,7 @@ MNL_LDLIBS := $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl)
 
 TEST_PROGS := br_netfilter.sh bridge_brouter.sh
 TEST_PROGS += br_netfilter_queue.sh
+TEST_PROGS += bridge_fastpath.sh
 TEST_PROGS += conntrack_dump_flush.sh
 TEST_PROGS += conntrack_icmp_related.sh
 TEST_PROGS += conntrack_ipip_mtu.sh
tools/testing/selftests/net/netfilter/bridge_fastpath.sh new file +1055 -0

1,055 lines not on this page · raw message

Signature · 1 line
2.50.0
maintainer
#1 lore raw
Quoted 3 lines · Eric Woudstra

Add a script to test various scenarios where a bridge is involved in the fastpath. It runs tests in the forward path, and also in a bridged path.

Why is this still an RFC, what is missing to appy this?

Also:

PASS: forward, without vlan-device, without vlan encap, client1, without fastpath

net/bridge/br_private.h:1627 suspicious rcu_dereference_protected() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
7 locks held by socat/410:
#0: ffff88800d7a9c90 (sk_lock-AF_INET){+.+.}-{0:0}, at: inet_stream_connect+0x43/0xa0 #1: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: __ip_queue_xmit+0x62/0x1830 #2: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: ip_output+0x57/0x3c0 #3: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: ip_finish_output2+0x263/0x17d0 #4: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: process_backlog+0x38a/0x14b0 #5: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: netif_receive_skb_internal+0x83/0x330 #6: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: nf_hook.constprop.0+0x8a/0x440

stack backtrace:
CPU: 0 UID: 0 PID: 410 Comm: socat Not tainted 6.17.0-rc7-virtme #1 PREEMPT(full)
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
 <IRQ>
 dump_stack_lvl+0x6f/0xb0
 lockdep_rcu_suspicious.cold+0x4f/0xb1
 br_vlan_fill_forward_path_pvid+0x32c/0x410 [bridge]
 br_fill_forward_path+0x7a/0x4d0 [bridge]
 ...

I did not see a mention of this, nor a bug fix.

Its a pre-existing bug, br_vlan_fill_forward_path_pvid uses br_vlan_group() instead of _rcu version.

Will you send a patch for this?

#2 lore raw
Quoted 6 lines · Florian Westphal
Quoted 3 lines · Eric Woudstra

Add a script to test various scenarios where a bridge is involved in the fastpath. It runs tests in the forward path, and also in a bridged path.

Why is this still an RFC, what is missing to appy this?

Changes in the patchset "conntrack: bridge: add double vlan, pppoe and pppoe-in-q" has lead to changes in this script. I'm waiting for that patch-set is to be accepted. Then I will send this script without the rfc tag.

Quoted 29 lines

Also:

PASS: forward, without vlan-device, without vlan encap, client1, without fastpath

net/bridge/br_private.h:1627 suspicious rcu_dereference_protected() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
7 locks held by socat/410:
#0: ffff88800d7a9c90 (sk_lock-AF_INET){+.+.}-{0:0}, at: inet_stream_connect+0x43/0xa0 #1: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: __ip_queue_xmit+0x62/0x1830 #2: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: ip_output+0x57/0x3c0 #3: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: ip_finish_output2+0x263/0x17d0 #4: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: process_backlog+0x38a/0x14b0 #5: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: netif_receive_skb_internal+0x83/0x330 #6: ffffffff9a779900 (rcu_read_lock){....}-{1:3}, at: nf_hook.constprop.0+0x8a/0x440

stack backtrace:
CPU: 0 UID: 0 PID: 410 Comm: socat Not tainted 6.17.0-rc7-virtme #1 PREEMPT(full)
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
 <IRQ>
 dump_stack_lvl+0x6f/0xb0
 lockdep_rcu_suspicious.cold+0x4f/0xb1
 br_vlan_fill_forward_path_pvid+0x32c/0x410 [bridge]
 br_fill_forward_path+0x7a/0x4d0 [bridge]
 ...
Quoted 6 lines

I did not see a mention of this, nor a bug fix.

Its a pre-existing bug, br_vlan_fill_forward_path_pvid uses br_vlan_group() instead of _rcu version.

Will you send a patch for this?

I had this as part of an upcoming patch-set, but I will remove it from there and send it as a separate patch. I assume this can go to nf instead of nf-next, as it is a bugfix?

maintainer
#3 lore raw
Quoted 4 lines · Eric Woudstra

Changes in the patchset "conntrack: bridge: add double vlan, pppoe and pppoe-in-q" has lead to changes in this script. I'm waiting for that patch-set is to be accepted. Then I will send this script without the rfc tag.

Can you send this script standalone? You can extend it along with the feature patches.

Quoted 7 lines
Quoted 4 lines

Its a pre-existing bug, br_vlan_fill_forward_path_pvid uses br_vlan_group() instead of _rcu version.

Will you send a patch for this?

I had this as part of an upcoming patch-set, but I will remove it from there and send it as a separate patch. I assume this can go to nf instead of nf-next, as it is a bugfix?

Yes, standalone fix for nf, with "Fies" tag pointing at the patch that introduced this bug.