WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / vxlan.sh
blob729a86cc4ede9c49b6119b182817177783704b3f
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Test various aspects of VxLAN offloading which are specific to mlxsw, such
5 # as sanitization of invalid configurations and offload indication.
7 lib_dir=$(dirname $0)/../../../net/forwarding
9 ALL_TESTS="sanitization_test offload_indication_test \
10 sanitization_vlan_aware_test offload_indication_vlan_aware_test"
11 NUM_NETIFS=2
12 : ${TIMEOUT:=20000} # ms
13 source $lib_dir/lib.sh
15 setup_prepare()
17 swp1=${NETIFS[p1]}
18 swp2=${NETIFS[p2]}
20 ip link set dev $swp1 up
21 ip link set dev $swp2 up
24 cleanup()
26 pre_cleanup
28 ip link set dev $swp2 down
29 ip link set dev $swp1 down
32 sanitization_single_dev_test_pass()
34 ip link set dev $swp1 master br0
35 check_err $?
36 ip link set dev vxlan0 master br0
37 check_err $?
39 ip link set dev $swp1 nomaster
41 ip link set dev $swp1 master br0
42 check_err $?
45 sanitization_single_dev_test_fail()
47 ip link set dev $swp1 master br0
48 check_err $?
49 ip link set dev vxlan0 master br0 &> /dev/null
50 check_fail $?
52 ip link set dev $swp1 nomaster
54 ip link set dev vxlan0 master br0
55 check_err $?
56 ip link set dev $swp1 master br0 &> /dev/null
57 check_fail $?
60 sanitization_single_dev_valid_test()
62 RET=0
64 ip link add dev br0 type bridge mcast_snooping 0
66 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
67 ttl 20 tos inherit local 198.51.100.1 dstport 4789
69 sanitization_single_dev_test_pass
71 ip link del dev vxlan0
72 ip link del dev br0
74 log_test "vxlan device - valid configuration"
77 sanitization_single_dev_vlan_aware_test()
79 RET=0
81 ip link add dev br0 type bridge mcast_snooping 0 vlan_filtering 1
83 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
84 ttl 20 tos inherit local 198.51.100.1 dstport 4789
86 sanitization_single_dev_test_pass
88 ip link del dev vxlan0
89 ip link del dev br0
91 log_test "vxlan device with a vlan-aware bridge"
94 sanitization_single_dev_mcast_enabled_test()
96 RET=0
98 ip link add dev br0 type bridge
100 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
101 ttl 20 tos inherit local 198.51.100.1 dstport 4789
103 sanitization_single_dev_test_fail
105 ip link del dev vxlan0
106 ip link del dev br0
108 log_test "vxlan device with a multicast enabled bridge"
111 sanitization_single_dev_mcast_group_test()
113 RET=0
115 ip link add dev br0 type bridge mcast_snooping 0
116 ip link add name dummy1 up type dummy
118 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
119 ttl 20 tos inherit local 198.51.100.1 dstport 4789 \
120 dev dummy1 group 239.0.0.1
122 sanitization_single_dev_test_fail
124 ip link del dev vxlan0
125 ip link del dev dummy1
126 ip link del dev br0
128 log_test "vxlan device with a multicast group"
131 sanitization_single_dev_no_local_ip_test()
133 RET=0
135 ip link add dev br0 type bridge mcast_snooping 0
137 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
138 ttl 20 tos inherit dstport 4789
140 sanitization_single_dev_test_fail
142 ip link del dev vxlan0
143 ip link del dev br0
145 log_test "vxlan device with no local ip"
148 sanitization_single_dev_local_ipv6_test()
150 RET=0
152 ip link add dev br0 type bridge mcast_snooping 0
154 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
155 ttl 20 tos inherit local 2001:db8::1 dstport 4789
157 sanitization_single_dev_test_fail
159 ip link del dev vxlan0
160 ip link del dev br0
162 log_test "vxlan device with local ipv6 address"
165 sanitization_single_dev_learning_enabled_test()
167 RET=0
169 ip link add dev br0 type bridge mcast_snooping 0
171 ip link add name vxlan0 up type vxlan id 10 learning noudpcsum \
172 ttl 20 tos inherit local 198.51.100.1 dstport 4789
174 sanitization_single_dev_test_pass
176 ip link del dev vxlan0
177 ip link del dev br0
179 log_test "vxlan device with learning enabled"
182 sanitization_single_dev_local_interface_test()
184 RET=0
186 ip link add dev br0 type bridge mcast_snooping 0
187 ip link add name dummy1 up type dummy
189 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
190 ttl 20 tos inherit local 198.51.100.1 dstport 4789 dev dummy1
192 sanitization_single_dev_test_fail
194 ip link del dev vxlan0
195 ip link del dev dummy1
196 ip link del dev br0
198 log_test "vxlan device with local interface"
201 sanitization_single_dev_port_range_test()
203 RET=0
205 ip link add dev br0 type bridge mcast_snooping 0
207 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
208 ttl 20 tos inherit local 198.51.100.1 dstport 4789 \
209 srcport 4000 5000
211 sanitization_single_dev_test_fail
213 ip link del dev vxlan0
214 ip link del dev br0
216 log_test "vxlan device with udp source port range"
219 sanitization_single_dev_tos_static_test()
221 RET=0
223 ip link add dev br0 type bridge mcast_snooping 0
225 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
226 ttl 20 tos 20 local 198.51.100.1 dstport 4789
228 sanitization_single_dev_test_fail
230 ip link del dev vxlan0
231 ip link del dev br0
233 log_test "vxlan device with static tos"
236 sanitization_single_dev_ttl_inherit_test()
238 RET=0
240 ip link add dev br0 type bridge mcast_snooping 0
242 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
243 ttl inherit tos inherit local 198.51.100.1 dstport 4789
245 sanitization_single_dev_test_fail
247 ip link del dev vxlan0
248 ip link del dev br0
250 log_test "vxlan device with inherit ttl"
253 sanitization_single_dev_udp_checksum_test()
255 RET=0
257 ip link add dev br0 type bridge mcast_snooping 0
259 ip link add name vxlan0 up type vxlan id 10 nolearning udpcsum \
260 ttl 20 tos inherit local 198.51.100.1 dstport 4789
262 sanitization_single_dev_test_fail
264 ip link del dev vxlan0
265 ip link del dev br0
267 log_test "vxlan device with udp checksum"
270 sanitization_single_dev_test()
272 # These tests make sure that we correctly sanitize VxLAN device
273 # configurations we do not support
274 sanitization_single_dev_valid_test
275 sanitization_single_dev_vlan_aware_test
276 sanitization_single_dev_mcast_enabled_test
277 sanitization_single_dev_mcast_group_test
278 sanitization_single_dev_no_local_ip_test
279 sanitization_single_dev_local_ipv6_test
280 sanitization_single_dev_learning_enabled_test
281 sanitization_single_dev_local_interface_test
282 sanitization_single_dev_port_range_test
283 sanitization_single_dev_tos_static_test
284 sanitization_single_dev_ttl_inherit_test
285 sanitization_single_dev_udp_checksum_test
288 sanitization_multi_devs_test_pass()
290 ip link set dev $swp1 master br0
291 check_err $?
292 ip link set dev vxlan0 master br0
293 check_err $?
294 ip link set dev $swp2 master br1
295 check_err $?
296 ip link set dev vxlan1 master br1
297 check_err $?
299 ip link set dev $swp2 nomaster
300 ip link set dev $swp1 nomaster
302 ip link set dev $swp1 master br0
303 check_err $?
304 ip link set dev $swp2 master br1
305 check_err $?
308 sanitization_multi_devs_test_fail()
310 ip link set dev $swp1 master br0
311 check_err $?
312 ip link set dev vxlan0 master br0
313 check_err $?
314 ip link set dev $swp2 master br1
315 check_err $?
316 ip link set dev vxlan1 master br1 &> /dev/null
317 check_fail $?
319 ip link set dev $swp2 nomaster
320 ip link set dev $swp1 nomaster
322 ip link set dev vxlan1 master br1
323 check_err $?
324 ip link set dev $swp1 master br0
325 check_err $?
326 ip link set dev $swp2 master br1 &> /dev/null
327 check_fail $?
330 sanitization_multi_devs_valid_test()
332 RET=0
334 ip link add dev br0 type bridge mcast_snooping 0
335 ip link add dev br1 type bridge mcast_snooping 0
337 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
338 ttl 20 tos inherit local 198.51.100.1 dstport 4789
339 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
340 ttl 20 tos inherit local 198.51.100.1 dstport 4789
342 sanitization_multi_devs_test_pass
344 ip link del dev vxlan1
345 ip link del dev vxlan0
346 ip link del dev br1
347 ip link del dev br0
349 log_test "multiple vxlan devices - valid configuration"
352 sanitization_multi_devs_ttl_test()
354 RET=0
356 ip link add dev br0 type bridge mcast_snooping 0
357 ip link add dev br1 type bridge mcast_snooping 0
359 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
360 ttl 20 tos inherit local 198.51.100.1 dstport 4789
361 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
362 ttl 40 tos inherit local 198.51.100.1 dstport 4789
364 sanitization_multi_devs_test_fail
366 ip link del dev vxlan1
367 ip link del dev vxlan0
368 ip link del dev br1
369 ip link del dev br0
371 log_test "multiple vxlan devices with different ttl"
374 sanitization_multi_devs_udp_dstport_test()
376 RET=0
378 ip link add dev br0 type bridge mcast_snooping 0
379 ip link add dev br1 type bridge mcast_snooping 0
381 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
382 ttl 20 tos inherit local 198.51.100.1 dstport 4789
383 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
384 ttl 20 tos inherit local 198.51.100.1 dstport 5789
386 sanitization_multi_devs_test_fail
388 ip link del dev vxlan1
389 ip link del dev vxlan0
390 ip link del dev br1
391 ip link del dev br0
393 log_test "multiple vxlan devices with different udp destination port"
396 sanitization_multi_devs_local_ip_test()
398 RET=0
400 ip link add dev br0 type bridge mcast_snooping 0
401 ip link add dev br1 type bridge mcast_snooping 0
403 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
404 ttl 20 tos inherit local 198.51.100.1 dstport 4789
405 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
406 ttl 20 tos inherit local 198.51.100.2 dstport 4789
408 sanitization_multi_devs_test_fail
410 ip link del dev vxlan1
411 ip link del dev vxlan0
412 ip link del dev br1
413 ip link del dev br0
415 log_test "multiple vxlan devices with different local ip"
418 sanitization_multi_devs_test()
420 # The device has a single VTEP, which means all the VxLAN devices
421 # we offload must share certain properties such as source IP and
422 # UDP destination port. These tests make sure that we forbid
423 # configurations that violate this limitation
424 sanitization_multi_devs_valid_test
425 sanitization_multi_devs_ttl_test
426 sanitization_multi_devs_udp_dstport_test
427 sanitization_multi_devs_local_ip_test
430 sanitization_test()
432 sanitization_single_dev_test
433 sanitization_multi_devs_test
436 offload_indication_setup_create()
438 # Create a simple setup with two bridges, each with a VxLAN device
439 # and one local port
440 ip link add name br0 up type bridge mcast_snooping 0
441 ip link add name br1 up type bridge mcast_snooping 0
443 ip link set dev $swp1 master br0
444 ip link set dev $swp2 master br1
446 ip address add 198.51.100.1/32 dev lo
448 ip link add name vxlan0 up master br0 type vxlan id 10 nolearning \
449 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
450 ip link add name vxlan1 up master br1 type vxlan id 20 nolearning \
451 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
454 offload_indication_setup_destroy()
456 ip link del dev vxlan1
457 ip link del dev vxlan0
459 ip address del 198.51.100.1/32 dev lo
461 ip link set dev $swp2 nomaster
462 ip link set dev $swp1 nomaster
464 ip link del dev br1
465 ip link del dev br0
468 offload_indication_fdb_flood_test()
470 RET=0
472 bridge fdb append 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.2
474 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb 00:00:00:00:00:00 \
475 bridge fdb show brport vxlan0
476 check_err $?
478 bridge fdb del 00:00:00:00:00:00 dev vxlan0 self
480 log_test "vxlan flood entry offload indication"
483 offload_indication_fdb_bridge_test()
485 RET=0
487 bridge fdb add de:ad:be:ef:13:37 dev vxlan0 self master static \
488 dst 198.51.100.2
490 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
491 de:ad:be:ef:13:37 self bridge fdb show brport vxlan0
492 check_err $?
493 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
494 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan0
495 check_err $?
497 log_test "vxlan entry offload indication - initial state"
499 # Remove FDB entry from the bridge driver and check that corresponding
500 # entry in the VxLAN driver is not marked as offloaded
501 RET=0
503 bridge fdb del de:ad:be:ef:13:37 dev vxlan0 master
504 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb \
505 de:ad:be:ef:13:37 self bridge fdb show brport vxlan0
506 check_err $?
508 log_test "vxlan entry offload indication - after removal from bridge"
510 # Add the FDB entry back to the bridge driver and make sure it is
511 # marked as offloaded in both drivers
512 RET=0
514 bridge fdb add de:ad:be:ef:13:37 dev vxlan0 master static
515 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
516 de:ad:be:ef:13:37 self bridge fdb show brport vxlan0
517 check_err $?
518 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
519 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan0
520 check_err $?
522 log_test "vxlan entry offload indication - after re-add to bridge"
524 # Remove FDB entry from the VxLAN driver and check that corresponding
525 # entry in the bridge driver is not marked as offloaded
526 RET=0
528 bridge fdb del de:ad:be:ef:13:37 dev vxlan0 self
529 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb \
530 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan0
531 check_err $?
533 log_test "vxlan entry offload indication - after removal from vxlan"
535 # Add the FDB entry back to the VxLAN driver and make sure it is
536 # marked as offloaded in both drivers
537 RET=0
539 bridge fdb add de:ad:be:ef:13:37 dev vxlan0 self dst 198.51.100.2
540 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
541 de:ad:be:ef:13:37 self bridge fdb show brport vxlan0
542 check_err $?
543 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
544 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan0
545 check_err $?
547 log_test "vxlan entry offload indication - after re-add to vxlan"
549 bridge fdb del de:ad:be:ef:13:37 dev vxlan0 self master
552 offload_indication_fdb_test()
554 offload_indication_fdb_flood_test
555 offload_indication_fdb_bridge_test
558 offload_indication_decap_route_test()
560 RET=0
562 busywait "$TIMEOUT" wait_for_offload \
563 ip route show table local 198.51.100.1
564 check_err $?
566 ip link set dev vxlan0 down
567 busywait "$TIMEOUT" wait_for_offload \
568 ip route show table local 198.51.100.1
569 check_err $?
571 ip link set dev vxlan1 down
572 busywait "$TIMEOUT" not wait_for_offload \
573 ip route show table local 198.51.100.1
574 check_err $?
576 log_test "vxlan decap route - vxlan device down"
578 RET=0
580 ip link set dev vxlan1 up
581 busywait "$TIMEOUT" wait_for_offload \
582 ip route show table local 198.51.100.1
583 check_err $?
585 ip link set dev vxlan0 up
586 busywait "$TIMEOUT" wait_for_offload \
587 ip route show table local 198.51.100.1
588 check_err $?
590 log_test "vxlan decap route - vxlan device up"
592 RET=0
594 ip address delete 198.51.100.1/32 dev lo
595 busywait "$TIMEOUT" not wait_for_offload \
596 ip route show table local 198.51.100.1
597 check_err $?
599 ip address add 198.51.100.1/32 dev lo
600 busywait "$TIMEOUT" wait_for_offload \
601 ip route show table local 198.51.100.1
602 check_err $?
604 log_test "vxlan decap route - add local route"
606 RET=0
608 ip link set dev $swp1 nomaster
609 busywait "$TIMEOUT" wait_for_offload \
610 ip route show table local 198.51.100.1
611 check_err $?
613 ip link set dev $swp2 nomaster
614 busywait "$TIMEOUT" not wait_for_offload \
615 ip route show table local 198.51.100.1
616 check_err $?
618 ip link set dev $swp1 master br0
619 ip link set dev $swp2 master br1
620 busywait "$TIMEOUT" wait_for_offload \
621 ip route show table local 198.51.100.1
622 check_err $?
624 log_test "vxlan decap route - local ports enslavement"
626 RET=0
628 ip link del dev br0
629 busywait "$TIMEOUT" wait_for_offload \
630 ip route show table local 198.51.100.1
631 check_err $?
633 ip link del dev br1
634 busywait "$TIMEOUT" not wait_for_offload \
635 ip route show table local 198.51.100.1
636 check_err $?
638 log_test "vxlan decap route - bridge device deletion"
640 RET=0
642 ip link add name br0 up type bridge mcast_snooping 0
643 ip link add name br1 up type bridge mcast_snooping 0
644 ip link set dev $swp1 master br0
645 ip link set dev $swp2 master br1
646 ip link set dev vxlan0 master br0
647 ip link set dev vxlan1 master br1
648 busywait "$TIMEOUT" wait_for_offload \
649 ip route show table local 198.51.100.1
650 check_err $?
652 ip link del dev vxlan0
653 busywait "$TIMEOUT" wait_for_offload \
654 ip route show table local 198.51.100.1
655 check_err $?
657 ip link del dev vxlan1
658 busywait "$TIMEOUT" not wait_for_offload \
659 ip route show table local 198.51.100.1
660 check_err $?
662 log_test "vxlan decap route - vxlan device deletion"
664 ip link add name vxlan0 up master br0 type vxlan id 10 nolearning \
665 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
666 ip link add name vxlan1 up master br1 type vxlan id 20 nolearning \
667 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
670 check_fdb_offloaded()
672 local mac=00:11:22:33:44:55
673 local zmac=00:00:00:00:00:00
675 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $mac self \
676 bridge fdb show dev vxlan0
677 check_err $?
678 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $mac master \
679 bridge fdb show dev vxlan0
680 check_err $?
682 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $zmac self \
683 bridge fdb show dev vxlan0
684 check_err $?
687 check_vxlan_fdb_not_offloaded()
689 local mac=00:11:22:33:44:55
690 local zmac=00:00:00:00:00:00
692 bridge fdb show dev vxlan0 | grep $mac | grep -q self
693 check_err $?
694 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb $mac self \
695 bridge fdb show dev vxlan0
696 check_err $?
698 bridge fdb show dev vxlan0 | grep $zmac | grep -q self
699 check_err $?
700 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb $zmac self \
701 bridge fdb show dev vxlan0
702 check_err $?
705 check_bridge_fdb_not_offloaded()
707 local mac=00:11:22:33:44:55
708 local zmac=00:00:00:00:00:00
710 bridge fdb show dev vxlan0 | grep $mac | grep -q master
711 check_err $?
712 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb $mac master \
713 bridge fdb show dev vxlan0
714 check_err $?
717 __offload_indication_join_vxlan_first()
719 local vid=$1; shift
721 local mac=00:11:22:33:44:55
722 local zmac=00:00:00:00:00:00
724 bridge fdb append $zmac dev vxlan0 self dst 198.51.100.2
726 ip link set dev vxlan0 master br0
727 bridge fdb add dev vxlan0 $mac self master static dst 198.51.100.2
729 RET=0
730 check_vxlan_fdb_not_offloaded
731 ip link set dev $swp1 master br0
732 sleep .1
733 check_fdb_offloaded
734 log_test "offload indication - attach vxlan first"
736 RET=0
737 ip link set dev vxlan0 down
738 check_vxlan_fdb_not_offloaded
739 check_bridge_fdb_not_offloaded
740 log_test "offload indication - set vxlan down"
742 RET=0
743 ip link set dev vxlan0 up
744 sleep .1
745 check_fdb_offloaded
746 log_test "offload indication - set vxlan up"
748 if [[ ! -z $vid ]]; then
749 RET=0
750 bridge vlan del dev vxlan0 vid $vid
751 check_vxlan_fdb_not_offloaded
752 check_bridge_fdb_not_offloaded
753 log_test "offload indication - delete VLAN"
755 RET=0
756 bridge vlan add dev vxlan0 vid $vid
757 check_vxlan_fdb_not_offloaded
758 check_bridge_fdb_not_offloaded
759 log_test "offload indication - add tagged VLAN"
761 RET=0
762 bridge vlan add dev vxlan0 vid $vid pvid untagged
763 sleep .1
764 check_fdb_offloaded
765 log_test "offload indication - add pvid/untagged VLAN"
768 RET=0
769 ip link set dev $swp1 nomaster
770 check_vxlan_fdb_not_offloaded
771 log_test "offload indication - detach port"
774 offload_indication_join_vxlan_first()
776 ip link add dev br0 up type bridge mcast_snooping 0
777 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
778 ttl 20 tos inherit local 198.51.100.1 dstport 4789
780 __offload_indication_join_vxlan_first
782 ip link del dev vxlan0
783 ip link del dev br0
786 __offload_indication_join_vxlan_last()
788 local zmac=00:00:00:00:00:00
790 RET=0
792 bridge fdb append $zmac dev vxlan0 self dst 198.51.100.2
794 ip link set dev $swp1 master br0
796 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb $zmac self \
797 bridge fdb show dev vxlan0
798 check_err $?
800 ip link set dev vxlan0 master br0
802 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $zmac self \
803 bridge fdb show dev vxlan0
804 check_err $?
806 log_test "offload indication - attach vxlan last"
809 offload_indication_join_vxlan_last()
811 ip link add dev br0 up type bridge mcast_snooping 0
812 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
813 ttl 20 tos inherit local 198.51.100.1 dstport 4789
815 __offload_indication_join_vxlan_last
817 ip link del dev vxlan0
818 ip link del dev br0
821 offload_indication_test()
823 offload_indication_setup_create
824 offload_indication_fdb_test
825 offload_indication_decap_route_test
826 offload_indication_setup_destroy
828 log_info "offload indication - replay & cleanup"
829 offload_indication_join_vxlan_first
830 offload_indication_join_vxlan_last
833 sanitization_vlan_aware_test()
835 RET=0
837 ip link add dev br0 type bridge mcast_snooping 0 vlan_filtering 1
839 ip link add name vxlan10 up master br0 type vxlan id 10 nolearning \
840 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
842 ip link add name vxlan20 up master br0 type vxlan id 20 nolearning \
843 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
845 # Test that when each VNI is mapped to a different VLAN we can enslave
846 # a port to the bridge
847 bridge vlan add vid 10 dev vxlan10 pvid untagged
848 bridge vlan add vid 20 dev vxlan20 pvid untagged
850 ip link set dev $swp1 master br0
851 check_err $?
853 log_test "vlan-aware - enslavement to vlan-aware bridge"
855 # Try to map both VNIs to the same VLAN and make sure configuration
856 # fails
857 RET=0
859 bridge vlan add vid 10 dev vxlan20 pvid untagged &> /dev/null
860 check_fail $?
862 log_test "vlan-aware - two vnis mapped to the same vlan"
864 # Test that enslavement of a port to a bridge fails when two VNIs
865 # are mapped to the same VLAN
866 RET=0
868 ip link set dev $swp1 nomaster
870 bridge vlan del vid 20 dev vxlan20 pvid untagged
871 bridge vlan add vid 10 dev vxlan20 pvid untagged
873 ip link set dev $swp1 master br0 &> /dev/null
874 check_fail $?
876 log_test "vlan-aware - failed enslavement to vlan-aware bridge"
878 bridge vlan del vid 10 dev vxlan20
879 bridge vlan add vid 20 dev vxlan20 pvid untagged
881 # Test that when two VXLAN tunnels with conflicting configurations
882 # (i.e., different TTL) are enslaved to the same VLAN-aware bridge,
883 # then the enslavement of a port to the bridge is denied.
885 # Use the offload indication of the local route to ensure the VXLAN
886 # configuration was correctly rollbacked.
887 ip address add 198.51.100.1/32 dev lo
889 ip link set dev vxlan10 type vxlan ttl 10
890 ip link set dev $swp1 master br0 &> /dev/null
891 check_fail $?
893 busywait "$TIMEOUT" not wait_for_offload \
894 ip route show table local 198.51.100.1
895 check_err $?
897 log_test "vlan-aware - failed enslavement to bridge due to conflict"
899 ip link set dev vxlan10 type vxlan ttl 20
900 ip address del 198.51.100.1/32 dev lo
902 ip link del dev vxlan20
903 ip link del dev vxlan10
904 ip link del dev br0
907 offload_indication_vlan_aware_setup_create()
909 # Create a simple setup with two VxLAN devices and a single VLAN-aware
910 # bridge
911 ip link add name br0 up type bridge mcast_snooping 0 vlan_filtering 1 \
912 vlan_default_pvid 0
914 ip link set dev $swp1 master br0
916 bridge vlan add vid 10 dev $swp1
917 bridge vlan add vid 20 dev $swp1
919 ip address add 198.51.100.1/32 dev lo
921 ip link add name vxlan10 up master br0 type vxlan id 10 nolearning \
922 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
923 ip link add name vxlan20 up master br0 type vxlan id 20 nolearning \
924 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
926 bridge vlan add vid 10 dev vxlan10 pvid untagged
927 bridge vlan add vid 20 dev vxlan20 pvid untagged
930 offload_indication_vlan_aware_setup_destroy()
932 bridge vlan del vid 20 dev vxlan20
933 bridge vlan del vid 10 dev vxlan10
935 ip link del dev vxlan20
936 ip link del dev vxlan10
938 ip address del 198.51.100.1/32 dev lo
940 bridge vlan del vid 20 dev $swp1
941 bridge vlan del vid 10 dev $swp1
943 ip link set dev $swp1 nomaster
945 ip link del dev br0
948 offload_indication_vlan_aware_fdb_test()
950 RET=0
952 log_info "vxlan entry offload indication - vlan-aware"
954 bridge fdb add de:ad:be:ef:13:37 dev vxlan10 self master static \
955 dst 198.51.100.2 vlan 10
957 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
958 de:ad:be:ef:13:37 self bridge fdb show brport vxlan10
959 check_err $?
960 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
961 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan10
962 check_err $?
964 log_test "vxlan entry offload indication - initial state"
966 # Remove FDB entry from the bridge driver and check that corresponding
967 # entry in the VxLAN driver is not marked as offloaded
968 RET=0
970 bridge fdb del de:ad:be:ef:13:37 dev vxlan10 master vlan 10
971 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb \
972 de:ad:be:ef:13:37 self bridge fdb show brport vxlan10
973 check_err $?
975 log_test "vxlan entry offload indication - after removal from bridge"
977 # Add the FDB entry back to the bridge driver and make sure it is
978 # marked as offloaded in both drivers
979 RET=0
981 bridge fdb add de:ad:be:ef:13:37 dev vxlan10 master static vlan 10
982 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
983 de:ad:be:ef:13:37 self bridge fdb show brport vxlan10
984 check_err $?
985 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
986 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan10
987 check_err $?
989 log_test "vxlan entry offload indication - after re-add to bridge"
991 # Remove FDB entry from the VxLAN driver and check that corresponding
992 # entry in the bridge driver is not marked as offloaded
993 RET=0
995 bridge fdb del de:ad:be:ef:13:37 dev vxlan10 self
996 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb \
997 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan10
998 check_err $?
1000 log_test "vxlan entry offload indication - after removal from vxlan"
1002 # Add the FDB entry back to the VxLAN driver and make sure it is
1003 # marked as offloaded in both drivers
1004 RET=0
1006 bridge fdb add de:ad:be:ef:13:37 dev vxlan10 self dst 198.51.100.2
1007 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
1008 de:ad:be:ef:13:37 self bridge fdb show brport vxlan10
1009 check_err $?
1010 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb \
1011 de:ad:be:ef:13:37 self -v bridge fdb show brport vxlan10
1012 check_err $?
1014 log_test "vxlan entry offload indication - after re-add to vxlan"
1016 bridge fdb del de:ad:be:ef:13:37 dev vxlan10 self master vlan 10
1019 offload_indication_vlan_aware_decap_route_test()
1021 RET=0
1023 busywait "$TIMEOUT" wait_for_offload \
1024 ip route show table local 198.51.100.1
1025 check_err $?
1027 # Toggle PVID flag on one VxLAN device and make sure route is still
1028 # marked as offloaded
1029 bridge vlan add vid 10 dev vxlan10 untagged
1031 busywait "$TIMEOUT" wait_for_offload \
1032 ip route show table local 198.51.100.1
1033 check_err $?
1035 # Toggle PVID flag on second VxLAN device and make sure route is no
1036 # longer marked as offloaded
1037 bridge vlan add vid 20 dev vxlan20 untagged
1039 busywait "$TIMEOUT" not wait_for_offload \
1040 ip route show table local 198.51.100.1
1041 check_err $?
1043 # Toggle PVID flag back and make sure route is marked as offloaded
1044 bridge vlan add vid 10 dev vxlan10 pvid untagged
1045 bridge vlan add vid 20 dev vxlan20 pvid untagged
1047 busywait "$TIMEOUT" wait_for_offload ip route show table local 198.51.100.1
1048 check_err $?
1050 log_test "vxlan decap route - vni map/unmap"
1053 offload_indication_vlan_aware_join_vxlan_first()
1055 ip link add dev br0 up type bridge mcast_snooping 0 \
1056 vlan_filtering 1 vlan_default_pvid 1
1057 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
1058 ttl 20 tos inherit local 198.51.100.1 dstport 4789
1060 __offload_indication_join_vxlan_first 1
1062 ip link del dev vxlan0
1063 ip link del dev br0
1066 offload_indication_vlan_aware_join_vxlan_last()
1068 ip link add dev br0 up type bridge mcast_snooping 0 \
1069 vlan_filtering 1 vlan_default_pvid 1
1070 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
1071 ttl 20 tos inherit local 198.51.100.1 dstport 4789
1073 __offload_indication_join_vxlan_last
1075 ip link del dev vxlan0
1076 ip link del dev br0
1079 offload_indication_vlan_aware_l3vni_test()
1081 local zmac=00:00:00:00:00:00
1083 RET=0
1085 sysctl_set net.ipv6.conf.default.disable_ipv6 1
1086 ip link add dev br0 up type bridge mcast_snooping 0 \
1087 vlan_filtering 1 vlan_default_pvid 0
1088 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
1089 ttl 20 tos inherit local 198.51.100.1 dstport 4789
1091 ip link set dev $swp1 master br0
1093 # The test will use the offload indication on the FDB entry to
1094 # understand if the tunnel is offloaded or not
1095 bridge fdb append $zmac dev vxlan0 self dst 192.0.2.1
1097 ip link set dev vxlan0 master br0
1098 bridge vlan add dev vxlan0 vid 10 pvid untagged
1100 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $zmac self \
1101 bridge fdb show brport vxlan0
1102 check_err $? "vxlan tunnel not offloaded when should"
1104 # Configure a VLAN interface and make sure tunnel is offloaded
1105 ip link add link br0 name br10 up type vlan id 10
1106 sysctl_set net.ipv6.conf.br10.disable_ipv6 0
1107 ip -6 address add 2001:db8:1::1/64 dev br10
1108 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $zmac self \
1109 bridge fdb show brport vxlan0
1110 check_err $? "vxlan tunnel not offloaded when should"
1112 # Unlink the VXLAN device, make sure tunnel is no longer offloaded,
1113 # then add it back to the bridge and make sure it is offloaded
1114 ip link set dev vxlan0 nomaster
1115 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb $zmac self \
1116 bridge fdb show brport vxlan0
1117 check_err $? "vxlan tunnel offloaded after unlinked from bridge"
1119 ip link set dev vxlan0 master br0
1120 busywait "$TIMEOUT" not wait_for_offload grep_bridge_fdb $zmac self \
1121 bridge fdb show brport vxlan0
1122 check_err $? "vxlan tunnel offloaded despite no matching vid"
1124 bridge vlan add dev vxlan0 vid 10 pvid untagged
1125 busywait "$TIMEOUT" wait_for_offload grep_bridge_fdb $zmac self \
1126 bridge fdb show brport vxlan0
1127 check_err $? "vxlan tunnel not offloaded after adding vid"
1129 log_test "vxlan - l3 vni"
1131 ip link del dev vxlan0
1132 ip link del dev br0
1133 sysctl_restore net.ipv6.conf.default.disable_ipv6
1136 offload_indication_vlan_aware_test()
1138 offload_indication_vlan_aware_setup_create
1139 offload_indication_vlan_aware_fdb_test
1140 offload_indication_vlan_aware_decap_route_test
1141 offload_indication_vlan_aware_setup_destroy
1143 log_info "offload indication - replay & cleanup - vlan aware"
1144 offload_indication_vlan_aware_join_vxlan_first
1145 offload_indication_vlan_aware_join_vxlan_last
1146 offload_indication_vlan_aware_l3vni_test
1149 trap cleanup EXIT
1151 setup_prepare
1152 setup_wait
1154 tests_run
1156 exit $EXIT_STATUS