selftests: bonding: add vlan over bond testing

Add a vlan over bond testing to make sure arp/ns target works.
Also change all the configs to mudules.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://patch.msgid.link/20250916080127.430626-2-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Hangbin Liu 2025-09-16 08:01:27 +00:00 committed by Jakub Kicinski
parent a8ba87f04c
commit dc5f94b1ec
2 changed files with 59 additions and 0 deletions

View File

@ -8,6 +8,7 @@ ALL_TESTS="
arp_validate
num_grat_arp
fail_over_mac
vlan_over_bond
"
lib_dir=$(dirname "$0")
@ -508,7 +509,64 @@ fail_over_mac()
log_test "fail_over_mac 2" "failover: backup slave mac inherit"
check_first_slave_random_mac
log_test "fail_over_mac 2" "first slave mac random"
}
vlan_over_bond_arp()
{
local mode="$1"
RET=0
bond_reset "mode $mode arp_interval 100 arp_ip_target 192.0.3.10"
ip -n "${s_ns}" link add bond0.3 link bond0 type vlan id 3
ip -n "${s_ns}" link set bond0.3 up
ip -n "${s_ns}" addr add 192.0.3.1/24 dev bond0.3
ip -n "${s_ns}" addr add 2001:db8::3:1/64 dev bond0.3
slowwait_for_counter 5 5 tc_rule_handle_stats_get \
"dev eth0.3 ingress" 101 ".packets" "-n ${c_ns}" &> /dev/null || RET=1
log_test "vlan over bond arp" "$mode"
}
vlan_over_bond_ns()
{
local mode="$1"
RET=0
if skip_ns; then
log_test_skip "vlan_over_bond ns" "$mode"
return 0
fi
bond_reset "mode $mode arp_interval 100 ns_ip6_target 2001:db8::3:10"
ip -n "${s_ns}" link add bond0.3 link bond0 type vlan id 3
ip -n "${s_ns}" link set bond0.3 up
ip -n "${s_ns}" addr add 192.0.3.1/24 dev bond0.3
ip -n "${s_ns}" addr add 2001:db8::3:1/64 dev bond0.3
slowwait_for_counter 5 5 tc_rule_handle_stats_get \
"dev eth0.3 ingress" 102 ".packets" "-n ${c_ns}" &> /dev/null || RET=1
log_test "vlan over bond ns" "$mode"
}
vlan_over_bond()
{
# add vlan 3 for client
ip -n "${c_ns}" link add eth0.3 link eth0 type vlan id 3
ip -n "${c_ns}" link set eth0.3 up
ip -n "${c_ns}" addr add 192.0.3.10/24 dev eth0.3
ip -n "${c_ns}" addr add 2001:db8::3:10/64 dev eth0.3
# Add tc rule to check the vlan pkts
tc -n "${c_ns}" qdisc add dev eth0.3 clsact
tc -n "${c_ns}" filter add dev eth0.3 ingress protocol arp \
handle 101 flower skip_hw arp_op request \
arp_sip 192.0.3.1 arp_tip 192.0.3.10 action pass
tc -n "${c_ns}" filter add dev eth0.3 ingress protocol ipv6 \
handle 102 flower skip_hw ip_proto icmpv6 \
type 135 src_ip 2001:db8::3:1 action pass
vlan_over_bond_arp "active-backup"
vlan_over_bond_ns "active-backup"
}
trap cleanup EXIT

View File

@ -10,3 +10,4 @@ CONFIG_NET_CLS_MATCHALL=m
CONFIG_NET_SCH_INGRESS=y
CONFIG_NLMON=y
CONFIG_VETH=y
CONFIG_VLAN_8021Q=m