Skip to content

Commit b9881d9

Browse files
committed
Merge branch 'bonding-ns-validation-fixes'
Hangbin Liu says: ==================== bonding: fix ns validation on backup slaves The first patch fixed a ns validation issue on backup slaves. The second patch re-format the bond option test and add a test lib file. The third patch add the arp validate regression test for the kernel patch. Here is the new bonding option test without the kernel fix: ]# ./bond_options.sh TEST: prio (active-backup miimon primary_reselect 0) [ OK ] TEST: prio (active-backup miimon primary_reselect 1) [ OK ] TEST: prio (active-backup miimon primary_reselect 2) [ OK ] TEST: prio (active-backup arp_ip_target primary_reselect 0) [ OK ] TEST: prio (active-backup arp_ip_target primary_reselect 1) [ OK ] TEST: prio (active-backup arp_ip_target primary_reselect 2) [ OK ] TEST: prio (active-backup ns_ip6_target primary_reselect 0) [ OK ] TEST: prio (active-backup ns_ip6_target primary_reselect 1) [ OK ] TEST: prio (active-backup ns_ip6_target primary_reselect 2) [ OK ] TEST: prio (balance-tlb miimon primary_reselect 0) [ OK ] TEST: prio (balance-tlb miimon primary_reselect 1) [ OK ] TEST: prio (balance-tlb miimon primary_reselect 2) [ OK ] TEST: prio (balance-tlb arp_ip_target primary_reselect 0) [ OK ] TEST: prio (balance-tlb arp_ip_target primary_reselect 1) [ OK ] TEST: prio (balance-tlb arp_ip_target primary_reselect 2) [ OK ] TEST: prio (balance-tlb ns_ip6_target primary_reselect 0) [ OK ] TEST: prio (balance-tlb ns_ip6_target primary_reselect 1) [ OK ] TEST: prio (balance-tlb ns_ip6_target primary_reselect 2) [ OK ] TEST: prio (balance-alb miimon primary_reselect 0) [ OK ] TEST: prio (balance-alb miimon primary_reselect 1) [ OK ] TEST: prio (balance-alb miimon primary_reselect 2) [ OK ] TEST: prio (balance-alb arp_ip_target primary_reselect 0) [ OK ] TEST: prio (balance-alb arp_ip_target primary_reselect 1) [ OK ] TEST: prio (balance-alb arp_ip_target primary_reselect 2) [ OK ] TEST: prio (balance-alb ns_ip6_target primary_reselect 0) [ OK ] TEST: prio (balance-alb ns_ip6_target primary_reselect 1) [ OK ] TEST: prio (balance-alb ns_ip6_target primary_reselect 2) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 0) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 1) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 2) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 3) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 4) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 5) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 6) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 0) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 1) [ OK ] TEST: arp_validate (interface eth1 mii_status DOWN) [FAIL] TEST: arp_validate (interface eth2 mii_status DOWN) [FAIL] TEST: arp_validate (active-backup ns_ip6_target arp_validate 2) [FAIL] TEST: arp_validate (interface eth1 mii_status DOWN) [FAIL] TEST: arp_validate (interface eth2 mii_status DOWN) [FAIL] TEST: arp_validate (active-backup ns_ip6_target arp_validate 3) [FAIL] TEST: arp_validate (active-backup ns_ip6_target arp_validate 4) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 5) [ OK ] TEST: arp_validate (interface eth1 mii_status DOWN) [FAIL] TEST: arp_validate (interface eth2 mii_status DOWN) [FAIL] TEST: arp_validate (active-backup ns_ip6_target arp_validate 6) [FAIL] Here is the test result after the kernel fix: TEST: arp_validate (active-backup arp_ip_target arp_validate 0) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 1) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 2) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 3) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 4) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 5) [ OK ] TEST: arp_validate (active-backup arp_ip_target arp_validate 6) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 0) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 1) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 2) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 3) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 4) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 5) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 6) [ OK ] ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents dc5110c + 2e825f8 commit b9881d9

