1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 3 # 4 # Test operations that we expect to report extended ack. 5 6 lib_dir=$(dirname $0)/../../../net/forwarding 7 8 ALL_TESTS=" 9 netdev_pre_up_test 10 vxlan_vlan_add_test 11 vxlan_bridge_create_test 12 bridge_create_test 13 " 14 NUM_NETIFS=2 15 source $lib_dir/lib.sh 16 17 setup_prepare() 18 { 19 swp1=${NETIFS[p1]} 20 swp2=${NETIFS[p2]} 21 22 ip link set dev $swp1 up 23 ip link set dev $swp2 up 24 } 25 26 cleanup() 27 { 28 pre_cleanup 29 30 ip link set dev $swp2 down 31 ip link set dev $swp1 down 32 } 33 34 netdev_pre_up_test() 35 { 36 RET=0 37 38 ip link add name br1 type bridge vlan_filtering 0 mcast_snooping 0 39 ip link set dev br1 addrgenmode none 40 ip link set dev br1 up 41 ip link add name vx1 up type vxlan id 1000 \ 42 local 192.0.2.17 remote 192.0.2.18 \ 43 dstport 4789 nolearning noudpcsum tos inherit ttl 100 44 45 ip link set dev vx1 master br1 46 check_err $? 47 48 ip link set dev $swp1 master br1 49 check_err $? 50 51 ip link add name br2 type bridge vlan_filtering 0 mcast_snooping 0 52 ip link set dev br2 addrgenmode none 53 ip link set dev br2 up 54 ip link add name vx2 up type vxlan id 2000 \ 55 local 192.0.2.17 remote 192.0.2.18 \ 56 dstport 4789 nolearning noudpcsum tos inherit ttl 100 57 58 ip link set dev vx2 master br2 59 check_err $? 60 61 ip link set dev $swp2 master br2 62 check_err $? 63 64 # Unsupported configuration: mlxsw demands that all offloaded VXLAN 65 # devices have the same TTL. 66 ip link set dev vx2 down 67 ip link set dev vx2 type vxlan ttl 200 68 69 ip link set dev vx2 up &>/dev/null 70 check_fail $? 71 72 ip link set dev vx2 up 2>&1 >/dev/null | grep -q mlxsw_spectrum 73 check_err $? 74 75 log_test "extack - NETDEV_PRE_UP" 76 77 ip link del dev vx2 78 ip link del dev br2 79 80 ip link del dev vx1 81 ip link del dev br1 82 } 83 84 vxlan_vlan_add_test() 85 { 86 RET=0 87 88 ip link add name br1 type bridge vlan_filtering 1 mcast_snooping 0 89 ip link set dev br1 addrgenmode none 90 ip link set dev br1 up 91 92 # Unsupported configuration: mlxsw demands VXLAN with "noudpcsum". 93 ip link add name vx1 up type vxlan id 1000 \ 94 local 192.0.2.17 remote 192.0.2.18 \ 95 dstport 4789 tos inherit ttl 100 96 97 ip link set dev vx1 master br1 98 check_err $? 99 100 bridge vlan add dev vx1 vid 1 101 check_err $? 102 103 ip link set dev $swp1 master br1 104 check_err $? 105 106 bridge vlan add dev vx1 vid 1 pvid untagged 2>&1 >/dev/null \ 107 | grep -q mlxsw_spectrum 108 check_err $? 109 110 log_test "extack - map VLAN at VXLAN device" 111 112 ip link del dev vx1 113 ip link del dev br1 114 } 115 116 vxlan_bridge_create_test() 117 { 118 RET=0 119 120 # Unsupported configuration: mlxsw demands VXLAN with "noudpcsum". 121 ip link add name vx1 up type vxlan id 1000 \ 122 local 192.0.2.17 remote 192.0.2.18 \ 123 dstport 4789 tos inherit ttl 100 124 125 # Test with VLAN-aware bridge. 126 ip link add name br1 type bridge vlan_filtering 1 mcast_snooping 0 127 ip link set dev br1 addrgenmode none 128 ip link set dev br1 up 129 130 ip link set dev vx1 master br1 131 132 ip link set dev $swp1 master br1 2>&1 > /dev/null \ 133 | grep -q mlxsw_spectrum 134 check_err $? 135 136 # Test with VLAN-unaware bridge. 137 ip link set dev br1 type bridge vlan_filtering 0 138 139 ip link set dev $swp1 master br1 2>&1 > /dev/null \ 140 | grep -q mlxsw_spectrum 141 check_err $? 142 143 log_test "extack - bridge creation with VXLAN" 144 145 ip link del dev br1 146 ip link del dev vx1 147 } 148 149 bridge_create_test() 150 { 151 RET=0 152 153 ip link add name br1 type bridge vlan_filtering 1 154 ip link set dev br1 addrgenmode none 155 ip link set dev br1 up 156 ip link add name br2 type bridge vlan_filtering 1 157 ip link set dev br2 addrgenmode none 158 ip link set dev br2 up 159 160 ip link set dev $swp1 master br1 161 check_err $? 162 163 # Only one VLAN-aware bridge is supported, so this should fail with 164 # an extack. 165 ip link set dev $swp2 master br2 2>&1 > /dev/null \ 166 | grep -q mlxsw_spectrum 167 check_err $? 168 169 log_test "extack - multiple VLAN-aware bridges creation" 170 171 ip link del dev br2 172 ip link del dev br1 173 } 174 175 trap cleanup EXIT 176 177 setup_prepare 178 setup_wait 179 180 tests_run 181 182 exit $EXIT_STATUS
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.