[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250603035243.402806-4-wilder@us.ibm.com>
Date: Mon, 2 Jun 2025 20:51:49 -0700
From: David J Wilder <wilder@...ibm.com>
To: netdev@...r.kernel.org
Subject: [PATCH net-next v2 3/4] bonding: Selftest for the arp_ip_target parameter.
This selftest provided a functional test for the arp_ip_target parameter
both with and without user supplied vlan tags.
Signed-off-by: David J Wilder <wilder@...ibm.com>
---
.../selftests/drivers/net/bonding/Makefile | 3 +-
.../drivers/net/bonding/bond-arp-ip-target.sh | 194 ++++++++++++++++++
2 files changed, 196 insertions(+), 1 deletion(-)
create mode 100755 tools/testing/selftests/drivers/net/bonding/bond-arp-ip-target.sh
diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile
index 2b10854e4b1e..c59bb2912a38 100644
--- a/tools/testing/selftests/drivers/net/bonding/Makefile
+++ b/tools/testing/selftests/drivers/net/bonding/Makefile
@@ -10,7 +10,8 @@ TEST_PROGS := \
mode-2-recovery-updelay.sh \
bond_options.sh \
bond-eth-type-change.sh \
- bond_macvlan_ipvlan.sh
+ bond_macvlan_ipvlan.sh \
+ bond-arp-ip-target.sh
TEST_FILES := \
lag_lib.sh \
diff --git a/tools/testing/selftests/drivers/net/bonding/bond-arp-ip-target.sh b/tools/testing/selftests/drivers/net/bonding/bond-arp-ip-target.sh
new file mode 100755
index 000000000000..7bd2f3beb1f0
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/bonding/bond-arp-ip-target.sh
@@ -0,0 +1,194 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Test bonding arp_ip_target.
+# Topology for Bond mode 1,5,6 testing
+#
+# +-------------------------+
+# | | Server
+# | bond.10.20.30 | 192.30.2.1/24
+# | | |
+# | bond0.10.20 | 192.20.2.1/24
+# | | |
+# | bond0.10 | 192.10.2.1/24
+# | | |
+# | bond0 | 192.0.2.1/24
+# | | |
+# | + |
+# | eth0 | eth1 |
+# | +---+---+ |
+# | | | |
+# +-------------------------+
+# | |
+# +-------------------------+
+# | | | |
+# | +---+-------+---+ | Gateway
+# | | br0 | |
+# | +-------+-------+ |
+# | | |
+# +-------------------------+
+# |
+# +-------------------------+
+# | | | Client
+# | eth0 | 192.0.0.2/24
+# | | |
+# | eth0.10 | 192.10.10.2/24
+# | | |
+# | eth0.10.20 | 192.20.20.2/24
+# | | |
+# | eth0.10.20.30 | 192.30.30.2/24
+# +-------------------------+
+
+
+lib_dir=$(dirname "$0")
+source ${lib_dir}/bond_topo_2d1c.sh
+
+DEBUG=${DEBUG:-0}
+test ${DEBUG} -ne 0 && set -x
+
+# vlan subnets
+s_ip4v10="192.10.2.1"
+s_ip4v20="192.20.2.1"
+s_ip4v30="192.30.2.1"
+c_ip4v10="192.10.2.10"
+c_ip4v20="192.20.2.10"
+c_ip4v30="192.30.2.10"
+
+ALL_TESTS="
+ no_vlan_hints
+ with_vlan_hints
+"
+
+# load bonding modules and set options.
+load_bonding() {
+ local bond_options="$*"
+
+ lsmod | grep bonding > /dev/null
+ if [ $? == 0 ]; then
+ rmmod bonding
+ fi
+ modprobe bonding ${bond_options}
+}
+
+# Build stacked vlans on top of an interface.
+stack_vlans()
+{
+ RET=0
+ local interface=$1
+ local ns=$2
+ local last=$interface
+ local tags="10 20 30"
+
+ ip -n ${ns} link show ${interface} > /dev/null
+ if [[ $? -ne 0 ]] && RET=1; then
+ msg="Failed to create ${interface}"
+ return
+ fi
+
+ if [ $ns == ${s_ns} ]; then host=1; else host=10;fi
+
+ for tag in $tags; do
+ ip -n ${ns} link add link $last name $last.$tag type vlan id $tag
+ ip -n ${ns} address add 192.$tag.2.$host/24 dev $last.$tag
+ ip -n ${ns} link set up dev $last.$tag
+ last=$last.$tag
+ done
+}
+
+# Check for link flapping
+check_failure_count()
+{
+ RET=0
+ local ns=$1
+ local proc_file=/proc/net/bonding/$2
+ local counts
+
+ # Give the bond time to settle.
+ sleep 10
+
+ counts=$(ip netns exec ${ns} grep -F "Link Failure Count" ${proc_file} | awk -F: '{print $2}')
+
+ local i
+ for i in $counts; do
+ [ $i != 0 ] && RET=1
+ done
+}
+
+setup_bond_topo()
+{
+ load_bonding $*
+ setup_prepare
+ setup_wait
+ stack_vlans bond0 ${s_ns}
+ stack_vlans eth0 ${c_ns}
+}
+
+skip_with_vlan_hints()
+{
+ local skip=1
+
+ # check if iproute support prio option
+ ip -n ${s_ns} link add bond2 type bond arp_ip_target 10.0.0.1[10]
+ [[ $? -ne 0 ]] && skip=0
+ ip -n ${s_ns} link del bond2 2> /dev/null
+
+ return $skip
+}
+
+no_vlan_hints()
+{
+ RET=0
+ local targets="${c_ip4} ${c_ip4v10} ${c_ip4v20}"
+ local target
+ msg=""
+
+ for target in $targets; do
+ bond_reset "mode $mode arp_interval 100 arp_ip_target ${target}"
+
+ stack_vlans bond0 ${s_ns}
+ if [ $RET -ne 0 ]; then
+ log_test "no_vlan_hints" "${msg}"
+ return
+ fi
+
+ check_failure_count ${s_ns} bond0
+ log_test "arp_ip_target=${target} ${msg}"
+ done
+}
+
+with_vlan_hints()
+{
+ RET=0
+ local targets="${c_ip4}[] ${c_ip4v10}[10] ${c_ip4v20}[10/20]"
+ local target
+ msg=""
+
+ if skip_with_vlan_hints; then
+ log_test_skip "skip_with_vlan_hints" \
+ "Current iproute doesn't support extended arp_ip_target options."
+ return 0
+ fi
+
+ for target in $targets; do
+ bond_reset "mode $mode arp_interval 100 arp_ip_target ${target}"
+
+ stack_vlans bond0 ${s_ns}
+ if [ $RET -ne 0 ]; then
+ log_test "no_vlan_hints" "${msg}"
+ return
+ fi
+
+ check_failure_count ${s_ns} bond0
+ log_test "arp_ip_target=${target} ${msg}"
+ done
+}
+
+
+trap cleanup EXIT
+
+mode=active-backup
+
+setup_bond_topo # dyndbg=+p
+tests_run
+
+exit $EXIT_STATUS
--
2.43.5
Powered by blists - more mailing lists