Skip to contentSkip to conversation

selftests: netfilter: Add bridge_fastpath.sh

RFC PATCH Superseded Eric Woudstra 1 participant 1 message Apr 8, 2025

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 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.

Because the development of this script has helped me find and fix a few issues in my last version of the patches needed for bridge-fastpath, I am sending the whole set again (split up in smaller patch-sets), including the latest fixes.

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
ERROR: unaware bridge, with double q vlan encaps, without fastpath: ipv4/6: established bytes 0 < 4194304
ERROR: unaware bridge, with 802.1ad vlan 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
ERROR: forward,        without vlan-device, with vlan encap,    client1, with fastpath: ipv4/6: tcp broken
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,    without vlan encap, client1, without fastpath
PASS:  forward,        with vlan-device,    without vlan encap, client1, with fastpath
ERROR: bridge fastpath test has failed

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:  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,    with vlan encap,    client1, without fastpath
PASS:  forward,        with 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:  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
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
ERROR: forward,        without vlan-device, without vlan encap, client1, with fastpath: ipv4: counted bytes 2118540 > 2097152
ERROR: forward,        without vlan-device, without vlan encap, client1, with fastpath: ipv6: counted bytes 2117904 > 2097152
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
ERROR: forward,        without vlan-device, with vlan encap,    client1, with fastpath: ipv4/6: tcp broken
PASS:  forward,        without vlan-device, with vlan encap,    client2, without fastpath
ERROR: forward,        without vlan-device, with vlan encap,    client2, with fastpath: ipv4/6: tcp broken
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:  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
ERROR: forward,        with vlan-device,    without vlan encap, client2, with fastpath: ipv4: counted bytes 2109596 > 2097152
ERROR: forward,        with vlan-device,    without vlan encap, client2, with fastpath: ipv6: counted bytes 2121432 > 2097152
ERROR: bridge fastpath test has failed

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:  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,    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:  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:  all tests passed

AM3359 (end1 supports SWITCHDEV_OBJ_ID_PORT_VLAN, ipv4 only for now):
=======
./bridge_fastpath.sh -t -a -4 -d -1 enu1u4c2,end1

Without patches:

Setup:
CLIENT 0
veth0cl
|
veth0rt
WAN
ROUTER
LAN1 LAN2
end1 veth2rt
| |
enu1u4c2 veth2cl
CLIENT 1 CLIENT 2

INFO: Skipping unaware bridge
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
ERROR: forward,        without vlan-device, without vlan encap, client1, with fastpath: ipv4: counted bytes 2190092 > 2097152
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, with vlan encap,    client1, without fastpath
ERROR: forward,        without vlan-device, with vlan encap,    client1, with fastpath: ipv4: tcp broken
PASS:  forward,        without vlan-device, with vlan encap,    client2, without fastpath
ERROR: forward,        without vlan-device, with vlan encap,    client2, with fastpath: ipv4: tcp broken
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,    client2, without fastpath
PASS:  forward,        with vlan-device,    with vlan encap,    client2, 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,    without vlan encap, client2, without fastpath
PASS:  forward,        with vlan-device,    without vlan encap, client2, with fastpath
ERROR: bridge fastpath test has failed

With patches:

INFO: Skipping unaware bridge
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, without vlan encap, client2, without fastpath
PASS:  forward,        without vlan-device, without vlan encap, client2, 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,        without vlan-device, with vlan encap,    client2, without fastpath
PASS:  forward,        without vlan-device, with vlan encap,    client2, 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:  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,    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, client2, without fastpath
PASS:  forward,        with vlan-device,    without vlan encap, client2, with fastpath
PASS:  all tests passed

(Some problem still to figure out for my AM3359 hardware: On the second run
of the command the tcp traffic is ok on all tests ipv4. On the first run the hardware is not setup correctly, some tests report broken tcp even without fastpath. Also ipv6 tcp broken even on second run even without fastpath. This may be a problem with my hardware or the test-script, but anyway it shows the fastpath is functional)

 .../testing/selftests/net/netfilter/Makefile  |   1 +
 .../net/netfilter/bridge_fastpath.sh          | 922 ++++++++++++++++++
 2 files changed, 923 insertions(+)
 create mode 100755 tools/testing/selftests/net/netfilter/bridge_fastpath.sh
tools/testing/selftests/net/netfilter/Makefile +1 -0
index ffe161fac8b5..104dd9e5e02a 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 +922 -0

922 lines not on this page · raw message

Signature · 1 line
2.47.1