OSDN Git Service

selftests: mlxsw: Test RIF's reference count when joining a LAG
authorIdo Schimmel <idosch@nvidia.com>
Sun, 6 Dec 2020 08:22:22 +0000 (10:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Dec 2020 03:22:14 +0000 (19:22 -0800)
Test that the reference count of a router interface (RIF) configured for
a LAG is incremented / decremented when ports join / leave the LAG. Use
the offload indication on routes configured on the RIF to understand if
it was created / destroyed.

The test fails without the previous patch.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh

index a2eff5f..ed346da 100755 (executable)
@@ -22,6 +22,7 @@ ALL_TESTS="
        duplicate_vlans_test
        vlan_rif_refcount_test
        subport_rif_refcount_test
+       subport_rif_lag_join_test
        vlan_dev_deletion_test
        lag_unlink_slaves_test
        lag_dev_deletion_test
@@ -440,6 +441,48 @@ subport_rif_refcount_test()
        ip link del dev bond1
 }
 
+subport_rif_lag_join_test()
+{
+       # Test that the reference count of a RIF configured for a LAG is
+       # incremented / decremented when ports join / leave the LAG. We use the
+       # offload indication on routes configured on the RIF to understand if
+       # it was created / destroyed
+       RET=0
+
+       ip link add name bond1 type bond mode 802.3ad
+       ip link set dev $swp1 down
+       ip link set dev $swp2 down
+       ip link set dev $swp1 master bond1
+       ip link set dev $swp2 master bond1
+
+       ip link set dev bond1 up
+       ip -6 address add 2001:db8:1::1/64 dev bond1
+
+       busywait "$TIMEOUT" wait_for_offload \
+               ip -6 route get fibmatch 2001:db8:1::2 dev bond1
+       check_err $? "subport rif was not created on lag device"
+
+       ip link set dev $swp1 nomaster
+       busywait "$TIMEOUT" wait_for_offload \
+               ip -6 route get fibmatch 2001:db8:1::2 dev bond1
+       check_err $? "subport rif of lag device was destroyed after removing one port"
+
+       ip link set dev $swp1 master bond1
+       ip link set dev $swp2 nomaster
+       busywait "$TIMEOUT" wait_for_offload \
+               ip -6 route get fibmatch 2001:db8:1::2 dev bond1
+       check_err $? "subport rif of lag device was destroyed after re-adding a port and removing another"
+
+       ip link set dev $swp1 nomaster
+       busywait "$TIMEOUT" not wait_for_offload \
+               ip -6 route get fibmatch 2001:db8:1::2 dev bond1
+       check_err $? "subport rif of lag device was not destroyed when should"
+
+       log_test "subport rif lag join"
+
+       ip link del dev bond1
+}
+
 vlan_dev_deletion_test()
 {
        # Test that VLAN devices are correctly deleted / unlinked when enslaved