staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / drivers / net / mlxsw / vxlan.sh
blobae6146ec5afd2a68f99803eb59fc590d18399913
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 source $lib_dir/lib.sh
14 setup_prepare()
16 swp1=${NETIFS[p1]}
17 swp2=${NETIFS[p2]}
19 ip link set dev $swp1 up
20 ip link set dev $swp2 up
23 cleanup()
25 pre_cleanup
27 ip link set dev $swp2 down
28 ip link set dev $swp1 down
31 sanitization_single_dev_test_pass()
33 ip link set dev $swp1 master br0
34 check_err $?
35 ip link set dev vxlan0 master br0
36 check_err $?
38 ip link set dev $swp1 nomaster
40 ip link set dev $swp1 master br0
41 check_err $?
44 sanitization_single_dev_test_fail()
46 ip link set dev $swp1 master br0
47 check_err $?
48 ip link set dev vxlan0 master br0 &> /dev/null
49 check_fail $?
51 ip link set dev $swp1 nomaster
53 ip link set dev vxlan0 master br0
54 check_err $?
55 ip link set dev $swp1 master br0 &> /dev/null
56 check_fail $?
59 sanitization_single_dev_valid_test()
61 RET=0
63 ip link add dev br0 type bridge mcast_snooping 0
65 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
66 ttl 20 tos inherit local 198.51.100.1 dstport 4789
68 sanitization_single_dev_test_pass
70 ip link del dev vxlan0
71 ip link del dev br0
73 log_test "vxlan device - valid configuration"
76 sanitization_single_dev_vlan_aware_test()
78 RET=0
80 ip link add dev br0 type bridge mcast_snooping 0 vlan_filtering 1
82 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
83 ttl 20 tos inherit local 198.51.100.1 dstport 4789
85 sanitization_single_dev_test_pass
87 ip link del dev vxlan0
88 ip link del dev br0
90 log_test "vxlan device with a vlan-aware bridge"
93 sanitization_single_dev_mcast_enabled_test()
95 RET=0
97 ip link add dev br0 type bridge
99 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
100 ttl 20 tos inherit local 198.51.100.1 dstport 4789
102 sanitization_single_dev_test_fail
104 ip link del dev vxlan0
105 ip link del dev br0
107 log_test "vxlan device with a multicast enabled bridge"
110 sanitization_single_dev_mcast_group_test()
112 RET=0
114 ip link add dev br0 type bridge mcast_snooping 0
116 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
117 ttl 20 tos inherit local 198.51.100.1 dstport 4789 \
118 dev $swp2 group 239.0.0.1
120 sanitization_single_dev_test_fail
122 ip link del dev vxlan0
123 ip link del dev br0
125 log_test "vxlan device with a multicast group"
128 sanitization_single_dev_no_local_ip_test()
130 RET=0
132 ip link add dev br0 type bridge mcast_snooping 0
134 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
135 ttl 20 tos inherit dstport 4789
137 sanitization_single_dev_test_fail
139 ip link del dev vxlan0
140 ip link del dev br0
142 log_test "vxlan device with no local ip"
145 sanitization_single_dev_local_ipv6_test()
147 RET=0
149 ip link add dev br0 type bridge mcast_snooping 0
151 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
152 ttl 20 tos inherit local 2001:db8::1 dstport 4789
154 sanitization_single_dev_test_fail
156 ip link del dev vxlan0
157 ip link del dev br0
159 log_test "vxlan device with local ipv6 address"
162 sanitization_single_dev_learning_enabled_test()
164 RET=0
166 ip link add dev br0 type bridge mcast_snooping 0
168 ip link add name vxlan0 up type vxlan id 10 learning noudpcsum \
169 ttl 20 tos inherit local 198.51.100.1 dstport 4789
171 sanitization_single_dev_test_pass
173 ip link del dev vxlan0
174 ip link del dev br0
176 log_test "vxlan device with learning enabled"
179 sanitization_single_dev_local_interface_test()
181 RET=0
183 ip link add dev br0 type bridge mcast_snooping 0
185 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
186 ttl 20 tos inherit local 198.51.100.1 dstport 4789 dev $swp2
188 sanitization_single_dev_test_fail
190 ip link del dev vxlan0
191 ip link del dev br0
193 log_test "vxlan device with local interface"
196 sanitization_single_dev_port_range_test()
198 RET=0
200 ip link add dev br0 type bridge mcast_snooping 0
202 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
203 ttl 20 tos inherit local 198.51.100.1 dstport 4789 \
204 srcport 4000 5000
206 sanitization_single_dev_test_fail
208 ip link del dev vxlan0
209 ip link del dev br0
211 log_test "vxlan device with udp source port range"
214 sanitization_single_dev_tos_static_test()
216 RET=0
218 ip link add dev br0 type bridge mcast_snooping 0
220 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
221 ttl 20 tos 20 local 198.51.100.1 dstport 4789
223 sanitization_single_dev_test_fail
225 ip link del dev vxlan0
226 ip link del dev br0
228 log_test "vxlan device with static tos"
231 sanitization_single_dev_ttl_inherit_test()
233 RET=0
235 ip link add dev br0 type bridge mcast_snooping 0
237 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
238 ttl inherit tos inherit local 198.51.100.1 dstport 4789
240 sanitization_single_dev_test_fail
242 ip link del dev vxlan0
243 ip link del dev br0
245 log_test "vxlan device with inherit ttl"
248 sanitization_single_dev_udp_checksum_test()
250 RET=0
252 ip link add dev br0 type bridge mcast_snooping 0
254 ip link add name vxlan0 up type vxlan id 10 nolearning udpcsum \
255 ttl 20 tos inherit local 198.51.100.1 dstport 4789
257 sanitization_single_dev_test_fail
259 ip link del dev vxlan0
260 ip link del dev br0
262 log_test "vxlan device with udp checksum"
265 sanitization_single_dev_test()
267 # These tests make sure that we correctly sanitize VxLAN device
268 # configurations we do not support
269 sanitization_single_dev_valid_test
270 sanitization_single_dev_vlan_aware_test
271 sanitization_single_dev_mcast_enabled_test
272 sanitization_single_dev_mcast_group_test
273 sanitization_single_dev_no_local_ip_test
274 sanitization_single_dev_local_ipv6_test
275 sanitization_single_dev_learning_enabled_test
276 sanitization_single_dev_local_interface_test
277 sanitization_single_dev_port_range_test
278 sanitization_single_dev_tos_static_test
279 sanitization_single_dev_ttl_inherit_test
280 sanitization_single_dev_udp_checksum_test
283 sanitization_multi_devs_test_pass()
285 ip link set dev $swp1 master br0
286 check_err $?
287 ip link set dev vxlan0 master br0
288 check_err $?
289 ip link set dev $swp2 master br1
290 check_err $?
291 ip link set dev vxlan1 master br1
292 check_err $?
294 ip link set dev $swp2 nomaster
295 ip link set dev $swp1 nomaster
297 ip link set dev $swp1 master br0
298 check_err $?
299 ip link set dev $swp2 master br1
300 check_err $?
303 sanitization_multi_devs_test_fail()
305 ip link set dev $swp1 master br0
306 check_err $?
307 ip link set dev vxlan0 master br0
308 check_err $?
309 ip link set dev $swp2 master br1
310 check_err $?
311 ip link set dev vxlan1 master br1 &> /dev/null
312 check_fail $?
314 ip link set dev $swp2 nomaster
315 ip link set dev $swp1 nomaster
317 ip link set dev vxlan1 master br1
318 check_err $?
319 ip link set dev $swp1 master br0
320 check_err $?
321 ip link set dev $swp2 master br1 &> /dev/null
322 check_fail $?
325 sanitization_multi_devs_valid_test()
327 RET=0
329 ip link add dev br0 type bridge mcast_snooping 0
330 ip link add dev br1 type bridge mcast_snooping 0
332 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
333 ttl 20 tos inherit local 198.51.100.1 dstport 4789
334 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
335 ttl 20 tos inherit local 198.51.100.1 dstport 4789
337 sanitization_multi_devs_test_pass
339 ip link del dev vxlan1
340 ip link del dev vxlan0
341 ip link del dev br1
342 ip link del dev br0
344 log_test "multiple vxlan devices - valid configuration"
347 sanitization_multi_devs_ttl_test()
349 RET=0
351 ip link add dev br0 type bridge mcast_snooping 0
352 ip link add dev br1 type bridge mcast_snooping 0
354 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
355 ttl 20 tos inherit local 198.51.100.1 dstport 4789
356 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
357 ttl 40 tos inherit local 198.51.100.1 dstport 4789
359 sanitization_multi_devs_test_fail
361 ip link del dev vxlan1
362 ip link del dev vxlan0
363 ip link del dev br1
364 ip link del dev br0
366 log_test "multiple vxlan devices with different ttl"
369 sanitization_multi_devs_udp_dstport_test()
371 RET=0
373 ip link add dev br0 type bridge mcast_snooping 0
374 ip link add dev br1 type bridge mcast_snooping 0
376 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
377 ttl 20 tos inherit local 198.51.100.1 dstport 4789
378 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
379 ttl 20 tos inherit local 198.51.100.1 dstport 5789
381 sanitization_multi_devs_test_fail
383 ip link del dev vxlan1
384 ip link del dev vxlan0
385 ip link del dev br1
386 ip link del dev br0
388 log_test "multiple vxlan devices with different udp destination port"
391 sanitization_multi_devs_local_ip_test()
393 RET=0
395 ip link add dev br0 type bridge mcast_snooping 0
396 ip link add dev br1 type bridge mcast_snooping 0
398 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
399 ttl 20 tos inherit local 198.51.100.1 dstport 4789
400 ip link add name vxlan1 up type vxlan id 20 nolearning noudpcsum \
401 ttl 20 tos inherit local 198.51.100.2 dstport 4789
403 sanitization_multi_devs_test_fail
405 ip link del dev vxlan1
406 ip link del dev vxlan0
407 ip link del dev br1
408 ip link del dev br0
410 log_test "multiple vxlan devices with different local ip"
413 sanitization_multi_devs_test()
415 # The device has a single VTEP, which means all the VxLAN devices
416 # we offload must share certain properties such as source IP and
417 # UDP destination port. These tests make sure that we forbid
418 # configurations that violate this limitation
419 sanitization_multi_devs_valid_test
420 sanitization_multi_devs_ttl_test
421 sanitization_multi_devs_udp_dstport_test
422 sanitization_multi_devs_local_ip_test
425 sanitization_test()
427 sanitization_single_dev_test
428 sanitization_multi_devs_test
431 offload_indication_setup_create()
433 # Create a simple setup with two bridges, each with a VxLAN device
434 # and one local port
435 ip link add name br0 up type bridge mcast_snooping 0
436 ip link add name br1 up type bridge mcast_snooping 0
438 ip link set dev $swp1 master br0
439 ip link set dev $swp2 master br1
441 ip address add 198.51.100.1/32 dev lo
443 ip link add name vxlan0 up master br0 type vxlan id 10 nolearning \
444 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
445 ip link add name vxlan1 up master br1 type vxlan id 20 nolearning \
446 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
449 offload_indication_setup_destroy()
451 ip link del dev vxlan1
452 ip link del dev vxlan0
454 ip address del 198.51.100.1/32 dev lo
456 ip link set dev $swp2 nomaster
457 ip link set dev $swp1 nomaster
459 ip link del dev br1
460 ip link del dev br0
463 offload_indication_fdb_flood_test()
465 RET=0
467 bridge fdb append 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.2
469 bridge fdb show brport vxlan0 | grep 00:00:00:00:00:00 \
470 | grep -q offload
471 check_err $?
473 bridge fdb del 00:00:00:00:00:00 dev vxlan0 self
475 log_test "vxlan flood entry offload indication"
478 offload_indication_fdb_bridge_test()
480 RET=0
482 bridge fdb add de:ad:be:ef:13:37 dev vxlan0 self master static \
483 dst 198.51.100.2
485 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep self \
486 | grep -q offload
487 check_err $?
488 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep -v self \
489 | grep -q offload
490 check_err $?
492 log_test "vxlan entry offload indication - initial state"
494 # Remove FDB entry from the bridge driver and check that corresponding
495 # entry in the VxLAN driver is not marked as offloaded
496 RET=0
498 bridge fdb del de:ad:be:ef:13:37 dev vxlan0 master
499 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep self \
500 | grep -q offload
501 check_fail $?
503 log_test "vxlan entry offload indication - after removal from bridge"
505 # Add the FDB entry back to the bridge driver and make sure it is
506 # marked as offloaded in both drivers
507 RET=0
509 bridge fdb add de:ad:be:ef:13:37 dev vxlan0 master static
510 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep self \
511 | grep -q offload
512 check_err $?
513 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep -v self \
514 | grep -q offload
515 check_err $?
517 log_test "vxlan entry offload indication - after re-add to bridge"
519 # Remove FDB entry from the VxLAN driver and check that corresponding
520 # entry in the bridge driver is not marked as offloaded
521 RET=0
523 bridge fdb del de:ad:be:ef:13:37 dev vxlan0 self
524 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep -v self \
525 | grep -q offload
526 check_fail $?
528 log_test "vxlan entry offload indication - after removal from vxlan"
530 # Add the FDB entry back to the VxLAN driver and make sure it is
531 # marked as offloaded in both drivers
532 RET=0
534 bridge fdb add de:ad:be:ef:13:37 dev vxlan0 self dst 198.51.100.2
535 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep self \
536 | grep -q offload
537 check_err $?
538 bridge fdb show brport vxlan0 | grep de:ad:be:ef:13:37 | grep -v self \
539 | grep -q offload
540 check_err $?
542 log_test "vxlan entry offload indication - after re-add to vxlan"
544 bridge fdb del de:ad:be:ef:13:37 dev vxlan0 self master
547 offload_indication_fdb_test()
549 offload_indication_fdb_flood_test
550 offload_indication_fdb_bridge_test
553 offload_indication_decap_route_test()
555 RET=0
557 ip route show table local | grep 198.51.100.1 | grep -q offload
558 check_err $?
560 ip link set dev vxlan0 down
561 ip route show table local | grep 198.51.100.1 | grep -q offload
562 check_err $?
564 ip link set dev vxlan1 down
565 ip route show table local | grep 198.51.100.1 | grep -q offload
566 check_fail $?
568 log_test "vxlan decap route - vxlan device down"
570 RET=0
572 ip link set dev vxlan1 up
573 ip route show table local | grep 198.51.100.1 | grep -q offload
574 check_err $?
576 ip link set dev vxlan0 up
577 ip route show table local | grep 198.51.100.1 | grep -q offload
578 check_err $?
580 log_test "vxlan decap route - vxlan device up"
582 RET=0
584 ip address delete 198.51.100.1/32 dev lo
585 ip route show table local | grep 198.51.100.1 | grep -q offload
586 check_fail $?
588 ip address add 198.51.100.1/32 dev lo
589 ip route show table local | grep 198.51.100.1 | grep -q offload
590 check_err $?
592 log_test "vxlan decap route - add local route"
594 RET=0
596 ip link set dev $swp1 nomaster
597 ip route show table local | grep 198.51.100.1 | grep -q offload
598 check_err $?
600 ip link set dev $swp2 nomaster
601 ip route show table local | grep 198.51.100.1 | grep -q offload
602 check_fail $?
604 ip link set dev $swp1 master br0
605 ip link set dev $swp2 master br1
606 ip route show table local | grep 198.51.100.1 | grep -q offload
607 check_err $?
609 log_test "vxlan decap route - local ports enslavement"
611 RET=0
613 ip link del dev br0
614 ip route show table local | grep 198.51.100.1 | grep -q offload
615 check_err $?
617 ip link del dev br1
618 ip route show table local | grep 198.51.100.1 | grep -q offload
619 check_fail $?
621 log_test "vxlan decap route - bridge device deletion"
623 RET=0
625 ip link add name br0 up type bridge mcast_snooping 0
626 ip link add name br1 up type bridge mcast_snooping 0
627 ip link set dev $swp1 master br0
628 ip link set dev $swp2 master br1
629 ip link set dev vxlan0 master br0
630 ip link set dev vxlan1 master br1
631 ip route show table local | grep 198.51.100.1 | grep -q offload
632 check_err $?
634 ip link del dev vxlan0
635 ip route show table local | grep 198.51.100.1 | grep -q offload
636 check_err $?
638 ip link del dev vxlan1
639 ip route show table local | grep 198.51.100.1 | grep -q offload
640 check_fail $?
642 log_test "vxlan decap route - vxlan device deletion"
644 ip link add name vxlan0 up master br0 type vxlan id 10 nolearning \
645 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
646 ip link add name vxlan1 up master br1 type vxlan id 20 nolearning \
647 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
650 check_fdb_offloaded()
652 local mac=00:11:22:33:44:55
653 local zmac=00:00:00:00:00:00
655 bridge fdb show dev vxlan0 | grep $mac | grep self | grep -q offload
656 check_err $?
657 bridge fdb show dev vxlan0 | grep $mac | grep master | grep -q offload
658 check_err $?
660 bridge fdb show dev vxlan0 | grep $zmac | grep self | grep -q offload
661 check_err $?
664 check_vxlan_fdb_not_offloaded()
666 local mac=00:11:22:33:44:55
667 local zmac=00:00:00:00:00:00
669 bridge fdb show dev vxlan0 | grep $mac | grep -q self
670 check_err $?
671 bridge fdb show dev vxlan0 | grep $mac | grep self | grep -q offload
672 check_fail $?
674 bridge fdb show dev vxlan0 | grep $zmac | grep -q self
675 check_err $?
676 bridge fdb show dev vxlan0 | grep $zmac | grep self | grep -q offload
677 check_fail $?
680 check_bridge_fdb_not_offloaded()
682 local mac=00:11:22:33:44:55
683 local zmac=00:00:00:00:00:00
685 bridge fdb show dev vxlan0 | grep $mac | grep -q master
686 check_err $?
687 bridge fdb show dev vxlan0 | grep $mac | grep master | grep -q offload
688 check_fail $?
691 __offload_indication_join_vxlan_first()
693 local vid=$1; shift
695 local mac=00:11:22:33:44:55
696 local zmac=00:00:00:00:00:00
698 bridge fdb append $zmac dev vxlan0 self dst 198.51.100.2
700 ip link set dev vxlan0 master br0
701 bridge fdb add dev vxlan0 $mac self master static dst 198.51.100.2
703 RET=0
704 check_vxlan_fdb_not_offloaded
705 ip link set dev $swp1 master br0
706 sleep .1
707 check_fdb_offloaded
708 log_test "offload indication - attach vxlan first"
710 RET=0
711 ip link set dev vxlan0 down
712 check_vxlan_fdb_not_offloaded
713 check_bridge_fdb_not_offloaded
714 log_test "offload indication - set vxlan down"
716 RET=0
717 ip link set dev vxlan0 up
718 sleep .1
719 check_fdb_offloaded
720 log_test "offload indication - set vxlan up"
722 if [[ ! -z $vid ]]; then
723 RET=0
724 bridge vlan del dev vxlan0 vid $vid
725 check_vxlan_fdb_not_offloaded
726 check_bridge_fdb_not_offloaded
727 log_test "offload indication - delete VLAN"
729 RET=0
730 bridge vlan add dev vxlan0 vid $vid
731 check_vxlan_fdb_not_offloaded
732 check_bridge_fdb_not_offloaded
733 log_test "offload indication - add tagged VLAN"
735 RET=0
736 bridge vlan add dev vxlan0 vid $vid pvid untagged
737 sleep .1
738 check_fdb_offloaded
739 log_test "offload indication - add pvid/untagged VLAN"
742 RET=0
743 ip link set dev $swp1 nomaster
744 check_vxlan_fdb_not_offloaded
745 log_test "offload indication - detach port"
748 offload_indication_join_vxlan_first()
750 ip link add dev br0 up type bridge mcast_snooping 0
751 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
752 ttl 20 tos inherit local 198.51.100.1 dstport 4789
754 __offload_indication_join_vxlan_first
756 ip link del dev vxlan0
757 ip link del dev br0
760 __offload_indication_join_vxlan_last()
762 local zmac=00:00:00:00:00:00
764 RET=0
766 bridge fdb append $zmac dev vxlan0 self dst 198.51.100.2
768 ip link set dev $swp1 master br0
770 bridge fdb show dev vxlan0 | grep $zmac | grep self | grep -q offload
771 check_fail $?
773 ip link set dev vxlan0 master br0
775 bridge fdb show dev vxlan0 | grep $zmac | grep self | grep -q offload
776 check_err $?
778 log_test "offload indication - attach vxlan last"
781 offload_indication_join_vxlan_last()
783 ip link add dev br0 up type bridge mcast_snooping 0
784 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
785 ttl 20 tos inherit local 198.51.100.1 dstport 4789
787 __offload_indication_join_vxlan_last
789 ip link del dev vxlan0
790 ip link del dev br0
793 offload_indication_test()
795 offload_indication_setup_create
796 offload_indication_fdb_test
797 offload_indication_decap_route_test
798 offload_indication_setup_destroy
800 log_info "offload indication - replay & cleanup"
801 offload_indication_join_vxlan_first
802 offload_indication_join_vxlan_last
805 sanitization_vlan_aware_test()
807 RET=0
809 ip link add dev br0 type bridge mcast_snooping 0 vlan_filtering 1
811 ip link add name vxlan10 up master br0 type vxlan id 10 nolearning \
812 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
814 ip link add name vxlan20 up master br0 type vxlan id 20 nolearning \
815 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
817 # Test that when each VNI is mapped to a different VLAN we can enslave
818 # a port to the bridge
819 bridge vlan add vid 10 dev vxlan10 pvid untagged
820 bridge vlan add vid 20 dev vxlan20 pvid untagged
822 ip link set dev $swp1 master br0
823 check_err $?
825 log_test "vlan-aware - enslavement to vlan-aware bridge"
827 # Try to map both VNIs to the same VLAN and make sure configuration
828 # fails
829 RET=0
831 bridge vlan add vid 10 dev vxlan20 pvid untagged &> /dev/null
832 check_fail $?
834 log_test "vlan-aware - two vnis mapped to the same vlan"
836 # Test that enslavement of a port to a bridge fails when two VNIs
837 # are mapped to the same VLAN
838 RET=0
840 ip link set dev $swp1 nomaster
842 bridge vlan del vid 20 dev vxlan20 pvid untagged
843 bridge vlan add vid 10 dev vxlan20 pvid untagged
845 ip link set dev $swp1 master br0 &> /dev/null
846 check_fail $?
848 log_test "vlan-aware - failed enslavement to vlan-aware bridge"
850 bridge vlan del vid 10 dev vxlan20
851 bridge vlan add vid 20 dev vxlan20 pvid untagged
853 # Test that offloading of an unsupported tunnel fails when it is
854 # triggered by addition of VLAN to a local port
855 RET=0
857 # TOS must be set to inherit
858 ip link set dev vxlan10 type vxlan tos 42
860 ip link set dev $swp1 master br0
861 bridge vlan add vid 10 dev $swp1 &> /dev/null
862 check_fail $?
864 log_test "vlan-aware - failed vlan addition to a local port"
866 ip link set dev vxlan10 type vxlan tos inherit
868 ip link del dev vxlan20
869 ip link del dev vxlan10
870 ip link del dev br0
873 offload_indication_vlan_aware_setup_create()
875 # Create a simple setup with two VxLAN devices and a single VLAN-aware
876 # bridge
877 ip link add name br0 up type bridge mcast_snooping 0 vlan_filtering 1 \
878 vlan_default_pvid 0
880 ip link set dev $swp1 master br0
882 bridge vlan add vid 10 dev $swp1
883 bridge vlan add vid 20 dev $swp1
885 ip address add 198.51.100.1/32 dev lo
887 ip link add name vxlan10 up master br0 type vxlan id 10 nolearning \
888 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
889 ip link add name vxlan20 up master br0 type vxlan id 20 nolearning \
890 noudpcsum ttl 20 tos inherit local 198.51.100.1 dstport 4789
892 bridge vlan add vid 10 dev vxlan10 pvid untagged
893 bridge vlan add vid 20 dev vxlan20 pvid untagged
896 offload_indication_vlan_aware_setup_destroy()
898 bridge vlan del vid 20 dev vxlan20
899 bridge vlan del vid 10 dev vxlan10
901 ip link del dev vxlan20
902 ip link del dev vxlan10
904 ip address del 198.51.100.1/32 dev lo
906 bridge vlan del vid 20 dev $swp1
907 bridge vlan del vid 10 dev $swp1
909 ip link set dev $swp1 nomaster
911 ip link del dev br0
914 offload_indication_vlan_aware_fdb_test()
916 RET=0
918 log_info "vxlan entry offload indication - vlan-aware"
920 bridge fdb add de:ad:be:ef:13:37 dev vxlan10 self master static \
921 dst 198.51.100.2 vlan 10
923 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep self \
924 | grep -q offload
925 check_err $?
926 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep -v self \
927 | grep -q offload
928 check_err $?
930 log_test "vxlan entry offload indication - initial state"
932 # Remove FDB entry from the bridge driver and check that corresponding
933 # entry in the VxLAN driver is not marked as offloaded
934 RET=0
936 bridge fdb del de:ad:be:ef:13:37 dev vxlan10 master vlan 10
937 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep self \
938 | grep -q offload
939 check_fail $?
941 log_test "vxlan entry offload indication - after removal from bridge"
943 # Add the FDB entry back to the bridge driver and make sure it is
944 # marked as offloaded in both drivers
945 RET=0
947 bridge fdb add de:ad:be:ef:13:37 dev vxlan10 master static vlan 10
948 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep self \
949 | grep -q offload
950 check_err $?
951 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep -v self \
952 | grep -q offload
953 check_err $?
955 log_test "vxlan entry offload indication - after re-add to bridge"
957 # Remove FDB entry from the VxLAN driver and check that corresponding
958 # entry in the bridge driver is not marked as offloaded
959 RET=0
961 bridge fdb del de:ad:be:ef:13:37 dev vxlan10 self
962 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep -v self \
963 | grep -q offload
964 check_fail $?
966 log_test "vxlan entry offload indication - after removal from vxlan"
968 # Add the FDB entry back to the VxLAN driver and make sure it is
969 # marked as offloaded in both drivers
970 RET=0
972 bridge fdb add de:ad:be:ef:13:37 dev vxlan10 self dst 198.51.100.2
973 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep self \
974 | grep -q offload
975 check_err $?
976 bridge fdb show brport vxlan10 | grep de:ad:be:ef:13:37 | grep -v self \
977 | grep -q offload
978 check_err $?
980 log_test "vxlan entry offload indication - after re-add to vxlan"
982 bridge fdb del de:ad:be:ef:13:37 dev vxlan10 self master vlan 10
985 offload_indication_vlan_aware_decap_route_test()
987 RET=0
989 ip route show table local | grep 198.51.100.1 | grep -q offload
990 check_err $?
992 # Toggle PVID flag on one VxLAN device and make sure route is still
993 # marked as offloaded
994 bridge vlan add vid 10 dev vxlan10 untagged
996 ip route show table local | grep 198.51.100.1 | grep -q offload
997 check_err $?
999 # Toggle PVID flag on second VxLAN device and make sure route is no
1000 # longer marked as offloaded
1001 bridge vlan add vid 20 dev vxlan20 untagged
1003 ip route show table local | grep 198.51.100.1 | grep -q offload
1004 check_fail $?
1006 # Toggle PVID flag back and make sure route is marked as offloaded
1007 bridge vlan add vid 10 dev vxlan10 pvid untagged
1008 bridge vlan add vid 20 dev vxlan20 pvid untagged
1010 ip route show table local | grep 198.51.100.1 | grep -q offload
1011 check_err $?
1013 log_test "vxlan decap route - vni map/unmap"
1016 offload_indication_vlan_aware_join_vxlan_first()
1018 ip link add dev br0 up type bridge mcast_snooping 0 \
1019 vlan_filtering 1 vlan_default_pvid 1
1020 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
1021 ttl 20 tos inherit local 198.51.100.1 dstport 4789
1023 __offload_indication_join_vxlan_first 1
1025 ip link del dev vxlan0
1026 ip link del dev br0
1029 offload_indication_vlan_aware_join_vxlan_last()
1031 ip link add dev br0 up type bridge mcast_snooping 0 \
1032 vlan_filtering 1 vlan_default_pvid 1
1033 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
1034 ttl 20 tos inherit local 198.51.100.1 dstport 4789
1036 __offload_indication_join_vxlan_last
1038 ip link del dev vxlan0
1039 ip link del dev br0
1042 offload_indication_vlan_aware_l3vni_test()
1044 local zmac=00:00:00:00:00:00
1046 RET=0
1048 sysctl_set net.ipv6.conf.default.disable_ipv6 1
1049 ip link add dev br0 up type bridge mcast_snooping 0 \
1050 vlan_filtering 1 vlan_default_pvid 0
1051 ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \
1052 ttl 20 tos inherit local 198.51.100.1 dstport 4789
1054 ip link set dev $swp1 master br0
1056 # The test will use the offload indication on the FDB entry to
1057 # understand if the tunnel is offloaded or not
1058 bridge fdb append $zmac dev vxlan0 self dst 192.0.2.1
1060 ip link set dev vxlan0 master br0
1061 bridge vlan add dev vxlan0 vid 10 pvid untagged
1063 # No local port or router port is member in the VLAN, so tunnel should
1064 # not be offloaded
1065 bridge fdb show brport vxlan0 | grep $zmac | grep self \
1066 | grep -q offload
1067 check_fail $? "vxlan tunnel offloaded when should not"
1069 # Configure a VLAN interface and make sure tunnel is offloaded
1070 ip link add link br0 name br10 up type vlan id 10
1071 sysctl_set net.ipv6.conf.br10.disable_ipv6 0
1072 ip -6 address add 2001:db8:1::1/64 dev br10
1073 bridge fdb show brport vxlan0 | grep $zmac | grep self \
1074 | grep -q offload
1075 check_err $? "vxlan tunnel not offloaded when should"
1077 # Unlink the VXLAN device, make sure tunnel is no longer offloaded,
1078 # then add it back to the bridge and make sure it is offloaded
1079 ip link set dev vxlan0 nomaster
1080 bridge fdb show brport vxlan0 | grep $zmac | grep self \
1081 | grep -q offload
1082 check_fail $? "vxlan tunnel offloaded after unlinked from bridge"
1084 ip link set dev vxlan0 master br0
1085 bridge fdb show brport vxlan0 | grep $zmac | grep self \
1086 | grep -q offload
1087 check_fail $? "vxlan tunnel offloaded despite no matching vid"
1089 bridge vlan add dev vxlan0 vid 10 pvid untagged
1090 bridge fdb show brport vxlan0 | grep $zmac | grep self \
1091 | grep -q offload
1092 check_err $? "vxlan tunnel not offloaded after adding vid"
1094 log_test "vxlan - l3 vni"
1096 ip link del dev vxlan0
1097 ip link del dev br0
1098 sysctl_restore net.ipv6.conf.default.disable_ipv6
1101 offload_indication_vlan_aware_test()
1103 offload_indication_vlan_aware_setup_create
1104 offload_indication_vlan_aware_fdb_test
1105 offload_indication_vlan_aware_decap_route_test
1106 offload_indication_vlan_aware_setup_destroy
1108 log_info "offload indication - replay & cleanup - vlan aware"
1109 offload_indication_vlan_aware_join_vxlan_first
1110 offload_indication_vlan_aware_join_vxlan_last
1111 offload_indication_vlan_aware_l3vni_test
1114 trap cleanup EXIT
1116 setup_prepare
1117 setup_wait
1119 tests_run
1121 exit $EXIT_STATUS