forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/tools/testing/selftests/bpf/test_tunnel.sh
....@@ -24,12 +24,12 @@
2424 # Root namespace with metadata-mode tunnel + BPF
2525 # Device names and addresses:
2626 # veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)
27
-# tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200 (overlay)
27
+# tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200, IPv6: 1::22 (overlay)
2828 #
2929 # Namespace at_ns0 with native tunnel
3030 # Device names and addresses:
3131 # veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)
32
-# tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100 (overlay)
32
+# tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100, IPv6: 1::11 (overlay)
3333 #
3434 #
3535 # End-to-end ping packet flow
....@@ -250,7 +250,7 @@
250250 ip addr add dev $DEV 10.1.1.200/24
251251 }
252252
253
-add_ipip6tnl_tunnel()
253
+add_ip6tnl_tunnel()
254254 {
255255 ip netns exec at_ns0 ip addr add ::11/96 dev veth0
256256 ip netns exec at_ns0 ip link set dev veth0 up
....@@ -262,11 +262,13 @@
262262 ip link add dev $DEV_NS type $TYPE \
263263 local ::11 remote ::22
264264 ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
265
+ ip netns exec at_ns0 ip addr add dev $DEV_NS 1::11/96
265266 ip netns exec at_ns0 ip link set dev $DEV_NS up
266267
267268 # root namespace
268269 ip link add dev $DEV type $TYPE external
269270 ip addr add dev $DEV 10.1.1.200/24
271
+ ip addr add dev $DEV 1::22/96
270272 ip link set dev $DEV up
271273 }
272274
....@@ -534,7 +536,7 @@
534536
535537 check $TYPE
536538 config_device
537
- add_ipip6tnl_tunnel
539
+ add_ip6tnl_tunnel
538540 ip link set dev veth1 mtu 1500
539541 attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
540542 # underlay
....@@ -551,6 +553,34 @@
551553 return 1
552554 fi
553555 echo -e ${GREEN}"PASS: $TYPE"${NC}
556
+}
557
+
558
+test_ip6ip6()
559
+{
560
+ TYPE=ip6tnl
561
+ DEV_NS=ip6ip6tnl00
562
+ DEV=ip6ip6tnl11
563
+ ret=0
564
+
565
+ check $TYPE
566
+ config_device
567
+ add_ip6tnl_tunnel
568
+ ip link set dev veth1 mtu 1500
569
+ attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
570
+ # underlay
571
+ ping6 $PING_ARG ::11
572
+ # ip6 over ip6
573
+ ping6 $PING_ARG 1::11
574
+ check_err $?
575
+ ip netns exec at_ns0 ping6 $PING_ARG 1::22
576
+ check_err $?
577
+ cleanup
578
+
579
+ if [ $ret -ne 0 ]; then
580
+ echo -e ${RED}"FAIL: ip6$TYPE"${NC}
581
+ return 1
582
+ fi
583
+ echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
554584 }
555585
556586 setup_xfrm_tunnel()
....@@ -646,6 +676,7 @@
646676 ip link del veth1 2> /dev/null
647677 ip link del ipip11 2> /dev/null
648678 ip link del ipip6tnl11 2> /dev/null
679
+ ip link del ip6ip6tnl11 2> /dev/null
649680 ip link del gretap11 2> /dev/null
650681 ip link del ip6gre11 2> /dev/null
651682 ip link del ip6gretap11 2> /dev/null
....@@ -696,30 +727,61 @@
696727
697728 bpf_tunnel_test()
698729 {
730
+ local errors=0
731
+
699732 echo "Testing GRE tunnel..."
700733 test_gre
734
+ errors=$(( $errors + $? ))
735
+
701736 echo "Testing IP6GRE tunnel..."
702737 test_ip6gre
738
+ errors=$(( $errors + $? ))
739
+
703740 echo "Testing IP6GRETAP tunnel..."
704741 test_ip6gretap
742
+ errors=$(( $errors + $? ))
743
+
705744 echo "Testing ERSPAN tunnel..."
706745 test_erspan v2
746
+ errors=$(( $errors + $? ))
747
+
707748 echo "Testing IP6ERSPAN tunnel..."
708749 test_ip6erspan v2
750
+ errors=$(( $errors + $? ))
751
+
709752 echo "Testing VXLAN tunnel..."
710753 test_vxlan
754
+ errors=$(( $errors + $? ))
755
+
711756 echo "Testing IP6VXLAN tunnel..."
712757 test_ip6vxlan
758
+ errors=$(( $errors + $? ))
759
+
713760 echo "Testing GENEVE tunnel..."
714761 test_geneve
762
+ errors=$(( $errors + $? ))
763
+
715764 echo "Testing IP6GENEVE tunnel..."
716765 test_ip6geneve
766
+ errors=$(( $errors + $? ))
767
+
717768 echo "Testing IPIP tunnel..."
718769 test_ipip
770
+ errors=$(( $errors + $? ))
771
+
719772 echo "Testing IPIP6 tunnel..."
720773 test_ipip6
774
+ errors=$(( $errors + $? ))
775
+
776
+ echo "Testing IP6IP6 tunnel..."
777
+ test_ip6ip6
778
+ errors=$(( $errors + $? ))
779
+
721780 echo "Testing IPSec tunnel..."
722781 test_xfrm_tunnel
782
+ errors=$(( $errors + $? ))
783
+
784
+ return $errors
723785 }
724786
725787 trap cleanup 0 3 6
....@@ -728,4 +790,9 @@
728790 cleanup
729791 bpf_tunnel_test
730792
793
+if [ $? -ne 0 ]; then
794
+ echo -e "$(basename $0): ${RED}FAIL${NC}"
795
+ exit 1
796
+fi
797
+echo -e "$(basename $0): ${GREEN}PASS${NC}"
731798 exit 0