Skip to content

Commit

Permalink
selftests: forwarding: generalize bail_on_lldpad from mlxsw
Browse files Browse the repository at this point in the history
mlxsw selftests often invoke a bail_on_lldpad() helper to make sure LLDPAD
is not running, to prevent conflicts between the QoS configuration applied
through TC or DCB command line tool, and the DCB configuration that LLDPAD
might apply. This helper might be useful to others. Move the function to
lib.sh, and parameterize to make reusable in other contexts.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Petr Machata authored and Jakub Kicinski committed Apr 21, 2023
1 parent 54e906f commit 8fcac79
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 46 deletions.
3 changes: 1 addition & 2 deletions tools/testing/selftests/drivers/net/mlxsw/qos_headroom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding
NUM_NETIFS=0
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
source qos_lib.sh

swp=$NETIF_NO_CABLE

Expand Down Expand Up @@ -371,7 +370,7 @@ test_tc_int_buf()
tc qdisc delete dev $swp root
}

bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"

trap cleanup EXIT
setup_wait
Expand Down
28 changes: 0 additions & 28 deletions tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,3 @@ measure_rate()
echo $ir $er
return $ret
}

bail_on_lldpad()
{
if systemctl is-active --quiet lldpad; then

cat >/dev/stderr <<-EOF
WARNING: lldpad is running
lldpad will likely configure DCB, and this test will
configure Qdiscs. mlxsw does not support both at the
same time, one of them is arbitrarily going to overwrite
the other. That will cause spurious failures (or,
unlikely, passes) of this test.
EOF

if [[ -z $ALLOW_LLDPAD ]]; then
cat >/dev/stderr <<-EOF
If you want to run the test anyway, please set
an environment variable ALLOW_LLDPAD to a
non-empty string.
EOF
exit 1
else
return
fi
fi
}
3 changes: 1 addition & 2 deletions tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding
NUM_NETIFS=6
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
source qos_lib.sh

_1KB=1000
_100KB=$((100 * _1KB))
Expand Down Expand Up @@ -393,7 +392,7 @@ test_qos_pfc()
log_test "PFC"
}

bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"

trap cleanup EXIT
setup_prepare
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
lib_dir=$(dirname $0)/../../../net/forwarding
source $lib_dir/sch_ets_core.sh
source $lib_dir/devlink_lib.sh
source qos_lib.sh

ALL_TESTS="
ping_ipv4
Expand Down Expand Up @@ -78,5 +77,5 @@ collect_stats()
done
}

bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"
ets_run
1 change: 0 additions & 1 deletion tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
source mlxsw_lib.sh
source qos_lib.sh

ipaddr()
{
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ecn_mirror_test()
uninstall_qdisc
}

bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"

trap cleanup EXIT
setup_prepare
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ red_mirror_test()
uninstall_qdisc
}

bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"

trap cleanup EXIT
setup_prepare
Expand Down
4 changes: 1 addition & 3 deletions tools/testing/selftests/drivers/net/mlxsw/sch_tbf_ets.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

source qos_lib.sh

sch_tbf_pre_hook()
{
bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"
}

lib_dir=$(dirname $0)/../../../net/forwarding
Expand Down
4 changes: 1 addition & 3 deletions tools/testing/selftests/drivers/net/mlxsw/sch_tbf_prio.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

source qos_lib.sh

sch_tbf_pre_hook()
{
bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"
}

lib_dir=$(dirname $0)/../../../net/forwarding
Expand Down
4 changes: 1 addition & 3 deletions tools/testing/selftests/drivers/net/mlxsw/sch_tbf_root.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

source qos_lib.sh

sch_tbf_pre_hook()
{
bail_on_lldpad
bail_on_lldpad "configure DCB" "configure Qdiscs"
}

lib_dir=$(dirname $0)/../../../net/forwarding
Expand Down
31 changes: 31 additions & 0 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1887,3 +1887,34 @@ mldv1_done_get()

payload_template_expand_checksum "$hbh$icmpv6" $checksum
}

bail_on_lldpad()
{
local reason1="$1"; shift
local reason2="$1"; shift

if systemctl is-active --quiet lldpad; then

cat >/dev/stderr <<-EOF
WARNING: lldpad is running
lldpad will likely $reason1, and this test will
$reason2. Both are not supported at the same time,
one of them is arbitrarily going to overwrite the
other. That will cause spurious failures (or, unlikely,
passes) of this test.
EOF

if [[ -z $ALLOW_LLDPAD ]]; then
cat >/dev/stderr <<-EOF
If you want to run the test anyway, please set
an environment variable ALLOW_LLDPAD to a
non-empty string.
EOF
exit 1
else
return
fi
fi
}

0 comments on commit 8fcac79

Please sign in to comment.