From 980e74cac800881b30d8984a43ead421487eb3a3 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Sun, 22 May 2022 12:50:38 +0300 Subject: [PATCH 1/3] selftests: ocelot: tc_flower_chains: streamline test output Bring this driver-specific selftest output in line with the other selftests. Before: Testing VLAN pop.. OK Testing VLAN push.. OK Testing ingress VLAN modification.. OK Testing egress VLAN modification.. OK Testing frame prioritization.. OK After: TEST: VLAN pop [ OK ] TEST: VLAN push [ OK ] TEST: Ingress VLAN modification [ OK ] TEST: Egress VLAN modification [ OK ] TEST: Frame prioritization [ OK ] Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- .../drivers/net/ocelot/tc_flower_chains.sh | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 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 4401a654c2c07..a27f24a6aa078 100755 --- a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh +++ b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh @@ -204,7 +204,7 @@ cleanup() test_vlan_pop() { - printf "Testing VLAN pop.. " + RET=0 tcpdump_start $eth2 @@ -217,18 +217,17 @@ test_vlan_pop() tcpdump_stop $eth2 - if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then - echo "OK" - else - echo "FAIL" - fi + tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4" + check_err "$?" "untagged reception" tcpdump_cleanup $eth2 + + log_test "VLAN pop" } test_vlan_push() { - printf "Testing VLAN push.. " + RET=0 tcpdump_start $eth3.100 @@ -238,18 +237,17 @@ test_vlan_push() tcpdump_stop $eth3.100 - if tcpdump_show $eth3.100 | grep -q "$eth2_mac > $eth3_mac"; then - echo "OK" - else - echo "FAIL" - fi + tcpdump_show $eth3.100 | grep -q "$eth2_mac > $eth3_mac" + check_err "$?" "tagged reception" tcpdump_cleanup $eth3.100 + + log_test "VLAN push" } test_vlan_ingress_modify() { - printf "Testing ingress VLAN modification.. " + RET=0 ip link set br0 type bridge vlan_filtering 1 bridge vlan add dev $eth0 vid 200 @@ -269,11 +267,8 @@ test_vlan_ingress_modify() tcpdump_stop $eth2 - if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then - echo "OK" - else - echo "FAIL" - fi + tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300" + check_err "$?" "tagged reception" tcpdump_cleanup $eth2 @@ -283,11 +278,13 @@ test_vlan_ingress_modify() bridge vlan del dev $eth0 vid 300 bridge vlan del dev $eth1 vid 300 ip link set br0 type bridge vlan_filtering 0 + + log_test "Ingress VLAN modification" } test_vlan_egress_modify() { - printf "Testing egress VLAN modification.. " + RET=0 tc qdisc add dev $eth1 clsact @@ -307,11 +304,8 @@ test_vlan_egress_modify() tcpdump_stop $eth2 - if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then - echo "OK" - else - echo "FAIL" - fi + tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300" + check_err "$?" "tagged reception" tcpdump_cleanup $eth2 @@ -321,14 +315,14 @@ test_vlan_egress_modify() bridge vlan del dev $eth0 vid 200 bridge vlan del dev $eth1 vid 200 ip link set br0 type bridge vlan_filtering 0 + + log_test "Egress VLAN modification" } test_skbedit_priority() { local num_pkts=100 - printf "Testing frame prioritization.. " - before=$(ethtool_stats_get $eth0 'rx_green_prio_7') $MZ $eth3 -q -c $num_pkts -p 64 -a $eth3_mac -b $eth2_mac -t ip -A 10.1.1.2 @@ -336,10 +330,12 @@ test_skbedit_priority() after=$(ethtool_stats_get $eth0 'rx_green_prio_7') if [ $((after - before)) = $num_pkts ]; then - echo "OK" + RET=0 else - echo "FAIL" + RET=1 fi + + log_test "Frame prioritization" } trap cleanup EXIT From 93196ef911bac57f43034317c50e9ca42acf55c4 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Sun, 22 May 2022 12:50:39 +0300 Subject: [PATCH 2/3] selftests: ocelot: tc_flower_chains: use conventional interface names This is a robotic rename as follows: eth0 -> swp1 eth1 -> swp2 eth2 -> h2 eth3 -> h1 This brings the selftest more in line with the other forwarding selftests, where h1 is connected to swp1, and h2 to swp2. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- .../drivers/net/ocelot/tc_flower_chains.sh | 134 +++++++++--------- 1 file changed, 67 insertions(+), 67 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 a27f24a6aa078..ecaeae7197b84 100755 --- a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh +++ b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh @@ -15,7 +15,7 @@ require_command tcpdump # | DUT ports Generator ports | # | +--------+ +--------+ +--------+ +--------+ | # | | | | | | | | | | -# | | eth0 | | eth1 | | eth2 | | eth3 | | +# | | swp1 | | swp2 | | h2 | | h1 | | # | | | | | | | | | | # +-+--------+-+--------+-+--------+-+--------+-+ # | | | | @@ -24,15 +24,15 @@ require_command tcpdump # | | # +--------------------------------+ -eth0=${NETIFS[p1]} -eth1=${NETIFS[p2]} -eth2=${NETIFS[p3]} -eth3=${NETIFS[p4]} +swp1=${NETIFS[p1]} +swp2=${NETIFS[p2]} +h2=${NETIFS[p3]} +h1=${NETIFS[p4]} -eth0_mac="de:ad:be:ef:00:00" -eth1_mac="de:ad:be:ef:00:01" -eth2_mac="de:ad:be:ef:00:02" -eth3_mac="de:ad:be:ef:00:03" +swp1_mac="de:ad:be:ef:00:00" +swp2_mac="de:ad:be:ef:00:01" +h2_mac="de:ad:be:ef:00:02" +h1_mac="de:ad:be:ef:00:03" # Helpers to map a VCAP IS1 and VCAP IS2 lookup and policy to a chain number # used by the kernel driver. The numbers are: @@ -156,39 +156,39 @@ create_tcam_skeleton() setup_prepare() { - ip link set $eth0 up - ip link set $eth1 up - ip link set $eth2 up - ip link set $eth3 up + ip link set $swp1 up + ip link set $swp2 up + ip link set $h2 up + ip link set $h1 up - create_tcam_skeleton $eth0 + create_tcam_skeleton $swp1 ip link add br0 type bridge - ip link set $eth0 master br0 - ip link set $eth1 master br0 + ip link set $swp1 master br0 + ip link set $swp2 master br0 ip link set br0 up - ip link add link $eth3 name $eth3.100 type vlan id 100 - ip link set $eth3.100 up + ip link add link $h1 name $h1.100 type vlan id 100 + ip link set $h1.100 up - ip link add link $eth3 name $eth3.200 type vlan id 200 - ip link set $eth3.200 up + ip link add link $h1 name $h1.200 type vlan id 200 + ip link set $h1.200 up - tc filter add dev $eth0 ingress chain $(IS1 1) pref 1 \ + tc filter add dev $swp1 ingress chain $(IS1 1) pref 1 \ protocol 802.1Q flower skip_sw vlan_id 100 \ action vlan pop \ action goto chain $(IS1 2) - tc filter add dev $eth0 egress chain $(ES0) pref 1 \ - flower skip_sw indev $eth1 \ + tc filter add dev $swp1 egress chain $(ES0) pref 1 \ + flower skip_sw indev $swp2 \ action vlan push protocol 802.1Q id 100 - tc filter add dev $eth0 ingress chain $(IS1 0) pref 2 \ + tc filter add dev $swp1 ingress chain $(IS1 0) pref 2 \ protocol ipv4 flower skip_sw src_ip 10.1.1.2 \ action skbedit priority 7 \ action goto chain $(IS1 1) - tc filter add dev $eth0 ingress chain $(IS2 0 0) pref 1 \ + tc filter add dev $swp1 ingress chain $(IS2 0 0) pref 1 \ protocol ipv4 flower skip_sw ip_proto udp dst_port 5201 \ action police rate 50mbit burst 64k conform-exceed drop/pipe \ action goto chain $(IS2 1 0) @@ -196,9 +196,9 @@ setup_prepare() cleanup() { - ip link del $eth3.200 - ip link del $eth3.100 - tc qdisc del dev $eth0 clsact + ip link del $h1.200 + ip link del $h1.100 + tc qdisc del dev $swp1 clsact ip link del br0 } @@ -206,21 +206,21 @@ test_vlan_pop() { RET=0 - tcpdump_start $eth2 + tcpdump_start $h2 # Work around Mausezahn VLAN builder bug # (https://github.com/netsniff-ng/netsniff-ng/issues/225) by using # an 8021q upper - $MZ $eth3.100 -q -c 1 -p 64 -a $eth3_mac -b $eth2_mac -t ip + $MZ $h1.100 -q -c 1 -p 64 -a $h1_mac -b $h2_mac -t ip sleep 1 - tcpdump_stop $eth2 + tcpdump_stop $h2 - tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4" + tcpdump_show $h2 | grep -q "$h1_mac > $h2_mac, ethertype IPv4" check_err "$?" "untagged reception" - tcpdump_cleanup $eth2 + tcpdump_cleanup $h2 log_test "VLAN pop" } @@ -229,18 +229,18 @@ test_vlan_push() { RET=0 - tcpdump_start $eth3.100 + tcpdump_start $h1.100 - $MZ $eth2 -q -c 1 -p 64 -a $eth2_mac -b $eth3_mac -t ip + $MZ $h2 -q -c 1 -p 64 -a $h2_mac -b $h1_mac -t ip sleep 1 - tcpdump_stop $eth3.100 + tcpdump_stop $h1.100 - tcpdump_show $eth3.100 | grep -q "$eth2_mac > $eth3_mac" + tcpdump_show $h1.100 | grep -q "$h2_mac > $h1_mac" check_err "$?" "tagged reception" - tcpdump_cleanup $eth3.100 + tcpdump_cleanup $h1.100 log_test "VLAN push" } @@ -250,33 +250,33 @@ test_vlan_ingress_modify() RET=0 ip link set br0 type bridge vlan_filtering 1 - bridge vlan add dev $eth0 vid 200 - bridge vlan add dev $eth0 vid 300 - bridge vlan add dev $eth1 vid 300 + bridge vlan add dev $swp1 vid 200 + bridge vlan add dev $swp1 vid 300 + bridge vlan add dev $swp2 vid 300 - tc filter add dev $eth0 ingress chain $(IS1 2) pref 3 \ + tc filter add dev $swp1 ingress chain $(IS1 2) pref 3 \ protocol 802.1Q flower skip_sw vlan_id 200 \ action vlan modify id 300 \ action goto chain $(IS2 0 0) - tcpdump_start $eth2 + tcpdump_start $h2 - $MZ $eth3.200 -q -c 1 -p 64 -a $eth3_mac -b $eth2_mac -t ip + $MZ $h1.200 -q -c 1 -p 64 -a $h1_mac -b $h2_mac -t ip sleep 1 - tcpdump_stop $eth2 + tcpdump_stop $h2 - tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300" + tcpdump_show $h2 | grep -q "$h1_mac > $h2_mac, .* vlan 300" check_err "$?" "tagged reception" - tcpdump_cleanup $eth2 + tcpdump_cleanup $h2 - tc filter del dev $eth0 ingress chain $(IS1 2) pref 3 + tc filter del dev $swp1 ingress chain $(IS1 2) pref 3 - bridge vlan del dev $eth0 vid 200 - bridge vlan del dev $eth0 vid 300 - bridge vlan del dev $eth1 vid 300 + bridge vlan del dev $swp1 vid 200 + bridge vlan del dev $swp1 vid 300 + bridge vlan del dev $swp2 vid 300 ip link set br0 type bridge vlan_filtering 0 log_test "Ingress VLAN modification" @@ -286,34 +286,34 @@ test_vlan_egress_modify() { RET=0 - tc qdisc add dev $eth1 clsact + tc qdisc add dev $swp2 clsact ip link set br0 type bridge vlan_filtering 1 - bridge vlan add dev $eth0 vid 200 - bridge vlan add dev $eth1 vid 200 + bridge vlan add dev $swp1 vid 200 + bridge vlan add dev $swp2 vid 200 - tc filter add dev $eth1 egress chain $(ES0) pref 3 \ + tc filter add dev $swp2 egress chain $(ES0) pref 3 \ protocol 802.1Q flower skip_sw vlan_id 200 vlan_prio 0 \ action vlan modify id 300 priority 7 - tcpdump_start $eth2 + tcpdump_start $h2 - $MZ $eth3.200 -q -c 1 -p 64 -a $eth3_mac -b $eth2_mac -t ip + $MZ $h1.200 -q -c 1 -p 64 -a $h1_mac -b $h2_mac -t ip sleep 1 - tcpdump_stop $eth2 + tcpdump_stop $h2 - tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300" + tcpdump_show $h2 | grep -q "$h1_mac > $h2_mac, .* vlan 300" check_err "$?" "tagged reception" - tcpdump_cleanup $eth2 + tcpdump_cleanup $h2 - tc filter del dev $eth1 egress chain $(ES0) pref 3 - tc qdisc del dev $eth1 clsact + tc filter del dev $swp2 egress chain $(ES0) pref 3 + tc qdisc del dev $swp2 clsact - bridge vlan del dev $eth0 vid 200 - bridge vlan del dev $eth1 vid 200 + bridge vlan del dev $swp1 vid 200 + bridge vlan del dev $swp2 vid 200 ip link set br0 type bridge vlan_filtering 0 log_test "Egress VLAN modification" @@ -323,11 +323,11 @@ test_skbedit_priority() { local num_pkts=100 - before=$(ethtool_stats_get $eth0 'rx_green_prio_7') + before=$(ethtool_stats_get $swp1 'rx_green_prio_7') - $MZ $eth3 -q -c $num_pkts -p 64 -a $eth3_mac -b $eth2_mac -t ip -A 10.1.1.2 + $MZ $h1 -q -c $num_pkts -p 64 -a $h1_mac -b $h2_mac -t ip -A 10.1.1.2 - after=$(ethtool_stats_get $eth0 'rx_green_prio_7') + after=$(ethtool_stats_get $swp1 'rx_green_prio_7') if [ $((after - before)) = $num_pkts ]; then RET=0 From 4ea1396a8bd5b7af4df15c52396c640a92b05b30 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Sun, 22 May 2022 12:50:40 +0300 Subject: [PATCH 3/3] selftests: ocelot: tc_flower_chains: reorder interfaces Use the standard interface order h1, swp1, swp2, h2 that is used by the forwarding selftest framework. The previous order was confusing even with the ASCII drawing. That isn't needed anymore. This also drops the fixed MAC addresses and uses STABLE_MAC_ADDRS, which ensures the MAC addresses are unique. Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller --- .../drivers/net/ocelot/tc_flower_chains.sh | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 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 ecaeae7197b84..9c79bbcce5a87 100755 --- a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh +++ b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh @@ -4,35 +4,17 @@ WAIT_TIME=1 NUM_NETIFS=4 +STABLE_MAC_ADDRS=yes lib_dir=$(dirname $0)/../../../net/forwarding source $lib_dir/tc_common.sh source $lib_dir/lib.sh require_command tcpdump -# -# +---------------------------------------------+ -# | DUT ports Generator ports | -# | +--------+ +--------+ +--------+ +--------+ | -# | | | | | | | | | | -# | | swp1 | | swp2 | | h2 | | h1 | | -# | | | | | | | | | | -# +-+--------+-+--------+-+--------+-+--------+-+ -# | | | | -# | | | | -# | +-----------+ | -# | | -# +--------------------------------+ - -swp1=${NETIFS[p1]} -swp2=${NETIFS[p2]} -h2=${NETIFS[p3]} -h1=${NETIFS[p4]} - -swp1_mac="de:ad:be:ef:00:00" -swp2_mac="de:ad:be:ef:00:01" -h2_mac="de:ad:be:ef:00:02" -h1_mac="de:ad:be:ef:00:03" +h1=${NETIFS[p1]} +swp1=${NETIFS[p2]} +swp2=${NETIFS[p3]} +h2=${NETIFS[p4]} # Helpers to map a VCAP IS1 and VCAP IS2 lookup and policy to a chain number # used by the kernel driver. The numbers are: @@ -204,6 +186,9 @@ cleanup() test_vlan_pop() { + local h1_mac=$(mac_get $h1) + local h2_mac=$(mac_get $h2) + RET=0 tcpdump_start $h2 @@ -227,6 +212,9 @@ test_vlan_pop() test_vlan_push() { + local h1_mac=$(mac_get $h1) + local h2_mac=$(mac_get $h2) + RET=0 tcpdump_start $h1.100 @@ -247,6 +235,9 @@ test_vlan_push() test_vlan_ingress_modify() { + local h1_mac=$(mac_get $h1) + local h2_mac=$(mac_get $h2) + RET=0 ip link set br0 type bridge vlan_filtering 1 @@ -284,6 +275,9 @@ test_vlan_ingress_modify() test_vlan_egress_modify() { + local h1_mac=$(mac_get $h1) + local h2_mac=$(mac_get $h2) + RET=0 tc qdisc add dev $swp2 clsact @@ -321,6 +315,8 @@ test_vlan_egress_modify() test_skbedit_priority() { + local h1_mac=$(mac_get $h1) + local h2_mac=$(mac_get $h2) local num_pkts=100 before=$(ethtool_stats_get $swp1 'rx_green_prio_7')