~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/rif_lag.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 lib_dir=$(dirname $0)/../../../net/forwarding
  5 
  6 ALL_TESTS="
  7         lag_rif_add
  8         lag_rif_nomaster
  9         lag_rif_remaster
 10         lag_rif_nomaster_addr
 11 "
 12 
 13 NUM_NETIFS=2
 14 source $lib_dir/lib.sh
 15 source $lib_dir/devlink_lib.sh
 16 
 17 setup_prepare()
 18 {
 19         swp1=${NETIFS[p1]}
 20         swp2=${NETIFS[p2]}
 21 
 22         team_create lag1 lacp
 23         ip link set dev lag1 addrgenmode none
 24         ip link set dev lag1 address $(mac_get $swp1)
 25 
 26         team_create lag2 lacp
 27         ip link set dev lag2 addrgenmode none
 28         ip link set dev lag2 address $(mac_get $swp2)
 29 
 30         ip link set dev $swp1 master lag1
 31         ip link set dev $swp1 up
 32 
 33         ip link set dev $swp2 master lag2
 34         ip link set dev $swp2 up
 35 }
 36 
 37 cleanup()
 38 {
 39         pre_cleanup
 40 
 41         ip link set dev $swp2 nomaster
 42         ip link set dev $swp2 down
 43 
 44         ip link set dev $swp1 nomaster
 45         ip link set dev $swp1 down
 46 
 47         ip link del dev lag2
 48         ip link del dev lag1
 49 }
 50 
 51 lag_rif_add()
 52 {
 53         RET=0
 54 
 55         local rifs_occ_t0=$(devlink_resource_occ_get rifs)
 56         __addr_add_del lag1 add 192.0.2.2/28
 57         sleep 1
 58         local rifs_occ_t1=$(devlink_resource_occ_get rifs)
 59         local expected_rifs=$((rifs_occ_t0 + 1))
 60 
 61         ((expected_rifs == rifs_occ_t1))
 62         check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
 63 
 64         log_test "Add RIF for LAG on address addition"
 65 }
 66 
 67 lag_rif_nomaster()
 68 {
 69         RET=0
 70 
 71         local rifs_occ_t0=$(devlink_resource_occ_get rifs)
 72         ip link set dev $swp1 nomaster
 73         sleep 1
 74         local rifs_occ_t1=$(devlink_resource_occ_get rifs)
 75         local expected_rifs=$((rifs_occ_t0 - 1))
 76 
 77         ((expected_rifs == rifs_occ_t1))
 78         check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
 79 
 80         log_test "Drop RIF for LAG on port deslavement"
 81 }
 82 
 83 lag_rif_remaster()
 84 {
 85         RET=0
 86 
 87         local rifs_occ_t0=$(devlink_resource_occ_get rifs)
 88         ip link set dev $swp1 down
 89         ip link set dev $swp1 master lag1
 90         ip link set dev $swp1 up
 91         setup_wait_dev $swp1
 92         local rifs_occ_t1=$(devlink_resource_occ_get rifs)
 93         local expected_rifs=$((rifs_occ_t0 + 1))
 94 
 95         ((expected_rifs == rifs_occ_t1))
 96         check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
 97 
 98         log_test "Add RIF for LAG on port reenslavement"
 99 }
100 
101 lag_rif_nomaster_addr()
102 {
103         local rifs_occ_t0=$(devlink_resource_occ_get rifs)
104 
105         # Adding an address while the port is LAG'd shouldn't generate a RIF.
106         __addr_add_del $swp1 add 192.0.2.65/28
107         sleep 1
108         local rifs_occ_t1=$(devlink_resource_occ_get rifs)
109         local expected_rifs=$((rifs_occ_t0))
110 
111         ((expected_rifs == rifs_occ_t1))
112         check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
113 
114         # Removing the port from LAG should drop RIF for the LAG (as tested in
115         # lag_rif_nomaster), but since the port now has an address, it should
116         # gain a RIF.
117         ip link set dev $swp1 nomaster
118         sleep 1
119         local rifs_occ_t2=$(devlink_resource_occ_get rifs)
120         local expected_rifs=$((rifs_occ_t0))
121 
122         ((expected_rifs == rifs_occ_t2))
123         check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
124 
125         __addr_add_del $swp1 del 192.0.2.65/28
126         log_test "Add RIF for port on deslavement from LAG"
127 }
128 
129 trap cleanup EXIT
130 
131 setup_prepare
132 setup_wait
133 
134 tests_run
135 
136 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php