Merge tag 'dma-mapping-5.15-1' of git://git.infradead.org/users/hch/dma-mapping
[platform/kernel/linux-starfive.git] / tools / testing / selftests / net / srv6_end_dt46_l3vpn_test.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # author: Andrea Mayer <andrea.mayer@uniroma2.it>
5 # author: Paolo Lungaroni <paolo.lungaroni@uniroma2.it>
6
7 # This test is designed for evaluating the new SRv6 End.DT46 Behavior used for
8 # implementing IPv4/IPv6 L3 VPN use cases.
9 #
10 # The current SRv6 code in the Linux kernel only implements SRv6 End.DT4 and
11 # End.DT6 Behaviors which can be used respectively to support IPv4-in-IPv6 and
12 # IPv6-in-IPv6 VPNs. With End.DT4 and End.DT6 it is not possible to create a
13 # single SRv6 VPN tunnel to carry both IPv4 and IPv6 traffic.
14 # The SRv6 End.DT46 Behavior implementation is meant to support the
15 # decapsulation of IPv4 and IPv6 traffic coming from a single SRv6 tunnel.
16 # Therefore, the SRv6 End.DT46 Behavior in the Linux kernel greatly simplifies
17 # the setup and operations of SRv6 VPNs.
18 #
19 # Hereafter a network diagram is shown, where two different tenants (named 100
20 # and 200) offer IPv4/IPv6 L3 VPN services allowing hosts to communicate with
21 # each other across an IPv6 network.
22 #
23 # Only hosts belonging to the same tenant (and to the same VPN) can communicate
24 # with each other. Instead, the communication among hosts of different tenants
25 # is forbidden.
26 # In other words, hosts hs-t100-1 and hs-t100-2 are connected through the
27 # IPv4/IPv6 L3 VPN of tenant 100 while hs-t200-3 and hs-t200-4 are connected
28 # using the IPv4/IPv6 L3 VPN of tenant 200. Cross connection between tenant 100
29 # and tenant 200 is forbidden and thus, for example, hs-t100-1 cannot reach
30 # hs-t200-3 and vice versa.
31 #
32 # Routers rt-1 and rt-2 implement IPv4/IPv6 L3 VPN services leveraging the SRv6
33 # architecture. The key components for such VPNs are: a) SRv6 Encap behavior,
34 # b) SRv6 End.DT46 Behavior and c) VRF.
35 #
36 # To explain how an IPv4/IPv6 L3 VPN based on SRv6 works, let us briefly
37 # consider an example where, within the same domain of tenant 100, the host
38 # hs-t100-1 pings the host hs-t100-2.
39 #
40 # First of all, L2 reachability of the host hs-t100-2 is taken into account by
41 # the router rt-1 which acts as a arp/ndp proxy.
42 #
43 # When the host hs-t100-1 sends an IPv6 or IPv4 packet destined to hs-t100-2,
44 # the router rt-1 receives the packet on the internal veth-t100 interface. Such
45 # interface is enslaved to the VRF vrf-100 whose associated table contains the
46 # SRv6 Encap route for encapsulating any IPv6 or IPv4 packet in a IPv6 plus the
47 # Segment Routing Header (SRH) packet. This packet is sent through the (IPv6)
48 # core network up to the router rt-2 that receives it on veth0 interface.
49 #
50 # The rt-2 router uses the 'localsid' routing table to process incoming
51 # IPv6+SRH packets which belong to the VPN of the tenant 100. For each of these
52 # packets, the SRv6 End.DT46 Behavior removes the outer IPv6+SRH headers and
53 # performs the lookup on the vrf-100 table using the destination address of
54 # the decapsulated IPv6 or IPv4 packet. Afterwards, the packet is sent to the
55 # host hs-t100-2 through the veth-t100 interface.
56 #
57 # The ping response follows the same processing but this time the roles of rt-1
58 # and rt-2 are swapped.
59 #
60 # Of course, the IPv4/IPv6 L3 VPN for tenant 200 works exactly as the IPv4/IPv6
61 # L3 VPN for tenant 100. In this case, only hosts hs-t200-3 and hs-t200-4 are
62 # able to connect with each other.
63 #
64 #
65 # +-------------------+                                   +-------------------+
66 # |                   |                                   |                   |
67 # |  hs-t100-1 netns  |                                   |  hs-t100-2 netns  |
68 # |                   |                                   |                   |
69 # |  +-------------+  |                                   |  +-------------+  |
70 # |  |    veth0    |  |                                   |  |    veth0    |  |
71 # |  |  cafe::1/64 |  |                                   |  |  cafe::2/64 |  |
72 # |  | 10.0.0.1/24 |  |                                   |  | 10.0.0.2/24 |  |
73 # |  +-------------+  |                                   |  +-------------+  |
74 # |        .          |                                   |         .         |
75 # +-------------------+                                   +-------------------+
76 #          .                                                        .
77 #          .                                                        .
78 #          .                                                        .
79 # +-----------------------------------+   +-----------------------------------+
80 # |        .                          |   |                         .         |
81 # | +---------------+                 |   |                 +---------------- |
82 # | |   veth-t100   |                 |   |                 |   veth-t100   | |
83 # | |  cafe::254/64 |                 |   |                 |  cafe::254/64 | |
84 # | | 10.0.0.254/24 |    +----------+ |   | +----------+    | 10.0.0.254/24 | |
85 # | +-------+-------+    | localsid | |   | | localsid |    +-------+-------- |
86 # |         |            |   table  | |   | |   table  |            |         |
87 # |    +----+----+       +----------+ |   | +----------+       +----+----+    |
88 # |    | vrf-100 |                    |   |                    | vrf-100 |    |
89 # |    +---------+     +------------+ |   | +------------+     +---------+    |
90 # |                    |   veth0    | |   | |   veth0    |                    |
91 # |                    | fd00::1/64 |.|...|.| fd00::2/64 |                    |
92 # |    +---------+     +------------+ |   | +------------+     +---------+    |
93 # |    | vrf-200 |                    |   |                    | vrf-200 |    |
94 # |    +----+----+                    |   |                    +----+----+    |
95 # |         |                         |   |                         |         |
96 # | +-------+-------+                 |   |                 +-------+-------- |
97 # | |   veth-t200   |                 |   |                 |   veth-t200   | |
98 # | |  cafe::254/64 |                 |   |                 |  cafe::254/64 | |
99 # | | 10.0.0.254/24 |                 |   |                 | 10.0.0.254/24 | |
100 # | +---------------+      rt-1 netns |   | rt-2 netns      +---------------- |
101 # |        .                          |   |                          .        |
102 # +-----------------------------------+   +-----------------------------------+
103 #          .                                                         .
104 #          .                                                         .
105 #          .                                                         .
106 #          .                                                         .
107 # +-------------------+                                   +-------------------+
108 # |        .          |                                   |          .        |
109 # |  +-------------+  |                                   |  +-------------+  |
110 # |  |    veth0    |  |                                   |  |    veth0    |  |
111 # |  |  cafe::3/64 |  |                                   |  |  cafe::4/64 |  |
112 # |  | 10.0.0.3/24 |  |                                   |  | 10.0.0.4/24 |  |
113 # |  +-------------+  |                                   |  +-------------+  |
114 # |                   |                                   |                   |
115 # |  hs-t200-3 netns  |                                   |  hs-t200-4 netns  |
116 # |                   |                                   |                   |
117 # +-------------------+                                   +-------------------+
118 #
119 #
120 # ~~~~~~~~~~~~~~~~~~~~~~~~~
121 # | Network configuration |
122 # ~~~~~~~~~~~~~~~~~~~~~~~~~
123 #
124 # rt-1: localsid table (table 90)
125 # +--------------------------------------------------+
126 # |SID              |Action                          |
127 # +--------------------------------------------------+
128 # |fc00:21:100::6046|apply SRv6 End.DT46 vrftable 100|
129 # +--------------------------------------------------+
130 # |fc00:21:200::6046|apply SRv6 End.DT46 vrftable 200|
131 # +--------------------------------------------------+
132 #
133 # rt-1: VRF tenant 100 (table 100)
134 # +---------------------------------------------------+
135 # |host       |Action                                 |
136 # +---------------------------------------------------+
137 # |cafe::2    |apply seg6 encap segs fc00:12:100::6046|
138 # +---------------------------------------------------+
139 # |cafe::/64  |forward to dev veth-t100               |
140 # +---------------------------------------------------+
141 # |10.0.0.2   |apply seg6 encap segs fc00:12:100::6046|
142 # +---------------------------------------------------+
143 # |10.0.0.0/24|forward to dev veth-t100               |
144 # +---------------------------------------------------+
145 #
146 # rt-1: VRF tenant 200 (table 200)
147 # +---------------------------------------------------+
148 # |host       |Action                                 |
149 # +---------------------------------------------------+
150 # |cafe::4    |apply seg6 encap segs fc00:12:200::6046|
151 # +---------------------------------------------------+
152 # |cafe::/64  |forward to dev veth-t200               |
153 # +---------------------------------------------------+
154 # |10.0.0.4   |apply seg6 encap segs fc00:12:200::6046|
155 # +---------------------------------------------------+
156 # |10.0.0.0/24|forward to dev veth-t200               |
157 # +---------------------------------------------------+
158 #
159 #
160 # rt-2: localsid table (table 90)
161 # +--------------------------------------------------+
162 # |SID              |Action                          |
163 # +--------------------------------------------------+
164 # |fc00:12:100::6046|apply SRv6 End.DT46 vrftable 100|
165 # +--------------------------------------------------+
166 # |fc00:12:200::6046|apply SRv6 End.DT46 vrftable 200|
167 # +--------------------------------------------------+
168 #
169 # rt-2: VRF tenant 100 (table 100)
170 # +---------------------------------------------------+
171 # |host       |Action                                 |
172 # +---------------------------------------------------+
173 # |cafe::1    |apply seg6 encap segs fc00:21:100::6046|
174 # +---------------------------------------------------+
175 # |cafe::/64  |forward to dev veth-t100               |
176 # +---------------------------------------------------+
177 # |10.0.0.1   |apply seg6 encap segs fc00:21:100::6046|
178 # +---------------------------------------------------+
179 # |10.0.0.0/24|forward to dev veth-t100               |
180 # +---------------------------------------------------+
181 #
182 # rt-2: VRF tenant 200 (table 200)
183 # +---------------------------------------------------+
184 # |host       |Action                                 |
185 # +---------------------------------------------------+
186 # |cafe::3    |apply seg6 encap segs fc00:21:200::6046|
187 # +---------------------------------------------------+
188 # |cafe::/64  |forward to dev veth-t200               |
189 # +---------------------------------------------------+
190 # |10.0.0.3   |apply seg6 encap segs fc00:21:200::6046|
191 # +---------------------------------------------------+
192 # |10.0.0.0/24|forward to dev veth-t200               |
193 # +---------------------------------------------------+
194 #
195
196 # Kselftest framework requirement - SKIP code is 4.
197 ksft_skip=4
198
199 readonly LOCALSID_TABLE_ID=90
200 readonly IPv6_RT_NETWORK=fd00
201 readonly IPv6_HS_NETWORK=cafe
202 readonly IPv4_HS_NETWORK=10.0.0
203 readonly VPN_LOCATOR_SERVICE=fc00
204 PING_TIMEOUT_SEC=4
205
206 ret=0
207
208 PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
209
210 log_test()
211 {
212         local rc=$1
213         local expected=$2
214         local msg="$3"
215
216         if [ ${rc} -eq ${expected} ]; then
217                 nsuccess=$((nsuccess+1))
218                 printf "\n    TEST: %-60s  [ OK ]\n" "${msg}"
219         else
220                 ret=1
221                 nfail=$((nfail+1))
222                 printf "\n    TEST: %-60s  [FAIL]\n" "${msg}"
223                 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
224                         echo
225                         echo "hit enter to continue, 'q' to quit"
226                         read a
227                         [ "$a" = "q" ] && exit 1
228                 fi
229         fi
230 }
231
232 print_log_test_results()
233 {
234         if [ "$TESTS" != "none" ]; then
235                 printf "\nTests passed: %3d\n" ${nsuccess}
236                 printf "Tests failed: %3d\n"   ${nfail}
237         fi
238 }
239
240 log_section()
241 {
242         echo
243         echo "################################################################################"
244         echo "TEST SECTION: $*"
245         echo "################################################################################"
246 }
247
248 cleanup()
249 {
250         ip link del veth-rt-1 2>/dev/null || true
251         ip link del veth-rt-2 2>/dev/null || true
252
253         # destroy routers rt-* and hosts hs-*
254         for ns in $(ip netns show | grep -E 'rt-*|hs-*'); do
255                 ip netns del ${ns} || true
256         done
257 }
258
259 # Setup the basic networking for the routers
260 setup_rt_networking()
261 {
262         local rt=$1
263         local nsname=rt-${rt}
264
265         ip netns add ${nsname}
266         ip link set veth-rt-${rt} netns ${nsname}
267         ip -netns ${nsname} link set veth-rt-${rt} name veth0
268
269         ip netns exec ${nsname} sysctl -wq net.ipv6.conf.all.accept_dad=0
270         ip netns exec ${nsname} sysctl -wq net.ipv6.conf.default.accept_dad=0
271
272         ip -netns ${nsname} addr add ${IPv6_RT_NETWORK}::${rt}/64 dev veth0 nodad
273         ip -netns ${nsname} link set veth0 up
274         ip -netns ${nsname} link set lo up
275
276         ip netns exec ${nsname} sysctl -wq net.ipv4.ip_forward=1
277         ip netns exec ${nsname} sysctl -wq net.ipv6.conf.all.forwarding=1
278 }
279
280 setup_hs()
281 {
282         local hs=$1
283         local rt=$2
284         local tid=$3
285         local hsname=hs-t${tid}-${hs}
286         local rtname=rt-${rt}
287         local rtveth=veth-t${tid}
288
289         # set the networking for the host
290         ip netns add ${hsname}
291
292         ip netns exec ${hsname} sysctl -wq net.ipv6.conf.all.accept_dad=0
293         ip netns exec ${hsname} sysctl -wq net.ipv6.conf.default.accept_dad=0
294
295         ip -netns ${hsname} link add veth0 type veth peer name ${rtveth}
296         ip -netns ${hsname} link set ${rtveth} netns ${rtname}
297         ip -netns ${hsname} addr add ${IPv6_HS_NETWORK}::${hs}/64 dev veth0 nodad
298         ip -netns ${hsname} addr add ${IPv4_HS_NETWORK}.${hs}/24 dev veth0
299         ip -netns ${hsname} link set veth0 up
300         ip -netns ${hsname} link set lo up
301
302         # configure the VRF for the tenant X on the router which is directly
303         # connected to the source host.
304         ip -netns ${rtname} link add vrf-${tid} type vrf table ${tid}
305         ip -netns ${rtname} link set vrf-${tid} up
306
307         ip netns exec ${rtname} sysctl -wq net.ipv6.conf.all.accept_dad=0
308         ip netns exec ${rtname} sysctl -wq net.ipv6.conf.default.accept_dad=0
309
310         # enslave the veth-tX interface to the vrf-X in the access router
311         ip -netns ${rtname} link set ${rtveth} master vrf-${tid}
312         ip -netns ${rtname} addr add ${IPv6_HS_NETWORK}::254/64 dev ${rtveth} nodad
313         ip -netns ${rtname} addr add ${IPv4_HS_NETWORK}.254/24 dev ${rtveth}
314         ip -netns ${rtname} link set ${rtveth} up
315
316         ip netns exec ${rtname} sysctl -wq net.ipv6.conf.${rtveth}.proxy_ndp=1
317         ip netns exec ${rtname} sysctl -wq net.ipv4.conf.${rtveth}.proxy_arp=1
318
319         # disable the rp_filter otherwise the kernel gets confused about how
320         # to route decap ipv4 packets.
321         ip netns exec ${rtname} sysctl -wq net.ipv4.conf.all.rp_filter=0
322         ip netns exec ${rtname} sysctl -wq net.ipv4.conf.${rtveth}.rp_filter=0
323
324         ip netns exec ${rtname} sh -c "echo 1 > /proc/sys/net/vrf/strict_mode"
325 }
326
327 setup_vpn_config()
328 {
329         local hssrc=$1
330         local rtsrc=$2
331         local hsdst=$3
332         local rtdst=$4
333         local tid=$5
334
335         local hssrc_name=hs-t${tid}-${hssrc}
336         local hsdst_name=hs-t${tid}-${hsdst}
337         local rtsrc_name=rt-${rtsrc}
338         local rtdst_name=rt-${rtdst}
339         local rtveth=veth-t${tid}
340         local vpn_sid=${VPN_LOCATOR_SERVICE}:${hssrc}${hsdst}:${tid}::6046
341
342         ip -netns ${rtsrc_name} -6 neigh add proxy ${IPv6_HS_NETWORK}::${hsdst} dev ${rtveth}
343
344         # set the encap route for encapsulating packets which arrive from the
345         # host hssrc and destined to the access router rtsrc.
346         ip -netns ${rtsrc_name} -6 route add ${IPv6_HS_NETWORK}::${hsdst}/128 vrf vrf-${tid} \
347                 encap seg6 mode encap segs ${vpn_sid} dev veth0
348         ip -netns ${rtsrc_name} -4 route add ${IPv4_HS_NETWORK}.${hsdst}/32 vrf vrf-${tid} \
349                 encap seg6 mode encap segs ${vpn_sid} dev veth0
350         ip -netns ${rtsrc_name} -6 route add ${vpn_sid}/128 vrf vrf-${tid} \
351                 via fd00::${rtdst} dev veth0
352
353         # set the decap route for decapsulating packets which arrive from
354         # the rtdst router and destined to the hsdst host.
355         ip -netns ${rtdst_name} -6 route add ${vpn_sid}/128 table ${LOCALSID_TABLE_ID} \
356                 encap seg6local action End.DT46 vrftable ${tid} dev vrf-${tid}
357
358         # all sids for VPNs start with a common locator which is fc00::/16.
359         # Routes for handling the SRv6 End.DT46 behavior instances are grouped
360         # together in the 'localsid' table.
361         #
362         # NOTE: added only once
363         if [ -z "$(ip -netns ${rtdst_name} -6 rule show | \
364             grep "to ${VPN_LOCATOR_SERVICE}::/16 lookup ${LOCALSID_TABLE_ID}")" ]; then
365                 ip -netns ${rtdst_name} -6 rule add \
366                         to ${VPN_LOCATOR_SERVICE}::/16 \
367                         lookup ${LOCALSID_TABLE_ID} prio 999
368         fi
369
370         # set default routes to unreachable for both ipv4 and ipv6
371         ip -netns ${rtsrc_name} -6 route add unreachable default metric 4278198272 \
372                 vrf vrf-${tid}
373
374         ip -netns ${rtsrc_name} -4 route add unreachable default metric 4278198272 \
375                 vrf vrf-${tid}
376 }
377
378 setup()
379 {
380         ip link add veth-rt-1 type veth peer name veth-rt-2
381         # setup the networking for router rt-1 and router rt-2
382         setup_rt_networking 1
383         setup_rt_networking 2
384
385         # setup two hosts for the tenant 100.
386         #  - host hs-1 is directly connected to the router rt-1;
387         #  - host hs-2 is directly connected to the router rt-2.
388         setup_hs 1 1 100  #args: host router tenant
389         setup_hs 2 2 100
390
391         # setup two hosts for the tenant 200
392         #  - host hs-3 is directly connected to the router rt-1;
393         #  - host hs-4 is directly connected to the router rt-2.
394         setup_hs 3 1 200
395         setup_hs 4 2 200
396
397         # setup the IPv4/IPv6 L3 VPN which connects the host hs-t100-1 and host
398         # hs-t100-2 within the same tenant 100.
399         setup_vpn_config 1 1 2 2 100  #args: src_host src_router dst_host dst_router tenant
400         setup_vpn_config 2 2 1 1 100
401
402         # setup the IPv4/IPv6 L3 VPN which connects the host hs-t200-3 and host
403         # hs-t200-4 within the same tenant 200.
404         setup_vpn_config 3 1 4 2 200
405         setup_vpn_config 4 2 3 1 200
406 }
407
408 check_rt_connectivity()
409 {
410         local rtsrc=$1
411         local rtdst=$2
412
413         ip netns exec rt-${rtsrc} ping -c 1 -W 1 ${IPv6_RT_NETWORK}::${rtdst} \
414                 >/dev/null 2>&1
415 }
416
417 check_and_log_rt_connectivity()
418 {
419         local rtsrc=$1
420         local rtdst=$2
421
422         check_rt_connectivity ${rtsrc} ${rtdst}
423         log_test $? 0 "Routers connectivity: rt-${rtsrc} -> rt-${rtdst}"
424 }
425
426 check_hs_ipv6_connectivity()
427 {
428         local hssrc=$1
429         local hsdst=$2
430         local tid=$3
431
432         ip netns exec hs-t${tid}-${hssrc} ping -c 1 -W ${PING_TIMEOUT_SEC} \
433                 ${IPv6_HS_NETWORK}::${hsdst} >/dev/null 2>&1
434 }
435
436 check_hs_ipv4_connectivity()
437 {
438         local hssrc=$1
439         local hsdst=$2
440         local tid=$3
441
442         ip netns exec hs-t${tid}-${hssrc} ping -c 1 -W ${PING_TIMEOUT_SEC} \
443                 ${IPv4_HS_NETWORK}.${hsdst} >/dev/null 2>&1
444 }
445
446 check_and_log_hs_connectivity()
447 {
448         local hssrc=$1
449         local hsdst=$2
450         local tid=$3
451
452         check_hs_ipv6_connectivity ${hssrc} ${hsdst} ${tid}
453         log_test $? 0 "IPv6 Hosts connectivity: hs-t${tid}-${hssrc} -> hs-t${tid}-${hsdst} (tenant ${tid})"
454
455         check_hs_ipv4_connectivity ${hssrc} ${hsdst} ${tid}
456         log_test $? 0 "IPv4 Hosts connectivity: hs-t${tid}-${hssrc} -> hs-t${tid}-${hsdst} (tenant ${tid})"
457
458 }
459
460 check_and_log_hs_isolation()
461 {
462         local hssrc=$1
463         local tidsrc=$2
464         local hsdst=$3
465         local tiddst=$4
466
467         check_hs_ipv6_connectivity ${hssrc} ${hsdst} ${tidsrc}
468         # NOTE: ping should fail
469         log_test $? 1 "IPv6 Hosts isolation: hs-t${tidsrc}-${hssrc} -X-> hs-t${tiddst}-${hsdst}"
470
471         check_hs_ipv4_connectivity ${hssrc} ${hsdst} ${tidsrc}
472         # NOTE: ping should fail
473         log_test $? 1 "IPv4 Hosts isolation: hs-t${tidsrc}-${hssrc} -X-> hs-t${tiddst}-${hsdst}"
474
475 }
476
477
478 check_and_log_hs2gw_connectivity()
479 {
480         local hssrc=$1
481         local tid=$2
482
483         check_hs_ipv6_connectivity ${hssrc} 254 ${tid}
484         log_test $? 0 "IPv6 Hosts connectivity: hs-t${tid}-${hssrc} -> gw (tenant ${tid})"
485
486         check_hs_ipv4_connectivity ${hssrc} 254 ${tid}
487         log_test $? 0 "IPv4 Hosts connectivity: hs-t${tid}-${hssrc} -> gw (tenant ${tid})"
488
489 }
490
491 router_tests()
492 {
493         log_section "IPv6 routers connectivity test"
494
495         check_and_log_rt_connectivity 1 2
496         check_and_log_rt_connectivity 2 1
497 }
498
499 host2gateway_tests()
500 {
501         log_section "IPv4/IPv6 connectivity test among hosts and gateway"
502
503         check_and_log_hs2gw_connectivity 1 100
504         check_and_log_hs2gw_connectivity 2 100
505
506         check_and_log_hs2gw_connectivity 3 200
507         check_and_log_hs2gw_connectivity 4 200
508 }
509
510 host_vpn_tests()
511 {
512         log_section "SRv6 VPN connectivity test among hosts in the same tenant"
513
514         check_and_log_hs_connectivity 1 2 100
515         check_and_log_hs_connectivity 2 1 100
516
517         check_and_log_hs_connectivity 3 4 200
518         check_and_log_hs_connectivity 4 3 200
519 }
520
521 host_vpn_isolation_tests()
522 {
523         local i
524         local j
525         local k
526         local tmp
527         local l1="1 2"
528         local l2="3 4"
529         local t1=100
530         local t2=200
531
532         log_section "SRv6 VPN isolation test among hosts in different tentants"
533
534         for k in 0 1; do
535                 for i in ${l1}; do
536                         for j in ${l2}; do
537                                 check_and_log_hs_isolation ${i} ${t1} ${j} ${t2}
538                         done
539                 done
540
541                 # let us test the reverse path
542                 tmp="${l1}"; l1="${l2}"; l2="${tmp}"
543                 tmp=${t1}; t1=${t2}; t2=${tmp}
544         done
545 }
546
547 if [ "$(id -u)" -ne 0 ];then
548         echo "SKIP: Need root privileges"
549         exit $ksft_skip
550 fi
551
552 if [ ! -x "$(command -v ip)" ]; then
553         echo "SKIP: Could not run test without ip tool"
554         exit $ksft_skip
555 fi
556
557 modprobe vrf &>/dev/null
558 if [ ! -e /proc/sys/net/vrf/strict_mode ]; then
559         echo "SKIP: vrf sysctl does not exist"
560         exit $ksft_skip
561 fi
562
563 cleanup &>/dev/null
564
565 setup
566
567 router_tests
568 host2gateway_tests
569 host_vpn_tests
570 host_vpn_isolation_tests
571
572 print_log_test_results
573
574 cleanup &>/dev/null
575
576 exit ${ret}