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 for mirroring to gretap and ip6gretap, such that the neighbor entry for
0008 # the tunnel remote address has invalid address at the time that the mirroring
0009 # is set up. Later on, the neighbor is deleted and it is expected to be
0010 # reinitialized using the usual ARP process, and the mirroring offload updated.
0011 
0012 ALL_TESTS="
0013         test_gretap
0014         test_ip6gretap
0015 "
0016 
0017 NUM_NETIFS=6
0018 source lib.sh
0019 source mirror_lib.sh
0020 source mirror_gre_lib.sh
0021 source mirror_gre_topo_lib.sh
0022 
0023 setup_prepare()
0024 {
0025         h1=${NETIFS[p1]}
0026         swp1=${NETIFS[p2]}
0027 
0028         swp2=${NETIFS[p3]}
0029         h2=${NETIFS[p4]}
0030 
0031         swp3=${NETIFS[p5]}
0032         h3=${NETIFS[p6]}
0033 
0034         vrf_prepare
0035         mirror_gre_topo_create
0036 
0037         ip address add dev $swp3 192.0.2.129/28
0038         ip address add dev $h3 192.0.2.130/28
0039 
0040         ip address add dev $swp3 2001:db8:2::1/64
0041         ip address add dev $h3 2001:db8:2::2/64
0042 }
0043 
0044 cleanup()
0045 {
0046         pre_cleanup
0047 
0048         ip address del dev $h3 2001:db8:2::2/64
0049         ip address del dev $swp3 2001:db8:2::1/64
0050 
0051         ip address del dev $h3 192.0.2.130/28
0052         ip address del dev $swp3 192.0.2.129/28
0053 
0054         mirror_gre_topo_destroy
0055         vrf_cleanup
0056 }
0057 
0058 test_span_gre_neigh()
0059 {
0060         local addr=$1; shift
0061         local tundev=$1; shift
0062         local direction=$1; shift
0063         local what=$1; shift
0064 
0065         RET=0
0066 
0067         ip neigh replace dev $swp3 $addr lladdr 00:11:22:33:44:55
0068         mirror_install $swp1 $direction $tundev "matchall $tcflags"
0069         fail_test_span_gre_dir $tundev ingress
0070         ip neigh del dev $swp3 $addr
0071         quick_test_span_gre_dir $tundev ingress
0072         mirror_uninstall $swp1 $direction
0073 
0074         log_test "$direction $what: neighbor change ($tcflags)"
0075 }
0076 
0077 test_gretap()
0078 {
0079         test_span_gre_neigh 192.0.2.130 gt4 ingress "mirror to gretap"
0080         test_span_gre_neigh 192.0.2.130 gt4 egress "mirror to gretap"
0081 }
0082 
0083 test_ip6gretap()
0084 {
0085         test_span_gre_neigh 2001:db8:2::2 gt6 ingress "mirror to ip6gretap"
0086         test_span_gre_neigh 2001:db8:2::2 gt6 egress "mirror to ip6gretap"
0087 }
0088 
0089 test_all()
0090 {
0091         slow_path_trap_install $swp1 ingress
0092         slow_path_trap_install $swp1 egress
0093 
0094         tests_run
0095 
0096         slow_path_trap_uninstall $swp1 egress
0097         slow_path_trap_uninstall $swp1 ingress
0098 }
0099 
0100 trap cleanup EXIT
0101 
0102 setup_prepare
0103 setup_wait
0104 
0105 tcflags="skip_hw"
0106 test_all
0107 
0108 if ! tc_offload_check; then
0109         echo "WARN: Could not test offloaded functionality"
0110 else
0111         tcflags="skip_sw"
0112         test_all
0113 fi
0114 
0115 exit $EXIT_STATUS