* [PATCH net-next 1/8] selftests: forwarding: add option to run tests with stable MAC addresses
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
@ 2022-04-22 10:14 ` Vladimir Oltean
2022-04-22 10:14 ` [PATCH net-next 2/8] selftests: forwarding: add TCPDUMP_EXTRA_FLAGS to lib.sh Vladimir Oltean
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:14 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
By default, DSA switch ports inherit their MAC address from the DSA
master.
This works well for practical situations, but some selftests like
bridge_vlan_unaware.sh loop back 2 standalone DSA ports with 2 bridged
DSA ports, and require the bridge to forward packets between the
standalone ports.
Due to the bridge seeing that the MAC DA it needs to forward is present
as a local FDB entry (it coincides with the MAC address of the bridge
ports), the test packets are not forwarded, but terminated locally on
br0. In turn, this makes the ping and ping6 tests fail.
Address this by introducing an option to have stable MAC addresses.
When mac_addr_prepare is called, the current addresses of the netifs are
saved and replaced with 00:01:02:03:04:${netif number}. Then when
mac_addr_restore is called at the end of the test, the original MAC
addresses are restored. This ensures that the MAC addresses are unique,
which makes the test pass even for DSA ports.
The usage model is for the behavior to be opt-in via STABLE_MAC_ADDRS,
which DSA should set to true, all others behave as before. By hooking
the calls to mac_addr_prepare and mac_addr_restore within the forwarding
lib itself, we do not need to patch each individual selftest, the only
requirement is that pre_cleanup is called.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 664b9ecaf228..e3b3cdef3170 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -27,6 +27,7 @@ INTERFACE_TIMEOUT=${INTERFACE_TIMEOUT:=600}
LOW_AGEING_TIME=${LOW_AGEING_TIME:=1000}
REQUIRE_JQ=${REQUIRE_JQ:=yes}
REQUIRE_MZ=${REQUIRE_MZ:=yes}
+STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no}
relative_path="${BASH_SOURCE%/*}"
if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
@@ -214,10 +215,41 @@ create_netif()
esac
}
+declare -A MAC_ADDR_ORIG
+mac_addr_prepare()
+{
+ local new_addr=
+ local dev=
+
+ for ((i = 1; i <= NUM_NETIFS; ++i)); do
+ dev=${NETIFS[p$i]}
+ new_addr=$(printf "00:01:02:03:04:%02x" $i)
+
+ MAC_ADDR_ORIG["$dev"]=$(ip -j link show dev $dev | jq -e '.[].address')
+ # Strip quotes
+ MAC_ADDR_ORIG["$dev"]=${MAC_ADDR_ORIG["$dev"]//\"/}
+ ip link set dev $dev address $new_addr
+ done
+}
+
+mac_addr_restore()
+{
+ local dev=
+
+ for ((i = 1; i <= NUM_NETIFS; ++i)); do
+ dev=${NETIFS[p$i]}
+ ip link set dev $dev address ${MAC_ADDR_ORIG["$dev"]}
+ done
+}
+
if [[ "$NETIF_CREATE" = "yes" ]]; then
create_netif
fi
+if [[ "$STABLE_MAC_ADDRS" = "yes" ]]; then
+ mac_addr_prepare
+fi
+
for ((i = 1; i <= NUM_NETIFS; ++i)); do
ip link show dev ${NETIFS[p$i]} &> /dev/null
if [[ $? -ne 0 ]]; then
@@ -503,6 +535,10 @@ pre_cleanup()
echo "Pausing before cleanup, hit any key to continue"
read
fi
+
+ if [[ "$STABLE_MAC_ADDRS" = "yes" ]]; then
+ mac_addr_restore
+ fi
}
vrf_prepare()
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 2/8] selftests: forwarding: add TCPDUMP_EXTRA_FLAGS to lib.sh
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
2022-04-22 10:14 ` [PATCH net-next 1/8] selftests: forwarding: add option to run tests with stable MAC addresses Vladimir Oltean
@ 2022-04-22 10:14 ` Vladimir Oltean
2022-04-22 10:14 ` [PATCH net-next 3/8] selftests: forwarding: multiple instances in tcpdump helper Vladimir Oltean
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:14 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
From: Joachim Wiberg <troglobit@gmail.com>
For some use-cases we may want to change the tcpdump flags used in
tcpdump_start(). For instance, observing interfaces without the PROMISC
flag, e.g. to see what's really being forwarded to the bridge interface.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
mode change 100644 => 100755 tools/testing/selftests/net/forwarding/lib.sh
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
old mode 100644
new mode 100755
index e3b3cdef3170..de10451d7671
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -28,6 +28,7 @@ LOW_AGEING_TIME=${LOW_AGEING_TIME:=1000}
REQUIRE_JQ=${REQUIRE_JQ:=yes}
REQUIRE_MZ=${REQUIRE_MZ:=yes}
STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no}
+TCPDUMP_EXTRA_FLAGS=${TCPDUMP_EXTRA_FLAGS:=}
relative_path="${BASH_SOURCE%/*}"
if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
@@ -1405,7 +1406,7 @@ tcpdump_start()
capuser="-Z $SUDO_USER"
fi
- $ns_cmd tcpdump -e -n -Q in -i $if_name \
+ $ns_cmd tcpdump $TCPDUMP_EXTRA_FLAGS -e -n -Q in -i $if_name \
-s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
cappid=$!
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 3/8] selftests: forwarding: multiple instances in tcpdump helper
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
2022-04-22 10:14 ` [PATCH net-next 1/8] selftests: forwarding: add option to run tests with stable MAC addresses Vladimir Oltean
2022-04-22 10:14 ` [PATCH net-next 2/8] selftests: forwarding: add TCPDUMP_EXTRA_FLAGS to lib.sh Vladimir Oltean
@ 2022-04-22 10:14 ` Vladimir Oltean
2022-04-22 10:15 ` [PATCH net-next 4/8] selftests: forwarding: add helpers for IP multicast group joins/leaves Vladimir Oltean
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:14 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
From: Joachim Wiberg <troglobit@gmail.com>
Extend tcpdump_start() & C:o to handle multiple instances. Useful when
observing bridge operation, e.g., unicast learning/flooding, and any
case of multicast distribution (to these ports but not that one ...).
This means the interface argument is now a mandatory argument to all
tcpdump_*() functions, hence the changes to the ocelot flower test.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
.../drivers/net/ocelot/tc_flower_chains.sh | 24 ++++++++---------
tools/testing/selftests/net/forwarding/lib.sh | 26 ++++++++++++++-----
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh
index eaf8a04a7ca5..7e684e27a682 100755
--- a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh
+++ b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh
@@ -215,15 +215,15 @@ test_vlan_pop()
sleep 1
- tcpdump_stop
+ tcpdump_stop $eth2
- if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then
+ if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then
echo "OK"
else
echo "FAIL"
fi
- tcpdump_cleanup
+ tcpdump_cleanup $eth2
}
test_vlan_push()
@@ -236,15 +236,15 @@ test_vlan_push()
sleep 1
- tcpdump_stop
+ tcpdump_stop $eth3.100
- if tcpdump_show | grep -q "$eth2_mac > $eth3_mac"; then
+ if tcpdump_show $eth3.100 | grep -q "$eth2_mac > $eth3_mac"; then
echo "OK"
else
echo "FAIL"
fi
- tcpdump_cleanup
+ tcpdump_cleanup $eth3.100
}
test_vlan_ingress_modify()
@@ -267,15 +267,15 @@ test_vlan_ingress_modify()
sleep 1
- tcpdump_stop
+ tcpdump_stop $eth2
- if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
+ if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
echo "OK"
else
echo "FAIL"
fi
- tcpdump_cleanup
+ tcpdump_cleanup $eth2
tc filter del dev $eth0 ingress chain $(IS1 2) pref 3
@@ -305,15 +305,15 @@ test_vlan_egress_modify()
sleep 1
- tcpdump_stop
+ tcpdump_stop $eth2
- if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
+ if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then
echo "OK"
else
echo "FAIL"
fi
- tcpdump_cleanup
+ tcpdump_cleanup $eth2
tc filter del dev $eth1 egress chain $(ES0) pref 3
tc qdisc del dev $eth1 clsact
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index de10451d7671..7eff5ecf7565 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -1386,13 +1386,17 @@ stop_traffic()
{ kill %% && wait %%; } 2>/dev/null
}
+declare -A cappid
+declare -A capfile
+declare -A capout
+
tcpdump_start()
{
local if_name=$1; shift
local ns=$1; shift
- capfile=$(mktemp)
- capout=$(mktemp)
+ capfile[$if_name]=$(mktemp)
+ capout[$if_name]=$(mktemp)
if [ -z $ns ]; then
ns_cmd=""
@@ -1407,26 +1411,34 @@ tcpdump_start()
fi
$ns_cmd tcpdump $TCPDUMP_EXTRA_FLAGS -e -n -Q in -i $if_name \
- -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 &
- cappid=$!
+ -s 65535 -B 32768 $capuser -w ${capfile[$if_name]} \
+ > "${capout[$if_name]}" 2>&1 &
+ cappid[$if_name]=$!
sleep 1
}
tcpdump_stop()
{
- $ns_cmd kill $cappid
+ local if_name=$1
+ local pid=${cappid[$if_name]}
+
+ $ns_cmd kill "$pid" && wait "$pid"
sleep 1
}
tcpdump_cleanup()
{
- rm $capfile $capout
+ local if_name=$1
+
+ rm ${capfile[$if_name]} ${capout[$if_name]}
}
tcpdump_show()
{
- tcpdump -e -n -r $capfile 2>&1
+ local if_name=$1
+
+ tcpdump -e -n -r ${capfile[$if_name]} 2>&1
}
# return 0 if the packet wasn't seen on host2_if or 1 if it was
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 4/8] selftests: forwarding: add helpers for IP multicast group joins/leaves
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (2 preceding siblings ...)
2022-04-22 10:14 ` [PATCH net-next 3/8] selftests: forwarding: multiple instances in tcpdump helper Vladimir Oltean
@ 2022-04-22 10:15 ` Vladimir Oltean
2022-04-22 10:15 ` [PATCH net-next 5/8] selftests: forwarding: add helper for retrieving IPv6 link-local address of interface Vladimir Oltean
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:15 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
Extend the forwarding library with calls to some small C programs which
join an IP multicast group and send some packets to it. Both IPv4 and
IPv6 groups are supported. Use cases range from testing IGMP/MLD
snooping, to RX filtering, to multicast routing.
Testing multicast traffic using msend/mreceive is intended to be done
using tcpdump.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 7eff5ecf7565..15fb46b39fe8 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -27,6 +27,7 @@ INTERFACE_TIMEOUT=${INTERFACE_TIMEOUT:=600}
LOW_AGEING_TIME=${LOW_AGEING_TIME:=1000}
REQUIRE_JQ=${REQUIRE_JQ:=yes}
REQUIRE_MZ=${REQUIRE_MZ:=yes}
+REQUIRE_MTOOLS=${REQUIRE_MTOOLS:=no}
STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no}
TCPDUMP_EXTRA_FLAGS=${TCPDUMP_EXTRA_FLAGS:=}
@@ -161,6 +162,12 @@ fi
if [[ "$REQUIRE_MZ" = "yes" ]]; then
require_command $MZ
fi
+if [[ "$REQUIRE_MTOOLS" = "yes" ]]; then
+ # https://github.com/vladimiroltean/mtools/
+ # patched for IPv6 support
+ require_command msend
+ require_command mreceive
+fi
if [[ ! -v NUM_NETIFS ]]; then
echo "SKIP: importer does not define \"NUM_NETIFS\""
@@ -1548,6 +1555,37 @@ brmcast_check_sg_state()
done
}
+mc_join()
+{
+ local if_name=$1
+ local group=$2
+ local vrf_name=$(master_name_get $if_name)
+
+ # We don't care about actual reception, just about joining the
+ # IP multicast group and adding the L2 address to the device's
+ # MAC filtering table
+ ip vrf exec $vrf_name \
+ mreceive -g $group -I $if_name > /dev/null 2>&1 &
+ mreceive_pid=$!
+
+ sleep 1
+}
+
+mc_leave()
+{
+ kill "$mreceive_pid" && wait "$mreceive_pid"
+}
+
+mc_send()
+{
+ local if_name=$1
+ local groups=$2
+ local vrf_name=$(master_name_get $if_name)
+
+ ip vrf exec $vrf_name \
+ msend -g $groups -I $if_name -c 1 > /dev/null 2>&1
+}
+
start_ip_monitor()
{
local mtype=$1; shift
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 5/8] selftests: forwarding: add helper for retrieving IPv6 link-local address of interface
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (3 preceding siblings ...)
2022-04-22 10:15 ` [PATCH net-next 4/8] selftests: forwarding: add helpers for IP multicast group joins/leaves Vladimir Oltean
@ 2022-04-22 10:15 ` Vladimir Oltean
2022-04-22 10:15 ` [PATCH net-next 6/8] selftests: forwarding: add a no_forwarding.sh test Vladimir Oltean
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:15 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
Pinging an IPv6 link-local multicast address selects the link-local
unicast address of the interface as source, and we'd like to monitor for
that in tcpdump.
Add a helper to the forwarding library which retrieves the link-local
IPv6 address of an interface, to make that task easier.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 15fb46b39fe8..5386c826e46a 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -868,6 +868,15 @@ mac_get()
ip -j link show dev $if_name | jq -r '.[]["address"]'
}
+ipv6_lladdr_get()
+{
+ local if_name=$1
+
+ ip -j addr show dev $if_name | \
+ jq -r '.[]["addr_info"][] | select(.scope == "link").local' | \
+ head -1
+}
+
bridge_ageing_time_get()
{
local bridge=$1
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 6/8] selftests: forwarding: add a no_forwarding.sh test
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (4 preceding siblings ...)
2022-04-22 10:15 ` [PATCH net-next 5/8] selftests: forwarding: add helper for retrieving IPv6 link-local address of interface Vladimir Oltean
@ 2022-04-22 10:15 ` Vladimir Oltean
2022-04-22 10:15 ` [PATCH net-next 7/8] selftests: forwarding: add a test for local_termination.sh Vladimir Oltean
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:15 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
Bombard a standalone switch port with various kinds of traffic to ensure
it is really standalone and doesn't leak packets to other switch ports.
Also check for switch ports in different bridges, and switch ports in a
VLAN-aware bridge but having different pvids. No forwarding should take
place in either case.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
.../selftests/net/forwarding/no_forwarding.sh | 261 ++++++++++++++++++
1 file changed, 261 insertions(+)
create mode 100755 tools/testing/selftests/net/forwarding/no_forwarding.sh
diff --git a/tools/testing/selftests/net/forwarding/no_forwarding.sh b/tools/testing/selftests/net/forwarding/no_forwarding.sh
new file mode 100755
index 000000000000..af3b398d13f0
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/no_forwarding.sh
@@ -0,0 +1,261 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+ALL_TESTS="standalone two_bridges one_bridge_two_pvids"
+NUM_NETIFS=4
+
+source lib.sh
+
+h1=${NETIFS[p1]}
+h2=${NETIFS[p3]}
+swp1=${NETIFS[p2]}
+swp2=${NETIFS[p4]}
+
+H1_IPV4="192.0.2.1"
+H2_IPV4="192.0.2.2"
+H1_IPV6="2001:db8:1::1"
+H2_IPV6="2001:db8:1::2"
+
+IPV4_ALLNODES="224.0.0.1"
+IPV6_ALLNODES="ff02::1"
+MACV4_ALLNODES="01:00:5e:00:00:01"
+MACV6_ALLNODES="33:33:00:00:00:01"
+NON_IP_MC="01:02:03:04:05:06"
+NON_IP_PKT="00:04 48:45:4c:4f"
+BC="ff:ff:ff:ff:ff:ff"
+
+# The full 4K VLAN space is too much to check, so strategically pick some
+# values which should provide reasonable coverage
+vids=(0 1 2 5 10 20 50 100 200 500 1000 1000 2000 4000 4094)
+
+send_non_ip()
+{
+ local if_name=$1
+ local smac=$2
+ local dmac=$3
+
+ $MZ -q $if_name "$dmac $smac $NON_IP_PKT"
+}
+
+send_uc_ipv4()
+{
+ local if_name=$1
+ local dmac=$2
+
+ ip neigh add $H2_IPV4 lladdr $dmac dev $if_name
+ ping_do $if_name $H2_IPV4
+ ip neigh del $H2_IPV4 dev $if_name
+}
+
+send_mc_ipv4()
+{
+ local if_name=$1
+
+ ping_do $if_name $IPV4_ALLNODES "-I $if_name"
+}
+
+send_uc_ipv6()
+{
+ local if_name=$1
+ local dmac=$2
+
+ ip -6 neigh add $H2_IPV6 lladdr $dmac dev $if_name
+ ping6_do $if_name $H2_IPV6
+ ip -6 neigh del $H2_IPV6 dev $if_name
+}
+
+send_mc_ipv6()
+{
+ local if_name=$1
+
+ ping6_do $if_name $IPV6_ALLNODES%$if_name
+}
+
+check_rcv()
+{
+ local if_name=$1
+ local type=$2
+ local pattern=$3
+ local should_fail=1
+
+ RET=0
+
+ tcpdump_show $if_name | grep -q "$pattern"
+
+ check_err_fail "$should_fail" "$?" "reception"
+
+ log_test "$type"
+}
+
+run_test()
+{
+ local test_name="$1"
+ local smac=$(mac_get $h1)
+ local dmac=$(mac_get $h2)
+ local h1_ipv6_lladdr=$(ipv6_lladdr_get $h1)
+ local vid=
+
+ echo "$test_name: Sending packets"
+
+ tcpdump_start $h2
+
+ send_non_ip $h1 $smac $dmac
+ send_non_ip $h1 $smac $NON_IP_MC
+ send_non_ip $h1 $smac $BC
+ send_uc_ipv4 $h1 $dmac
+ send_mc_ipv4 $h1
+ send_uc_ipv6 $h1 $dmac
+ send_mc_ipv6 $h1
+
+ for vid in "${vids[@]}"; do
+ vlan_create $h1 $vid
+ simple_if_init $h1.$vid $H1_IPV4/24 $H1_IPV6/64
+
+ send_non_ip $h1.$vid $smac $dmac
+ send_non_ip $h1.$vid $smac $NON_IP_MC
+ send_non_ip $h1.$vid $smac $BC
+ send_uc_ipv4 $h1.$vid $dmac
+ send_mc_ipv4 $h1.$vid
+ send_uc_ipv6 $h1.$vid $dmac
+ send_mc_ipv6 $h1.$vid
+
+ simple_if_fini $h1.$vid $H1_IPV4/24 $H1_IPV6/64
+ vlan_destroy $h1 $vid
+ done
+
+ sleep 1
+
+ echo "$test_name: Checking which packets were received"
+
+ tcpdump_stop $h2
+
+ check_rcv $h2 "$test_name: Unicast non-IP untagged" \
+ "$smac > $dmac, 802.3, length 4:"
+
+ check_rcv $h2 "$test_name: Multicast non-IP untagged" \
+ "$smac > $NON_IP_MC, 802.3, length 4:"
+
+ check_rcv $h2 "$test_name: Broadcast non-IP untagged" \
+ "$smac > $BC, 802.3, length 4:"
+
+ check_rcv $h2 "$test_name: Unicast IPv4 untagged" \
+ "$smac > $dmac, ethertype IPv4 (0x0800)"
+
+ check_rcv $h2 "$test_name: Multicast IPv4 untagged" \
+ "$smac > $MACV4_ALLNODES, ethertype IPv4 (0x0800).*: $H1_IPV4 > $IPV4_ALLNODES"
+
+ check_rcv $h2 "$test_name: Unicast IPv6 untagged" \
+ "$smac > $dmac, ethertype IPv6 (0x86dd).*8: $H1_IPV6 > $H2_IPV6"
+
+ check_rcv $h2 "$test_name: Multicast IPv6 untagged" \
+ "$smac > $MACV6_ALLNODES, ethertype IPv6 (0x86dd).*: $h1_ipv6_lladdr > $IPV6_ALLNODES"
+
+ for vid in "${vids[@]}"; do
+ check_rcv $h2 "$test_name: Unicast non-IP VID $vid" \
+ "$smac > $dmac, ethertype 802.1Q (0x8100).*vlan $vid,.*length 4"
+
+ check_rcv $h2 "$test_name: Multicast non-IP VID $vid" \
+ "$smac > $NON_IP_MC, ethertype 802.1Q (0x8100).*vlan $vid,.*length 4"
+
+ check_rcv $h2 "$test_name: Broadcast non-IP VID $vid" \
+ "$smac > $BC, ethertype 802.1Q (0x8100).*vlan $vid,.*length 4"
+
+ check_rcv $h2 "$test_name: Unicast IPv4 VID $vid" \
+ "$smac > $dmac, ethertype 802.1Q (0x8100).*vlan $vid,.*ethertype IPv4 (0x0800), $H1_IPV4 > $H2_IPV4"
+
+ check_rcv $h2 "$test_name: Multicast IPv4 VID $vid" \
+ "$smac > $MACV4_ALLNODES, ethertype 802.1Q (0x8100).*vlan $vid,.*ethertype IPv4 (0x0800), $H1_IPV4 > $IPV4_ALLNODES"
+
+ check_rcv $h2 "$test_name: Unicast IPv6 VID $vid" \
+ "$smac > $dmac, ethertype 802.1Q (0x8100).*vlan $vid,.*ethertype IPv6 (0x86dd), $H1_IPV6 > $H2_IPV6"
+
+ check_rcv $h2 "$test_name: Multicast IPv6 VID $vid" \
+ "$smac > $MACV6_ALLNODES, ethertype 802.1Q (0x8100).*vlan $vid,.*ethertype IPv6 (0x86dd), $h1_ipv6_lladdr > $IPV6_ALLNODES"
+ done
+
+ tcpdump_cleanup $h2
+}
+
+standalone()
+{
+ run_test "Standalone switch ports"
+}
+
+two_bridges()
+{
+ ip link add br0 type bridge && ip link set br0 up
+ ip link add br1 type bridge && ip link set br1 up
+ ip link set $swp1 master br0
+ ip link set $swp2 master br1
+
+ run_test "Switch ports in different bridges"
+
+ ip link del br1
+ ip link del br0
+}
+
+one_bridge_two_pvids()
+{
+ ip link add br0 type bridge vlan_filtering 1 vlan_default_pvid 0
+ ip link set br0 up
+ ip link set $swp1 master br0
+ ip link set $swp2 master br0
+
+ bridge vlan add dev $swp1 vid 1 pvid untagged
+ bridge vlan add dev $swp1 vid 2 pvid untagged
+
+ run_test "Switch ports in VLAN-aware bridge with different PVIDs"
+
+ ip link del br0
+}
+
+h1_create()
+{
+ simple_if_init $h1 $H1_IPV4/24 $H1_IPV6/64
+}
+
+h1_destroy()
+{
+ simple_if_fini $h1 $H1_IPV4/24 $H1_IPV6/64
+}
+
+h2_create()
+{
+ simple_if_init $h2 $H2_IPV4/24 $H2_IPV6/64
+}
+
+h2_destroy()
+{
+ simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
+}
+
+cleanup()
+{
+ pre_cleanup
+
+ h2_destroy
+ h1_destroy
+
+ vrf_cleanup
+}
+
+setup_prepare()
+{
+ vrf_prepare
+
+ h1_create
+ h2_create
+ # we call simple_if_init from the test itself, but setup_wait expects
+ # that we call it from here, and waits until the interfaces are up
+ ip link set dev $swp1 up
+ ip link set dev $swp2 up
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+
+tests_run
+
+exit $EXIT_STATUS
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 7/8] selftests: forwarding: add a test for local_termination.sh
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (5 preceding siblings ...)
2022-04-22 10:15 ` [PATCH net-next 6/8] selftests: forwarding: add a no_forwarding.sh test Vladimir Oltean
@ 2022-04-22 10:15 ` Vladimir Oltean
2022-04-22 10:15 ` [PATCH net-next 8/8] selftests: drivers: dsa: add a subset of forwarding selftests Vladimir Oltean
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:15 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
This tests the capability of switch ports to filter out undesired
traffic. Different drivers are expected to have different capabilities
here (so some may fail and some may pass), yet the test still has some
value, for example to check for regressions.
There are 2 kinds of failures, one is when a packet which should have
been accepted isn't (and that should be fixed), and the other "failure"
(as reported by the test) is when a packet could have been filtered out
(for being unnecessary) yet it was received.
The bridge driver fares particularly badly at this test:
TEST: br0: Unicast IPv4 to primary MAC address [ OK ]
TEST: br0: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: br0: Unicast IPv4 to unknown MAC address [FAIL]
reception succeeded, but should have failed
TEST: br0: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: br0: Unicast IPv4 to unknown MAC address, allmulti [FAIL]
reception succeeded, but should have failed
TEST: br0: Multicast IPv4 to joined group [ OK ]
TEST: br0: Multicast IPv4 to unknown group [FAIL]
reception succeeded, but should have failed
TEST: br0: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: br0: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: br0: Multicast IPv6 to joined group [ OK ]
TEST: br0: Multicast IPv6 to unknown group [FAIL]
reception succeeded, but should have failed
TEST: br0: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: br0: Multicast IPv6 to unknown group, allmulti [ OK ]
mainly because it does not implement IFF_UNICAST_FLT. Yet I still think
having the test (with the failures) is useful in case somebody wants to
tackle that problem in the future, to make an easy before-and-after
comparison.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
.../net/forwarding/local_termination.sh | 299 ++++++++++++++++++
1 file changed, 299 insertions(+)
create mode 100755 tools/testing/selftests/net/forwarding/local_termination.sh
diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh
new file mode 100755
index 000000000000..c5b0cbc85b3e
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/local_termination.sh
@@ -0,0 +1,299 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+ALL_TESTS="standalone bridge"
+NUM_NETIFS=2
+PING_COUNT=1
+REQUIRE_MTOOLS=yes
+REQUIRE_MZ=no
+
+source lib.sh
+
+H1_IPV4="192.0.2.1"
+H2_IPV4="192.0.2.2"
+H1_IPV6="2001:db8:1::1"
+H2_IPV6="2001:db8:1::2"
+
+BRIDGE_ADDR="00:00:de:ad:be:ee"
+MACVLAN_ADDR="00:00:de:ad:be:ef"
+UNKNOWN_UC_ADDR1="de:ad:be:ef:ee:03"
+UNKNOWN_UC_ADDR2="de:ad:be:ef:ee:04"
+UNKNOWN_UC_ADDR3="de:ad:be:ef:ee:05"
+JOINED_IPV4_MC_ADDR="225.1.2.3"
+UNKNOWN_IPV4_MC_ADDR1="225.1.2.4"
+UNKNOWN_IPV4_MC_ADDR2="225.1.2.5"
+UNKNOWN_IPV4_MC_ADDR3="225.1.2.6"
+JOINED_IPV6_MC_ADDR="ff2e::0102:0304"
+UNKNOWN_IPV6_MC_ADDR1="ff2e::0102:0305"
+UNKNOWN_IPV6_MC_ADDR2="ff2e::0102:0306"
+UNKNOWN_IPV6_MC_ADDR3="ff2e::0102:0307"
+
+JOINED_MACV4_MC_ADDR="01:00:5e:01:02:03"
+UNKNOWN_MACV4_MC_ADDR1="01:00:5e:01:02:04"
+UNKNOWN_MACV4_MC_ADDR2="01:00:5e:01:02:05"
+UNKNOWN_MACV4_MC_ADDR3="01:00:5e:01:02:06"
+JOINED_MACV6_MC_ADDR="33:33:01:02:03:04"
+UNKNOWN_MACV6_MC_ADDR1="33:33:01:02:03:05"
+UNKNOWN_MACV6_MC_ADDR2="33:33:01:02:03:06"
+UNKNOWN_MACV6_MC_ADDR3="33:33:01:02:03:07"
+
+NON_IP_MC="01:02:03:04:05:06"
+NON_IP_PKT="00:04 48:45:4c:4f"
+BC="ff:ff:ff:ff:ff:ff"
+
+# Disable promisc to ensure we don't receive unknown MAC DA packets
+export TCPDUMP_EXTRA_FLAGS="-pl"
+
+h1=${NETIFS[p1]}
+h2=${NETIFS[p2]}
+
+send_non_ip()
+{
+ local if_name=$1
+ local smac=$2
+ local dmac=$3
+
+ $MZ -q $if_name "$dmac $smac $NON_IP_PKT"
+}
+
+send_uc_ipv4()
+{
+ local if_name=$1
+ local dmac=$2
+
+ ip neigh add $H2_IPV4 lladdr $dmac dev $if_name
+ ping_do $if_name $H2_IPV4
+ ip neigh del $H2_IPV4 dev $if_name
+}
+
+check_rcv()
+{
+ local if_name=$1
+ local type=$2
+ local pattern=$3
+ local should_receive=$4
+ local should_fail=
+
+ [ $should_receive = true ] && should_fail=0 || should_fail=1
+ RET=0
+
+ tcpdump_show $if_name | grep -q "$pattern"
+
+ check_err_fail "$should_fail" "$?" "reception"
+
+ log_test "$if_name: $type"
+}
+
+mc_route_prepare()
+{
+ local if_name=$1
+ local vrf_name=$(master_name_get $if_name)
+
+ ip route add 225.100.1.0/24 dev $if_name vrf $vrf_name
+ ip -6 route add ff2e::/64 dev $if_name vrf $vrf_name
+}
+
+mc_route_destroy()
+{
+ local if_name=$1
+ local vrf_name=$(master_name_get $if_name)
+
+ ip route del 225.100.1.0/24 dev $if_name vrf $vrf_name
+ ip -6 route del ff2e::/64 dev $if_name vrf $vrf_name
+}
+
+run_test()
+{
+ local rcv_if_name=$1
+ local smac=$(mac_get $h1)
+ local rcv_dmac=$(mac_get $rcv_if_name)
+
+ tcpdump_start $rcv_if_name
+
+ mc_route_prepare $h1
+ mc_route_prepare $rcv_if_name
+
+ send_uc_ipv4 $h1 $rcv_dmac
+ send_uc_ipv4 $h1 $MACVLAN_ADDR
+ send_uc_ipv4 $h1 $UNKNOWN_UC_ADDR1
+
+ ip link set dev $rcv_if_name promisc on
+ send_uc_ipv4 $h1 $UNKNOWN_UC_ADDR2
+ mc_send $h1 $UNKNOWN_IPV4_MC_ADDR2
+ mc_send $h1 $UNKNOWN_IPV6_MC_ADDR2
+ ip link set dev $rcv_if_name promisc off
+
+ mc_join $rcv_if_name $JOINED_IPV4_MC_ADDR
+ mc_send $h1 $JOINED_IPV4_MC_ADDR
+ mc_leave
+
+ mc_join $rcv_if_name $JOINED_IPV6_MC_ADDR
+ mc_send $h1 $JOINED_IPV6_MC_ADDR
+ mc_leave
+
+ mc_send $h1 $UNKNOWN_IPV4_MC_ADDR1
+ mc_send $h1 $UNKNOWN_IPV6_MC_ADDR1
+
+ ip link set dev $rcv_if_name allmulticast on
+ send_uc_ipv4 $h1 $UNKNOWN_UC_ADDR3
+ mc_send $h1 $UNKNOWN_IPV4_MC_ADDR3
+ mc_send $h1 $UNKNOWN_IPV6_MC_ADDR3
+ ip link set dev $rcv_if_name allmulticast off
+
+ mc_route_destroy $rcv_if_name
+ mc_route_destroy $h1
+
+ sleep 1
+
+ tcpdump_stop $rcv_if_name
+
+ check_rcv $rcv_if_name "Unicast IPv4 to primary MAC address" \
+ "$smac > $rcv_dmac, ethertype IPv4 (0x0800)" \
+ true
+
+ check_rcv $rcv_if_name "Unicast IPv4 to macvlan MAC address" \
+ "$smac > $MACVLAN_ADDR, ethertype IPv4 (0x0800)" \
+ true
+
+ check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \
+ "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \
+ false
+
+ check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, promisc" \
+ "$smac > $UNKNOWN_UC_ADDR2, ethertype IPv4 (0x0800)" \
+ true
+
+ check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, allmulti" \
+ "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \
+ false
+
+ check_rcv $rcv_if_name "Multicast IPv4 to joined group" \
+ "$smac > $JOINED_MACV4_MC_ADDR, ethertype IPv4 (0x0800)" \
+ true
+
+ check_rcv $rcv_if_name "Multicast IPv4 to unknown group" \
+ "$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 (0x0800)" \
+ false
+
+ check_rcv $rcv_if_name "Multicast IPv4 to unknown group, promisc" \
+ "$smac > $UNKNOWN_MACV4_MC_ADDR2, ethertype IPv4 (0x0800)" \
+ true
+
+ check_rcv $rcv_if_name "Multicast IPv4 to unknown group, allmulti" \
+ "$smac > $UNKNOWN_MACV4_MC_ADDR3, ethertype IPv4 (0x0800)" \
+ true
+
+ check_rcv $rcv_if_name "Multicast IPv6 to joined group" \
+ "$smac > $JOINED_MACV6_MC_ADDR, ethertype IPv6 (0x86dd)" \
+ true
+
+ check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \
+ "$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 (0x86dd)" \
+ false
+
+ check_rcv $rcv_if_name "Multicast IPv6 to unknown group, promisc" \
+ "$smac > $UNKNOWN_MACV6_MC_ADDR2, ethertype IPv6 (0x86dd)" \
+ true
+
+ check_rcv $rcv_if_name "Multicast IPv6 to unknown group, allmulti" \
+ "$smac > $UNKNOWN_MACV6_MC_ADDR3, ethertype IPv6 (0x86dd)" \
+ true
+
+ tcpdump_cleanup $rcv_if_name
+}
+
+h1_create()
+{
+ simple_if_init $h1 $H1_IPV4/24 $H1_IPV6/64
+}
+
+h1_destroy()
+{
+ simple_if_fini $h1 $H1_IPV4/24 $H1_IPV6/64
+}
+
+h2_create()
+{
+ simple_if_init $h2 $H2_IPV4/24 $H2_IPV6/64
+}
+
+h2_destroy()
+{
+ simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
+}
+
+bridge_create()
+{
+ ip link add br0 type bridge
+ ip link set br0 address $BRIDGE_ADDR
+ ip link set br0 up
+
+ ip link set $h2 master br0
+ ip link set $h2 up
+
+ simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
+}
+
+bridge_destroy()
+{
+ simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64
+
+ ip link del br0
+}
+
+standalone()
+{
+ h1_create
+ h2_create
+
+ ip link add link $h2 name macvlan0 type macvlan mode private
+ ip link set macvlan0 address $MACVLAN_ADDR
+ ip link set macvlan0 up
+
+ run_test $h2
+
+ ip link del macvlan0
+
+ h2_destroy
+ h1_destroy
+}
+
+bridge()
+{
+ h1_create
+ bridge_create
+
+ ip link add link br0 name macvlan0 type macvlan mode private
+ ip link set macvlan0 address $MACVLAN_ADDR
+ ip link set macvlan0 up
+
+ run_test br0
+
+ ip link del macvlan0
+
+ bridge_destroy
+ h1_destroy
+}
+
+cleanup()
+{
+ pre_cleanup
+ vrf_cleanup
+}
+
+setup_prepare()
+{
+ vrf_prepare
+ # setup_wait() needs this
+ ip link set $h1 up
+ ip link set $h2 up
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+
+tests_run
+
+exit $EXIT_STATUS
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 8/8] selftests: drivers: dsa: add a subset of forwarding selftests
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (6 preceding siblings ...)
2022-04-22 10:15 ` [PATCH net-next 7/8] selftests: forwarding: add a test for local_termination.sh Vladimir Oltean
@ 2022-04-22 10:15 ` Vladimir Oltean
2022-04-22 10:22 ` [PATCH net-next 0/8] DSA selftests Vladimir Oltean
2022-04-23 11:20 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:15 UTC (permalink / raw)
To: netdev
Cc: Jakub Kicinski, David S. Miller, Paolo Abeni, Florian Fainelli,
Andrew Lunn, Vivien Didelot, Vladimir Oltean, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
This adds an initial subset of forwarding selftests which I considered
to be relevant for DSA drivers, along with a forwarding.config that
makes it easier to run them (disables veth pair creation, makes sure MAC
addresses are unique and stable).
The intention is to request driver writers to run these selftests during
review and make sure that the tests pass, or at least that the problems
are known.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh | 1 +
tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh | 1 +
tools/testing/selftests/drivers/net/dsa/bridge_mld.sh | 1 +
tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh | 1 +
tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh | 1 +
tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh | 1 +
tools/testing/selftests/drivers/net/dsa/forwarding.config | 2 ++
tools/testing/selftests/drivers/net/dsa/lib.sh | 1 +
tools/testing/selftests/drivers/net/dsa/local_termination.sh | 1 +
tools/testing/selftests/drivers/net/dsa/no_forwarding.sh | 1 +
10 files changed, 11 insertions(+)
create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
create mode 100644 tools/testing/selftests/drivers/net/dsa/forwarding.config
create mode 120000 tools/testing/selftests/drivers/net/dsa/lib.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/local_termination.sh
create mode 120000 tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh b/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
new file mode 120000
index 000000000000..f5eb940c4c7c
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
@@ -0,0 +1 @@
+../../../net/forwarding/bridge_locked_port.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh b/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
new file mode 120000
index 000000000000..76492da525f7
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
@@ -0,0 +1 @@
+../../../net/forwarding/bridge_mdb.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh b/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
new file mode 120000
index 000000000000..81a7e0df0474
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
@@ -0,0 +1 @@
+../../../net/forwarding/bridge_mld.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
new file mode 120000
index 000000000000..9831ed74376a
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
@@ -0,0 +1 @@
+../../../net/forwarding/bridge_vlan_aware.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
new file mode 120000
index 000000000000..7f3c3f0bf719
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
@@ -0,0 +1 @@
+../../../net/forwarding/bridge_vlan_mcast.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
new file mode 120000
index 000000000000..bf1a57e6bde1
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
@@ -0,0 +1 @@
+../../../net/forwarding/bridge_vlan_unaware.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/forwarding.config b/tools/testing/selftests/drivers/net/dsa/forwarding.config
new file mode 100644
index 000000000000..7adc1396fae0
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/forwarding.config
@@ -0,0 +1,2 @@
+NETIF_CREATE=no
+STABLE_MAC_ADDRS=yes
diff --git a/tools/testing/selftests/drivers/net/dsa/lib.sh b/tools/testing/selftests/drivers/net/dsa/lib.sh
new file mode 120000
index 000000000000..39c96828c5ef
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/lib.sh
@@ -0,0 +1 @@
+../../../net/forwarding/lib.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/local_termination.sh b/tools/testing/selftests/drivers/net/dsa/local_termination.sh
new file mode 120000
index 000000000000..c08166f84501
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/local_termination.sh
@@ -0,0 +1 @@
+../../../net/forwarding/local_termination.sh
\ No newline at end of file
diff --git a/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh b/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
new file mode 120000
index 000000000000..b9757466bc97
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
@@ -0,0 +1 @@
+../../../net/forwarding/no_forwarding.sh
\ No newline at end of file
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH net-next 0/8] DSA selftests
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (7 preceding siblings ...)
2022-04-22 10:15 ` [PATCH net-next 8/8] selftests: drivers: dsa: add a subset of forwarding selftests Vladimir Oltean
@ 2022-04-22 10:22 ` Vladimir Oltean
2022-04-23 11:20 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: Vladimir Oltean @ 2022-04-22 10:22 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, Jakub Kicinski, David S. Miller, Paolo Abeni,
Florian Fainelli, Andrew Lunn, Vivien Didelot, Claudiu Manoil,
Alexandre Belloni, UNGLinuxDriver, Tobias Waldekranz,
Mattias Forsblad, Roopa Prabhu, Nikolay Aleksandrov, Jiri Pirko,
Ido Schimmel, Joachim Wiberg, Marek Behún, Ansuel Smith,
DENG Qingfang, Kurt Kanzenbach
On Fri, Apr 22, 2022 at 01:14:56PM +0300, Vladimir Oltean wrote:
> When working on complex new features or reworks it becomes increasingly
> difficult to ensure there aren't regressions being introduced, and
> therefore it would be nice if we could go over the functionality we
> already have and write some tests for it.
>
> Verbally I know from Tobias Waldekranz that he has been working on some
> selftests for DSA, yet I have never seen them, so here I am adding some
> tests I have written which have been useful for me. The list is by no
> means complete (it only covers elementary functionality), but it's still
> good to have as a starting point. I also borrowed some refactoring
> changes from Joachim Wiberg that he submitted for his "net: bridge:
> forwarding of unknown IPv4/IPv6/MAC BUM traffic" series, but not the
> entirety of his selftests. I now think that his selftests have some
> overlap with bridge_vlan_unaware.sh and bridge_vlan_aware.sh and they
> should be more tightly integrated with each other - yet I didn't do that
> either :). Another issue I had with his selftests was that they jumped
> straight ahead to configure brport flags on br0 (a radical new idea
> still at RFC status) while we have bigger problems, and we don't have
> nearly enough coverage for the *existing* functionality.
>
> One idea introduced here which I haven't seen before is the symlinking
> of relevant forwarding selftests to the selftests/drivers/net/<my-driver>/
> folder, plus a forwarding.config file. I think there's some value in
> having things structured this way, since the forwarding dir has so many
> selftests that aren't relevant to DSA that it is a bit difficult to find
> the ones that are.
>
> While searching for applications that I could use for multicast testing
> (not my domain of interest/knowledge really), I found Joachim Wiberg's
> mtools, mcjoin and omping, and I tried them all with various degrees of
> success. In particular, I was going to use mcjoin, but I faced some
> issues getting IPv6 multicast traffic to work in a VRF, and I bothered
> David Ahern about it here:
> https://lore.kernel.org/netdev/97eaffb8-2125-834e-641f-c99c097b6ee2@gmail.com/t/
> It seems that the problem is that this application should use
> SO_BINDTODEVICE, yet it doesn't.
>
> So I ended up patching the bare-bones mtools (msend, mreceive) forked by
> Joachim from the University of Virginia's Multimedia Networks Group to
> include IPv6 support, and to use SO_BINDTODEVICE. This is what I'm using
> now for IPv6.
>
> Note that mausezahn doesn't appear to do a particularly good job of
> supporting IPv6 really, and I needed a program to emit the actual
> IP_ADD_MEMBERSHIP calls, for dev_mc_add(), so I could test RX filtering.
> Crafting the IGMP/MLD reports by hand doesn't really do the trick.
> While extremely bare-bones, the mreceive application now seems to do
> what I need it to.
>
> Feedback appreciated, it is very likely that I could have done things in
> a better way.
>
> Joachim Wiberg (2):
> selftests: forwarding: add TCPDUMP_EXTRA_FLAGS to lib.sh
> selftests: forwarding: multiple instances in tcpdump helper
>
> Vladimir Oltean (6):
> selftests: forwarding: add option to run tests with stable MAC
> addresses
> selftests: forwarding: add helpers for IP multicast group joins/leaves
> selftests: forwarding: add helper for retrieving IPv6 link-local
> address of interface
> selftests: forwarding: add a no_forwarding.sh test
> selftests: forwarding: add a test for local_termination.sh
> selftests: drivers: dsa: add a subset of forwarding selftests
>
> .../drivers/net/dsa/bridge_locked_port.sh | 1 +
> .../selftests/drivers/net/dsa/bridge_mdb.sh | 1 +
> .../selftests/drivers/net/dsa/bridge_mld.sh | 1 +
> .../drivers/net/dsa/bridge_vlan_aware.sh | 1 +
> .../drivers/net/dsa/bridge_vlan_mcast.sh | 1 +
> .../drivers/net/dsa/bridge_vlan_unaware.sh | 1 +
> .../drivers/net/dsa/forwarding.config | 2 +
> .../testing/selftests/drivers/net/dsa/lib.sh | 1 +
> .../drivers/net/dsa/local_termination.sh | 1 +
> .../drivers/net/dsa/no_forwarding.sh | 1 +
> .../drivers/net/ocelot/tc_flower_chains.sh | 24 +-
> tools/testing/selftests/net/forwarding/lib.sh | 112 ++++++-
> .../net/forwarding/local_termination.sh | 299 ++++++++++++++++++
> .../selftests/net/forwarding/no_forwarding.sh | 261 +++++++++++++++
> 14 files changed, 687 insertions(+), 20 deletions(-)
> create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_locked_port.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_mdb.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_mld.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_vlan_aware.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_vlan_mcast.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/bridge_vlan_unaware.sh
> create mode 100644 tools/testing/selftests/drivers/net/dsa/forwarding.config
> create mode 120000 tools/testing/selftests/drivers/net/dsa/lib.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/local_termination.sh
> create mode 120000 tools/testing/selftests/drivers/net/dsa/no_forwarding.sh
> mode change 100644 => 100755 tools/testing/selftests/net/forwarding/lib.sh
> create mode 100755 tools/testing/selftests/net/forwarding/local_termination.sh
> create mode 100755 tools/testing/selftests/net/forwarding/no_forwarding.sh
>
> --
> 2.25.1
>
Sorry again, now I've really fixed all the places from which I could
have possibly copy-pasted Nikolay's dead NVIDIA email address.
It shouldn't happen again next time.
For those who consider replying, if you don't forget, maybe you can also
replace Nikolay's address in Cc: here to avoid getting a bounce-back
email from NVIDIA.
Sorry!
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH net-next 0/8] DSA selftests
2022-04-22 10:14 [PATCH net-next 0/8] DSA selftests Vladimir Oltean
` (8 preceding siblings ...)
2022-04-22 10:22 ` [PATCH net-next 0/8] DSA selftests Vladimir Oltean
@ 2022-04-23 11:20 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-23 11:20 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, kuba, davem, pabeni, f.fainelli, andrew, vivien.didelot,
olteanv, claudiu.manoil, alexandre.belloni, UNGLinuxDriver,
tobias, mattias.forsblad, roopa, nikolay, jiri, idosch, troglobit,
kabel, ansuelsmth, dqfext, kurt
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Fri, 22 Apr 2022 13:14:56 +0300 you wrote:
> When working on complex new features or reworks it becomes increasingly
> difficult to ensure there aren't regressions being introduced, and
> therefore it would be nice if we could go over the functionality we
> already have and write some tests for it.
>
> Verbally I know from Tobias Waldekranz that he has been working on some
> selftests for DSA, yet I have never seen them, so here I am adding some
> tests I have written which have been useful for me. The list is by no
> means complete (it only covers elementary functionality), but it's still
> good to have as a starting point. I also borrowed some refactoring
> changes from Joachim Wiberg that he submitted for his "net: bridge:
> forwarding of unknown IPv4/IPv6/MAC BUM traffic" series, but not the
> entirety of his selftests. I now think that his selftests have some
> overlap with bridge_vlan_unaware.sh and bridge_vlan_aware.sh and they
> should be more tightly integrated with each other - yet I didn't do that
> either :). Another issue I had with his selftests was that they jumped
> straight ahead to configure brport flags on br0 (a radical new idea
> still at RFC status) while we have bigger problems, and we don't have
> nearly enough coverage for the *existing* functionality.
>
> [...]
Here is the summary with links:
- [net-next,1/8] selftests: forwarding: add option to run tests with stable MAC addresses
https://git.kernel.org/netdev/net-next/c/b343734ee265
- [net-next,2/8] selftests: forwarding: add TCPDUMP_EXTRA_FLAGS to lib.sh
https://git.kernel.org/netdev/net-next/c/fe32dffdcd33
- [net-next,3/8] selftests: forwarding: multiple instances in tcpdump helper
https://git.kernel.org/netdev/net-next/c/6182c5c5098f
- [net-next,4/8] selftests: forwarding: add helpers for IP multicast group joins/leaves
https://git.kernel.org/netdev/net-next/c/f23cddc72294
- [net-next,5/8] selftests: forwarding: add helper for retrieving IPv6 link-local address of interface
https://git.kernel.org/netdev/net-next/c/a5114df6c613
- [net-next,6/8] selftests: forwarding: add a no_forwarding.sh test
https://git.kernel.org/netdev/net-next/c/476a4f05d9b8
- [net-next,7/8] selftests: forwarding: add a test for local_termination.sh
https://git.kernel.org/netdev/net-next/c/90b9566aa5cd
- [net-next,8/8] selftests: drivers: dsa: add a subset of forwarding selftests
https://git.kernel.org/netdev/net-next/c/07c8a2dd69f6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 11+ messages in thread