Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 # This test uses standard topology for testing gretap. See
0005 # mirror_gre_topo_lib.sh for more details.
0006 #
0007 # Test that gretap and ip6gretap mirroring works when the other tunnel endpoint
0008 # is reachable through a next-hop route (as opposed to directly-attached route).
0009 
0010 ALL_TESTS="
0011         test_gretap
0012         test_ip6gretap
0013 "
0014 
0015 NUM_NETIFS=6
0016 source lib.sh
0017 source mirror_lib.sh
0018 source mirror_gre_lib.sh
0019 source mirror_gre_topo_lib.sh
0020 
0021 setup_prepare()
0022 {
0023         h1=${NETIFS[p1]}
0024         swp1=${NETIFS[p2]}
0025 
0026         swp2=${NETIFS[p3]}
0027         h2=${NETIFS[p4]}
0028 
0029         swp3=${NETIFS[p5]}
0030         h3=${NETIFS[p6]}
0031 
0032         sysctl_set net.ipv4.conf.all.rp_filter 0
0033         sysctl_set net.ipv4.conf.$h3.rp_filter 0
0034 
0035         vrf_prepare
0036         mirror_gre_topo_create
0037 
0038         sysctl_set net.ipv4.conf.v$h3.rp_filter 0
0039 
0040         ip address add dev $swp3 192.0.2.161/28
0041         ip address add dev $h3 192.0.2.162/28
0042         ip address add dev gt4 192.0.2.129/32
0043         ip address add dev h3-gt4 192.0.2.130/32
0044 
0045         # IPv6 route can't be added after address. Such routes are rejected due
0046         # to the gateway address having been configured on the local system. It
0047         # works the other way around though.
0048         ip address add dev $swp3 2001:db8:4::1/64
0049         ip -6 route add 2001:db8:2::2/128 via 2001:db8:4::2
0050         ip address add dev $h3 2001:db8:4::2/64
0051         ip address add dev gt6 2001:db8:2::1
0052         ip address add dev h3-gt6 2001:db8:2::2
0053 }
0054 
0055 cleanup()
0056 {
0057         pre_cleanup
0058 
0059         ip -6 route del 2001:db8:2::2/128 via 2001:db8:4::2
0060         ip address del dev $h3 2001:db8:4::2/64
0061         ip address del dev $swp3 2001:db8:4::1/64
0062 
0063         ip address del dev $h3 192.0.2.162/28
0064         ip address del dev $swp3 192.0.2.161/28
0065 
0066         sysctl_restore net.ipv4.conf.v$h3.rp_filter 0
0067 
0068         mirror_gre_topo_destroy
0069         vrf_cleanup
0070 
0071         sysctl_restore net.ipv4.conf.$h3.rp_filter
0072         sysctl_restore net.ipv4.conf.all.rp_filter
0073 }
0074 
0075 test_gretap()
0076 {
0077         RET=0
0078         mirror_install $swp1 ingress gt4 "matchall $tcflags"
0079 
0080         # For IPv4, test that there's no mirroring without the route directing
0081         # the traffic to tunnel remote address. Then add it and test that
0082         # mirroring starts. For IPv6 we can't test this due to the limitation
0083         # that routes for locally-specified IPv6 addresses can't be added.
0084         fail_test_span_gre_dir gt4 ingress
0085 
0086         ip route add 192.0.2.130/32 via 192.0.2.162
0087         quick_test_span_gre_dir gt4 ingress
0088         ip route del 192.0.2.130/32 via 192.0.2.162
0089 
0090         mirror_uninstall $swp1 ingress
0091         log_test "mirror to gre with next-hop remote ($tcflags)"
0092 }
0093 
0094 test_ip6gretap()
0095 {
0096         RET=0
0097 
0098         mirror_install $swp1 ingress gt6 "matchall $tcflags"
0099         quick_test_span_gre_dir gt6 ingress
0100         mirror_uninstall $swp1 ingress
0101 
0102         log_test "mirror to ip6gre with next-hop remote ($tcflags)"
0103 }
0104 
0105 test_all()
0106 {
0107         slow_path_trap_install $swp1 ingress
0108         slow_path_trap_install $swp1 egress
0109 
0110         tests_run
0111 
0112         slow_path_trap_uninstall $swp1 egress
0113         slow_path_trap_uninstall $swp1 ingress
0114 }
0115 
0116 trap cleanup EXIT
0117 
0118 setup_prepare
0119 setup_wait
0120 
0121 tcflags="skip_hw"
0122 test_all
0123 
0124 if ! tc_offload_check; then
0125         echo "WARN: Could not test offloaded functionality"
0126 else
0127         tcflags="skip_sw"
0128         test_all
0129 fi
0130 
0131 exit $EXIT_STATUS