File tree

6 files changed

+418
-250
lines changed

6 files changed

+418
-250
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,8 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
32693269

32703270
combined = skb_header_pointer(skb, 0, sizeof(_combined), &_combined);
32713271
if (!combined || combined->ip6.nexthdr != NEXTHDR_ICMP ||
3272-
combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)
3272+
(combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_SOLICITATION &&
3273+
combined->icmp6.icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT))
32733274
goto out;
32743275

32753276
saddr = &combined->ip6.saddr;
@@ -3291,7 +3292,7 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
32913292
else if (curr_active_slave &&
32923293
time_after(slave_last_rx(bond, curr_active_slave),
32933294
curr_active_slave->last_link_up))
3294-
bond_validate_na(bond, slave, saddr, daddr);
3295+
bond_validate_na(bond, slave, daddr, saddr);
32953296
else if (curr_arp_slave &&
32963297
bond_time_in_interval(bond, slave_last_tx(curr_arp_slave), 1))
32973298
bond_validate_na(bond, slave, saddr, daddr);

include/net/bonding.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,17 @@ static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)
761761
#if IS_ENABLED(CONFIG_IPV6)
762762
static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip)
763763
{
764+
struct in6_addr mcaddr;
764765
int i;
765766

766-
for (i = 0; i < BOND_MAX_NS_TARGETS; i++)
767-
if (ipv6_addr_equal(&targets[i], ip))
767+
for (i = 0; i < BOND_MAX_NS_TARGETS; i++) {
768+
addrconf_addr_solict_mult(&targets[i], &mcaddr);
769+
if ((ipv6_addr_equal(&targets[i], ip)) ||
770+
(ipv6_addr_equal(&mcaddr, ip)))
768771
return i;
769772
else if (ipv6_addr_any(&targets[i]))
770773
break;
774+
}
771775

772776
return -1;
773777
}

tools/testing/selftests/drivers/net/bonding/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ TEST_PROGS := \
88
dev_addr_lists.sh \
99
mode-1-recovery-updelay.sh \
1010
mode-2-recovery-updelay.sh \
11-
option_prio.sh \
11+
bond_options.sh \
1212
bond-eth-type-change.sh
1313

1414
TEST_FILES := \
1515
lag_lib.sh \
16+
bond_topo_3d1c.sh \
1617
net_forwarding_lib.sh
1718

