18c2ecf20Sopenharmony_ci#!/bin/bash
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Test various interface configuration scenarios. Observe that configurations
58c2ecf20Sopenharmony_ci# deemed valid by mlxsw succeed, invalid configurations fail and that no traces
68c2ecf20Sopenharmony_ci# are produced. To prevent the test from passing in case traces are produced,
78c2ecf20Sopenharmony_ci# the user can set the 'kernel.panic_on_warn' and 'kernel.panic_on_oops'
88c2ecf20Sopenharmony_ci# sysctls in its environment.
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cilib_dir=$(dirname $0)/../../../net/forwarding
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciALL_TESTS="
138c2ecf20Sopenharmony_ci	rif_set_addr_test
148c2ecf20Sopenharmony_ci	rif_vrf_set_addr_test
158c2ecf20Sopenharmony_ci	rif_inherit_bridge_addr_test
168c2ecf20Sopenharmony_ci	rif_non_inherit_bridge_addr_test
178c2ecf20Sopenharmony_ci	vlan_interface_deletion_test
188c2ecf20Sopenharmony_ci	bridge_deletion_test
198c2ecf20Sopenharmony_ci	bridge_vlan_flags_test
208c2ecf20Sopenharmony_ci	vlan_1_test
218c2ecf20Sopenharmony_ci	lag_bridge_upper_test
228c2ecf20Sopenharmony_ci	duplicate_vlans_test
238c2ecf20Sopenharmony_ci	vlan_rif_refcount_test
248c2ecf20Sopenharmony_ci	subport_rif_refcount_test
258c2ecf20Sopenharmony_ci	vlan_dev_deletion_test
268c2ecf20Sopenharmony_ci	lag_unlink_slaves_test
278c2ecf20Sopenharmony_ci	lag_dev_deletion_test
288c2ecf20Sopenharmony_ci	vlan_interface_uppers_test
298c2ecf20Sopenharmony_ci	bridge_extern_learn_test
308c2ecf20Sopenharmony_ci	neigh_offload_test
318c2ecf20Sopenharmony_ci	nexthop_offload_test
328c2ecf20Sopenharmony_ci	devlink_reload_test
338c2ecf20Sopenharmony_ci"
348c2ecf20Sopenharmony_ciNUM_NETIFS=2
358c2ecf20Sopenharmony_ci: ${TIMEOUT:=20000} # ms
368c2ecf20Sopenharmony_cisource $lib_dir/lib.sh
378c2ecf20Sopenharmony_cisource $lib_dir/devlink_lib.sh
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cisetup_prepare()
408c2ecf20Sopenharmony_ci{
418c2ecf20Sopenharmony_ci	swp1=${NETIFS[p1]}
428c2ecf20Sopenharmony_ci	swp2=${NETIFS[p2]}
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	ip link set dev $swp1 up
458c2ecf20Sopenharmony_ci	ip link set dev $swp2 up
468c2ecf20Sopenharmony_ci}
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cicleanup()
498c2ecf20Sopenharmony_ci{
508c2ecf20Sopenharmony_ci	pre_cleanup
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	ip link set dev $swp2 down
538c2ecf20Sopenharmony_ci	ip link set dev $swp1 down
548c2ecf20Sopenharmony_ci}
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cirif_set_addr_test()
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	local swp1_mac=$(mac_get $swp1)
598c2ecf20Sopenharmony_ci	local swp2_mac=$(mac_get $swp2)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	RET=0
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	# $swp1 and $swp2 likely got their IPv6 local addresses already, but
648c2ecf20Sopenharmony_ci	# here we need to test the transition to RIF.
658c2ecf20Sopenharmony_ci	ip addr flush dev $swp1
668c2ecf20Sopenharmony_ci	ip addr flush dev $swp2
678c2ecf20Sopenharmony_ci	sleep .1
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	ip addr add dev $swp1 192.0.2.1/28
708c2ecf20Sopenharmony_ci	check_err $?
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	ip link set dev $swp1 addr 00:11:22:33:44:55
738c2ecf20Sopenharmony_ci	check_err $?
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	# IP address enablement should be rejected if the MAC address prefix
768c2ecf20Sopenharmony_ci	# doesn't match other RIFs.
778c2ecf20Sopenharmony_ci	ip addr add dev $swp2 192.0.2.2/28 &>/dev/null
788c2ecf20Sopenharmony_ci	check_fail $? "IP address addition passed for a device with a wrong MAC"
798c2ecf20Sopenharmony_ci	ip addr add dev $swp2 192.0.2.2/28 2>&1 >/dev/null \
808c2ecf20Sopenharmony_ci	    | grep -q mlxsw_spectrum
818c2ecf20Sopenharmony_ci	check_err $? "no extack for IP address addition"
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr 00:11:22:33:44:66
848c2ecf20Sopenharmony_ci	check_err $?
858c2ecf20Sopenharmony_ci	ip addr add dev $swp2 192.0.2.2/28 &>/dev/null
868c2ecf20Sopenharmony_ci	check_err $?
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	# Change of MAC address of a RIF should be forbidden if the new MAC
898c2ecf20Sopenharmony_ci	# doesn't share the prefix with other MAC addresses.
908c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr 00:11:22:33:00:66 &>/dev/null
918c2ecf20Sopenharmony_ci	check_fail $? "change of MAC address passed for a wrong MAC"
928c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr 00:11:22:33:00:66 2>&1 >/dev/null \
938c2ecf20Sopenharmony_ci	    | grep -q mlxsw_spectrum
948c2ecf20Sopenharmony_ci	check_err $? "no extack for MAC address change"
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	log_test "RIF - bad MAC change"
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	ip addr del dev $swp2 192.0.2.2/28
998c2ecf20Sopenharmony_ci	ip addr del dev $swp1 192.0.2.1/28
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr $swp2_mac
1028c2ecf20Sopenharmony_ci	ip link set dev $swp1 addr $swp1_mac
1038c2ecf20Sopenharmony_ci}
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_cirif_vrf_set_addr_test()
1068c2ecf20Sopenharmony_ci{
1078c2ecf20Sopenharmony_ci	# Test that it is possible to set an IP address on a VRF upper despite
1088c2ecf20Sopenharmony_ci	# its random MAC address.
1098c2ecf20Sopenharmony_ci	RET=0
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	ip link add name vrf-test type vrf table 10
1128c2ecf20Sopenharmony_ci	ip link set dev $swp1 master vrf-test
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	ip -4 address add 192.0.2.1/24 dev vrf-test
1158c2ecf20Sopenharmony_ci	check_err $? "failed to set IPv4 address on VRF"
1168c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev vrf-test
1178c2ecf20Sopenharmony_ci	check_err $? "failed to set IPv6 address on VRF"
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	log_test "RIF - setting IP address on VRF"
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci	ip link del dev vrf-test
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cirif_inherit_bridge_addr_test()
1258c2ecf20Sopenharmony_ci{
1268c2ecf20Sopenharmony_ci	RET=0
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	# Create first RIF
1298c2ecf20Sopenharmony_ci	ip addr add dev $swp1 192.0.2.1/28
1308c2ecf20Sopenharmony_ci	check_err $?
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	# Create a FID RIF
1338c2ecf20Sopenharmony_ci	ip link add name br1 up type bridge vlan_filtering 0
1348c2ecf20Sopenharmony_ci	ip link set dev $swp2 master br1
1358c2ecf20Sopenharmony_ci	ip addr add dev br1 192.0.2.17/28
1368c2ecf20Sopenharmony_ci	check_err $?
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci	# Prepare a device with a low MAC address
1398c2ecf20Sopenharmony_ci	ip link add name d up type dummy
1408c2ecf20Sopenharmony_ci	ip link set dev d addr 00:11:22:33:44:55
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	# Attach the device to br1. That prompts bridge address change, which
1438c2ecf20Sopenharmony_ci	# should be vetoed, thus preventing the attachment.
1448c2ecf20Sopenharmony_ci	ip link set dev d master br1 &>/dev/null
1458c2ecf20Sopenharmony_ci	check_fail $? "Device with low MAC was permitted to attach a bridge with RIF"
1468c2ecf20Sopenharmony_ci	ip link set dev d master br1 2>&1 >/dev/null \
1478c2ecf20Sopenharmony_ci	    | grep -q mlxsw_spectrum
1488c2ecf20Sopenharmony_ci	check_err $? "no extack for bridge attach rejection"
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr 00:11:22:33:44:55 &>/dev/null
1518c2ecf20Sopenharmony_ci	check_fail $? "Changing swp2's MAC address permitted"
1528c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr 00:11:22:33:44:55 2>&1 >/dev/null \
1538c2ecf20Sopenharmony_ci	    | grep -q mlxsw_spectrum
1548c2ecf20Sopenharmony_ci	check_err $? "no extack for bridge port MAC address change rejection"
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	log_test "RIF - attach port with bad MAC to bridge"
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	ip link del dev d
1598c2ecf20Sopenharmony_ci	ip link del dev br1
1608c2ecf20Sopenharmony_ci	ip addr del dev $swp1 192.0.2.1/28
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_cirif_non_inherit_bridge_addr_test()
1648c2ecf20Sopenharmony_ci{
1658c2ecf20Sopenharmony_ci	local swp2_mac=$(mac_get $swp2)
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	RET=0
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	# Create first RIF
1708c2ecf20Sopenharmony_ci	ip addr add dev $swp1 192.0.2.1/28
1718c2ecf20Sopenharmony_ci	check_err $?
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	# Create a FID RIF
1748c2ecf20Sopenharmony_ci	ip link add name br1 up type bridge vlan_filtering 0
1758c2ecf20Sopenharmony_ci	ip link set dev br1 addr $swp2_mac
1768c2ecf20Sopenharmony_ci	ip link set dev $swp2 master br1
1778c2ecf20Sopenharmony_ci	ip addr add dev br1 192.0.2.17/28
1788c2ecf20Sopenharmony_ci	check_err $?
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	# Prepare a device with a low MAC address
1818c2ecf20Sopenharmony_ci	ip link add name d up type dummy
1828c2ecf20Sopenharmony_ci	ip link set dev d addr 00:11:22:33:44:55
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	# Attach the device to br1. Since the bridge address was set, it should
1858c2ecf20Sopenharmony_ci	# work.
1868c2ecf20Sopenharmony_ci	ip link set dev d master br1 &>/dev/null
1878c2ecf20Sopenharmony_ci	check_err $? "Could not attach a device with low MAC to a bridge with RIF"
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci	# Port MAC address change should be allowed for a bridge with set MAC.
1908c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr 00:11:22:33:44:55
1918c2ecf20Sopenharmony_ci	check_err $? "Changing swp2's MAC address not permitted"
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	log_test "RIF - attach port with bad MAC to bridge with set MAC"
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	ip link set dev $swp2 addr $swp2_mac
1968c2ecf20Sopenharmony_ci	ip link del dev d
1978c2ecf20Sopenharmony_ci	ip link del dev br1
1988c2ecf20Sopenharmony_ci	ip addr del dev $swp1 192.0.2.1/28
1998c2ecf20Sopenharmony_ci}
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_civlan_interface_deletion_test()
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	# Test that when a VLAN interface is deleted, its associated router
2048c2ecf20Sopenharmony_ci	# interface (RIF) is correctly deleted and not leaked. See commit
2058c2ecf20Sopenharmony_ci	# c360867ec46a ("mlxsw: spectrum: Delete RIF when VLAN device is
2068c2ecf20Sopenharmony_ci	# removed") for more details
2078c2ecf20Sopenharmony_ci	RET=0
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
2108c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci	ip link add link br0 name br0.10 type vlan id 10
2138c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev br0.10
2148c2ecf20Sopenharmony_ci	ip link del dev br0.10
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci	# If we leaked the previous RIF, then this should produce a trace
2178c2ecf20Sopenharmony_ci	ip link add link br0 name br0.20 type vlan id 20
2188c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev br0.20
2198c2ecf20Sopenharmony_ci	ip link del dev br0.20
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	log_test "vlan interface deletion"
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci	ip link del dev br0
2248c2ecf20Sopenharmony_ci}
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_cibridge_deletion_test()
2278c2ecf20Sopenharmony_ci{
2288c2ecf20Sopenharmony_ci	# Test that when a bridge with VLAN interfaces is deleted, we correctly
2298c2ecf20Sopenharmony_ci	# delete the associated RIFs. See commit 602b74eda813 ("mlxsw:
2308c2ecf20Sopenharmony_ci	# spectrum_switchdev: Do not leak RIFs when removing bridge") for more
2318c2ecf20Sopenharmony_ci	# details
2328c2ecf20Sopenharmony_ci	RET=0
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
2358c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
2368c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8::1/64 dev br0
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci	ip link add link br0 name br0.10 type vlan id 10
2398c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev br0.10
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	ip link add link br0 name br0.20 type vlan id 20
2428c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:2::1/64 dev br0.20
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	ip link del dev br0
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	# If we leaked previous RIFs, then this should produce a trace
2478c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev $swp1
2488c2ecf20Sopenharmony_ci	ip -6 address del 2001:db8:1::1/64 dev $swp1
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	log_test "bridge deletion"
2518c2ecf20Sopenharmony_ci}
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_cibridge_vlan_flags_test()
2548c2ecf20Sopenharmony_ci{
2558c2ecf20Sopenharmony_ci	# Test that when bridge VLAN flags are toggled, we do not take
2568c2ecf20Sopenharmony_ci	# unnecessary references on related structs. See commit 9e25826ffc94
2578c2ecf20Sopenharmony_ci	# ("mlxsw: spectrum_switchdev: Fix port_vlan refcounting") for more
2588c2ecf20Sopenharmony_ci	# details
2598c2ecf20Sopenharmony_ci	RET=0
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
2628c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1 pvid untagged
2658c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1 untagged
2668c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1 pvid
2678c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1
2688c2ecf20Sopenharmony_ci	ip link del dev br0
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	# If we did not handle references correctly, then this should produce a
2718c2ecf20Sopenharmony_ci	# trace
2728c2ecf20Sopenharmony_ci	devlink dev reload "$DEVLINK_DEV"
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	# Allow netdevices to be re-created following the reload
2758c2ecf20Sopenharmony_ci	sleep 20
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	log_test "bridge vlan flags"
2788c2ecf20Sopenharmony_ci}
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_civlan_1_test()
2818c2ecf20Sopenharmony_ci{
2828c2ecf20Sopenharmony_ci	# Test that VLAN 1 can be configured over mlxsw ports. In the past it
2838c2ecf20Sopenharmony_ci	# was used internally for untagged traffic. See commit 47bf9df2e820
2848c2ecf20Sopenharmony_ci	# ("mlxsw: spectrum: Forbid creation of VLAN 1 over port/LAG") for more
2858c2ecf20Sopenharmony_ci	# details
2868c2ecf20Sopenharmony_ci	RET=0
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.1 type vlan id 1
2898c2ecf20Sopenharmony_ci	check_err $? "did not manage to create vlan 1 when should"
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci	log_test "vlan 1"
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	ip link del dev $swp1.1
2948c2ecf20Sopenharmony_ci}
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_cilag_bridge_upper_test()
2978c2ecf20Sopenharmony_ci{
2988c2ecf20Sopenharmony_ci	# Test that ports cannot be enslaved to LAG devices that have uppers
2998c2ecf20Sopenharmony_ci	# and that failure is handled gracefully. See commit b3529af6bb0d
3008c2ecf20Sopenharmony_ci	# ("spectrum: Reference count VLAN entries") for more details
3018c2ecf20Sopenharmony_ci	RET=0
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	ip link add name bond1 type bond mode 802.3ad
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
3068c2ecf20Sopenharmony_ci	ip link set dev bond1 master br0
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci	ip link set dev $swp1 down
3098c2ecf20Sopenharmony_ci	ip link set dev $swp1 master bond1 &> /dev/null
3108c2ecf20Sopenharmony_ci	check_fail $? "managed to enslave port to lag when should not"
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	# This might generate a trace, if we did not handle the failure
3138c2ecf20Sopenharmony_ci	# correctly
3148c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev $swp1
3158c2ecf20Sopenharmony_ci	ip -6 address del 2001:db8:1::1/64 dev $swp1
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	log_test "lag with bridge upper"
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	ip link del dev br0
3208c2ecf20Sopenharmony_ci	ip link del dev bond1
3218c2ecf20Sopenharmony_ci}
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ciduplicate_vlans_test()
3248c2ecf20Sopenharmony_ci{
3258c2ecf20Sopenharmony_ci	# Test that on a given port a VLAN is only used once. Either as VLAN
3268c2ecf20Sopenharmony_ci	# in a VLAN-aware bridge or as a VLAN device
3278c2ecf20Sopenharmony_ci	RET=0
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
3308c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
3318c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.10 type vlan id 10 &> /dev/null
3348c2ecf20Sopenharmony_ci	check_fail $? "managed to create vlan device when should not"
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci	bridge vlan del vid 10 dev $swp1
3378c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.10 type vlan id 10
3388c2ecf20Sopenharmony_ci	check_err $? "did not manage to create vlan device when should"
3398c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1 &> /dev/null
3408c2ecf20Sopenharmony_ci	check_fail $? "managed to add bridge vlan when should not"
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci	log_test "duplicate vlans"
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	ip link del dev $swp1.10
3458c2ecf20Sopenharmony_ci	ip link del dev br0
3468c2ecf20Sopenharmony_ci}
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_civlan_rif_refcount_test()
3498c2ecf20Sopenharmony_ci{
3508c2ecf20Sopenharmony_ci	# Test that RIFs representing VLAN interfaces are not affected from
3518c2ecf20Sopenharmony_ci	# ports member in the VLAN. We use the offload indication on routes
3528c2ecf20Sopenharmony_ci	# configured on the RIF to understand if it was created / destroyed
3538c2ecf20Sopenharmony_ci	RET=0
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
3568c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci	ip link set dev $swp1 up
3598c2ecf20Sopenharmony_ci	ip link set dev br0 up
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	ip link add link br0 name br0.10 up type vlan id 10
3628c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev br0.10
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
3658c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev br0.10
3668c2ecf20Sopenharmony_ci	check_err $? "vlan rif was not created before adding port to vlan"
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci	bridge vlan add vid 10 dev $swp1
3698c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
3708c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev br0.10
3718c2ecf20Sopenharmony_ci	check_err $? "vlan rif was destroyed after adding port to vlan"
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	bridge vlan del vid 10 dev $swp1
3748c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
3758c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev br0.10
3768c2ecf20Sopenharmony_ci	check_err $? "vlan rif was destroyed after removing port from vlan"
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_ci	ip link set dev $swp1 nomaster
3798c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" not wait_for_offload \
3808c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev br0.10
3818c2ecf20Sopenharmony_ci	check_err $? "vlan rif was not destroyed after unlinking port from bridge"
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	log_test "vlan rif refcount"
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci	ip link del dev br0.10
3868c2ecf20Sopenharmony_ci	ip link set dev $swp1 down
3878c2ecf20Sopenharmony_ci	ip link del dev br0
3888c2ecf20Sopenharmony_ci}
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_cisubport_rif_refcount_test()
3918c2ecf20Sopenharmony_ci{
3928c2ecf20Sopenharmony_ci	# Test that RIFs representing upper devices of physical ports are
3938c2ecf20Sopenharmony_ci	# reference counted correctly and destroyed when should. We use the
3948c2ecf20Sopenharmony_ci	# offload indication on routes configured on the RIF to understand if
3958c2ecf20Sopenharmony_ci	# it was created / destroyed
3968c2ecf20Sopenharmony_ci	RET=0
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci	ip link add name bond1 type bond mode 802.3ad
3998c2ecf20Sopenharmony_ci	ip link set dev $swp1 down
4008c2ecf20Sopenharmony_ci	ip link set dev $swp2 down
4018c2ecf20Sopenharmony_ci	ip link set dev $swp1 master bond1
4028c2ecf20Sopenharmony_ci	ip link set dev $swp2 master bond1
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci	ip link set dev bond1 up
4058c2ecf20Sopenharmony_ci	ip link add link bond1 name bond1.10 up type vlan id 10
4068c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev bond1
4078c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:2::1/64 dev bond1.10
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
4108c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev bond1
4118c2ecf20Sopenharmony_ci	check_err $? "subport rif was not created on lag device"
4128c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
4138c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:2::2 dev bond1.10
4148c2ecf20Sopenharmony_ci	check_err $? "subport rif was not created on vlan device"
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	ip link set dev $swp1 nomaster
4178c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
4188c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev bond1
4198c2ecf20Sopenharmony_ci	check_err $? "subport rif of lag device was destroyed when should not"
4208c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
4218c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:2::2 dev bond1.10
4228c2ecf20Sopenharmony_ci	check_err $? "subport rif of vlan device was destroyed when should not"
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	ip link set dev $swp2 nomaster
4258c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" not wait_for_offload \
4268c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:1::2 dev bond1
4278c2ecf20Sopenharmony_ci	check_err $? "subport rif of lag device was not destroyed when should"
4288c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" not wait_for_offload \
4298c2ecf20Sopenharmony_ci		ip -6 route get fibmatch 2001:db8:2::2 dev bond1.10
4308c2ecf20Sopenharmony_ci	check_err $? "subport rif of vlan device was not destroyed when should"
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	log_test "subport rif refcount"
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci	ip link del dev bond1.10
4358c2ecf20Sopenharmony_ci	ip link del dev bond1
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_civlan_dev_deletion_test()
4398c2ecf20Sopenharmony_ci{
4408c2ecf20Sopenharmony_ci	# Test that VLAN devices are correctly deleted / unlinked when enslaved
4418c2ecf20Sopenharmony_ci	# to bridge
4428c2ecf20Sopenharmony_ci	RET=0
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci	ip link add name br10 type bridge
4458c2ecf20Sopenharmony_ci	ip link add name br20 type bridge
4468c2ecf20Sopenharmony_ci	ip link add name br30 type bridge
4478c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.10 type vlan id 10
4488c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.20 type vlan id 20
4498c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.30 type vlan id 30
4508c2ecf20Sopenharmony_ci	ip link set dev $swp1.10 master br10
4518c2ecf20Sopenharmony_ci	ip link set dev $swp1.20 master br20
4528c2ecf20Sopenharmony_ci	ip link set dev $swp1.30 master br30
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci	# If we did not handle the situation correctly, then these operations
4558c2ecf20Sopenharmony_ci	# might produce a trace
4568c2ecf20Sopenharmony_ci	ip link set dev $swp1.30 nomaster
4578c2ecf20Sopenharmony_ci	ip link del dev $swp1.20
4588c2ecf20Sopenharmony_ci	# Deletion via ioctl uses different code paths from netlink
4598c2ecf20Sopenharmony_ci	vconfig rem $swp1.10 &> /dev/null
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	log_test "vlan device deletion"
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci	ip link del dev $swp1.30
4648c2ecf20Sopenharmony_ci	ip link del dev br30
4658c2ecf20Sopenharmony_ci	ip link del dev br20
4668c2ecf20Sopenharmony_ci	ip link del dev br10
4678c2ecf20Sopenharmony_ci}
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_cilag_create()
4708c2ecf20Sopenharmony_ci{
4718c2ecf20Sopenharmony_ci	ip link add name bond1 type bond mode 802.3ad
4728c2ecf20Sopenharmony_ci	ip link set dev $swp1 down
4738c2ecf20Sopenharmony_ci	ip link set dev $swp2 down
4748c2ecf20Sopenharmony_ci	ip link set dev $swp1 master bond1
4758c2ecf20Sopenharmony_ci	ip link set dev $swp2 master bond1
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci	ip link add link bond1 name bond1.10 type vlan id 10
4788c2ecf20Sopenharmony_ci	ip link add link bond1 name bond1.20 type vlan id 20
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
4818c2ecf20Sopenharmony_ci	ip link set dev bond1 master br0
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci	ip link add name br10 type bridge
4848c2ecf20Sopenharmony_ci	ip link set dev bond1.10 master br10
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci	ip link add name br20 type bridge
4878c2ecf20Sopenharmony_ci	ip link set dev bond1.20 master br20
4888c2ecf20Sopenharmony_ci}
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_cilag_unlink_slaves_test()
4918c2ecf20Sopenharmony_ci{
4928c2ecf20Sopenharmony_ci	# Test that ports are correctly unlinked from their LAG master, when
4938c2ecf20Sopenharmony_ci	# the LAG and its VLAN uppers are enslaved to bridges
4948c2ecf20Sopenharmony_ci	RET=0
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci	lag_create
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_ci	ip link set dev $swp1 nomaster
4998c2ecf20Sopenharmony_ci	check_err $? "lag slave $swp1 was not unlinked from master"
5008c2ecf20Sopenharmony_ci	ip link set dev $swp2 nomaster
5018c2ecf20Sopenharmony_ci	check_err $? "lag slave $swp2 was not unlinked from master"
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci	# Try to configure corresponding VLANs as router interfaces
5048c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev $swp1
5058c2ecf20Sopenharmony_ci	check_err $? "failed to configure ip address on $swp1"
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.10 type vlan id 10
5088c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:10::1/64 dev $swp1.10
5098c2ecf20Sopenharmony_ci	check_err $? "failed to configure ip address on $swp1.10"
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci	ip link add link $swp1 name $swp1.20 type vlan id 20
5128c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:20::1/64 dev $swp1.20
5138c2ecf20Sopenharmony_ci	check_err $? "failed to configure ip address on $swp1.20"
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	log_test "lag slaves unlinking"
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	ip link del dev $swp1.20
5188c2ecf20Sopenharmony_ci	ip link del dev $swp1.10
5198c2ecf20Sopenharmony_ci	ip address flush dev $swp1
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci	ip link del dev br20
5228c2ecf20Sopenharmony_ci	ip link del dev br10
5238c2ecf20Sopenharmony_ci	ip link del dev br0
5248c2ecf20Sopenharmony_ci	ip link del dev bond1
5258c2ecf20Sopenharmony_ci}
5268c2ecf20Sopenharmony_ci
5278c2ecf20Sopenharmony_cilag_dev_deletion_test()
5288c2ecf20Sopenharmony_ci{
5298c2ecf20Sopenharmony_ci	# Test that LAG device is correctly deleted, when the LAG and its VLAN
5308c2ecf20Sopenharmony_ci	# uppers are enslaved to bridges
5318c2ecf20Sopenharmony_ci	RET=0
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci	lag_create
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci	ip link del dev bond1
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci	log_test "lag device deletion"
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	ip link del dev br20
5408c2ecf20Sopenharmony_ci	ip link del dev br10
5418c2ecf20Sopenharmony_ci	ip link del dev br0
5428c2ecf20Sopenharmony_ci}
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_civlan_interface_uppers_test()
5458c2ecf20Sopenharmony_ci{
5468c2ecf20Sopenharmony_ci	# Test that uppers of a VLAN interface are correctly sanitized
5478c2ecf20Sopenharmony_ci	RET=0
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci	ip link add name br0 type bridge vlan_filtering 1
5508c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_ci	ip link add link br0 name br0.10 type vlan id 10
5538c2ecf20Sopenharmony_ci	ip link add link br0.10 name macvlan0 \
5548c2ecf20Sopenharmony_ci		type macvlan mode private &> /dev/null
5558c2ecf20Sopenharmony_ci	check_fail $? "managed to create a macvlan when should not"
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev br0.10
5588c2ecf20Sopenharmony_ci	ip link add link br0.10 name macvlan0 type macvlan mode private
5598c2ecf20Sopenharmony_ci	check_err $? "did not manage to create a macvlan when should"
5608c2ecf20Sopenharmony_ci
5618c2ecf20Sopenharmony_ci	ip link del dev macvlan0
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	ip link add name vrf-test type vrf table 10
5648c2ecf20Sopenharmony_ci	ip link set dev br0.10 master vrf-test
5658c2ecf20Sopenharmony_ci	check_err $? "did not manage to enslave vlan interface to vrf"
5668c2ecf20Sopenharmony_ci	ip link del dev vrf-test
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	ip link add name br-test type bridge
5698c2ecf20Sopenharmony_ci	ip link set dev br0.10 master br-test &> /dev/null
5708c2ecf20Sopenharmony_ci	check_fail $? "managed to enslave vlan interface to bridge when should not"
5718c2ecf20Sopenharmony_ci	ip link del dev br-test
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ci	log_test "vlan interface uppers"
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci	ip link del dev br0
5768c2ecf20Sopenharmony_ci}
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_cibridge_extern_learn_test()
5798c2ecf20Sopenharmony_ci{
5808c2ecf20Sopenharmony_ci	# Test that externally learned entries added from user space are
5818c2ecf20Sopenharmony_ci	# marked as offloaded
5828c2ecf20Sopenharmony_ci	RET=0
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci	ip link add name br0 type bridge
5858c2ecf20Sopenharmony_ci	ip link set dev $swp1 master br0
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci	bridge fdb add de:ad:be:ef:13:37 dev $swp1 master extern_learn
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
5908c2ecf20Sopenharmony_ci		bridge fdb show brport $swp1 de:ad:be:ef:13:37
5918c2ecf20Sopenharmony_ci	check_err $? "fdb entry not marked as offloaded when should"
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci	log_test "externally learned fdb entry"
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ci	ip link del dev br0
5968c2ecf20Sopenharmony_ci}
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_cineigh_offload_test()
5998c2ecf20Sopenharmony_ci{
6008c2ecf20Sopenharmony_ci	# Test that IPv4 and IPv6 neighbour entries are marked as offloaded
6018c2ecf20Sopenharmony_ci	RET=0
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci	ip -4 address add 192.0.2.1/24 dev $swp1
6048c2ecf20Sopenharmony_ci	ip -6 address add 2001:db8:1::1/64 dev $swp1
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_ci	ip -4 neigh add 192.0.2.2 lladdr de:ad:be:ef:13:37 nud perm dev $swp1
6078c2ecf20Sopenharmony_ci	ip -6 neigh add 2001:db8:1::2 lladdr de:ad:be:ef:13:37 nud perm \
6088c2ecf20Sopenharmony_ci		dev $swp1
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
6118c2ecf20Sopenharmony_ci		ip -4 neigh show dev $swp1 192.0.2.2
6128c2ecf20Sopenharmony_ci	check_err $? "ipv4 neigh entry not marked as offloaded when should"
6138c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
6148c2ecf20Sopenharmony_ci		ip -6 neigh show dev $swp1 2001:db8:1::2
6158c2ecf20Sopenharmony_ci	check_err $? "ipv6 neigh entry not marked as offloaded when should"
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci	log_test "neighbour offload indication"
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci	ip -6 neigh del 2001:db8:1::2 dev $swp1
6208c2ecf20Sopenharmony_ci	ip -4 neigh del 192.0.2.2 dev $swp1
6218c2ecf20Sopenharmony_ci	ip -6 address del 2001:db8:1::1/64 dev $swp1
6228c2ecf20Sopenharmony_ci	ip -4 address del 192.0.2.1/24 dev $swp1
6238c2ecf20Sopenharmony_ci}
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_cinexthop_offload_test()
6268c2ecf20Sopenharmony_ci{
6278c2ecf20Sopenharmony_ci	# Test that IPv4 and IPv6 nexthops are marked as offloaded
6288c2ecf20Sopenharmony_ci	RET=0
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	sysctl_set net.ipv6.conf.$swp2.keep_addr_on_down 1
6318c2ecf20Sopenharmony_ci	simple_if_init $swp1 192.0.2.1/24 2001:db8:1::1/64
6328c2ecf20Sopenharmony_ci	simple_if_init $swp2 192.0.2.2/24 2001:db8:1::2/64
6338c2ecf20Sopenharmony_ci	setup_wait
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci	ip -4 route add 198.51.100.0/24 vrf v$swp1 \
6368c2ecf20Sopenharmony_ci		nexthop via 192.0.2.2 dev $swp1
6378c2ecf20Sopenharmony_ci	ip -6 route add 2001:db8:2::/64 vrf v$swp1 \
6388c2ecf20Sopenharmony_ci		nexthop via 2001:db8:1::2 dev $swp1
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
6418c2ecf20Sopenharmony_ci		ip -4 route show 198.51.100.0/24 vrf v$swp1
6428c2ecf20Sopenharmony_ci	check_err $? "ipv4 nexthop not marked as offloaded when should"
6438c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
6448c2ecf20Sopenharmony_ci		ip -6 route show 2001:db8:2::/64 vrf v$swp1
6458c2ecf20Sopenharmony_ci	check_err $? "ipv6 nexthop not marked as offloaded when should"
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci	ip link set dev $swp2 down
6488c2ecf20Sopenharmony_ci	sleep 1
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" not wait_for_offload \
6518c2ecf20Sopenharmony_ci		ip -4 route show 198.51.100.0/24 vrf v$swp1
6528c2ecf20Sopenharmony_ci	check_err $? "ipv4 nexthop marked as offloaded when should not"
6538c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" not wait_for_offload \
6548c2ecf20Sopenharmony_ci		ip -6 route show 2001:db8:2::/64 vrf v$swp1
6558c2ecf20Sopenharmony_ci	check_err $? "ipv6 nexthop marked as offloaded when should not"
6568c2ecf20Sopenharmony_ci
6578c2ecf20Sopenharmony_ci	ip link set dev $swp2 up
6588c2ecf20Sopenharmony_ci	setup_wait
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
6618c2ecf20Sopenharmony_ci		ip -4 route show 198.51.100.0/24 vrf v$swp1
6628c2ecf20Sopenharmony_ci	check_err $? "ipv4 nexthop not marked as offloaded after neigh add"
6638c2ecf20Sopenharmony_ci	busywait "$TIMEOUT" wait_for_offload \
6648c2ecf20Sopenharmony_ci		ip -6 route show 2001:db8:2::/64 vrf v$swp1
6658c2ecf20Sopenharmony_ci	check_err $? "ipv6 nexthop not marked as offloaded after neigh add"
6668c2ecf20Sopenharmony_ci
6678c2ecf20Sopenharmony_ci	log_test "nexthop offload indication"
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	ip -6 route del 2001:db8:2::/64 vrf v$swp1
6708c2ecf20Sopenharmony_ci	ip -4 route del 198.51.100.0/24 vrf v$swp1
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci	simple_if_fini $swp2 192.0.2.2/24 2001:db8:1::2/64
6738c2ecf20Sopenharmony_ci	simple_if_fini $swp1 192.0.2.1/24 2001:db8:1::1/64
6748c2ecf20Sopenharmony_ci	sysctl_restore net.ipv6.conf.$swp2.keep_addr_on_down
6758c2ecf20Sopenharmony_ci}
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_cidevlink_reload_test()
6788c2ecf20Sopenharmony_ci{
6798c2ecf20Sopenharmony_ci	# Test that after executing all the above configuration tests, a
6808c2ecf20Sopenharmony_ci	# devlink reload can be performed without errors
6818c2ecf20Sopenharmony_ci	RET=0
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci	devlink dev reload "$DEVLINK_DEV"
6848c2ecf20Sopenharmony_ci	check_err $? "devlink reload failed"
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ci	log_test "devlink reload - last test"
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_ci	sleep 20
6898c2ecf20Sopenharmony_ci}
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_citrap cleanup EXIT
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_cisetup_prepare
6948c2ecf20Sopenharmony_cisetup_wait
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_citests_run
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ciexit $EXIT_STATUS
699