Skip to content

Commit 86fb617

Browse files
liuhangbinPaolo Abeni
authored andcommitted
selftests: bonding: add ns multicast group testing
Add a test to make sure the backup slaves join correct multicast group when arp_validate enabled and ns_ip6_target is set. Here is the result: TEST: arp_validate (active-backup ns_ip6_target arp_validate 0) [ OK ] TEST: arp_validate (join mcast group) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 1) [ OK ] TEST: arp_validate (join mcast group) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 2) [ OK ] TEST: arp_validate (join mcast group) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 3) [ OK ] TEST: arp_validate (join mcast group) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 4) [ OK ] TEST: arp_validate (join mcast group) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 5) [ OK ] TEST: arp_validate (join mcast group) [ OK ] TEST: arp_validate (active-backup ns_ip6_target arp_validate 6) [ OK ] TEST: arp_validate (join mcast group) [ OK ] Signed-off-by: Hangbin Liu <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 8eb3616 commit 86fb617

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

tools/testing/selftests/drivers/net/bonding/bond_options.sh

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ ALL_TESTS="
1111

1212
lib_dir=$(dirname "$0")
1313
source ${lib_dir}/bond_topo_3d1c.sh
14+
c_maddr="33:33:00:00:00:10"
15+
g_maddr="33:33:00:00:02:54"
1416

1517
skip_prio()
1618
{
@@ -240,6 +242,54 @@ arp_validate_test()
240242
done
241243
}
242244

245+
# Testing correct multicast groups are added to slaves for ns targets
246+
arp_validate_mcast()
247+
{
248+
RET=0
249+
local arp_valid=$(cmd_jq "ip -n ${s_ns} -j -d link show bond0" ".[].linkinfo.info_data.arp_validate")
250+
local active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
251+
252+
for i in $(seq 0 2); do
253+
maddr_list=$(ip -n ${s_ns} maddr show dev eth${i})
254+
255+
# arp_valid == 0 or active_slave should not join any maddrs
256+
if { [ "$arp_valid" == "null" ] || [ "eth${i}" == ${active_slave} ]; } && \
257+
echo "$maddr_list" | grep -qE "${c_maddr}|${g_maddr}"; then
258+
RET=1
259+
check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
260+
# arp_valid != 0 and backup_slave should join both maddrs
261+
elif [ "$arp_valid" != "null" ] && [ "eth${i}" != ${active_slave} ] && \
262+
( ! echo "$maddr_list" | grep -q "${c_maddr}" || \
263+
! echo "$maddr_list" | grep -q "${m_maddr}"); then
264+
RET=1
265+
check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
266+
fi
267+
done
268+
269+
# Do failover
270+
ip -n ${s_ns} link set ${active_slave} down
271+
# wait for active link change
272+
slowwait 2 active_slave_changed $active_slave
273+
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
274+
275+
for i in $(seq 0 2); do
276+
maddr_list=$(ip -n ${s_ns} maddr show dev eth${i})
277+
278+
# arp_valid == 0 or active_slave should not join any maddrs
279+
if { [ "$arp_valid" == "null" ] || [ "eth${i}" == ${active_slave} ]; } && \
280+
echo "$maddr_list" | grep -qE "${c_maddr}|${g_maddr}"; then
281+
RET=1
282+
check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
283+
# arp_valid != 0 and backup_slave should join both maddrs
284+
elif [ "$arp_valid" != "null" ] && [ "eth${i}" != ${active_slave} ] && \
285+
( ! echo "$maddr_list" | grep -q "${c_maddr}" || \
286+
! echo "$maddr_list" | grep -q "${m_maddr}"); then
287+
RET=1
288+
check_err 1 "arp_valid $arp_valid active_slave $active_slave, eth$i has mcast group"
289+
fi
290+
done
291+
}
292+
243293
arp_validate_arp()
244294
{
245295
local mode=$1
@@ -261,8 +311,10 @@ arp_validate_ns()
261311
fi
262312

263313
for val in $(seq 0 6); do
264-
arp_validate_test "mode $mode arp_interval 100 ns_ip6_target ${g_ip6} arp_validate $val"
314+
arp_validate_test "mode $mode arp_interval 100 ns_ip6_target ${g_ip6},${c_ip6} arp_validate $val"
265315
log_test "arp_validate" "$mode ns_ip6_target arp_validate $val"
316+
arp_validate_mcast
317+
log_test "arp_validate" "join mcast group"
266318
done
267319
}
268320

0 commit comments

Comments
 (0)