2 # SPDX-License-Identifier: GPL-2.0
4 # Test devlink-trap tunnel drops and exceptions functionality over mlxsw.
5 # Check all traps to make sure they are triggered under the right
8 # +--------------------+
12 # +----|---------------+
14 # +----|----------------------------------------------------------------------+
16 # | +--|--------------------------------------------------------------------+ |
17 # | | + $swp1 BR1 (802.1d) | |
19 # | | + vx1 (vxlan) | |
20 # | | local 192.0.2.17 | |
21 # | | id 1000 dstport $VXPORT | |
22 # | +-----------------------------------------------------------------------+ |
26 # +----|----------------------------------------------------------------------+
28 # +----|--------------------------------------------------------+
33 # +-------------------------------------------------------------+
35 lib_dir
=$
(dirname $0)/..
/..
/..
/net
/forwarding
39 overlay_smac_is_mc_test
43 source $lib_dir/lib.sh
44 source $lib_dir/tc_common.sh
45 source $lib_dir/devlink_lib.sh
52 simple_if_init
$h1 192.0.2.1/28
57 simple_if_fini
$h1 192.0.2.1/28
62 ip link add name br1
type bridge vlan_filtering
0 mcast_snooping
0
63 # Make sure the bridge uses the MAC address of the local port and not
64 # that of the VxLAN's device.
65 ip link
set dev br1 address $
(mac_get
$swp1)
66 ip link
set dev br1 up
68 tc qdisc add dev
$swp1 clsact
69 ip link
set dev
$swp1 master br1
70 ip link
set dev
$swp1 up
72 ip link add name vx1
type vxlan id
1000 local 192.0.2.17 \
73 dstport
"$VXPORT" nolearning noudpcsum tos inherit ttl
100
74 ip link
set dev vx1 master br1
75 ip link
set dev vx1 up
77 ip address add dev
$rp1 192.0.2.17/28
78 ip link
set dev
$rp1 up
83 ip link
set dev
$rp1 down
84 ip address del dev
$rp1 192.0.2.17/28
86 ip link
set dev vx1 down
87 ip link
set dev vx1 nomaster
90 ip link
set dev
$swp1 down
91 ip link
set dev
$swp1 nomaster
92 tc qdisc del dev
$swp1 clsact
94 ip link
set dev br1 down
100 simple_if_init
$rp2 192.0.2.18/28
105 simple_if_fini
$rp2 192.0.2.18/28
136 dest_mac
=$
(mac_get
$h1)
138 )"08:"$
( : VXLAN flags
139 )"00:00:00:"$
( : VXLAN reserved
140 )"00:03:e8:"$
( : VXLAN VNI
: 1000
141 )"00:"$
( : VXLAN reserved
142 )"$dest_mac:"$
( : ETH daddr
143 )"00:00:00:00:00:00:"$
( : ETH saddr
144 )"08:00:"$
( : ETH
type
145 )"45:"$
( : IP version
+ IHL
147 )"00:14:"$
( : IP total length
148 )"00:00:"$
( : IP identification
149 )"20:00:"$
( : IP flags
+ frag off
152 )"D6:E5:"$
( : IP header csum
153 )"c0:00:02:03:"$
( : IP saddr
: 192.0.2.3
154 )"c0:00:02:01:"$
( : IP daddr
: 192.0.2.1
161 local trap_name
="decap_error"
163 local ecn_desc
=$1; shift
164 local outer_tos
=$1; shift
169 tc filter add dev
$swp1 egress protocol ip pref
1 handle
101 \
170 flower src_ip
192.0.2.3 dst_ip
192.0.2.1 action pass
172 rp1_mac
=$
(mac_get
$rp1)
173 payload
=$
(ecn_payload_get
)
175 ip vrf
exec v
$rp2 $MZ $rp2 -c 0 -d 1msec
-b $rp1_mac -B 192.0.2.17 \
176 -t udp sp
=12345,dp
=$VXPORT,tos
=$outer_tos,p
=$payload -q &
179 devlink_trap_exception_test
$trap_name
181 tc_check_packets
"dev $swp1 egress" 101 0
182 check_err $?
"Packets were not dropped"
184 log_test
"$desc: Inner ECN is not ECT and outer is $ecn_desc"
186 kill $mz_pid && wait $mz_pid &> /dev
/null
187 tc filter del dev
$swp1 egress protocol ip pref
1 handle
101 flower
190 reserved_bits_payload_get
()
192 dest_mac
=$
(mac_get
$h1)
194 )"08:"$
( : VXLAN flags
195 )"01:00:00:"$
( : VXLAN reserved
196 )"00:03:e8:"$
( : VXLAN VNI
: 1000
197 )"00:"$
( : VXLAN reserved
198 )"$dest_mac:"$
( : ETH daddr
199 )"00:00:00:00:00:00:"$
( : ETH saddr
200 )"08:00:"$
( : ETH
type
201 )"45:"$
( : IP version
+ IHL
203 )"00:14:"$
( : IP total length
204 )"00:00:"$
( : IP identification
205 )"20:00:"$
( : IP flags
+ frag off
208 )"00:00:"$
( : IP header csum
209 )"c0:00:02:03:"$
( : IP saddr
: 192.0.2.3
210 )"c0:00:02:01:"$
( : IP daddr
: 192.0.2.1
217 dest_mac
=$
(mac_get
$h1)
219 )"08:"$
( : VXLAN flags
220 )"01:00:00:"$
( : VXLAN reserved
221 )"00:03:e8:"$
( : VXLAN VNI
: 1000
222 )"00:"$
( : VXLAN reserved
227 corrupted_packet_test
()
229 local trap_name
="decap_error"
231 local payload_get
=$1; shift
236 # In case of too short packet, there is no any inner packet,
237 # so the matching will always succeed
238 tc filter add dev
$swp1 egress protocol ip pref
1 handle
101 \
239 flower skip_hw src_ip
192.0.2.3 dst_ip
192.0.2.1 action pass
241 rp1_mac
=$
(mac_get
$rp1)
242 payload
=$
($payload_get)
243 ip vrf
exec v
$rp2 $MZ $rp2 -c 0 -d 1msec
-b $rp1_mac \
244 -B 192.0.2.17 -t udp sp
=12345,dp
=$VXPORT,p
=$payload -q &
247 devlink_trap_exception_test
$trap_name
249 tc_check_packets
"dev $swp1 egress" 101 0
250 check_err $?
"Packets were not dropped"
254 kill $mz_pid && wait $mz_pid &> /dev
/null
255 tc filter del dev
$swp1 egress protocol ip pref
1 handle
101 flower
260 ecn_decap_test
"Decap error" "ECT(1)" 01
261 ecn_decap_test
"Decap error" "ECT(0)" 02
262 ecn_decap_test
"Decap error" "CE" 03
264 corrupted_packet_test
"Decap error: Reserved bits in use" \
265 "reserved_bits_payload_get"
266 corrupted_packet_test
"Decap error: No L2 header" "short_payload_get"
269 mc_smac_payload_get
()
271 dest_mac
=$
(mac_get
$h1)
272 source_mac
=01:02:03:04:05:06
274 )"08:"$
( : VXLAN flags
275 )"00:00:00:"$
( : VXLAN reserved
276 )"00:03:e8:"$
( : VXLAN VNI
: 1000
277 )"00:"$
( : VXLAN reserved
278 )"$dest_mac:"$
( : ETH daddr
279 )"$source_mac:"$
( : ETH saddr
280 )"08:00:"$
( : ETH
type
281 )"45:"$
( : IP version
+ IHL
283 )"00:14:"$
( : IP total length
284 )"00:00:"$
( : IP identification
285 )"20:00:"$
( : IP flags
+ frag off
288 )"00:00:"$
( : IP header csum
289 )"c0:00:02:03:"$
( : IP saddr
: 192.0.2.3
290 )"c0:00:02:01:"$
( : IP daddr
: 192.0.2.1
295 overlay_smac_is_mc_test
()
297 local trap_name
="overlay_smac_is_mc"
302 # The matching will be checked on devlink_trap_drop_test()
303 # and the filter will be removed on devlink_trap_drop_cleanup()
304 tc filter add dev
$swp1 egress protocol ip pref
1 handle
101 \
305 flower src_mac
01:02:03:04:05:06 action pass
307 rp1_mac
=$
(mac_get
$rp1)
308 payload
=$
(mc_smac_payload_get
)
310 ip vrf
exec v
$rp2 $MZ $rp2 -c 0 -d 1msec
-b $rp1_mac \
311 -B 192.0.2.17 -t udp sp
=12345,dp
=$VXPORT,p
=$payload -q &
314 devlink_trap_drop_test
$trap_name $swp1 101
316 log_test
"Overlay source MAC is multicast"
318 devlink_trap_drop_cleanup
$mz_pid $swp1 "ip" 1 101