summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/net/forwarding
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/net/forwarding')
-rw-r--r--tools/testing/selftests/net/forwarding/Makefile9
-rw-r--r--tools/testing/selftests/net/forwarding/README33
-rwxr-xr-xtools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh18
-rw-r--r--tools/testing/selftests/net/forwarding/devlink_lib.sh2
-rwxr-xr-xtools/testing/selftests/net/forwarding/ethtool.sh301
-rwxr-xr-xtools/testing/selftests/net/forwarding/ethtool_extended_state.sh117
-rw-r--r--tools/testing/selftests/net/forwarding/ethtool_lib.sh120
-rwxr-xr-xtools/testing/selftests/net/forwarding/ethtool_mm.sh340
-rwxr-xr-xtools/testing/selftests/net/forwarding/ethtool_rmon.sh143
-rw-r--r--tools/testing/selftests/net/forwarding/forwarding.config.sample53
-rwxr-xr-xtools/testing/selftests/net/forwarding/hw_stats_l3.sh340
-rwxr-xr-xtools/testing/selftests/net/forwarding/hw_stats_l3_gre.sh111
-rw-r--r--tools/testing/selftests/net/forwarding/ipip_lib.sh1
-rw-r--r--tools/testing/selftests/net/forwarding/lib.sh253
-rwxr-xr-xtools/testing/selftests/net/forwarding/lib_sh_test.sh208
-rwxr-xr-xtools/testing/selftests/net/forwarding/local_termination.sh30
-rwxr-xr-xtools/testing/selftests/net/forwarding/loopback.sh102
-rwxr-xr-xtools/testing/selftests/net/forwarding/router_mpath_nh.sh35
-rw-r--r--tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh12
-rwxr-xr-xtools/testing/selftests/net/forwarding/router_mpath_nh_res.sh35
-rwxr-xr-xtools/testing/selftests/net/forwarding/router_nh.sh14
-rw-r--r--tools/testing/selftests/net/forwarding/sch_ets_tests.sh19
-rwxr-xr-xtools/testing/selftests/net/forwarding/sch_red.sh10
-rw-r--r--tools/testing/selftests/net/forwarding/sch_tbf_core.sh2
-rw-r--r--tools/testing/selftests/net/forwarding/tc_common.sh2
-rwxr-xr-xtools/testing/selftests/net/forwarding/tc_tunnel_key.sh2
26 files changed, 607 insertions, 1705 deletions
diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile
index 535865b3d1..fa7b59ff40 100644
--- a/tools/testing/selftests/net/forwarding/Makefile
+++ b/tools/testing/selftests/net/forwarding/Makefile
@@ -15,18 +15,12 @@ TEST_PROGS = bridge_fdb_learning_limit.sh \
bridge_vlan_unaware.sh \
custom_multipath_hash.sh \
dual_vxlan_bridge.sh \
- ethtool_extended_state.sh \
- ethtool_mm.sh \
- ethtool_rmon.sh \
- ethtool.sh \
gre_custom_multipath_hash.sh \
gre_inner_v4_multipath.sh \
gre_inner_v6_multipath.sh \
gre_multipath_nh_res.sh \
gre_multipath_nh.sh \
gre_multipath.sh \
- hw_stats_l3.sh \
- hw_stats_l3_gre.sh \
ip6_forward_instats_vrf.sh \
ip6gre_custom_multipath_hash.sh \
ip6gre_flat_key.sh \
@@ -43,8 +37,8 @@ TEST_PROGS = bridge_fdb_learning_limit.sh \
ipip_hier_gre_key.sh \
ipip_hier_gre_keys.sh \
ipip_hier_gre.sh \
+ lib_sh_test.sh \
local_termination.sh \
- loopback.sh \
mirror_gre_bound.sh \
mirror_gre_bridge_1d.sh \
mirror_gre_bridge_1d_vlan.sh \
@@ -113,7 +107,6 @@ TEST_PROGS = bridge_fdb_learning_limit.sh \
vxlan_symmetric.sh
TEST_FILES := devlink_lib.sh \
- ethtool_lib.sh \
fib_offload_lib.sh \
forwarding.config.sample \
ip6gre_lib.sh \
diff --git a/tools/testing/selftests/net/forwarding/README b/tools/testing/selftests/net/forwarding/README
index b8a2af8fcf..7fdb6a9ca5 100644
--- a/tools/testing/selftests/net/forwarding/README
+++ b/tools/testing/selftests/net/forwarding/README
@@ -56,3 +56,36 @@ o Checks shall be added to lib.sh for any external dependencies.
o Code shall be checked using ShellCheck [1] prior to submission.
1. https://www.shellcheck.net/
+
+Customization
+=============
+
+The forwarding selftests framework uses a number of variables that
+influence its behavior and tools it invokes, and how it invokes them, in
+various ways. A number of these variables can be overridden. The way these
+overridable variables are specified is typically one of the following two
+syntaxes:
+
+ : "${VARIABLE:=default_value}"
+ VARIABLE=${VARIABLE:=default_value}
+
+Any of these variables can be overridden. Notably net/forwarding/lib.sh and
+net/lib.sh contain a number of overridable variables.
+
+One way of overriding these variables is through the environment:
+
+ PAUSE_ON_FAIL=yes ./some_test.sh
+
+The variable NETIFS is special. Since it is an array variable, there is no
+way to pass it through the environment. Its value can instead be given as
+consecutive arguments to the selftest:
+
+ ./some_test.sh swp{1..8}
+
+A way to customize variables in a persistent fashion is to create a file
+named forwarding.config in this directory. lib.sh sources the file if
+present, so it can contain any shell code. Typically it will contain
+assignments of variables whose value should be overridden.
+
+forwarding.config.sample is available in the directory as an example of
+how forwarding.config might look.
diff --git a/tools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh b/tools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh
index 0760a34b71..a21b7085da 100755
--- a/tools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh
+++ b/tools/testing/selftests/net/forwarding/bridge_fdb_learning_limit.sh
@@ -178,6 +178,22 @@ fdb_del()
check_err $? "Failed to remove a FDB entry of type ${type}"
}
+check_fdb_n_learned_support()
+{
+ if ! ip link help bridge 2>&1 | grep -q "fdb_max_learned"; then
+ echo "SKIP: iproute2 too old, missing bridge max learned support"
+ exit $ksft_skip
+ fi
+
+ ip link add dev br0 type bridge
+ local learned=$(fdb_get_n_learned)
+ ip link del dev br0
+ if [ "$learned" == "null" ]; then
+ echo "SKIP: kernel too old; bridge fdb_n_learned feature not supported."
+ exit $ksft_skip
+ fi
+}
+
check_accounting_one_type()
{
local type=$1 is_counted=$2 overrides_learned=$3
@@ -274,6 +290,8 @@ check_limit()
done
}
+check_fdb_n_learned_support
+
trap cleanup EXIT
setup_prepare
diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh
index f1de525cfa..62a05bca1e 100644
--- a/tools/testing/selftests/net/forwarding/devlink_lib.sh
+++ b/tools/testing/selftests/net/forwarding/devlink_lib.sh
@@ -122,6 +122,8 @@ devlink_reload()
still_pending=$(devlink resource show "$DEVLINK_DEV" | \
grep -c "size_new")
check_err $still_pending "Failed reload - There are still unset sizes"
+
+ udevadm settle
}
declare -A DEVLINK_ORIG
diff --git a/tools/testing/selftests/net/forwarding/ethtool.sh b/tools/testing/selftests/net/forwarding/ethtool.sh
deleted file mode 100755
index aa2eafb7b2..0000000000
--- a/tools/testing/selftests/net/forwarding/ethtool.sh
+++ /dev/null
@@ -1,301 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-ALL_TESTS="
- same_speeds_autoneg_off
- different_speeds_autoneg_off
- combination_of_neg_on_and_off
- advertise_subset_of_speeds
- check_highest_speed_is_chosen
- different_speeds_autoneg_on
-"
-NUM_NETIFS=2
-source lib.sh
-source ethtool_lib.sh
-
-h1_create()
-{
- simple_if_init $h1 192.0.2.1/24
-}
-
-h1_destroy()
-{
- simple_if_fini $h1 192.0.2.1/24
-}
-
-h2_create()
-{
- simple_if_init $h2 192.0.2.2/24
-}
-
-h2_destroy()
-{
- simple_if_fini $h2 192.0.2.2/24
-}
-
-setup_prepare()
-{
- h1=${NETIFS[p1]}
- h2=${NETIFS[p2]}
-
- h1_create
- h2_create
-}
-
-cleanup()
-{
- pre_cleanup
-
- h2_destroy
- h1_destroy
-}
-
-same_speeds_autoneg_off()
-{
- # Check that when each of the reported speeds is forced, the links come
- # up and are operational.
- local -a speeds_arr=($(common_speeds_get $h1 $h2 0 0))
-
- for speed in "${speeds_arr[@]}"; do
- RET=0
- ethtool_set $h1 speed $speed autoneg off
- ethtool_set $h2 speed $speed autoneg off
-
- setup_wait_dev_with_timeout $h1
- setup_wait_dev_with_timeout $h2
- ping_do $h1 192.0.2.2
- check_err $? "speed $speed autoneg off"
- log_test "force of same speed autoneg off"
- log_info "speed = $speed"
- done
-
- ethtool -s $h2 autoneg on
- ethtool -s $h1 autoneg on
-}
-
-different_speeds_autoneg_off()
-{
- # Test that when we force different speeds, links are not up and ping
- # fails.
- RET=0
-
- local -a speeds_arr=($(different_speeds_get $h1 $h2 0 0))
- local speed1=${speeds_arr[0]}
- local speed2=${speeds_arr[1]}
-
- ethtool_set $h1 speed $speed1 autoneg off
- ethtool_set $h2 speed $speed2 autoneg off
-
- setup_wait_dev_with_timeout $h1
- setup_wait_dev_with_timeout $h2
- ping_do $h1 192.0.2.2
- check_fail $? "ping with different speeds"
-
- log_test "force of different speeds autoneg off"
-
- ethtool -s $h2 autoneg on
- ethtool -s $h1 autoneg on
-}
-
-combination_of_neg_on_and_off()
-{
- # Test that when one device is forced to a speed supported by both
- # endpoints and the other device is configured to autoneg on, the links
- # are up and ping passes.
- local -a speeds_arr=($(common_speeds_get $h1 $h2 0 1))
-
- for speed in "${speeds_arr[@]}"; do
- RET=0
- ethtool_set $h1 speed $speed autoneg off
-
- setup_wait_dev_with_timeout $h1
- setup_wait_dev_with_timeout $h2
- ping_do $h1 192.0.2.2
- check_err $? "h1-speed=$speed autoneg off, h2 autoneg on"
- log_test "one side with autoneg off and another with autoneg on"
- log_info "force speed = $speed"
- done
-
- ethtool -s $h1 autoneg on
-}
-
-hex_speed_value_get()
-{
- local speed=$1; shift
-
- local shift_size=${speed_values[$speed]}
- speed=$((0x1 << $"shift_size"))
- printf "%#x" "$speed"
-}
-
-subset_of_common_speeds_get()
-{
- local dev1=$1; shift
- local dev2=$1; shift
- local adver=$1; shift
-
- local -a speeds_arr=($(common_speeds_get $dev1 $dev2 0 $adver))
- local speed_to_advertise=0
- local speed_to_remove=${speeds_arr[0]}
- speed_to_remove+='base'
-
- local -a speeds_mode_arr=($(common_speeds_get $dev1 $dev2 1 $adver))
-
- for speed in ${speeds_mode_arr[@]}; do
- if [[ $speed != $speed_to_remove* ]]; then
- speed=$(hex_speed_value_get $speed)
- speed_to_advertise=$(($speed_to_advertise | \
- $speed))
- fi
-
- done
-
- # Convert to hex.
- printf "%#x" "$speed_to_advertise"
-}
-
-speed_to_advertise_get()
-{
- # The function returns the hex number that is composed by OR-ing all
- # the modes corresponding to the provided speed.
- local speed_without_mode=$1; shift
- local supported_speeds=("$@"); shift
- local speed_to_advertise=0
-
- speed_without_mode+='base'
-
- for speed in ${supported_speeds[@]}; do
- if [[ $speed == $speed_without_mode* ]]; then
- speed=$(hex_speed_value_get $speed)
- speed_to_advertise=$(($speed_to_advertise | \
- $speed))
- fi
-
- done
-
- # Convert to hex.
- printf "%#x" "$speed_to_advertise"
-}
-
-advertise_subset_of_speeds()
-{
- # Test that when one device advertises a subset of speeds and another
- # advertises a specific speed (but all modes of this speed), the links
- # are up and ping passes.
- RET=0
-
- local speed_1_to_advertise=$(subset_of_common_speeds_get $h1 $h2 1)
- ethtool_set $h1 advertise $speed_1_to_advertise
-
- if [ $RET != 0 ]; then
- log_test "advertise subset of speeds"
- return
- fi
-
- local -a speeds_arr_without_mode=($(common_speeds_get $h1 $h2 0 1))
- # Check only speeds that h1 advertised. Remove the first speed.
- unset speeds_arr_without_mode[0]
- local -a speeds_arr_with_mode=($(common_speeds_get $h1 $h2 1 1))
-
- for speed_value in ${speeds_arr_without_mode[@]}; do
- RET=0
- local speed_2_to_advertise=$(speed_to_advertise_get $speed_value \
- "${speeds_arr_with_mode[@]}")
- ethtool_set $h2 advertise $speed_2_to_advertise
-
- setup_wait_dev_with_timeout $h1
- setup_wait_dev_with_timeout $h2
- ping_do $h1 192.0.2.2
- check_err $? "h1=$speed_1_to_advertise, h2=$speed_2_to_advertise ($speed_value)"
-
- log_test "advertise subset of speeds"
- log_info "h1=$speed_1_to_advertise, h2=$speed_2_to_advertise"
- done
-
- ethtool -s $h2 autoneg on
- ethtool -s $h1 autoneg on
-}
-
-check_highest_speed_is_chosen()
-{
- # Test that when one device advertises a subset of speeds, the other
- # chooses the highest speed. This test checks configuration without
- # traffic.
- RET=0
-
- local max_speed
- local chosen_speed
- local speed_to_advertise=$(subset_of_common_speeds_get $h1 $h2 1)
-
- ethtool_set $h1 advertise $speed_to_advertise
-
- if [ $RET != 0 ]; then
- log_test "check highest speed"
- return
- fi
-
- local -a speeds_arr=($(common_speeds_get $h1 $h2 0 1))
-
- max_speed=${speeds_arr[0]}
- for current in ${speeds_arr[@]}; do
- if [[ $current -gt $max_speed ]]; then
- max_speed=$current
- fi
- done
-
- setup_wait_dev_with_timeout $h1
- setup_wait_dev_with_timeout $h2
- chosen_speed=$(ethtool $h1 | grep 'Speed:')
- chosen_speed=${chosen_speed%"Mb/s"*}
- chosen_speed=${chosen_speed#*"Speed: "}
- ((chosen_speed == max_speed))
- check_err $? "h1 advertise $speed_to_advertise, h2 sync to speed $chosen_speed"
-
- log_test "check highest speed"
-
- ethtool -s $h2 autoneg on
- ethtool -s $h1 autoneg on
-}
-
-different_speeds_autoneg_on()
-{
- # Test that when we configure links to advertise different speeds,
- # links are not up and ping fails.
- RET=0
-
- local -a speeds=($(different_speeds_get $h1 $h2 1 1))
- local speed1=${speeds[0]}
- local speed2=${speeds[1]}
-
- speed1=$(hex_speed_value_get $speed1)
- speed2=$(hex_speed_value_get $speed2)
-
- ethtool_set $h1 advertise $speed1
- ethtool_set $h2 advertise $speed2
-
- if (($RET)); then
- setup_wait_dev_with_timeout $h1
- setup_wait_dev_with_timeout $h2
- ping_do $h1 192.0.2.2
- check_fail $? "ping with different speeds autoneg on"
- fi
-
- log_test "advertise different speeds autoneg on"
-
- ethtool -s $h2 autoneg on
- ethtool -s $h1 autoneg on
-}
-
-skip_on_veth
-
-trap cleanup EXIT
-
-setup_prepare
-setup_wait
-
-declare -gA speed_values
-eval "speed_values=($(speeds_arr_get))"
-
-tests_run
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/ethtool_extended_state.sh b/tools/testing/selftests/net/forwarding/ethtool_extended_state.sh
deleted file mode 100755
index 17f89c3b7c..0000000000
--- a/tools/testing/selftests/net/forwarding/ethtool_extended_state.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-ALL_TESTS="
- autoneg
- autoneg_force_mode
- no_cable
-"
-
-NUM_NETIFS=2
-source lib.sh
-source ethtool_lib.sh
-
-TIMEOUT=$((WAIT_TIMEOUT * 1000)) # ms
-
-setup_prepare()
-{
- swp1=${NETIFS[p1]}
- swp2=${NETIFS[p2]}
- swp3=$NETIF_NO_CABLE
-}
-
-ethtool_ext_state()
-{
- local dev=$1; shift
- local expected_ext_state=$1; shift
- local expected_ext_substate=${1:-""}; shift
-
- local ext_state=$(ethtool $dev | grep "Link detected" \
- | cut -d "(" -f2 | cut -d ")" -f1)
- local ext_substate=$(echo $ext_state | cut -sd "," -f2 \
- | sed -e 's/^[[:space:]]*//')
- ext_state=$(echo $ext_state | cut -d "," -f1)
-
- if [[ $ext_state != $expected_ext_state ]]; then
- echo "Expected \"$expected_ext_state\", got \"$ext_state\""
- return 1
- fi
- if [[ $ext_substate != $expected_ext_substate ]]; then
- echo "Expected \"$expected_ext_substate\", got \"$ext_substate\""
- return 1
- fi
-}
-
-autoneg()
-{
- local msg
-
- RET=0
-
- ip link set dev $swp1 up
-
- msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \
- "Autoneg" "No partner detected")
- check_err $? "$msg"
-
- log_test "Autoneg, No partner detected"
-
- ip link set dev $swp1 down
-}
-
-autoneg_force_mode()
-{
- local msg
-
- RET=0
-
- ip link set dev $swp1 up
- ip link set dev $swp2 up
-
- local -a speeds_arr=($(different_speeds_get $swp1 $swp2 0 0))
- local speed1=${speeds_arr[0]}
- local speed2=${speeds_arr[1]}
-
- ethtool_set $swp1 speed $speed1 autoneg off
- ethtool_set $swp2 speed $speed2 autoneg off
-
- msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \
- "Autoneg" "No partner detected during force mode")
- check_err $? "$msg"
-
- msg=$(busywait $TIMEOUT ethtool_ext_state $swp2 \
- "Autoneg" "No partner detected during force mode")
- check_err $? "$msg"
-
- log_test "Autoneg, No partner detected during force mode"
-
- ethtool -s $swp2 autoneg on
- ethtool -s $swp1 autoneg on
-
- ip link set dev $swp2 down
- ip link set dev $swp1 down
-}
-
-no_cable()
-{
- local msg
-
- RET=0
-
- ip link set dev $swp3 up
-
- msg=$(busywait $TIMEOUT ethtool_ext_state $swp3 "No cable")
- check_err $? "$msg"
-
- log_test "No cable"
-
- ip link set dev $swp3 down
-}
-
-skip_on_veth
-
-setup_prepare
-
-tests_run
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/ethtool_lib.sh b/tools/testing/selftests/net/forwarding/ethtool_lib.sh
deleted file mode 100644
index b9bfb45085..0000000000
--- a/tools/testing/selftests/net/forwarding/ethtool_lib.sh
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-speeds_arr_get()
-{
- cmd='/ETHTOOL_LINK_MODE_[^[:space:]]*_BIT[[:space:]]+=[[:space:]]+/ \
- {sub(/,$/, "") \
- sub(/ETHTOOL_LINK_MODE_/,"") \
- sub(/_BIT/,"") \
- sub(/_Full/,"/Full") \
- sub(/_Half/,"/Half");\
- print "["$1"]="$3}'
-
- awk "${cmd}" /usr/include/linux/ethtool.h
-}
-
-ethtool_set()
-{
- local cmd="$@"
- local out=$(ethtool -s $cmd 2>&1 | wc -l)
-
- check_err $out "error in configuration. $cmd"
-}
-
-dev_linkmodes_params_get()
-{
- local dev=$1; shift
- local adver=$1; shift
- local -a linkmodes_params
- local param_count
- local arr
-
- if (($adver)); then
- mode="Advertised link modes"
- else
- mode="Supported link modes"
- fi
-
- local -a dev_linkmodes=($(dev_speeds_get $dev 1 $adver))
- for ((i=0; i<${#dev_linkmodes[@]}; i++)); do
- linkmodes_params[$i]=$(echo -e "${dev_linkmodes[$i]}" | \
- # Replaces all non numbers with spaces
- sed -e 's/[^0-9]/ /g' | \
- # Squeeze spaces in sequence to 1 space
- tr -s ' ')
- # Count how many numbers were found in the linkmode
- param_count=$(echo "${linkmodes_params[$i]}" | wc -w)
- if [[ $param_count -eq 1 ]]; then
- linkmodes_params[$i]="${linkmodes_params[$i]} 1"
- elif [[ $param_count -ge 3 ]]; then
- arr=(${linkmodes_params[$i]})
- # Take only first two params
- linkmodes_params[$i]=$(echo "${arr[@]:0:2}")
- fi
- done
- echo ${linkmodes_params[@]}
-}
-
-dev_speeds_get()
-{
- local dev=$1; shift
- local with_mode=$1; shift
- local adver=$1; shift
- local speeds_str
-
- if (($adver)); then
- mode="Advertised link modes"
- else
- mode="Supported link modes"
- fi
-
- speeds_str=$(ethtool "$dev" | \
- # Snip everything before the link modes section.
- sed -n '/'"$mode"':/,$p' | \
- # Quit processing the rest at the start of the next section.
- # When checking, skip the header of this section (hence the 2,).
- sed -n '2,${/^[\t][^ \t]/q};p' | \
- # Drop the section header of the current section.
- cut -d':' -f2)
-
- local -a speeds_arr=($speeds_str)
- if [[ $with_mode -eq 0 ]]; then
- for ((i=0; i<${#speeds_arr[@]}; i++)); do
- speeds_arr[$i]=${speeds_arr[$i]%base*}
- done
- fi
- echo ${speeds_arr[@]}
-}
-
-common_speeds_get()
-{
- dev1=$1; shift
- dev2=$1; shift
- with_mode=$1; shift
- adver=$1; shift
-
- local -a dev1_speeds=($(dev_speeds_get $dev1 $with_mode $adver))
- local -a dev2_speeds=($(dev_speeds_get $dev2 $with_mode $adver))
-
- comm -12 \
- <(printf '%s\n' "${dev1_speeds[@]}" | sort -u) \
- <(printf '%s\n' "${dev2_speeds[@]}" | sort -u)
-}
-
-different_speeds_get()
-{
- local dev1=$1; shift
- local dev2=$1; shift
- local with_mode=$1; shift
- local adver=$1; shift
-
- local -a speeds_arr
-
- speeds_arr=($(common_speeds_get $dev1 $dev2 $with_mode $adver))
- if [[ ${#speeds_arr[@]} < 2 ]]; then
- check_err 1 "cannot check different speeds. There are not enough speeds"
- fi
-
- echo ${speeds_arr[0]} ${speeds_arr[1]}
-}
diff --git a/tools/testing/selftests/net/forwarding/ethtool_mm.sh b/tools/testing/selftests/net/forwarding/ethtool_mm.sh
deleted file mode 100755
index 50d5bfb17e..0000000000
--- a/tools/testing/selftests/net/forwarding/ethtool_mm.sh
+++ /dev/null
@@ -1,340 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-ALL_TESTS="
- manual_with_verification_h1_to_h2
- manual_with_verification_h2_to_h1
- manual_without_verification_h1_to_h2
- manual_without_verification_h2_to_h1
- manual_failed_verification_h1_to_h2
- manual_failed_verification_h2_to_h1
- lldp
-"
-
-NUM_NETIFS=2
-REQUIRE_MZ=no
-PREEMPTIBLE_PRIO=0
-source lib.sh
-
-traffic_test()
-{
- local if=$1; shift
- local src=$1; shift
- local num_pkts=10000
- local before=
- local after=
- local delta=
-
- if [ ${has_pmac_stats[$if]} = false ]; then
- src="aggregate"
- fi
-
- before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
-
- $MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
-
- after=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
-
- delta=$((after - before))
-
- # Allow an extra 1% tolerance for random packets sent by the stack
- [ $delta -ge $num_pkts ] && [ $delta -le $((num_pkts + 100)) ]
-}
-
-manual_with_verification()
-{
- local tx=$1; shift
- local rx=$1; shift
-
- RET=0
-
- # It isn't completely clear from IEEE 802.3-2018 Figure 99-5: Transmit
- # Processing state diagram whether the "send_r" variable (send response
- # to verification frame) should be taken into consideration while the
- # MAC Merge TX direction is disabled. That being said, at least the
- # NXP ENETC does not, and requires tx-enabled on in order to respond to
- # the link partner's verification frames.
- ethtool --set-mm $rx tx-enabled on
- ethtool --set-mm $tx verify-enabled on tx-enabled on
-
- # Wait for verification to finish
- sleep 1
-
- ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
- grep -q 'SUCCEEDED'
- check_err "$?" "Verification did not succeed"
-
- ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
- check_err "$?" "pMAC TX is not active"
-
- traffic_test $tx "pmac"
- check_err "$?" "Traffic did not get sent through $tx's pMAC"
-
- ethtool --set-mm $tx verify-enabled off tx-enabled off
- ethtool --set-mm $rx tx-enabled off
-
- log_test "Manual configuration with verification: $tx to $rx"
-}
-
-manual_with_verification_h1_to_h2()
-{
- manual_with_verification $h1 $h2
-}
-
-manual_with_verification_h2_to_h1()
-{
- manual_with_verification $h2 $h1
-}
-
-manual_without_verification()
-{
- local tx=$1; shift
- local rx=$1; shift
-
- RET=0
-
- ethtool --set-mm $tx verify-enabled off tx-enabled on
-
- ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
- grep -q 'DISABLED'
- check_err "$?" "Verification is not disabled"
-
- ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
- check_err "$?" "pMAC TX is not active"
-
- traffic_test $tx "pmac"
- check_err "$?" "Traffic did not get sent through $tx's pMAC"
-
- ethtool --set-mm $tx verify-enabled off tx-enabled off
-
- log_test "Manual configuration without verification: $tx to $rx"
-}
-
-manual_without_verification_h1_to_h2()
-{
- manual_without_verification $h1 $h2
-}
-
-manual_without_verification_h2_to_h1()
-{
- manual_without_verification $h2 $h1
-}
-
-manual_failed_verification()
-{
- local tx=$1; shift
- local rx=$1; shift
-
- RET=0
-
- ethtool --set-mm $rx pmac-enabled off
- ethtool --set-mm $tx verify-enabled on tx-enabled on
-
- # Wait for verification to time out
- sleep 1
-
- ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
- grep -q 'SUCCEEDED'
- check_fail "$?" "Verification succeeded when it shouldn't have"
-
- ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
- check_fail "$?" "pMAC TX is active when it shouldn't have"
-
- traffic_test $tx "emac"
- check_err "$?" "Traffic did not get sent through $tx's eMAC"
-
- ethtool --set-mm $tx verify-enabled off tx-enabled off
- ethtool --set-mm $rx pmac-enabled on
-
- log_test "Manual configuration with failed verification: $tx to $rx"
-}
-
-manual_failed_verification_h1_to_h2()
-{
- manual_failed_verification $h1 $h2
-}
-
-manual_failed_verification_h2_to_h1()
-{
- manual_failed_verification $h2 $h1
-}
-
-smallest_supported_add_frag_size()
-{
- local iface=$1
- local rx_min_frag_size=
-
- rx_min_frag_size=$(ethtool --json --show-mm $iface | \
- jq '.[]."rx-min-frag-size"')
-
- if [ $rx_min_frag_size -le 60 ]; then
- echo 0
- elif [ $rx_min_frag_size -le 124 ]; then
- echo 1
- elif [ $rx_min_frag_size -le 188 ]; then
- echo 2
- elif [ $rx_min_frag_size -le 252 ]; then
- echo 3
- else
- echo "$iface: RX min frag size $rx_min_frag_size cannot be advertised over LLDP"
- exit 1
- fi
-}
-
-expected_add_frag_size()
-{
- local iface=$1
- local requested=$2
- local min=$(smallest_supported_add_frag_size $iface)
-
- [ $requested -le $min ] && echo $min || echo $requested
-}
-
-lldp_change_add_frag_size()
-{
- local add_frag_size=$1
- local pattern=
-
- lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
- # Wait for TLVs to be received
- sleep 2
- pattern=$(printf "Additional fragment size: %d" \
- $(expected_add_frag_size $h1 $add_frag_size))
- lldptool -i $h2 -t -n -V addEthCaps | grep -q "$pattern"
-}
-
-lldp()
-{
- RET=0
-
- systemctl start lldpad
-
- # Configure the interfaces to receive and transmit LLDPDUs
- lldptool -L -i $h1 adminStatus=rxtx >/dev/null
- lldptool -L -i $h2 adminStatus=rxtx >/dev/null
-
- # Enable the transmission of Additional Ethernet Capabilities TLV
- lldptool -T -i $h1 -V addEthCaps enableTx=yes >/dev/null
- lldptool -T -i $h2 -V addEthCaps enableTx=yes >/dev/null
-
- # Wait for TLVs to be received
- sleep 2
-
- lldptool -i $h1 -t -n -V addEthCaps | \
- grep -q "Preemption capability active"
- check_err "$?" "$h1 pMAC TX is not active"
-
- lldptool -i $h2 -t -n -V addEthCaps | \
- grep -q "Preemption capability active"
- check_err "$?" "$h2 pMAC TX is not active"
-
- lldp_change_add_frag_size 3
- check_err "$?" "addFragSize 3"
-
- lldp_change_add_frag_size 2
- check_err "$?" "addFragSize 2"
-
- lldp_change_add_frag_size 1
- check_err "$?" "addFragSize 1"
-
- lldp_change_add_frag_size 0
- check_err "$?" "addFragSize 0"
-
- traffic_test $h1 "pmac"
- check_err "$?" "Traffic did not get sent through $h1's pMAC"
-
- traffic_test $h2 "pmac"
- check_err "$?" "Traffic did not get sent through $h2's pMAC"
-
- systemctl stop lldpad
-
- log_test "LLDP"
-}
-
-h1_create()
-{
- ip link set dev $h1 up
-
- tc qdisc add dev $h1 root mqprio num_tc 4 map 0 1 2 3 \
- queues 1@0 1@1 1@2 1@3 \
- fp P E E E \
- hw 1
-
- ethtool --set-mm $h1 pmac-enabled on tx-enabled off verify-enabled off
-}
-
-h2_create()
-{
- ip link set dev $h2 up
-
- ethtool --set-mm $h2 pmac-enabled on tx-enabled off verify-enabled off
-
- tc qdisc add dev $h2 root mqprio num_tc 4 map 0 1 2 3 \
- queues 1@0 1@1 1@2 1@3 \
- fp P E E E \
- hw 1
-}
-
-h1_destroy()
-{
- ethtool --set-mm $h1 pmac-enabled off tx-enabled off verify-enabled off
-
- tc qdisc del dev $h1 root
-
- ip link set dev $h1 down
-}
-
-h2_destroy()
-{
- tc qdisc del dev $h2 root
-
- ethtool --set-mm $h2 pmac-enabled off tx-enabled off verify-enabled off
-
- ip link set dev $h2 down
-}
-
-setup_prepare()
-{
- h1=${NETIFS[p1]}
- h2=${NETIFS[p2]}
-
- h1_create
- h2_create
-}
-
-cleanup()
-{
- pre_cleanup
-
- h2_destroy
- h1_destroy
-}
-
-check_ethtool_mm_support
-check_tc_fp_support
-require_command lldptool
-bail_on_lldpad "autoconfigure the MAC Merge layer" "configure it manually"
-
-for netif in ${NETIFS[@]}; do
- ethtool --show-mm $netif 2>&1 &> /dev/null
- if [[ $? -ne 0 ]]; then
- echo "SKIP: $netif does not support MAC Merge"
- exit $ksft_skip
- fi
-
- if check_ethtool_pmac_std_stats_support $netif eth-mac; then
- has_pmac_stats[$netif]=true
- else
- has_pmac_stats[$netif]=false
- echo "$netif does not report pMAC statistics, falling back to aggregate"
- fi
-done
-
-trap cleanup EXIT
-
-setup_prepare
-setup_wait
-
-tests_run
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/ethtool_rmon.sh b/tools/testing/selftests/net/forwarding/ethtool_rmon.sh
deleted file mode 100755
index e78776db85..0000000000
--- a/tools/testing/selftests/net/forwarding/ethtool_rmon.sh
+++ /dev/null
@@ -1,143 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-ALL_TESTS="
- rmon_rx_histogram
- rmon_tx_histogram
-"
-
-NUM_NETIFS=2
-source lib.sh
-
-ETH_FCS_LEN=4
-ETH_HLEN=$((6+6+2))
-
-declare -A netif_mtu
-
-ensure_mtu()
-{
- local iface=$1; shift
- local len=$1; shift
- local current=$(ip -j link show dev $iface | jq -r '.[0].mtu')
- local required=$((len - ETH_HLEN - ETH_FCS_LEN))
-
- if [ $current -lt $required ]; then
- ip link set dev $iface mtu $required || return 1
- fi
-}
-
-bucket_test()
-{
- local iface=$1; shift
- local neigh=$1; shift
- local set=$1; shift
- local bucket=$1; shift
- local len=$1; shift
- local num_rx=10000
- local num_tx=20000
- local expected=
- local before=
- local after=
- local delta=
-
- # Mausezahn does not include FCS bytes in its length - but the
- # histogram counters do
- len=$((len - ETH_FCS_LEN))
-
- before=$(ethtool --json -S $iface --groups rmon | \
- jq -r ".[0].rmon[\"${set}-pktsNtoM\"][$bucket].val")
-
- # Send 10k one way and 20k in the other, to detect counters
- # mapped to the wrong direction
- $MZ $neigh -q -c $num_rx -p $len -a own -b bcast -d 10us
- $MZ $iface -q -c $num_tx -p $len -a own -b bcast -d 10us
-
- after=$(ethtool --json -S $iface --groups rmon | \
- jq -r ".[0].rmon[\"${set}-pktsNtoM\"][$bucket].val")
-
- delta=$((after - before))
-
- expected=$([ $set = rx ] && echo $num_rx || echo $num_tx)
-
- # Allow some extra tolerance for other packets sent by the stack
- [ $delta -ge $expected ] && [ $delta -le $((expected + 100)) ]
-}
-
-rmon_histogram()
-{
- local iface=$1; shift
- local neigh=$1; shift
- local set=$1; shift
- local nbuckets=0
- local step=
-
- RET=0
-
- while read -r -a bucket; do
- step="$set-pkts${bucket[0]}to${bucket[1]} on $iface"
-
- for if in $iface $neigh; do
- if ! ensure_mtu $if ${bucket[0]}; then
- log_test_xfail "$if does not support the required MTU for $step"
- return
- fi
- done
-
- if ! bucket_test $iface $neigh $set $nbuckets ${bucket[0]}; then
- check_err 1 "$step failed"
- return 1
- fi
- log_test "$step"
- nbuckets=$((nbuckets + 1))
- done < <(ethtool --json -S $iface --groups rmon | \
- jq -r ".[0].rmon[\"${set}-pktsNtoM\"][]|[.low, .high]|@tsv" 2>/dev/null)
-
- if [ $nbuckets -eq 0 ]; then
- log_test_xfail "$iface does not support $set histogram counters"
- return
- fi
-}
-
-rmon_rx_histogram()
-{
- rmon_histogram $h1 $h2 rx
- rmon_histogram $h2 $h1 rx
-}
-
-rmon_tx_histogram()
-{
- rmon_histogram $h1 $h2 tx
- rmon_histogram $h2 $h1 tx
-}
-
-setup_prepare()
-{
- h1=${NETIFS[p1]}
- h2=${NETIFS[p2]}
-
- for iface in $h1 $h2; do
- netif_mtu[$iface]=$(ip -j link show dev $iface | jq -r '.[0].mtu')
- ip link set dev $iface up
- done
-}
-
-cleanup()
-{
- pre_cleanup
-
- for iface in $h2 $h1; do
- ip link set dev $iface \
- mtu ${netif_mtu[$iface]} \
- down
- done
-}
-
-check_ethtool_counter_group_support
-trap cleanup EXIT
-
-setup_prepare
-setup_wait
-
-tests_run
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/forwarding.config.sample b/tools/testing/selftests/net/forwarding/forwarding.config.sample
index 1fc4f0242f..f1ca95e79a 100644
--- a/tools/testing/selftests/net/forwarding/forwarding.config.sample
+++ b/tools/testing/selftests/net/forwarding/forwarding.config.sample
@@ -3,51 +3,28 @@
##############################################################################
# Topology description. p1 looped back to p2, p3 to p4 and so on.
-declare -A NETIFS
-NETIFS[p1]=veth0
-NETIFS[p2]=veth1
-NETIFS[p3]=veth2
-NETIFS[p4]=veth3
-NETIFS[p5]=veth4
-NETIFS[p6]=veth5
-NETIFS[p7]=veth6
-NETIFS[p8]=veth7
-NETIFS[p9]=veth8
-NETIFS[p10]=veth9
+NETIFS=(
+ [p1]=veth0
+ [p2]=veth1
+ [p3]=veth2
+ [p4]=veth3
+ [p5]=veth4
+ [p6]=veth5
+ [p7]=veth6
+ [p8]=veth7
+ [p9]=veth8
+ [p10]=veth9
+)
# Port that does not have a cable connected.
NETIF_NO_CABLE=eth8
##############################################################################
-# Defines
+# In addition to the topology-related variables, it is also possible to override
+# in this file other variables that net/lib.sh, net/forwarding/lib.sh or other
+# libraries or selftests use. E.g.:
-# IPv4 ping utility name
-PING=ping
-# IPv6 ping utility name. Some distributions use 'ping' for IPv6.
PING6=ping6
-# Packet generator. Some distributions use 'mz'.
MZ=mausezahn
-# mausezahn delay between transmissions in microseconds.
-MZ_DELAY=0
-# Time to wait after interfaces participating in the test are all UP
WAIT_TIME=5
-# Whether to pause on failure or not.
-PAUSE_ON_FAIL=no
-# Whether to pause on cleanup or not.
-PAUSE_ON_CLEANUP=no
-# Type of network interface to create
-NETIF_TYPE=veth
-# Whether to create virtual interfaces (veth) or not
-NETIF_CREATE=yes
-# Timeout (in seconds) before ping exits regardless of how many packets have
-# been sent or received
-PING_TIMEOUT=5
-# Minimum ageing_time (in centiseconds) supported by hardware
-LOW_AGEING_TIME=1000
-# Flag for tc match, supposed to be skip_sw/skip_hw which means do not process
-# filter by software/hardware
-TC_FLAG=skip_hw
-# IPv6 traceroute utility name.
-TROUTE6=traceroute6
-
diff --git a/tools/testing/selftests/net/forwarding/hw_stats_l3.sh b/tools/testing/selftests/net/forwarding/hw_stats_l3.sh
deleted file mode 100755
index 48584a5138..0000000000
--- a/tools/testing/selftests/net/forwarding/hw_stats_l3.sh
+++ /dev/null
@@ -1,340 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-# +--------------------+ +----------------------+
-# | H1 | | H2 |
-# | | | |
-# | $h1.200 + | | + $h2.200 |
-# | 192.0.2.1/28 | | | | 192.0.2.18/28 |
-# | 2001:db8:1::1/64 | | | | 2001:db8:2::1/64 |
-# | | | | | |
-# | $h1 + | | + $h2 |
-# | | | | | |
-# +------------------|-+ +-|--------------------+
-# | |
-# +------------------|-------------------------|--------------------+
-# | SW | | |
-# | | | |
-# | $rp1 + + $rp2 |
-# | | | |
-# | $rp1.200 + + $rp2.200 |
-# | 192.0.2.2/28 192.0.2.17/28 |
-# | 2001:db8:1::2/64 2001:db8:2::2/64 |
-# | |
-# +-----------------------------------------------------------------+
-
-ALL_TESTS="
- ping_ipv4
- ping_ipv6
- test_stats_rx_ipv4
- test_stats_tx_ipv4
- test_stats_rx_ipv6
- test_stats_tx_ipv6
- respin_enablement
- test_stats_rx_ipv4
- test_stats_tx_ipv4
- test_stats_rx_ipv6
- test_stats_tx_ipv6
- reapply_config
- ping_ipv4
- ping_ipv6
- test_stats_rx_ipv4
- test_stats_tx_ipv4
- test_stats_rx_ipv6
- test_stats_tx_ipv6
- test_stats_report_rx
- test_stats_report_tx
- test_destroy_enabled
- test_double_enable
-"
-NUM_NETIFS=4
-source lib.sh
-
-h1_create()
-{
- simple_if_init $h1
- vlan_create $h1 200 v$h1 192.0.2.1/28 2001:db8:1::1/64
- ip route add 192.0.2.16/28 vrf v$h1 nexthop via 192.0.2.2
- ip -6 route add 2001:db8:2::/64 vrf v$h1 nexthop via 2001:db8:1::2
-}
-
-h1_destroy()
-{
- ip -6 route del 2001:db8:2::/64 vrf v$h1 nexthop via 2001:db8:1::2
- ip route del 192.0.2.16/28 vrf v$h1 nexthop via 192.0.2.2
- vlan_destroy $h1 200
- simple_if_fini $h1
-}
-
-h2_create()
-{
- simple_if_init $h2
- vlan_create $h2 200 v$h2 192.0.2.18/28 2001:db8:2::1/64
- ip route add 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.17
- ip -6 route add 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::2
-}
-
-h2_destroy()
-{
- ip -6 route del 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::2
- ip route del 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.17
- vlan_destroy $h2 200
- simple_if_fini $h2
-}
-
-router_rp1_200_create()
-{
- ip link add name $rp1.200 link $rp1 type vlan id 200
- ip link set dev $rp1.200 addrgenmode eui64
- ip link set dev $rp1.200 up
- ip address add dev $rp1.200 192.0.2.2/28
- ip address add dev $rp1.200 2001:db8:1::2/64
- ip stats set dev $rp1.200 l3_stats on
-}
-
-router_rp1_200_destroy()
-{
- ip stats set dev $rp1.200 l3_stats off
- ip address del dev $rp1.200 2001:db8:1::2/64
- ip address del dev $rp1.200 192.0.2.2/28
- ip link del dev $rp1.200
-}
-
-router_create()
-{
- ip link set dev $rp1 up
- router_rp1_200_create
-
- ip link set dev $rp2 up
- vlan_create $rp2 200 "" 192.0.2.17/28 2001:db8:2::2/64
-}
-
-router_destroy()
-{
- vlan_destroy $rp2 200
- ip link set dev $rp2 down
-
- router_rp1_200_destroy
- ip link set dev $rp1 down
-}
-
-setup_prepare()
-{
- h1=${NETIFS[p1]}
- rp1=${NETIFS[p2]}
-
- rp2=${NETIFS[p3]}
- h2=${NETIFS[p4]}
-
- rp1mac=$(mac_get $rp1)
- rp2mac=$(mac_get $rp2)
-
- vrf_prepare
-
- h1_create
- h2_create
-
- router_create
-
- forwarding_enable
-}
-
-cleanup()
-{
- pre_cleanup
-
- forwarding_restore
-
- router_destroy
-
- h2_destroy
- h1_destroy
-
- vrf_cleanup
-}
-
-ping_ipv4()
-{
- ping_test $h1.200 192.0.2.18 " IPv4"
-}
-
-ping_ipv6()
-{
- ping_test $h1.200 2001:db8:2::1 " IPv6"
-}
-
-send_packets_rx_ipv4()
-{
- # Send 21 packets instead of 20, because the first one might trap and go
- # through the SW datapath, which might not bump the HW counter.
- $MZ $h1.200 -c 21 -d 20msec -p 100 \
- -a own -b $rp1mac -A 192.0.2.1 -B 192.0.2.18 \
- -q -t udp sp=54321,dp=12345
-}
-
-send_packets_rx_ipv6()
-{
- $MZ $h1.200 -6 -c 21 -d 20msec -p 100 \
- -a own -b $rp1mac -A 2001:db8:1::1 -B 2001:db8:2::1 \
- -q -t udp sp=54321,dp=12345
-}
-
-send_packets_tx_ipv4()
-{
- $MZ $h2.200 -c 21 -d 20msec -p 100 \
- -a own -b $rp2mac -A 192.0.2.18 -B 192.0.2.1 \
- -q -t udp sp=54321,dp=12345
-}
-
-send_packets_tx_ipv6()
-{
- $MZ $h2.200 -6 -c 21 -d 20msec -p 100 \
- -a own -b $rp2mac -A 2001:db8:2::1 -B 2001:db8:1::1 \
- -q -t udp sp=54321,dp=12345
-}
-
-___test_stats()
-{
- local dir=$1; shift
- local prot=$1; shift
-
- local a
- local b
-
- a=$(hw_stats_get l3_stats $rp1.200 ${dir} packets)
- send_packets_${dir}_${prot}
- "$@"
- b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
- hw_stats_get l3_stats $rp1.200 ${dir} packets)
- check_err $? "Traffic not reflected in the counter: $a -> $b"
-}
-
-__test_stats()
-{
- local dir=$1; shift
- local prot=$1; shift
-
- RET=0
- ___test_stats "$dir" "$prot"
- log_test "Test $dir packets: $prot"
-}
-
-test_stats_rx_ipv4()
-{
- __test_stats rx ipv4
-}
-
-test_stats_tx_ipv4()
-{
- __test_stats tx ipv4
-}
-
-test_stats_rx_ipv6()
-{
- __test_stats rx ipv6
-}
-
-test_stats_tx_ipv6()
-{
- __test_stats tx ipv6
-}
-
-# Make sure everything works well even after stats have been disabled and
-# reenabled on the same device without touching the L3 configuration.
-respin_enablement()
-{
- log_info "Turning stats off and on again"
- ip stats set dev $rp1.200 l3_stats off
- ip stats set dev $rp1.200 l3_stats on
-}
-
-# For the initial run, l3_stats is enabled on a completely set up netdevice. Now
-# do it the other way around: enabling the L3 stats on an L2 netdevice, and only
-# then apply the L3 configuration.
-reapply_config()
-{
- log_info "Reapplying configuration"
-
- router_rp1_200_destroy
-
- ip link add name $rp1.200 link $rp1 type vlan id 200
- ip link set dev $rp1.200 addrgenmode none
- ip stats set dev $rp1.200 l3_stats on
- ip link set dev $rp1.200 addrgenmode eui64
- ip link set dev $rp1.200 up
- ip address add dev $rp1.200 192.0.2.2/28
- ip address add dev $rp1.200 2001:db8:1::2/64
-}
-
-__test_stats_report()
-{
- local dir=$1; shift
- local prot=$1; shift
-
- local a
- local b
-
- RET=0
-
- a=$(hw_stats_get l3_stats $rp1.200 ${dir} packets)
- send_packets_${dir}_${prot}
- ip address flush dev $rp1.200
- b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
- hw_stats_get l3_stats $rp1.200 ${dir} packets)
- check_err $? "Traffic not reflected in the counter: $a -> $b"
- log_test "Test ${dir} packets: stats pushed on loss of L3"
-
- ip stats set dev $rp1.200 l3_stats off
- ip link del dev $rp1.200
- router_rp1_200_create
-}
-
-test_stats_report_rx()
-{
- __test_stats_report rx ipv4
-}
-
-test_stats_report_tx()
-{
- __test_stats_report tx ipv4
-}
-
-test_destroy_enabled()
-{
- RET=0
-
- ip link del dev $rp1.200
- router_rp1_200_create
-
- log_test "Destroy l3_stats-enabled netdev"
-}
-
-test_double_enable()
-{
- RET=0
- ___test_stats rx ipv4 \
- ip stats set dev $rp1.200 l3_stats on
- log_test "Test stat retention across a spurious enablement"
-}
-
-trap cleanup EXIT
-
-setup_prepare
-setup_wait
-
-used=$(ip -j stats show dev $rp1.200 group offload subgroup hw_stats_info |
- jq '.[].info.l3_stats.used')
-kind=$(ip -j -d link show dev $rp1 |
- jq -r '.[].linkinfo.info_kind')
-if [[ $used != true ]]; then
- if [[ $kind == veth ]]; then
- log_test_skip "l3_stats not offloaded on veth interface"
- EXIT_STATUS=$ksft_skip
- else
- RET=1 log_test "l3_stats not offloaded"
- fi
-else
- tests_run
-fi
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/hw_stats_l3_gre.sh b/tools/testing/selftests/net/forwarding/hw_stats_l3_gre.sh
deleted file mode 100755
index 7594bbb490..0000000000
--- a/tools/testing/selftests/net/forwarding/hw_stats_l3_gre.sh
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-# Test L3 stats on IP-in-IP GRE tunnel without key.
-
-# This test uses flat topology for IP tunneling tests. See ipip_lib.sh for more
-# details.
-
-ALL_TESTS="
- ping_ipv4
- test_stats_rx
- test_stats_tx
-"
-NUM_NETIFS=6
-source lib.sh
-source ipip_lib.sh
-
-setup_prepare()
-{
- h1=${NETIFS[p1]}
- ol1=${NETIFS[p2]}
-
- ul1=${NETIFS[p3]}
- ul2=${NETIFS[p4]}
-
- ol2=${NETIFS[p5]}
- h2=${NETIFS[p6]}
-
- ol1mac=$(mac_get $ol1)
-
- forwarding_enable
- vrf_prepare
- h1_create
- h2_create
- sw1_flat_create gre $ol1 $ul1
- sw2_flat_create gre $ol2 $ul2
- ip stats set dev g1a l3_stats on
- ip stats set dev g2a l3_stats on
-}
-
-cleanup()
-{
- pre_cleanup
-
- ip stats set dev g1a l3_stats off
- ip stats set dev g2a l3_stats off
-
- sw2_flat_destroy $ol2 $ul2
- sw1_flat_destroy $ol1 $ul1
- h2_destroy
- h1_destroy
-
- vrf_cleanup
- forwarding_restore
-}
-
-ping_ipv4()
-{
- RET=0
-
- ping_test $h1 192.0.2.18 " gre flat"
-}
-
-send_packets_ipv4()
-{
- # Send 21 packets instead of 20, because the first one might trap and go
- # through the SW datapath, which might not bump the HW counter.
- $MZ $h1 -c 21 -d 20msec -p 100 \
- -a own -b $ol1mac -A 192.0.2.1 -B 192.0.2.18 \
- -q -t udp sp=54321,dp=12345
-}
-
-test_stats()
-{
- local dev=$1; shift
- local dir=$1; shift
-
- local a
- local b
-
- RET=0
-
- a=$(hw_stats_get l3_stats $dev $dir packets)
- send_packets_ipv4
- b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
- hw_stats_get l3_stats $dev $dir packets)
- check_err $? "Traffic not reflected in the counter: $a -> $b"
-
- log_test "Test $dir packets: $prot"
-}
-
-test_stats_tx()
-{
- test_stats g1a tx
-}
-
-test_stats_rx()
-{
- test_stats g2a rx
-}
-
-skip_on_veth
-
-trap cleanup EXIT
-
-setup_prepare
-setup_wait
-
-tests_run
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/ipip_lib.sh b/tools/testing/selftests/net/forwarding/ipip_lib.sh
index 30f36a57ba..01e62c4ac9 100644
--- a/tools/testing/selftests/net/forwarding/ipip_lib.sh
+++ b/tools/testing/selftests/net/forwarding/ipip_lib.sh
@@ -141,7 +141,6 @@
# | $h2 + |
# | 192.0.2.18/28 |
# +---------------------------+
-source lib.sh
h1_create()
{
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index e78f11140e..eabbdf00d8 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -2,33 +2,124 @@
# SPDX-License-Identifier: GPL-2.0
##############################################################################
+# Topology description. p1 looped back to p2, p3 to p4 and so on.
+
+declare -A NETIFS=(
+ [p1]=veth0
+ [p2]=veth1
+ [p3]=veth2
+ [p4]=veth3
+ [p5]=veth4
+ [p6]=veth5
+ [p7]=veth6
+ [p8]=veth7
+ [p9]=veth8
+ [p10]=veth9
+)
+
+# Port that does not have a cable connected.
+: "${NETIF_NO_CABLE:=eth8}"
+
+##############################################################################
# Defines
-# Can be overridden by the configuration file.
-PING=${PING:=ping}
-PING6=${PING6:=ping6}
-MZ=${MZ:=mausezahn}
-MZ_DELAY=${MZ_DELAY:=0}
-ARPING=${ARPING:=arping}
-TEAMD=${TEAMD:=teamd}
-WAIT_TIME=${WAIT_TIME:=5}
-PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
-PAUSE_ON_CLEANUP=${PAUSE_ON_CLEANUP:=no}
-NETIF_TYPE=${NETIF_TYPE:=veth}
-NETIF_CREATE=${NETIF_CREATE:=yes}
-MCD=${MCD:=smcrouted}
-MC_CLI=${MC_CLI:=smcroutectl}
-PING_COUNT=${PING_COUNT:=10}
-PING_TIMEOUT=${PING_TIMEOUT:=5}
-WAIT_TIMEOUT=${WAIT_TIMEOUT:=20}
-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:=}
-TROUTE6=${TROUTE6:=traceroute6}
+# Networking utilities.
+: "${PING:=ping}"
+: "${PING6:=ping6}" # Some distros just use ping.
+: "${ARPING:=arping}"
+: "${TROUTE6:=traceroute6}"
+
+# Packet generator.
+: "${MZ:=mausezahn}" # Some distributions use 'mz'.
+: "${MZ_DELAY:=0}"
+
+# Host configuration tools.
+: "${TEAMD:=teamd}"
+: "${MCD:=smcrouted}"
+: "${MC_CLI:=smcroutectl}"
+
+# Constants for netdevice bring-up:
+# Default time in seconds to wait for an interface to come up before giving up
+# and bailing out. Used during initial setup.
+: "${INTERFACE_TIMEOUT:=600}"
+# Like INTERFACE_TIMEOUT, but default for ad-hoc waiting in testing scripts.
+: "${WAIT_TIMEOUT:=20}"
+# Time to wait after interfaces participating in the test are all UP.
+: "${WAIT_TIME:=5}"
+
+# Whether to pause on, respectively, after a failure and before cleanup.
+: "${PAUSE_ON_FAIL:=no}"
+: "${PAUSE_ON_CLEANUP:=no}"
+
+# Whether to create virtual interfaces, and what netdevice type they should be.
+: "${NETIF_CREATE:=yes}"
+: "${NETIF_TYPE:=veth}"
+
+# Constants for ping tests:
+# How many packets should be sent.
+: "${PING_COUNT:=10}"
+# Timeout (in seconds) before ping exits regardless of how many packets have
+# been sent or received
+: "${PING_TIMEOUT:=5}"
+
+# Minimum ageing_time (in centiseconds) supported by hardware
+: "${LOW_AGEING_TIME:=1000}"
+
+# Whether to check for availability of certain tools.
+: "${REQUIRE_JQ:=yes}"
+: "${REQUIRE_MZ:=yes}"
+: "${REQUIRE_MTOOLS:=no}"
+
+# Whether to override MAC addresses on interfaces participating in the test.
+: "${STABLE_MAC_ADDRS:=no}"
+
+# Flags for tcpdump
+: "${TCPDUMP_EXTRA_FLAGS:=}"
+
+# Flags for TC filters.
+: "${TC_FLAG:=skip_hw}"
+
+# Whether the machine is "slow" -- i.e. might be incapable of running tests
+# involving heavy traffic. This might be the case on a debug kernel, a VM, or
+# e.g. a low-power board.
+: "${KSFT_MACHINE_SLOW:=no}"
+
+##############################################################################
+# Find netifs by test-specified driver name
+
+driver_name_get()
+{
+ local dev=$1; shift
+ local driver_path="/sys/class/net/$dev/device/driver"
+
+ if [[ -L $driver_path ]]; then
+ basename `realpath $driver_path`
+ fi
+}
+
+netif_find_driver()
+{
+ local ifnames=`ip -j link show | jq -r ".[].ifname"`
+ local count=0
+
+ for ifname in $ifnames
+ do
+ local driver_name=`driver_name_get $ifname`
+ if [[ ! -z $driver_name && $driver_name == $NETIF_FIND_DRIVER ]]; then
+ count=$((count + 1))
+ NETIFS[p$count]="$ifname"
+ fi
+ done
+}
+
+# Whether to find netdevice according to the driver speficied by the importer
+: "${NETIF_FIND_DRIVER:=}"
+
+if [[ $NETIF_FIND_DRIVER ]]; then
+ unset NETIFS
+ declare -A NETIFS
+ netif_find_driver
+fi
net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
@@ -179,22 +270,23 @@ check_port_mab_support()
fi
}
-skip_on_veth()
+if [[ "$(id -u)" -ne 0 ]]; then
+ echo "SKIP: need root privileges"
+ exit $ksft_skip
+fi
+
+check_driver()
{
- local kind=$(ip -j -d link show dev ${NETIFS[p1]} |
- jq -r '.[].linkinfo.info_kind')
+ local dev=$1; shift
+ local expected=$1; shift
+ local driver_name=`driver_name_get $dev`
- if [[ $kind == veth ]]; then
- echo "SKIP: Test cannot be run with veth pairs"
+ if [[ $driver_name != $expected ]]; then
+ echo "SKIP: expected driver $expected for $dev, got $driver_name instead"
exit $ksft_skip
fi
}
-if [[ "$(id -u)" -ne 0 ]]; then
- echo "SKIP: need root privileges"
- exit $ksft_skip
-fi
-
if [[ "$CHECK_TC" = "yes" ]]; then
check_tc_version
fi
@@ -209,6 +301,21 @@ require_command()
fi
}
+# IPv6 support was added in v3.0
+check_mtools_version()
+{
+ local version="$(msend -v)"
+ local major
+
+ version=${version##msend version }
+ major=$(echo $version | cut -d. -f1)
+
+ if [ $major -lt 3 ]; then
+ echo "SKIP: expected mtools version 3.0, got $version"
+ exit $ksft_skip
+ fi
+}
+
if [[ "$REQUIRE_JQ" = "yes" ]]; then
require_command jq
fi
@@ -216,15 +323,10 @@ if [[ "$REQUIRE_MZ" = "yes" ]]; then
require_command $MZ
fi
if [[ "$REQUIRE_MTOOLS" = "yes" ]]; then
- # https://github.com/vladimiroltean/mtools/
- # patched for IPv6 support
+ # https://github.com/troglobit/mtools
require_command msend
require_command mreceive
-fi
-
-if [[ ! -v NUM_NETIFS ]]; then
- echo "SKIP: importer does not define \"NUM_NETIFS\""
- exit $ksft_skip
+ check_mtools_version
fi
##############################################################################
@@ -245,6 +347,23 @@ done
##############################################################################
# Network interfaces configuration
+if [[ ! -v NUM_NETIFS ]]; then
+ echo "SKIP: importer does not define \"NUM_NETIFS\""
+ exit $ksft_skip
+fi
+
+if (( NUM_NETIFS > ${#NETIFS[@]} )); then
+ echo "SKIP: Importer requires $NUM_NETIFS NETIFS, but only ${#NETIFS[@]} are defined (${NETIFS[@]})"
+ exit $ksft_skip
+fi
+
+for i in $(seq ${#NETIFS[@]}); do
+ if [[ ! ${NETIFS[p$i]} ]]; then
+ echo "SKIP: NETIFS[p$i] not given"
+ exit $ksft_skip
+ fi
+done
+
create_netif_veth()
{
local i
@@ -343,13 +462,20 @@ ret_set_ksft_status()
fi
}
+# Whether FAILs should be interpreted as XFAILs. Internal.
+FAIL_TO_XFAIL=
+
check_err()
{
local err=$1
local msg=$2
if ((err)); then
- ret_set_ksft_status $ksft_fail "$msg"
+ if [[ $FAIL_TO_XFAIL = yes ]]; then
+ ret_set_ksft_status $ksft_xfail "$msg"
+ else
+ ret_set_ksft_status $ksft_fail "$msg"
+ fi
fi
}
@@ -374,6 +500,29 @@ check_err_fail()
fi
}
+xfail_on_slow()
+{
+ if [[ $KSFT_MACHINE_SLOW = yes ]]; then
+ FAIL_TO_XFAIL=yes "$@"
+ else
+ "$@"
+ fi
+}
+
+xfail_on_veth()
+{
+ local dev=$1; shift
+ local kind
+
+ kind=$(ip -j -d link show dev $dev |
+ jq -r '.[].linkinfo.info_kind')
+ if [[ $kind = veth ]]; then
+ FAIL_TO_XFAIL=yes "$@"
+ else
+ "$@"
+ fi
+}
+
log_test_result()
{
local test_name=$1; shift
@@ -569,6 +718,19 @@ setup_wait()
sleep $WAIT_TIME
}
+wait_for_dev()
+{
+ local dev=$1; shift
+ local timeout=${1:-$WAIT_TIMEOUT}; shift
+
+ slowwait $timeout ip link show dev $dev &> /dev/null
+ if (( $? )); then
+ check_err 1
+ log_test wait_for_dev "Interface $dev did not appear."
+ exit $EXIT_STATUS
+ fi
+}
+
cmd_jq()
{
local cmd=$1
@@ -1995,6 +2157,8 @@ bail_on_lldpad()
{
local reason1="$1"; shift
local reason2="$1"; shift
+ local caller=${FUNCNAME[1]}
+ local src=${BASH_SOURCE[1]}
if systemctl is-active --quiet lldpad; then
@@ -2015,7 +2179,8 @@ bail_on_lldpad()
an environment variable ALLOW_LLDPAD to a
non-empty string.
EOF
- exit 1
+ log_test_skip $src:$caller
+ exit $EXIT_STATUS
else
return
fi
diff --git a/tools/testing/selftests/net/forwarding/lib_sh_test.sh b/tools/testing/selftests/net/forwarding/lib_sh_test.sh
new file mode 100755
index 0000000000..ff2accccaf
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/lib_sh_test.sh
@@ -0,0 +1,208 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# This tests the operation of lib.sh itself.
+
+ALL_TESTS="
+ test_ret
+ test_exit_status
+"
+NUM_NETIFS=0
+source lib.sh
+
+# Simulated checks.
+
+do_test()
+{
+ local msg=$1; shift
+
+ "$@"
+ check_err $? "$msg"
+}
+
+tpass()
+{
+ do_test "tpass" true
+}
+
+tfail()
+{
+ do_test "tfail" false
+}
+
+txfail()
+{
+ FAIL_TO_XFAIL=yes do_test "txfail" false
+}
+
+# Simulated tests.
+
+pass()
+{
+ RET=0
+ do_test "true" true
+ log_test "true"
+}
+
+fail()
+{
+ RET=0
+ do_test "false" false
+ log_test "false"
+}
+
+xfail()
+{
+ RET=0
+ FAIL_TO_XFAIL=yes do_test "xfalse" false
+ log_test "xfalse"
+}
+
+skip()
+{
+ RET=0
+ log_test_skip "skip"
+}
+
+slow_xfail()
+{
+ RET=0
+ xfail_on_slow do_test "slow_false" false
+ log_test "slow_false"
+}
+
+# lib.sh tests.
+
+ret_tests_run()
+{
+ local t
+
+ RET=0
+ retmsg=
+ for t in "$@"; do
+ $t
+ done
+ echo "$retmsg"
+ return $RET
+}
+
+ret_subtest()
+{
+ local expect_ret=$1; shift
+ local expect_retmsg=$1; shift
+ local -a tests=( "$@" )
+
+ local status_names=(pass fail xfail xpass skip)
+ local ret
+ local out
+
+ RET=0
+
+ # Run this in a subshell, so that our environment is intact.
+ out=$(ret_tests_run "${tests[@]}")
+ ret=$?
+
+ (( ret == expect_ret ))
+ check_err $? "RET=$ret expected $expect_ret"
+
+ [[ $out == $expect_retmsg ]]
+ check_err $? "retmsg=$out expected $expect_retmsg"
+
+ log_test "RET $(echo ${tests[@]}) -> ${status_names[$ret]}"
+}
+
+test_ret()
+{
+ ret_subtest $ksft_pass ""
+
+ ret_subtest $ksft_pass "" tpass
+ ret_subtest $ksft_fail "tfail" tfail
+ ret_subtest $ksft_xfail "txfail" txfail
+
+ ret_subtest $ksft_pass "" tpass tpass
+ ret_subtest $ksft_fail "tfail" tpass tfail
+ ret_subtest $ksft_xfail "txfail" tpass txfail
+
+ ret_subtest $ksft_fail "tfail" tfail tpass
+ ret_subtest $ksft_xfail "txfail" txfail tpass
+
+ ret_subtest $ksft_fail "tfail" tfail tfail
+ ret_subtest $ksft_fail "tfail" tfail txfail
+
+ ret_subtest $ksft_fail "tfail" txfail tfail
+
+ ret_subtest $ksft_xfail "txfail" txfail txfail
+}
+
+exit_status_tests_run()
+{
+ EXIT_STATUS=0
+ tests_run > /dev/null
+ return $EXIT_STATUS
+}
+
+exit_status_subtest()
+{
+ local expect_exit_status=$1; shift
+ local tests=$1; shift
+ local what=$1; shift
+
+ local status_names=(pass fail xfail xpass skip)
+ local exit_status
+ local out
+
+ RET=0
+
+ # Run this in a subshell, so that our environment is intact.
+ out=$(TESTS="$tests" exit_status_tests_run)
+ exit_status=$?
+
+ (( exit_status == expect_exit_status ))
+ check_err $? "EXIT_STATUS=$exit_status, expected $expect_exit_status"
+
+ log_test "EXIT_STATUS $tests$what -> ${status_names[$exit_status]}"
+}
+
+test_exit_status()
+{
+ exit_status_subtest $ksft_pass ":"
+
+ exit_status_subtest $ksft_pass "pass"
+ exit_status_subtest $ksft_fail "fail"
+ exit_status_subtest $ksft_pass "xfail"
+ exit_status_subtest $ksft_skip "skip"
+
+ exit_status_subtest $ksft_pass "pass pass"
+ exit_status_subtest $ksft_fail "pass fail"
+ exit_status_subtest $ksft_pass "pass xfail"
+ exit_status_subtest $ksft_skip "pass skip"
+
+ exit_status_subtest $ksft_fail "fail pass"
+ exit_status_subtest $ksft_pass "xfail pass"
+ exit_status_subtest $ksft_skip "skip pass"
+
+ exit_status_subtest $ksft_fail "fail fail"
+ exit_status_subtest $ksft_fail "fail xfail"
+ exit_status_subtest $ksft_fail "fail skip"
+
+ exit_status_subtest $ksft_fail "xfail fail"
+ exit_status_subtest $ksft_fail "skip fail"
+
+ exit_status_subtest $ksft_pass "xfail xfail"
+ exit_status_subtest $ksft_skip "xfail skip"
+ exit_status_subtest $ksft_skip "skip xfail"
+
+ exit_status_subtest $ksft_skip "skip skip"
+
+ KSFT_MACHINE_SLOW=yes \
+ exit_status_subtest $ksft_pass "slow_xfail" ": slow"
+
+ KSFT_MACHINE_SLOW=no \
+ exit_status_subtest $ksft_fail "slow_xfail" ": fast"
+}
+
+trap pre_cleanup EXIT
+
+tests_run
+
+exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/local_termination.sh b/tools/testing/selftests/net/forwarding/local_termination.sh
index c5b0cbc85b..4b364cdf3e 100755
--- a/tools/testing/selftests/net/forwarding/local_termination.sh
+++ b/tools/testing/selftests/net/forwarding/local_termination.sh
@@ -155,25 +155,30 @@ run_test()
"$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
+ xfail_on_veth $h1 \
+ 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
+ xfail_on_veth $h1 \
+ 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
+ xfail_on_veth $h1 \
+ 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)" \
@@ -187,9 +192,10 @@ run_test()
"$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
+ xfail_on_veth $h1 \
+ 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)" \
diff --git a/tools/testing/selftests/net/forwarding/loopback.sh b/tools/testing/selftests/net/forwarding/loopback.sh
deleted file mode 100755
index 8f4057310b..0000000000
--- a/tools/testing/selftests/net/forwarding/loopback.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-# Kselftest framework requirement - SKIP code is 4.
-ksft_skip=4
-
-ALL_TESTS="loopback_test"
-NUM_NETIFS=2
-source tc_common.sh
-source lib.sh
-
-h1_create()
-{
- simple_if_init $h1 192.0.2.1/24
- tc qdisc add dev $h1 clsact
-}
-
-h1_destroy()
-{
- tc qdisc del dev $h1 clsact
- simple_if_fini $h1 192.0.2.1/24
-}
-
-h2_create()
-{
- simple_if_init $h2
-}
-
-h2_destroy()
-{
- simple_if_fini $h2
-}
-
-loopback_test()
-{
- RET=0
-
- tc filter add dev $h1 ingress protocol arp pref 1 handle 101 flower \
- skip_hw arp_op reply arp_tip 192.0.2.1 action drop
-
- $MZ $h1 -c 1 -t arp -q
-
- tc_check_packets "dev $h1 ingress" 101 1
- check_fail $? "Matched on a filter without loopback setup"
-
- ethtool -K $h1 loopback on
- check_err $? "Failed to enable loopback"
-
- setup_wait_dev $h1
-
- $MZ $h1 -c 1 -t arp -q
-
- tc_check_packets "dev $h1 ingress" 101 1
- check_err $? "Did not match on filter with loopback"
-
- ethtool -K $h1 loopback off
- check_err $? "Failed to disable loopback"
-
- $MZ $h1 -c 1 -t arp -q
-
- tc_check_packets "dev $h1 ingress" 101 2
- check_fail $? "Matched on a filter after loopback was removed"
-
- tc filter del dev $h1 ingress protocol arp pref 1 handle 101 flower
-
- log_test "loopback"
-}
-
-setup_prepare()
-{
- h1=${NETIFS[p1]}
- h2=${NETIFS[p2]}
-
- vrf_prepare
-
- h1_create
- h2_create
-
- if ethtool -k $h1 | grep loopback | grep -q fixed; then
- log_test "SKIP: dev $h1 does not support loopback feature"
- exit $ksft_skip
- fi
-}
-
-cleanup()
-{
- pre_cleanup
-
- h2_destroy
- h1_destroy
-
- vrf_cleanup
-}
-
-trap cleanup EXIT
-
-setup_prepare
-setup_wait
-
-tests_run
-
-exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh.sh
index 3f0f5dc955..2ba44247c6 100755
--- a/tools/testing/selftests/net/forwarding/router_mpath_nh.sh
+++ b/tools/testing/selftests/net/forwarding/router_mpath_nh.sh
@@ -1,6 +1,41 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
+# +-------------------------+
+# | H1 |
+# | $h1 + |
+# | 192.0.2.2/24 | |
+# | 2001:db8:1::2/64 | |
+# +-------------------|-----+
+# |
+# +-------------------|----------------------+
+# | | R1 |
+# | $rp11 + |
+# | 192.0.2.1/24 |
+# | 2001:db8:1::1/64 |
+# | |
+# | + $rp12 + $rp13 |
+# | | 169.254.2.12/24 | 169.254.3.13/24 |
+# | | fe80:2::12/64 | fe80:3::13/64 |
+# +--|--------------------|------------------+
+# | |
+# +--|--------------------|------------------+
+# | + $rp22 + $rp23 |
+# | 169.254.2.22/24 169.254.3.23/24 |
+# | fe80:2::22/64 fe80:3::23/64 |
+# | |
+# | $rp21 + |
+# | 198.51.100.1/24 | |
+# | 2001:db8:2::1/64 | R2 |
+# +-------------------|----------------------+
+# |
+# +-------------------|-----+
+# | | |
+# | $h2 + |
+# | 198.51.100.2/24 |
+# | 2001:db8:2::2/64 H2 |
+# +-------------------------+
+
ALL_TESTS="
ping_ipv4
ping_ipv6
diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh
index b2d2c6cecc..2903294d8b 100644
--- a/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh
+++ b/tools/testing/selftests/net/forwarding/router_mpath_nh_lib.sh
@@ -56,21 +56,12 @@ nh_stats_test_dispatch_swhw()
local group_id=$1; shift
local mz="$@"
- local used
-
nh_stats_do_test "$what" "$nh1_id" "$nh2_id" "$group_id" \
nh_stats_get "${mz[@]}"
- used=$(ip -s -j -d nexthop show id $group_id |
- jq '.[].hw_stats.used')
- kind=$(ip -j -d link show dev $rp11 |
- jq -r '.[].linkinfo.info_kind')
- if [[ $used == true ]]; then
+ xfail_on_veth $rp11 \
nh_stats_do_test "HW $what" "$nh1_id" "$nh2_id" "$group_id" \
nh_stats_get_hw "${mz[@]}"
- elif [[ $kind == veth ]]; then
- log_test_xfail "HW stats not offloaded on veth topology"
- fi
}
nh_stats_test_dispatch()
@@ -83,7 +74,6 @@ nh_stats_test_dispatch()
local mz="$@"
local enabled
- local kind
if ! ip nexthop help 2>&1 | grep -q hw_stats; then
log_test_skip "NH stats test: ip doesn't support HW stats"
diff --git a/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh b/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh
index 4b483d24ad..cd9e346436 100755
--- a/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh
+++ b/tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh
@@ -1,6 +1,41 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
+# +-------------------------+
+# | H1 |
+# | $h1 + |
+# | 192.0.2.2/24 | |
+# | 2001:db8:1::2/64 | |
+# +-------------------|-----+
+# |
+# +-------------------|----------------------+
+# | | R1 |
+# | $rp11 + |
+# | 192.0.2.1/24 |
+# | 2001:db8:1::1/64 |
+# | |
+# | + $rp12 + $rp13 |
+# | | 169.254.2.12/24 | 169.254.3.13/24 |
+# | | fe80:2::12/64 | fe80:3::13/64 |
+# +--|--------------------|------------------+
+# | |
+# +--|--------------------|------------------+
+# | + $rp22 + $rp23 |
+# | 169.254.2.22/24 169.254.3.23/24 |
+# | fe80:2::22/64 fe80:3::23/64 |
+# | |
+# | $rp21 + |
+# | 198.51.100.1/24 | |
+# | 2001:db8:2::1/64 | R2 |
+# +-------------------|----------------------+
+# |
+# +-------------------|-----+
+# | | |
+# | $h2 + |
+# | 198.51.100.2/24 |
+# | 2001:db8:2::2/64 H2 |
+# +-------------------------+
+
ALL_TESTS="
ping_ipv4
ping_ipv6
diff --git a/tools/testing/selftests/net/forwarding/router_nh.sh b/tools/testing/selftests/net/forwarding/router_nh.sh
index f3a53738bd..92904b01ea 100755
--- a/tools/testing/selftests/net/forwarding/router_nh.sh
+++ b/tools/testing/selftests/net/forwarding/router_nh.sh
@@ -1,6 +1,20 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
+# +-------------------------+ +-------------------------+
+# | H1 | | H2 |
+# | $h1 + | | $h2 + |
+# | 192.0.2.2/24 | | | 198.51.100.2/24 | |
+# | 2001:db8:1::2/64 | | | 2001:db8:2::2/64 | |
+# +-------------------|-----+ +-------------------|-----+
+# | |
+# +-------------------|----------------------------|-----+
+# | R1 | | |
+# | $rp1 + $rp2 + |
+# | 192.0.2.1/24 198.51.100.1/24 |
+# | 2001:db8:1::1/64 2001:db8:2::1/64 |
+# +------------------------------------------------------+
+
ALL_TESTS="
ping_ipv4
ping_ipv6
diff --git a/tools/testing/selftests/net/forwarding/sch_ets_tests.sh b/tools/testing/selftests/net/forwarding/sch_ets_tests.sh
index cdf689e994..f9d26a7911 100644
--- a/tools/testing/selftests/net/forwarding/sch_ets_tests.sh
+++ b/tools/testing/selftests/net/forwarding/sch_ets_tests.sh
@@ -199,25 +199,28 @@ ets_set_dwrr_two_bands()
ets_test_strict()
{
ets_set_strict
- ets_dwrr_test_01
- ets_dwrr_test_12
+ xfail_on_slow ets_dwrr_test_01
+ xfail_on_slow ets_dwrr_test_12
}
ets_test_mixed()
{
ets_set_mixed
- ets_dwrr_test_01
- ets_dwrr_test_12
+ xfail_on_slow ets_dwrr_test_01
+ xfail_on_slow ets_dwrr_test_12
}
ets_test_dwrr()
{
ets_set_dwrr_uniform
- ets_dwrr_test_012
+ xfail_on_slow ets_dwrr_test_012
+
ets_set_dwrr_varying
- ets_dwrr_test_012
+ xfail_on_slow ets_dwrr_test_012
+
ets_change_quantum
- ets_dwrr_test_012
+ xfail_on_slow ets_dwrr_test_012
+
ets_set_dwrr_two_bands
- ets_dwrr_test_01
+ xfail_on_slow ets_dwrr_test_01
}
diff --git a/tools/testing/selftests/net/forwarding/sch_red.sh b/tools/testing/selftests/net/forwarding/sch_red.sh
index 81f31179ac..17f2864456 100755
--- a/tools/testing/selftests/net/forwarding/sch_red.sh
+++ b/tools/testing/selftests/net/forwarding/sch_red.sh
@@ -451,35 +451,35 @@ uninstall_qdisc()
ecn_test()
{
install_qdisc ecn
- do_ecn_test $BACKLOG
+ xfail_on_slow do_ecn_test $BACKLOG
uninstall_qdisc
}
ecn_nodrop_test()
{
install_qdisc ecn nodrop
- do_ecn_nodrop_test $BACKLOG
+ xfail_on_slow do_ecn_nodrop_test $BACKLOG
uninstall_qdisc
}
red_test()
{
install_qdisc
- do_red_test $BACKLOG
+ xfail_on_slow do_red_test $BACKLOG
uninstall_qdisc
}
red_qevent_test()
{
install_qdisc qevent early_drop block 10
- do_red_qevent_test $BACKLOG
+ xfail_on_slow do_red_qevent_test $BACKLOG
uninstall_qdisc
}
ecn_qevent_test()
{
install_qdisc ecn qevent mark block 10
- do_ecn_qevent_test $BACKLOG
+ xfail_on_slow do_ecn_qevent_test $BACKLOG
uninstall_qdisc
}
diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
index d1f26cb7cd..9cd884d4a5 100644
--- a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
+++ b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh
@@ -227,7 +227,7 @@ do_tbf_test()
local nr=$(rate $t2 $t3 10)
local nr_pct=$((100 * (nr - er) / er))
((-5 <= nr_pct && nr_pct <= 5))
- check_err $? "Expected rate $(humanize $er), got $(humanize $nr), which is $nr_pct% off. Required accuracy is +-5%."
+ xfail_on_slow check_err $? "Expected rate $(humanize $er), got $(humanize $nr), which is $nr_pct% off. Required accuracy is +-5%."
log_test "TC $((vlan - 10)): TBF rate ${mbit}Mbit"
}
diff --git a/tools/testing/selftests/net/forwarding/tc_common.sh b/tools/testing/selftests/net/forwarding/tc_common.sh
index bce8bb8d2b..2e3326edfa 100644
--- a/tools/testing/selftests/net/forwarding/tc_common.sh
+++ b/tools/testing/selftests/net/forwarding/tc_common.sh
@@ -4,7 +4,7 @@
CHECK_TC="yes"
# Can be overridden by the configuration file. See lib.sh
-TC_HIT_TIMEOUT=${TC_HIT_TIMEOUT:=1000} # ms
+: "${TC_HIT_TIMEOUT:=1000}" # ms
tc_check_packets()
{
diff --git a/tools/testing/selftests/net/forwarding/tc_tunnel_key.sh b/tools/testing/selftests/net/forwarding/tc_tunnel_key.sh
index 5a5dd90348..79775b10b9 100755
--- a/tools/testing/selftests/net/forwarding/tc_tunnel_key.sh
+++ b/tools/testing/selftests/net/forwarding/tc_tunnel_key.sh
@@ -1,7 +1,5 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
-# Kselftest framework requirement - SKIP code is 4.
-ksft_skip=4
ALL_TESTS="tunnel_key_nofrag_test"