Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: forwarding: Add IPv6 GRE hierarchical tests

Add tests that check IPv6-in-IPv6, IPv4-in-IPv6 and MTU change of GRE
tunnel. The tests use hierarchical model - the tunnel is bound to a device
in a different VRF.

These tests can be run with TC_FLAG=skip_sw, so then they will verify
that packets go through hardware as part of enacp and decap phases.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Amit Cohen and committed by
David S. Miller
4b3d967b 7df29960

+364 -1
+65
tools/testing/selftests/net/forwarding/ip6gre_hier.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + # Test IP-in-IP GRE tunnels without key. 5 + # This test uses hierarchical topology for IP tunneling tests. See 6 + # ip6gre_lib.sh for more details. 7 + 8 + ALL_TESTS=" 9 + gre_hier 10 + gre_mtu_change 11 + " 12 + 13 + NUM_NETIFS=6 14 + source lib.sh 15 + source ip6gre_lib.sh 16 + 17 + setup_prepare() 18 + { 19 + h1=${NETIFS[p1]} 20 + ol1=${NETIFS[p2]} 21 + 22 + ul1=${NETIFS[p3]} 23 + ul2=${NETIFS[p4]} 24 + 25 + ol2=${NETIFS[p5]} 26 + h2=${NETIFS[p6]} 27 + 28 + forwarding_enable 29 + vrf_prepare 30 + h1_create 31 + h2_create 32 + sw1_hierarchical_create $ol1 $ul1 33 + sw2_hierarchical_create $ol2 $ul2 34 + } 35 + 36 + gre_hier() 37 + { 38 + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6" 39 + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6" 40 + } 41 + 42 + gre_mtu_change() 43 + { 44 + test_mtu_change gre 45 + } 46 + 47 + cleanup() 48 + { 49 + pre_cleanup 50 + 51 + sw2_hierarchical_destroy $ol2 $ul2 52 + sw1_hierarchical_destroy $ol1 $ul1 53 + h2_destroy 54 + h1_destroy 55 + vrf_cleanup 56 + forwarding_restore 57 + } 58 + 59 + trap cleanup EXIT 60 + 61 + setup_prepare 62 + setup_wait 63 + tests_run 64 + 65 + exit $EXIT_STATUS
+65
tools/testing/selftests/net/forwarding/ip6gre_hier_key.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + # Test IP-in-IP GRE tunnels without key. 5 + # This test uses hierarchical topology for IP tunneling tests. See 6 + # ip6gre_lib.sh for more details. 7 + 8 + ALL_TESTS=" 9 + gre_hier 10 + gre_mtu_change 11 + " 12 + 13 + NUM_NETIFS=6 14 + source lib.sh 15 + source ip6gre_lib.sh 16 + 17 + setup_prepare() 18 + { 19 + h1=${NETIFS[p1]} 20 + ol1=${NETIFS[p2]} 21 + 22 + ul1=${NETIFS[p3]} 23 + ul2=${NETIFS[p4]} 24 + 25 + ol2=${NETIFS[p5]} 26 + h2=${NETIFS[p6]} 27 + 28 + forwarding_enable 29 + vrf_prepare 30 + h1_create 31 + h2_create 32 + sw1_hierarchical_create $ol1 $ul1 key 22 33 + sw2_hierarchical_create $ol2 $ul2 key 22 34 + } 35 + 36 + gre_hier() 37 + { 38 + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 with key" 39 + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 with key" 40 + } 41 + 42 + gre_mtu_change() 43 + { 44 + test_mtu_change gre 45 + } 46 + 47 + cleanup() 48 + { 49 + pre_cleanup 50 + 51 + sw2_hierarchical_destroy $ol2 $ul2 52 + sw1_hierarchical_destroy $ol1 $ul1 53 + h2_destroy 54 + h1_destroy 55 + vrf_cleanup 56 + forwarding_restore 57 + } 58 + 59 + trap cleanup EXIT 60 + 61 + setup_prepare 62 + setup_wait 63 + tests_run 64 + 65 + exit $EXIT_STATUS
+65
tools/testing/selftests/net/forwarding/ip6gre_hier_keys.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + # Test IP-in-IP GRE tunnels without key. 5 + # This test uses hierarchical topology for IP tunneling tests. See 6 + # ip6gre_lib.sh for more details. 7 + 8 + ALL_TESTS=" 9 + gre_hier 10 + gre_mtu_change 11 + " 12 + 13 + NUM_NETIFS=6 14 + source lib.sh 15 + source ip6gre_lib.sh 16 + 17 + setup_prepare() 18 + { 19 + h1=${NETIFS[p1]} 20 + ol1=${NETIFS[p2]} 21 + 22 + ul1=${NETIFS[p3]} 23 + ul2=${NETIFS[p4]} 24 + 25 + ol2=${NETIFS[p5]} 26 + h2=${NETIFS[p6]} 27 + 28 + forwarding_enable 29 + vrf_prepare 30 + h1_create 31 + h2_create 32 + sw1_hierarchical_create $ol1 $ul1 ikey 111 okey 222 33 + sw2_hierarchical_create $ol2 $ul2 ikey 222 okey 111 34 + } 35 + 36 + gre_hier() 37 + { 38 + test_traffic_ip4ip6 "GRE hierarchical IPv4-in-IPv6 with ikey/okey" 39 + test_traffic_ip6ip6 "GRE hierarchical IPv6-in-IPv6 with ikey/okey" 40 + } 41 + 42 + gre_mtu_change() 43 + { 44 + test_mtu_change gre 45 + } 46 + 47 + cleanup() 48 + { 49 + pre_cleanup 50 + 51 + sw2_hierarchical_destroy $ol2 $ul2 52 + sw1_hierarchical_destroy $ol1 $ul1 53 + h2_destroy 54 + h1_destroy 55 + vrf_cleanup 56 + forwarding_restore 57 + } 58 + 59 + trap cleanup EXIT 60 + 61 + setup_prepare 62 + setup_wait 63 + tests_run 64 + 65 + exit $EXIT_STATUS
+169 -1
tools/testing/selftests/net/forwarding/ip6gre_lib.sh
··· 2 2 #!/bin/bash 3 3 4 4 # Handles creation and destruction of IP-in-IP or GRE tunnels over the given 5 - # topology. 5 + # topology. Supports both flat and hierarchical models. 6 6 # 7 7 # Flat Model: 8 8 # Overlay and underlay share the same VRF. ··· 62 62 # | $h2 + | 63 63 # | 203.0.113.1/24 | 64 64 # | 2001:db8:2::1/64 | 65 + # +--------------------------------+ 66 + # 67 + # Hierarchical model: 68 + # The tunnel is bound to a device in a different VRF 69 + # 70 + # +--------------------------------+ 71 + # | H1 | 72 + # | $h1 + | 73 + # | 198.51.100.1/24 | | 74 + # | 2001:db8:1::1/64 | | 75 + # +-------------------------|------+ 76 + # | 77 + # +-------------------------|-------------------+ 78 + # | SW1 | | 79 + # | +-----------------------|-----------------+ | 80 + # | | $ol1 + | | 81 + # | | 198.51.100.2/24 | | 82 + # | | 2001:db8:1::2/64 | | 83 + # | | | | 84 + # | | + g1a (ip6gre) | | 85 + # | | loc=2001:db8:3::1 | | 86 + # | | rem=2001:db8:3::2 | | 87 + # | | tos=inherit | | 88 + # | | ^ | | 89 + # | | VRF v$ol1 | | | 90 + # | +--------------------|--------------------+ | 91 + # | | | 92 + # | +--------------------|--------------------+ | 93 + # | | VRF v$ul1 | | | 94 + # | | | | | 95 + # | | v | | 96 + # | | dummy1 + | | 97 + # | | 2001:db8:3::1/64 | | 98 + # | | .-----------' | | 99 + # | | | | | 100 + # | | v | | 101 + # | | + $ul1.111 (vlan) | | 102 + # | | | 2001:db8:10::1/64 | | 103 + # | | \ | | 104 + # | | \__________ | | 105 + # | | | | | 106 + # | | + $ul1 | | 107 + # | +---------------------|-------------------+ | 108 + # +-----------------------|---------------------+ 109 + # | 110 + # +-----------------------|---------------------+ 111 + # | SW2 | | 112 + # | +---------------------|-------------------+ | 113 + # | | + $ul2 | | 114 + # | | _____| | | 115 + # | | / | | 116 + # | | / | | 117 + # | | | $ul2.111 (vlan) | | 118 + # | | + 2001:db8:10::2/64 | | 119 + # | | ^ | | 120 + # | | | | | 121 + # | | '------. | | 122 + # | | dummy2 + | | 123 + # | | 2001:db8:3::2/64 | | 124 + # | | ^ | | 125 + # | | | | | 126 + # | | | | | 127 + # | | VRF v$ul2 | | | 128 + # | +---------------------|-------------------+ | 129 + # | | | 130 + # | +---------------------|-------------------+ | 131 + # | | VRF v$ol2 | | | 132 + # | | | | | 133 + # | | v | | 134 + # | | g2a (ip6gre) + | | 135 + # | | loc=2001:db8:3::2 | | 136 + # | | rem=2001:db8:3::1 | | 137 + # | | tos=inherit | | 138 + # | | | | 139 + # | | $ol2 + | | 140 + # | | 203.0.113.2/24 | | | 141 + # | | 2001:db8:2::2/64 | | | 142 + # | +---------------------|-------------------+ | 143 + # +-----------------------|---------------------+ 144 + # | 145 + # +-----------------------|--------+ 146 + # | H2 | | 147 + # | $h2 + | 148 + # | 203.0.113.1/24 | 149 + # | 2001:db8:2::1/64 | 65 150 # +--------------------------------+ 66 151 67 152 source lib.sh ··· 254 169 255 170 vlan_destroy $ul2 111 256 171 __simple_if_fini $ul2 172 + simple_if_fini $ol2 203.0.113.2/24 2001:db8:2::2/64 173 + } 174 + 175 + sw1_hierarchical_create() 176 + { 177 + local ol1=$1; shift 178 + local ul1=$1; shift 179 + 180 + simple_if_init $ol1 198.51.100.2/24 2001:db8:1::2/64 181 + simple_if_init $ul1 182 + ip link add name dummy1 type dummy 183 + __simple_if_init dummy1 v$ul1 2001:db8:3::1/64 184 + 185 + vlan_create $ul1 111 v$ul1 2001:db8:10::1/64 186 + tunnel_create g1a ip6gre 2001:db8:3::1 2001:db8:3::2 tos inherit \ 187 + ttl inherit dev dummy1 "$@" 188 + ip link set dev g1a master v$ol1 189 + 190 + ip -6 route add vrf v$ul1 2001:db8:3::2/128 via 2001:db8:10::2 191 + ip route add vrf v$ol1 203.0.113.0/24 dev g1a 192 + ip -6 route add vrf v$ol1 2001:db8:2::/64 dev g1a 193 + } 194 + 195 + sw1_hierarchical_destroy() 196 + { 197 + local ol1=$1; shift 198 + local ul1=$1; shift 199 + 200 + ip -6 route del vrf v$ol1 2001:db8:2::/64 201 + ip route del vrf v$ol1 203.0.113.0/24 202 + ip -6 route del vrf v$ul1 2001:db8:3::2/128 203 + 204 + tunnel_destroy g1a 205 + vlan_destroy $ul1 111 206 + 207 + __simple_if_fini dummy1 2001:db8:3::1/64 208 + ip link del dev dummy1 209 + 210 + simple_if_fini $ul1 211 + simple_if_fini $ol1 198.51.100.2/24 2001:db8:1::2/64 212 + } 213 + 214 + sw2_hierarchical_create() 215 + { 216 + local ol2=$1; shift 217 + local ul2=$1; shift 218 + 219 + simple_if_init $ol2 203.0.113.2/24 2001:db8:2::2/64 220 + simple_if_init $ul2 221 + 222 + ip link add name dummy2 type dummy 223 + __simple_if_init dummy2 v$ul2 2001:db8:3::2/64 224 + 225 + vlan_create $ul2 111 v$ul2 2001:db8:10::2/64 226 + tunnel_create g2a ip6gre 2001:db8:3::2 2001:db8:3::1 tos inherit \ 227 + ttl inherit dev dummy2 "$@" 228 + ip link set dev g2a master v$ol2 229 + 230 + # Replace neighbor to avoid 1 dropped packet due to "unresolved neigh" 231 + ip neigh replace dev $ol2 203.0.113.1 lladdr $(mac_get $h2) 232 + ip -6 neigh replace dev $ol2 2001:db8:2::1 lladdr $(mac_get $h2) 233 + 234 + ip -6 route add vrf v$ul2 2001:db8:3::1/128 via 2001:db8:10::1 235 + ip route add vrf v$ol2 198.51.100.0/24 dev g2a 236 + ip -6 route add vrf v$ol2 2001:db8:1::/64 dev g2a 237 + } 238 + 239 + sw2_hierarchical_destroy() 240 + { 241 + local ol2=$1; shift 242 + local ul2=$1; shift 243 + 244 + ip -6 route del vrf v$ol2 2001:db8:2::/64 245 + ip route del vrf v$ol2 198.51.100.0/24 246 + ip -6 route del vrf v$ul2 2001:db8:3::1/128 247 + 248 + tunnel_destroy g2a 249 + vlan_destroy $ul2 111 250 + 251 + __simple_if_fini dummy2 2001:db8:3::2/64 252 + ip link del dev dummy2 253 + 254 + simple_if_fini $ul2 257 255 simple_if_fini $ol2 203.0.113.2/24 2001:db8:2::2/64 258 256 } 259 257