Skip to content

Commit

Permalink
kselftest: bonding: add num_grat_arp test
Browse files Browse the repository at this point in the history
TEST: num_grat_arp (active-backup miimon num_grat_arp 10)           [ OK ]
TEST: num_grat_arp (active-backup miimon num_grat_arp 20)           [ OK ]
TEST: num_grat_arp (active-backup miimon num_grat_arp 30)           [ OK ]
TEST: num_grat_arp (active-backup miimon num_grat_arp 50)           [ OK ]

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hangbin Liu authored and David S. Miller committed May 10, 2023
1 parent b6d1599 commit 6cbe791
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tools/testing/selftests/drivers/net/bonding/bond_options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ALL_TESTS="
prio
arp_validate
num_grat_arp
"

REQUIRE_MZ=no
Expand Down Expand Up @@ -255,6 +256,55 @@ arp_validate()
arp_validate_ns "active-backup"
}

garp_test()
{
local param="$1"
local active_slave exp_num real_num i
RET=0

# create bond
bond_reset "${param}"

bond_check_connection
[ $RET -ne 0 ] && log_test "num_grat_arp" "$retmsg"


# Add tc rules to count GARP number
for i in $(seq 0 2); do
tc -n ${g_ns} filter add dev s$i ingress protocol arp pref 1 handle 101 \
flower skip_hw arp_op request arp_sip ${s_ip4} arp_tip ${s_ip4} action pass
done

# Do failover
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
ip -n ${s_ns} link set ${active_slave} down

exp_num=$(echo "${param}" | cut -f6 -d ' ')
sleep $((exp_num + 2))

active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")

# check result
real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}")
if [ "${real_num}" -ne "${exp_num}" ]; then
echo "$real_num garp packets sent on active slave ${active_slave}"
RET=1
fi

for i in $(seq 0 2); do
tc -n ${g_ns} filter del dev s$i ingress
done
}

num_grat_arp()
{
local val
for val in 10 20 30 50; do
garp_test "mode active-backup miimon 100 num_grat_arp $val peer_notify_delay 1000"
log_test "num_grat_arp" "active-backup miimon num_grat_arp $val"
done
}

trap cleanup EXIT

setup_prepare
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/drivers/net/bonding/bond_topo_3d1c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ server_create()
ip -n ${g_ns} link set s${i} up
ip -n ${g_ns} link set s${i} master br0
ip -n ${s_ns} link set eth${i} master bond0

tc -n ${g_ns} qdisc add dev s${i} clsact
done

ip -n ${s_ns} link set bond0 up
Expand Down

0 comments on commit 6cbe791

Please sign in to comment.