Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | #!/bin/bash # SPDX-License-Identifier: GPL-2.0 # +---------------------+ +---------------------+ # | H1 | | H2 | # | + $h1 | | $h2 + | # | | 192.0.2.1/28 | | 192.0.2.2/28 | | # +-----|---------------+ +---------------|-----+ # | | # +-----|-------------------------------------------------------------|-----+ # | SW o--> mirror | | # | +---|-------------------------------------------------------------|---+ | # | | + $swp1 BR $swp2 + | | # | +---------------------------------------------------------------------+ | # | | # | +---------------------------------------------------------------------+ | # | | OL + gt6 (ip6gretap) + gt4 (gretap) | | # | | : loc=2001:db8:2::1 : loc=192.0.2.129 | | # | | : rem=2001:db8:2::2 : rem=192.0.2.130 | | # | | : ttl=100 : ttl=100 | | # | | : tos=inherit : tos=inherit | | # | +-------------------------:--|-------------------:--|-----------------+ | # | : | : | | # | +-------------------------:--|-------------------:--|-----------------+ | # | | UL : |,---------------------' | | # | | + $swp3 : || : | | # | | | 192.0.2.129/28 : vv : | | # | | | 2001:db8:2::1/64 : + ul (dummy) : | | # | +---|---------------------:----------------------:--------------------+ | # +-----|---------------------:----------------------:----------------------+ # | : : # +-----|---------------------:----------------------:----------------------+ # | H3 + $h3 + h3-gt6 (ip6gretap) + h3-gt4 (gretap) | # | 192.0.2.130/28 loc=2001:db8:2::2 loc=192.0.2.130 | # | 2001:db8:2::2/64 rem=2001:db8:2::1 rem=192.0.2.129 | # | ttl=100 ttl=100 | # | tos=inherit tos=inherit | # | | # +-------------------------------------------------------------------------+ # # This tests mirroring to gretap and ip6gretap configured in an overlay / # underlay manner, i.e. with a bound dummy device that marks underlay VRF where # the encapsulated packed should be routed. ALL_TESTS=" test_gretap test_ip6gretap " NUM_NETIFS=6 source lib.sh source mirror_lib.sh source mirror_gre_lib.sh h1_create() { simple_if_init $h1 192.0.2.1/28 } h1_destroy() { simple_if_fini $h1 192.0.2.1/28 } h2_create() { simple_if_init $h2 192.0.2.2/28 } h2_destroy() { simple_if_fini $h2 192.0.2.2/28 } h3_create() { simple_if_init $h3 192.0.2.130/28 2001:db8:2::2/64 tunnel_create h3-gt4 gretap 192.0.2.130 192.0.2.129 ip link set h3-gt4 vrf v$h3 matchall_sink_create h3-gt4 tunnel_create h3-gt6 ip6gretap 2001:db8:2::2 2001:db8:2::1 ip link set h3-gt6 vrf v$h3 matchall_sink_create h3-gt6 } h3_destroy() { tunnel_destroy h3-gt6 tunnel_destroy h3-gt4 simple_if_fini $h3 192.0.2.130/28 2001:db8:2::2/64 } switch_create() { # Bridge between H1 and H2. ip link add name br1 type bridge vlan_filtering 1 ip link set dev br1 addrgenmode none ip link set dev br1 up ip link set dev $swp1 master br1 ip link set dev $swp1 up ip link set dev $swp2 master br1 ip link set dev $swp2 up tc qdisc add dev $swp1 clsact # Underlay. simple_if_init $swp3 192.0.2.129/28 2001:db8:2::1/64 ip link add name ul type dummy ip link set dev ul master v$swp3 ip link set dev ul up # Overlay. vrf_create vrf-ol ip link set dev vrf-ol up tunnel_create gt4 gretap 192.0.2.129 192.0.2.130 \ ttl 100 tos inherit dev ul ip link set dev gt4 master vrf-ol ip link set dev gt4 up tunnel_create gt6 ip6gretap 2001:db8:2::1 2001:db8:2::2 \ ttl 100 tos inherit dev ul allow-localremote ip link set dev gt6 master vrf-ol ip link set dev gt6 up } switch_destroy() { vrf_destroy vrf-ol tunnel_destroy gt6 tunnel_destroy gt4 simple_if_fini $swp3 192.0.2.129/28 2001:db8:2::1/64 ip link del dev ul tc qdisc del dev $swp1 clsact ip link set dev $swp1 down ip link set dev $swp2 down ip link del dev br1 } setup_prepare() { h1=${NETIFS[p1]} swp1=${NETIFS[p2]} swp2=${NETIFS[p3]} h2=${NETIFS[p4]} swp3=${NETIFS[p5]} h3=${NETIFS[p6]} vrf_prepare h1_create h2_create h3_create switch_create } cleanup() { pre_cleanup switch_destroy h3_destroy h2_destroy h1_destroy vrf_cleanup } test_gretap() { full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap w/ UL" full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap w/ UL" } test_ip6gretap() { full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap w/ UL" full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap w/ UL" } test_all() { RET=0 slow_path_trap_install $swp1 ingress slow_path_trap_install $swp1 egress tests_run slow_path_trap_uninstall $swp1 egress slow_path_trap_uninstall $swp1 ingress } trap cleanup EXIT setup_prepare setup_wait tcflags="skip_hw" test_all if ! tc_offload_check; then echo "WARN: Could not test offloaded functionality" else tcflags="skip_sw" test_all fi exit $EXIT_STATUS |