~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/mirror_gre.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 # This test uses standard topology for testing gretap. See
  5 # mirror_gre_topo_lib.sh for more details.
  6 #
  7 # Test for "tc action mirred egress mirror" when the device to mirror to is a
  8 # gretap or ip6gretap netdevice. Expect that the packets come out encapsulated,
  9 # and another gretap / ip6gretap netdevice is then capable of decapsulating the
 10 # traffic. Test that the payload is what is expected (ICMP ping request or
 11 # reply, depending on test).
 12 
 13 ALL_TESTS="
 14         test_gretap
 15         test_ip6gretap
 16         test_gretap_mac
 17         test_ip6gretap_mac
 18         test_two_spans
 19 "
 20 
 21 NUM_NETIFS=6
 22 source lib.sh
 23 source mirror_lib.sh
 24 source mirror_gre_lib.sh
 25 source mirror_gre_topo_lib.sh
 26 
 27 setup_prepare()
 28 {
 29         h1=${NETIFS[p1]}
 30         swp1=${NETIFS[p2]}
 31 
 32         swp2=${NETIFS[p3]}
 33         h2=${NETIFS[p4]}
 34 
 35         swp3=${NETIFS[p5]}
 36         h3=${NETIFS[p6]}
 37 
 38         vrf_prepare
 39         mirror_gre_topo_create
 40 
 41         ip address add dev $swp3 192.0.2.129/28
 42         ip address add dev $h3 192.0.2.130/28
 43 
 44         ip address add dev $swp3 2001:db8:2::1/64
 45         ip address add dev $h3 2001:db8:2::2/64
 46 }
 47 
 48 cleanup()
 49 {
 50         pre_cleanup
 51 
 52         ip address del dev $h3 2001:db8:2::2/64
 53         ip address del dev $swp3 2001:db8:2::1/64
 54 
 55         ip address del dev $h3 192.0.2.130/28
 56         ip address del dev $swp3 192.0.2.129/28
 57 
 58         mirror_gre_topo_destroy
 59         vrf_cleanup
 60 }
 61 
 62 test_span_gre_mac()
 63 {
 64         local tundev=$1; shift
 65         local direction=$1; shift
 66         local what=$1; shift
 67 
 68         case "$direction" in
 69         ingress) local src_mac=$(mac_get $h1); local dst_mac=$(mac_get $h2)
 70                 ;;
 71         egress) local src_mac=$(mac_get $h2); local dst_mac=$(mac_get $h1)
 72                 ;;
 73         esac
 74 
 75         RET=0
 76 
 77         mirror_install $swp1 $direction $tundev "matchall"
 78         icmp_capture_install h3-${tundev} "src_mac $src_mac dst_mac $dst_mac"
 79 
 80         mirror_test v$h1 192.0.2.1 192.0.2.2 h3-${tundev} 100 10
 81 
 82         icmp_capture_uninstall h3-${tundev}
 83         mirror_uninstall $swp1 $direction
 84 
 85         log_test "$direction $what: envelope MAC"
 86 }
 87 
 88 test_two_spans()
 89 {
 90         RET=0
 91 
 92         mirror_install $swp1 ingress gt4 "matchall"
 93         mirror_install $swp1 egress gt6 "matchall"
 94         quick_test_span_gre_dir gt4 8 0
 95         quick_test_span_gre_dir gt6 0 8
 96 
 97         mirror_uninstall $swp1 ingress
 98         fail_test_span_gre_dir gt4 8 0
 99         quick_test_span_gre_dir gt6 0 8
100 
101         mirror_install $swp1 ingress gt4 "matchall"
102         mirror_uninstall $swp1 egress
103         quick_test_span_gre_dir gt4 8 0
104         fail_test_span_gre_dir gt6 0 8
105 
106         mirror_uninstall $swp1 ingress
107         log_test "two simultaneously configured mirrors"
108 }
109 
110 test_gretap()
111 {
112         full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap"
113         full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap"
114 }
115 
116 test_ip6gretap()
117 {
118         full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap"
119         full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap"
120 }
121 
122 test_gretap_mac()
123 {
124         test_span_gre_mac gt4 ingress "mirror to gretap"
125         test_span_gre_mac gt4 egress "mirror to gretap"
126 }
127 
128 test_ip6gretap_mac()
129 {
130         test_span_gre_mac gt6 ingress "mirror to ip6gretap"
131         test_span_gre_mac gt6 egress "mirror to ip6gretap"
132 }
133 
134 trap cleanup EXIT
135 
136 setup_prepare
137 setup_wait
138 
139 tests_run
140 
141 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php