WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / devlink_trap_control.sh
bloba37273473c1b553490dc937ef0890e64e0453517
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test devlink-trap control trap functionality over mlxsw. Each registered
5 # control packet trap is tested to make sure it is triggered under the right
6 # conditions.
8 # +---------------------------------+
9 # | H1 (vrf) |
10 # | + $h1 |
11 # | | 192.0.2.1/24 |
12 # | | 2001:db8:1::1/64 |
13 # | | |
14 # | | default via 192.0.2.2 |
15 # | | default via 2001:db8:1::2 |
16 # +----|----------------------------+
17 # |
18 # +----|----------------------------------------------------------------------+
19 # | SW | |
20 # | + $rp1 |
21 # | 192.0.2.2/24 |
22 # | 2001:db8:1::2/64 |
23 # | |
24 # | 2001:db8:2::2/64 |
25 # | 198.51.100.2/24 |
26 # | + $rp2 |
27 # | | |
28 # +----|----------------------------------------------------------------------+
29 # |
30 # +----|----------------------------+
31 # | | default via 198.51.100.2 |
32 # | | default via 2001:db8:2::2 |
33 # | | |
34 # | | 2001:db8:2::1/64 |
35 # | | 198.51.100.1/24 |
36 # | + $h2 |
37 # | H2 (vrf) |
38 # +---------------------------------+
40 lib_dir=$(dirname $0)/../../../net/forwarding
42 ALL_TESTS="
43 stp_test
44 lacp_test
45 lldp_test
46 igmp_query_test
47 igmp_v1_report_test
48 igmp_v2_report_test
49 igmp_v3_report_test
50 igmp_v2_leave_test
51 mld_query_test
52 mld_v1_report_test
53 mld_v2_report_test
54 mld_v1_done_test
55 ipv4_dhcp_test
56 ipv6_dhcp_test
57 arp_request_test
58 arp_response_test
59 ipv6_neigh_solicit_test
60 ipv6_neigh_advert_test
61 ipv4_bfd_test
62 ipv6_bfd_test
63 ipv4_ospf_test
64 ipv6_ospf_test
65 ipv4_bgp_test
66 ipv6_bgp_test
67 ipv4_vrrp_test
68 ipv6_vrrp_test
69 ipv4_pim_test
70 ipv6_pim_test
71 uc_loopback_test
72 local_route_test
73 external_route_test
74 ipv6_uc_dip_link_local_scope_test
75 ipv4_router_alert_test
76 ipv6_router_alert_test
77 ipv6_dip_all_nodes_test
78 ipv6_dip_all_routers_test
79 ipv6_router_solicit_test
80 ipv6_router_advert_test
81 ipv6_redirect_test
82 ptp_event_test
83 ptp_general_test
84 flow_action_sample_test
85 flow_action_trap_test
87 NUM_NETIFS=4
88 source $lib_dir/lib.sh
89 source $lib_dir/devlink_lib.sh
91 h1_create()
93 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
95 ip -4 route add default vrf v$h1 nexthop via 192.0.2.2
96 ip -6 route add default vrf v$h1 nexthop via 2001:db8:1::2
99 h1_destroy()
101 ip -6 route del default vrf v$h1 nexthop via 2001:db8:1::2
102 ip -4 route del default vrf v$h1 nexthop via 192.0.2.2
104 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
107 h2_create()
109 simple_if_init $h2 198.51.100.1/24 2001:db8:2::1/64
111 ip -4 route add default vrf v$h2 nexthop via 198.51.100.2
112 ip -6 route add default vrf v$h2 nexthop via 2001:db8:2::2
115 h2_destroy()
117 ip -6 route del default vrf v$h2 nexthop via 2001:db8:2::2
118 ip -4 route del default vrf v$h2 nexthop via 198.51.100.2
120 simple_if_fini $h2 198.51.100.1/24 2001:db8:2::1/64
123 router_create()
125 ip link set dev $rp1 up
126 ip link set dev $rp2 up
128 __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64
129 __addr_add_del $rp2 add 198.51.100.2/24 2001:db8:2::2/64
132 router_destroy()
134 __addr_add_del $rp2 del 198.51.100.2/24 2001:db8:2::2/64
135 __addr_add_del $rp1 del 192.0.2.2/24 2001:db8:1::2/64
137 ip link set dev $rp2 down
138 ip link set dev $rp1 down
141 setup_prepare()
143 h1=${NETIFS[p1]}
144 rp1=${NETIFS[p2]}
146 rp2=${NETIFS[p3]}
147 h2=${NETIFS[p4]}
149 vrf_prepare
150 forwarding_enable
152 h1_create
153 h2_create
154 router_create
157 cleanup()
159 pre_cleanup
161 router_destroy
162 h2_destroy
163 h1_destroy
165 forwarding_restore
166 vrf_cleanup
169 stp_test()
171 devlink_trap_stats_test "STP" "stp" $MZ $h1 -c 1 -t bpdu -q
174 lacp_payload_get()
176 local source_mac=$1; shift
177 local p
179 p=$(:
180 )"01:80:C2:00:00:02:"$( : ETH daddr
181 )"$source_mac:"$( : ETH saddr
182 )"88:09:"$( : ETH type
184 echo $p
187 lacp_test()
189 local h1mac=$(mac_get $h1)
191 devlink_trap_stats_test "LACP" "lacp" $MZ $h1 -c 1 \
192 $(lacp_payload_get $h1mac) -p 100 -q
195 lldp_payload_get()
197 local source_mac=$1; shift
198 local p
200 p=$(:
201 )"01:80:C2:00:00:0E:"$( : ETH daddr
202 )"$source_mac:"$( : ETH saddr
203 )"88:CC:"$( : ETH type
205 echo $p
208 lldp_test()
210 local h1mac=$(mac_get $h1)
212 devlink_trap_stats_test "LLDP" "lldp" $MZ $h1 -c 1 \
213 $(lldp_payload_get $h1mac) -p 100 -q
216 igmp_query_test()
218 # IGMP (IP Protocol 2) Membership Query (Type 0x11)
219 devlink_trap_stats_test "IGMP Membership Query" "igmp_query" \
220 $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
221 -A 192.0.2.1 -B 224.0.0.1 -t ip proto=2,p=11 -p 100 -q
224 igmp_v1_report_test()
226 # IGMP (IP Protocol 2) Version 1 Membership Report (Type 0x12)
227 devlink_trap_stats_test "IGMP Version 1 Membership Report" \
228 "igmp_v1_report" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
229 -A 192.0.2.1 -B 244.0.0.1 -t ip proto=2,p=12 -p 100 -q
232 igmp_v2_report_test()
234 # IGMP (IP Protocol 2) Version 2 Membership Report (Type 0x16)
235 devlink_trap_stats_test "IGMP Version 2 Membership Report" \
236 "igmp_v2_report" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
237 -A 192.0.2.1 -B 244.0.0.1 -t ip proto=2,p=16 -p 100 -q
240 igmp_v3_report_test()
242 # IGMP (IP Protocol 2) Version 3 Membership Report (Type 0x22)
243 devlink_trap_stats_test "IGMP Version 3 Membership Report" \
244 "igmp_v3_report" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
245 -A 192.0.2.1 -B 244.0.0.1 -t ip proto=2,p=22 -p 100 -q
248 igmp_v2_leave_test()
250 # IGMP (IP Protocol 2) Version 2 Leave Group (Type 0x17)
251 devlink_trap_stats_test "IGMP Version 2 Leave Group" \
252 "igmp_v2_leave" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:02 \
253 -A 192.0.2.1 -B 224.0.0.2 -t ip proto=2,p=17 -p 100 -q
256 mld_payload_get()
258 local type=$1; shift
259 local p
261 type=$(printf "%x" $type)
262 p=$(:
263 )"3A:"$( : Next Header - ICMPv6
264 )"00:"$( : Hdr Ext Len
265 )"00:00:00:00:00:00:"$( : Options and Padding
266 )"$type:"$( : ICMPv6.type
267 )"00:"$( : ICMPv6.code
268 )"00:"$( : ICMPv6.checksum
270 echo $p
273 mld_query_test()
275 # MLD Multicast Listener Query (Type 130)
276 devlink_trap_stats_test "MLD Multicast Listener Query" "mld_query" \
277 $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::1 \
278 -t ip hop=1,next=0,payload=$(mld_payload_get 130) -p 100 -q
281 mld_v1_report_test()
283 # MLD Version 1 Multicast Listener Report (Type 131)
284 devlink_trap_stats_test "MLD Version 1 Multicast Listener Report" \
285 "mld_v1_report" $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::16 \
286 -t ip hop=1,next=0,payload=$(mld_payload_get 131) -p 100 -q
289 mld_v2_report_test()
291 # MLD Version 2 Multicast Listener Report (Type 143)
292 devlink_trap_stats_test "MLD Version 2 Multicast Listener Report" \
293 "mld_v2_report" $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::16 \
294 -t ip hop=1,next=0,payload=$(mld_payload_get 143) -p 100 -q
297 mld_v1_done_test()
299 # MLD Version 1 Multicast Listener Done (Type 132)
300 devlink_trap_stats_test "MLD Version 1 Multicast Listener Done" \
301 "mld_v1_done" $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::16 \
302 -t ip hop=1,next=0,payload=$(mld_payload_get 132) -p 100 -q
305 ipv4_dhcp_test()
307 devlink_trap_stats_test "IPv4 DHCP Port 67" "ipv4_dhcp" \
308 $MZ $h1 -c 1 -a own -b bcast -A 0.0.0.0 -B 255.255.255.255 \
309 -t udp sp=68,dp=67 -p 100 -q
311 devlink_trap_stats_test "IPv4 DHCP Port 68" "ipv4_dhcp" \
312 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) -A 192.0.2.1 \
313 -B 255.255.255.255 -t udp sp=67,dp=68 -p 100 -q
316 ipv6_dhcp_test()
318 devlink_trap_stats_test "IPv6 DHCP Port 547" "ipv6_dhcp" \
319 $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::1:2 -t udp sp=546,dp=547 \
320 -p 100 -q
322 devlink_trap_stats_test "IPv6 DHCP Port 546" "ipv6_dhcp" \
323 $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::1:2 -t udp sp=547,dp=546 \
324 -p 100 -q
327 arp_request_test()
329 devlink_trap_stats_test "ARP Request" "arp_request" \
330 $MZ $h1 -c 1 -a own -b bcast -t arp request -p 100 -q
333 arp_response_test()
335 devlink_trap_stats_test "ARP Response" "arp_response" \
336 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) -t arp reply -p 100 -q
339 icmpv6_header_get()
341 local type=$1; shift
342 local p
344 type=$(printf "%x" $type)
345 p=$(:
346 )"$type:"$( : ICMPv6.type
347 )"00:"$( : ICMPv6.code
348 )"00:"$( : ICMPv6.checksum
350 echo $p
353 ipv6_neigh_solicit_test()
355 devlink_trap_stats_test "IPv6 Neighbour Solicitation" \
356 "ipv6_neigh_solicit" $MZ $h1 -6 -c 1 \
357 -A fe80::1 -B ff02::1:ff00:02 \
358 -t ip hop=1,next=58,payload=$(icmpv6_header_get 135) -p 100 -q
361 ipv6_neigh_advert_test()
363 devlink_trap_stats_test "IPv6 Neighbour Advertisement" \
364 "ipv6_neigh_advert" $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
365 -A fe80::1 -B 2001:db8:1::2 \
366 -t ip hop=1,next=58,payload=$(icmpv6_header_get 136) -p 100 -q
369 ipv4_bfd_test()
371 devlink_trap_stats_test "IPv4 BFD Control - Port 3784" "ipv4_bfd" \
372 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
373 -A 192.0.2.1 -B 192.0.2.2 -t udp sp=49153,dp=3784 -p 100 -q
375 devlink_trap_stats_test "IPv4 BFD Echo - Port 3785" "ipv4_bfd" \
376 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
377 -A 192.0.2.1 -B 192.0.2.2 -t udp sp=49153,dp=3785 -p 100 -q
380 ipv6_bfd_test()
382 devlink_trap_stats_test "IPv6 BFD Control - Port 3784" "ipv6_bfd" \
383 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
384 -A 2001:db8:1::1 -B 2001:db8:1::2 \
385 -t udp sp=49153,dp=3784 -p 100 -q
387 devlink_trap_stats_test "IPv6 BFD Echo - Port 3785" "ipv6_bfd" \
388 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
389 -A 2001:db8:1::1 -B 2001:db8:1::2 \
390 -t udp sp=49153,dp=3785 -p 100 -q
393 ipv4_ospf_test()
395 devlink_trap_stats_test "IPv4 OSPF - Multicast" "ipv4_ospf" \
396 $MZ $h1 -c 1 -a own -b 01:00:5e:00:00:05 \
397 -A 192.0.2.1 -B 224.0.0.5 -t ip proto=89 -p 100 -q
399 devlink_trap_stats_test "IPv4 OSPF - Unicast" "ipv4_ospf" \
400 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
401 -A 192.0.2.1 -B 192.0.2.2 -t ip proto=89 -p 100 -q
404 ipv6_ospf_test()
406 devlink_trap_stats_test "IPv6 OSPF - Multicast" "ipv6_ospf" \
407 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:05 \
408 -A fe80::1 -B ff02::5 -t ip next=89 -p 100 -q
410 devlink_trap_stats_test "IPv6 OSPF - Unicast" "ipv6_ospf" \
411 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
412 -A 2001:db8:1::1 -B 2001:db8:1::2 -t ip next=89 -p 100 -q
415 ipv4_bgp_test()
417 devlink_trap_stats_test "IPv4 BGP" "ipv4_bgp" \
418 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
419 -A 192.0.2.1 -B 192.0.2.2 -t tcp sp=54321,dp=179,flags=rst \
420 -p 100 -q
423 ipv6_bgp_test()
425 devlink_trap_stats_test "IPv6 BGP" "ipv6_bgp" \
426 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
427 -A 2001:db8:1::1 -B 2001:db8:1::2 \
428 -t tcp sp=54321,dp=179,flags=rst -p 100 -q
431 ipv4_vrrp_test()
433 devlink_trap_stats_test "IPv4 VRRP" "ipv4_vrrp" \
434 $MZ $h1 -c 1 -a own -b 01:00:5e:00:00:12 \
435 -A 192.0.2.1 -B 224.0.0.18 -t ip proto=112 -p 100 -q
438 ipv6_vrrp_test()
440 devlink_trap_stats_test "IPv6 VRRP" "ipv6_vrrp" \
441 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:12 \
442 -A fe80::1 -B ff02::12 -t ip next=112 -p 100 -q
445 ipv4_pim_test()
447 devlink_trap_stats_test "IPv4 PIM - Multicast" "ipv4_pim" \
448 $MZ $h1 -c 1 -a own -b 01:00:5e:00:00:0d \
449 -A 192.0.2.1 -B 224.0.0.13 -t ip proto=103 -p 100 -q
451 devlink_trap_stats_test "IPv4 PIM - Unicast" "ipv4_pim" \
452 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
453 -A 192.0.2.1 -B 192.0.2.2 -t ip proto=103 -p 100 -q
456 ipv6_pim_test()
458 devlink_trap_stats_test "IPv6 PIM - Multicast" "ipv6_pim" \
459 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:0d \
460 -A fe80::1 -B ff02::d -t ip next=103 -p 100 -q
462 devlink_trap_stats_test "IPv6 PIM - Unicast" "ipv6_pim" \
463 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
464 -A fe80::1 -B 2001:db8:1::2 -t ip next=103 -p 100 -q
467 uc_loopback_test()
469 # Add neighbours to the fake destination IPs, so that the packets are
470 # routed in the device and not trapped due to an unresolved neighbour
471 # exception.
472 ip -4 neigh add 192.0.2.3 lladdr 00:11:22:33:44:55 nud permanent \
473 dev $rp1
474 ip -6 neigh add 2001:db8:1::3 lladdr 00:11:22:33:44:55 nud permanent \
475 dev $rp1
477 devlink_trap_stats_test "IPv4 Unicast Loopback" "uc_loopback" \
478 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
479 -A 192.0.2.1 -B 192.0.2.3 -t udp sp=54321,dp=12345 -p 100 -q
481 devlink_trap_stats_test "IPv6 Unicast Loopback" "uc_loopback" \
482 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
483 -A 2001:db8:1::1 -B 2001:db8:1::3 -t udp sp=54321,dp=12345 \
484 -p 100 -q
486 ip -6 neigh del 2001:db8:1::3 dev $rp1
487 ip -4 neigh del 192.0.2.3 dev $rp1
490 local_route_test()
492 # Use a fake source IP to prevent the trap from being triggered twice
493 # when the router sends back a port unreachable message.
494 devlink_trap_stats_test "IPv4 Local Route" "local_route" \
495 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
496 -A 192.0.2.3 -B 192.0.2.2 -t udp sp=54321,dp=12345 -p 100 -q
498 devlink_trap_stats_test "IPv6 Local Route" "local_route" \
499 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
500 -A 2001:db8:1::3 -B 2001:db8:1::2 -t udp sp=54321,sp=12345 \
501 -p 100 -q
504 external_route_test()
506 # Add a dummy device through which the incoming packets should be
507 # routed.
508 ip link add name dummy10 up type dummy
509 ip address add 203.0.113.1/24 dev dummy10
510 ip -6 address add 2001:db8:10::1/64 dev dummy10
512 devlink_trap_stats_test "IPv4 External Route" "external_route" \
513 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
514 -A 192.0.2.1 -B 203.0.113.2 -t udp sp=54321,dp=12345 -p 100 -q
516 devlink_trap_stats_test "IPv6 External Route" "external_route" \
517 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
518 -A 2001:db8:1::1 -B 2001:db8:10::2 -t udp sp=54321,sp=12345 \
519 -p 100 -q
521 ip -6 address del 2001:db8:10::1/64 dev dummy10
522 ip address del 203.0.113.1/24 dev dummy10
523 ip link del dev dummy10
526 ipv6_uc_dip_link_local_scope_test()
528 # Add a dummy link-local prefix route to allow the packet to be routed.
529 ip -6 route add fe80:1::/64 dev $rp2
531 devlink_trap_stats_test \
532 "IPv6 Unicast Destination IP With Link-Local Scope" \
533 "ipv6_uc_dip_link_local_scope" \
534 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
535 -A fe80::1 -B fe80:1::2 -t udp sp=54321,sp=12345 \
536 -p 100 -q
538 ip -6 route del fe80:1::/64 dev $rp2
541 ipv4_router_alert_get()
543 local p
545 # https://en.wikipedia.org/wiki/IPv4#Options
546 p=$(:
547 )"94:"$( : Option Number
548 )"04:"$( : Option Length
549 )"00:00:"$( : Option Data
551 echo $p
554 ipv4_router_alert_test()
556 devlink_trap_stats_test "IPv4 Router Alert" "ipv4_router_alert" \
557 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
558 -A 192.0.2.1 -B 198.51.100.3 \
559 -t ip option=$(ipv4_router_alert_get) -p 100 -q
562 ipv6_router_alert_get()
564 local p
566 # https://en.wikipedia.org/wiki/IPv6_packet#Hop-by-hop_options_and_destination_options
567 # https://tools.ietf.org/html/rfc2711#section-2.1
568 p=$(:
569 )"11:"$( : Next Header - UDP
570 )"00:"$( : Hdr Ext Len
571 )"05:02:00:00:00:00:"$( : Option Data
573 echo $p
576 ipv6_router_alert_test()
578 devlink_trap_stats_test "IPv6 Router Alert" "ipv6_router_alert" \
579 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
580 -A 2001:db8:1::1 -B 2001:db8:1::3 \
581 -t ip next=0,payload=$(ipv6_router_alert_get) -p 100 -q
584 ipv6_dip_all_nodes_test()
586 devlink_trap_stats_test "IPv6 Destination IP \"All Nodes Address\"" \
587 "ipv6_dip_all_nodes" \
588 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:01 \
589 -A 2001:db8:1::1 -B ff02::1 -t udp sp=12345,dp=54321 -p 100 -q
592 ipv6_dip_all_routers_test()
594 devlink_trap_stats_test "IPv6 Destination IP \"All Routers Address\"" \
595 "ipv6_dip_all_routers" \
596 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:02 \
597 -A 2001:db8:1::1 -B ff02::2 -t udp sp=12345,dp=54321 -p 100 -q
600 ipv6_router_solicit_test()
602 devlink_trap_stats_test "IPv6 Router Solicitation" \
603 "ipv6_router_solicit" \
604 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:02 \
605 -A fe80::1 -B ff02::2 \
606 -t ip hop=1,next=58,payload=$(icmpv6_header_get 133) -p 100 -q
609 ipv6_router_advert_test()
611 devlink_trap_stats_test "IPv6 Router Advertisement" \
612 "ipv6_router_advert" \
613 $MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:01 \
614 -A fe80::1 -B ff02::1 \
615 -t ip hop=1,next=58,payload=$(icmpv6_header_get 134) -p 100 -q
618 ipv6_redirect_test()
620 devlink_trap_stats_test "IPv6 Redirect Message" \
621 "ipv6_redirect" \
622 $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
623 -A fe80::1 -B 2001:db8:1::2 \
624 -t ip hop=1,next=58,payload=$(icmpv6_header_get 137) -p 100 -q
627 ptp_event_test()
629 # PTP is only supported on Spectrum-1, for now.
630 [[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
632 # PTP Sync (0)
633 devlink_trap_stats_test "PTP Time-Critical Event Message" "ptp_event" \
634 $MZ $h1 -c 1 -a own -b 01:00:5e:00:01:81 \
635 -A 192.0.2.1 -B 224.0.1.129 \
636 -t udp sp=12345,dp=319,payload=10 -p 100 -q
639 ptp_general_test()
641 # PTP is only supported on Spectrum-1, for now.
642 [[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
644 # PTP Announce (b)
645 devlink_trap_stats_test "PTP General Message" "ptp_general" \
646 $MZ $h1 -c 1 -a own -b 01:00:5e:00:01:81 \
647 -A 192.0.2.1 -B 224.0.1.129 \
648 -t udp sp=12345,dp=320,payload=1b -p 100 -q
651 flow_action_sample_test()
653 # Install a filter that samples every incoming packet.
654 tc qdisc add dev $rp1 clsact
655 tc filter add dev $rp1 ingress proto all pref 1 handle 101 matchall \
656 skip_sw action sample rate 1 group 1
658 devlink_trap_stats_test "Flow Sampling" "flow_action_sample" \
659 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
660 -A 192.0.2.1 -B 198.51.100.1 -t udp sp=12345,dp=54321 -p 100 -q
662 tc filter del dev $rp1 ingress proto all pref 1 handle 101 matchall
663 tc qdisc del dev $rp1 clsact
666 flow_action_trap_test()
668 # Install a filter that traps a specific flow.
669 tc qdisc add dev $rp1 clsact
670 tc filter add dev $rp1 ingress proto ip pref 1 handle 101 flower \
671 skip_sw ip_proto udp src_port 12345 dst_port 54321 action trap
673 devlink_trap_stats_test "Flow Trapping (Logging)" "flow_action_trap" \
674 $MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
675 -A 192.0.2.1 -B 198.51.100.1 -t udp sp=12345,dp=54321 -p 100 -q
677 tc filter del dev $rp1 ingress proto ip pref 1 handle 101 flower
678 tc qdisc del dev $rp1 clsact
681 trap cleanup EXIT
683 setup_prepare
684 setup_wait
686 tests_run
688 exit $EXIT_STATUS