1819
include ../../../lib.mk
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Test bonding options with mode 1,5,6
5+
6+
ALL_TESTS="
7+
prio
8+
arp_validate
9+
"
10+
11+
REQUIRE_MZ=no
12+
NUM_NETIFS=0
13+
lib_dir=$(dirname "$0")
14+
source ${lib_dir}/net_forwarding_lib.sh
15+
source ${lib_dir}/bond_topo_3d1c.sh
16+
17+
skip_prio()
18+
{
19+
local skip=1
20+
21+
# check if iproute support prio option
22+
ip -n ${s_ns} link set eth0 type bond_slave prio 10
23+
[[ $? -ne 0 ]] && skip=0
24+
25+
# check if kernel support prio option
26+
ip -n ${s_ns} -d link show eth0 | grep -q "prio 10"
27+
[[ $? -ne 0 ]] && skip=0
28+
29+
return $skip
30+
}
31+
32+
skip_ns()
33+
{
34+
local skip=1
35+
36+
# check if iproute support ns_ip6_target option
37+
ip -n ${s_ns} link add bond1 type bond ns_ip6_target ${g_ip6}
38+
[[ $? -ne 0 ]] && skip=0
39+
40+
# check if kernel support ns_ip6_target option
41+
ip -n ${s_ns} -d link show bond1 | grep -q "ns_ip6_target ${g_ip6}"
42+
[[ $? -ne 0 ]] && skip=0
43+
44+
ip -n ${s_ns} link del bond1
45+
46+
return $skip
47+
}
48+
49+
active_slave=""
50+
check_active_slave()
51+
{
52+
local target_active_slave=$1
53+
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
54+
test "$active_slave" = "$target_active_slave"
55+
check_err $? "Current active slave is $active_slave but not $target_active_slave"
56+
}
57+
58+
59+
# Test bonding prio option
60+
prio_test()
61+
{
62+
local param="$1"
63+
RET=0
64+
65+
# create bond
66+
bond_reset "${param}"
67+
68+
# check bonding member prio value
69+
ip -n ${s_ns} link set eth0 type bond_slave prio 0
70+
ip -n ${s_ns} link set eth1 type bond_slave prio 10
71+
ip -n ${s_ns} link set eth2 type bond_slave prio 11
72+
cmd_jq "ip -n ${s_ns} -d -j link show eth0" \
73+
".[].linkinfo.info_slave_data | select (.prio == 0)" "-e" &> /dev/null
74+
check_err $? "eth0 prio is not 0"
75+
cmd_jq "ip -n ${s_ns} -d -j link show eth1" \
76+
".[].linkinfo.info_slave_data | select (.prio == 10)" "-e" &> /dev/null
77+
check_err $? "eth1 prio is not 10"
78+
cmd_jq "ip -n ${s_ns} -d -j link show eth2" \
79+
".[].linkinfo.info_slave_data | select (.prio == 11)" "-e" &> /dev/null
80+
check_err $? "eth2 prio is not 11"
81+
82+
bond_check_connection "setup"
83+
84+
# active slave should be the primary slave
85+
check_active_slave eth1
86+
87+
# active slave should be the higher prio slave
88+
ip -n ${s_ns} link set $active_slave down
89+
bond_check_connection "fail over"
90+
check_active_slave eth2
91+
92+
# when only 1 slave is up
93+
ip -n ${s_ns} link set $active_slave down
94+
bond_check_connection "only 1 slave up"
95+
check_active_slave eth0
96+
97+
# when a higher prio slave change to up
98+
ip -n ${s_ns} link set eth2 up
99+
bond_check_connection "higher prio slave up"
100+
case $primary_reselect in
101+
"0")
102+
check_active_slave "eth2"
103+
;;
104+
"1")
105+
check_active_slave "eth0"
106+
;;
107+
"2")
108+
check_active_slave "eth0"
109+
;;
110+
esac
111+
local pre_active_slave=$active_slave
112+
113+
# when the primary slave change to up
114+
ip -n ${s_ns} link set eth1 up
115+
bond_check_connection "primary slave up"
116+
case $primary_reselect in
117+
"0")
118+
check_active_slave "eth1"
119+
;;
120+
"1")
121+
check_active_slave "$pre_active_slave"
122+
;;
123+
"2")
124+
check_active_slave "$pre_active_slave"
125+
ip -n ${s_ns} link set $active_slave down
126+
bond_check_connection "pre_active slave down"
127+
check_active_slave "eth1"
128+
;;
129+
esac
130+
131+
# Test changing bond slave prio
132+
if [[ "$primary_reselect" == "0" ]];then
133+
ip -n ${s_ns} link set eth0 type bond_slave prio 1000000
134+
ip -n ${s_ns} link set eth1 type bond_slave prio 0
135+
ip -n ${s_ns} link set eth2 type bond_slave prio -50
136+
ip -n ${s_ns} -d link show eth0 | grep -q 'prio 1000000'
137+
check_err $? "eth0 prio is not 1000000"
138+
ip -n ${s_ns} -d link show eth1 | grep -q 'prio 0'
139+
check_err $? "eth1 prio is not 0"
140+
ip -n ${s_ns} -d link show eth2 | grep -q 'prio -50'
141+
check_err $? "eth3 prio is not -50"
142+
check_active_slave "eth1"
143+
144+
ip -n ${s_ns} link set $active_slave down
145+
bond_check_connection "change slave prio"
146+
check_active_slave "eth0"
147+
fi
148+
}
149+
150+
prio_miimon()
151+
{
152+
local primary_reselect
153+
local mode=$1
154+
155+
for primary_reselect in 0 1 2; do
156+
prio_test "mode $mode miimon 100 primary eth1 primary_reselect $primary_reselect"
157+
log_test "prio" "$mode miimon primary_reselect $primary_reselect"
158+
done
159+
}
160+
161+
prio_arp()
162+
{
163+
local primary_reselect
164+
local mode=$1
165+
166+
for primary_reselect in 0 1 2; do
167+
prio_test "mode active-backup arp_interval 100 arp_ip_target ${g_ip4} primary eth1 primary_reselect $primary_reselect"
168+
log_test "prio" "$mode arp_ip_target primary_reselect $primary_reselect"
169+
done
170+
}
171+
172+
prio_ns()
173+
{
174+
local primary_reselect
175+
local mode=$1
176+
177+
if skip_ns; then
178+
log_test_skip "prio ns" "Current iproute or kernel doesn't support bond option 'ns_ip6_target'."
179+
return 0
180+
fi
181+
182+
for primary_reselect in 0 1 2; do
183+
prio_test "mode active-backup arp_interval 100 ns_ip6_target ${g_ip6} primary eth1 primary_reselect $primary_reselect"
184+
log_test "prio" "$mode ns_ip6_target primary_reselect $primary_reselect"
185+
done
186+
}
187+
188+
prio()
189+
{
190+
local mode modes="active-backup balance-tlb balance-alb"
191+
192+
if skip_prio; then
193+
log_test_skip "prio" "Current iproute or kernel doesn't support bond option 'prio'."
194+
return 0
195+
fi
196+
197+
for mode in $modes; do
198+
prio_miimon $mode
199+
prio_arp $mode
200+
prio_ns $mode
201+
done
202+
}
203+
204+
arp_validate_test()
205+
{
206+
local param="$1"
207+
RET=0
208+
209+
# create bond
210+
bond_reset "${param}"
211+
212+
bond_check_connection
213+
[ $RET -ne 0 ] && log_test "arp_validate" "$retmsg"
214+
215+
# wait for a while to make sure the mii status stable
216+
sleep 5
217+
for i in $(seq 0 2); do
218+
mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
219+
if [ ${mii_status} != "UP" ]; then
220+
RET=1
221+
log_test "arp_validate" "interface eth$i mii_status $mii_status"
222+
fi
223+
done
224+
}
225+
226+
arp_validate_arp()
227+
{
228+
local mode=$1
229+
local val
230+
for val in $(seq 0 6); do
231+
arp_validate_test "mode $mode arp_interval 100 arp_ip_target ${g_ip4} arp_validate $val"
232+
log_test "arp_validate" "$mode arp_ip_target arp_validate $val"
233+
done
234+
}
235+
236+
arp_validate_ns()
237+
{
238+
local mode=$1
239+
local val
240+
241+
if skip_ns; then
242+
log_test_skip "arp_validate ns" "Current iproute or kernel doesn't support bond option 'ns_ip6_target'."
243+
return 0
244+
fi
245+
246+
for val in $(seq 0 6); do
247+
arp_validate_test "mode $mode arp_interval 100 ns_ip6_target ${g_ip6} arp_validate $val"
248+
log_test "arp_validate" "$mode ns_ip6_target arp_validate $val"
249+
done
250+
}
251+
252+
arp_validate()
253+
{
254+
arp_validate_arp "active-backup"
255+
arp_validate_ns "active-backup"
256+
}
257+
258+
trap cleanup EXIT
259+
260+
setup_prepare
261+
setup_wait
262+
tests_run
263+
264+
exit $EXIT_STATUS

0 commit comments

Comments
 (0)