xref: /openbmc/linux/tools/testing/selftests/net/ioam6.sh (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1968691c7SJustin Iurman#!/bin/bash
2968691c7SJustin Iurman# SPDX-License-Identifier: GPL-2.0+
3968691c7SJustin Iurman#
4968691c7SJustin Iurman# Author: Justin Iurman <justin.iurman@uliege.be>
5968691c7SJustin Iurman#
6752be297SJustin Iurman# This script evaluates the IOAM insertion for IPv6 by checking the IOAM data
7752be297SJustin Iurman# consistency directly inside packets on the receiver side. Tests are divided
8752be297SJustin Iurman# into three categories: OUTPUT (evaluates the IOAM processing by the sender),
9bf77b140SJustin Iurman# INPUT (evaluates the IOAM processing by a receiver) and GLOBAL (evaluates
10752be297SJustin Iurman# wider use cases that do not fall into the other two categories). Both OUTPUT
11752be297SJustin Iurman# and INPUT tests only use a two-node topology (alpha and beta), while GLOBAL
12752be297SJustin Iurman# tests use the entire three-node topology (alpha, beta, gamma). Each test is
13752be297SJustin Iurman# documented inside its own handler in the code below.
14968691c7SJustin Iurman#
15752be297SJustin Iurman# An IOAM domain is configured from Alpha to Gamma but not on the reverse path.
16752be297SJustin Iurman# When either Beta or Gamma is the destination (depending on the test category),
17752be297SJustin Iurman# Alpha adds an IOAM option (Pre-allocated Trace) inside a Hop-by-hop.
18752be297SJustin Iurman#
19968691c7SJustin Iurman#
20968691c7SJustin Iurman#            +-------------------+            +-------------------+
21968691c7SJustin Iurman#            |                   |            |                   |
22752be297SJustin Iurman#            |    Alpha netns    |            |    Gamma netns    |
23968691c7SJustin Iurman#            |                   |            |                   |
24968691c7SJustin Iurman#            |  +-------------+  |            |  +-------------+  |
25968691c7SJustin Iurman#            |  |    veth0    |  |            |  |    veth0    |  |
26968691c7SJustin Iurman#            |  |  db01::2/64 |  |            |  |  db02::2/64 |  |
27968691c7SJustin Iurman#            |  +-------------+  |            |  +-------------+  |
28968691c7SJustin Iurman#            |         .         |            |         .         |
29968691c7SJustin Iurman#            +-------------------+            +-------------------+
30968691c7SJustin Iurman#                      .                                .
31968691c7SJustin Iurman#                      .                                .
32968691c7SJustin Iurman#                      .                                .
33968691c7SJustin Iurman#            +----------------------------------------------------+
34968691c7SJustin Iurman#            |         .                                .         |
35968691c7SJustin Iurman#            |  +-------------+                  +-------------+  |
36968691c7SJustin Iurman#            |  |    veth0    |                  |    veth1    |  |
37968691c7SJustin Iurman#            |  |  db01::1/64 | ................ |  db02::1/64 |  |
38968691c7SJustin Iurman#            |  +-------------+                  +-------------+  |
39968691c7SJustin Iurman#            |                                                    |
40752be297SJustin Iurman#            |                      Beta netns                    |
41968691c7SJustin Iurman#            |                                                    |
42752be297SJustin Iurman#            +----------------------------------------------------+
43968691c7SJustin Iurman#
44968691c7SJustin Iurman#
45968691c7SJustin Iurman#
46752be297SJustin Iurman#        =============================================================
47752be297SJustin Iurman#        |                Alpha - IOAM configuration                 |
48752be297SJustin Iurman#        +===========================================================+
49968691c7SJustin Iurman#        | Node ID             | 1                                   |
50968691c7SJustin Iurman#        +-----------------------------------------------------------+
51968691c7SJustin Iurman#        | Node Wide ID        | 11111111                            |
52968691c7SJustin Iurman#        +-----------------------------------------------------------+
53968691c7SJustin Iurman#        | Ingress ID          | 0xffff (default value)              |
54968691c7SJustin Iurman#        +-----------------------------------------------------------+
55968691c7SJustin Iurman#        | Ingress Wide ID     | 0xffffffff (default value)          |
56968691c7SJustin Iurman#        +-----------------------------------------------------------+
57968691c7SJustin Iurman#        | Egress ID           | 101                                 |
58968691c7SJustin Iurman#        +-----------------------------------------------------------+
59968691c7SJustin Iurman#        | Egress Wide ID      | 101101                              |
60968691c7SJustin Iurman#        +-----------------------------------------------------------+
61968691c7SJustin Iurman#        | Namespace Data      | 0xdeadbee0                          |
62968691c7SJustin Iurman#        +-----------------------------------------------------------+
63968691c7SJustin Iurman#        | Namespace Wide Data | 0xcafec0caf00dc0de                  |
64968691c7SJustin Iurman#        +-----------------------------------------------------------+
65968691c7SJustin Iurman#        | Schema ID           | 777                                 |
66968691c7SJustin Iurman#        +-----------------------------------------------------------+
67968691c7SJustin Iurman#        | Schema Data         | something that will be 4n-aligned   |
68968691c7SJustin Iurman#        +-----------------------------------------------------------+
69968691c7SJustin Iurman#
70968691c7SJustin Iurman#
71752be297SJustin Iurman#        =============================================================
72752be297SJustin Iurman#        |                 Beta - IOAM configuration                 |
73752be297SJustin Iurman#        +===========================================================+
74968691c7SJustin Iurman#        | Node ID             | 2                                   |
75968691c7SJustin Iurman#        +-----------------------------------------------------------+
76968691c7SJustin Iurman#        | Node Wide ID        | 22222222                            |
77968691c7SJustin Iurman#        +-----------------------------------------------------------+
78968691c7SJustin Iurman#        | Ingress ID          | 201                                 |
79968691c7SJustin Iurman#        +-----------------------------------------------------------+
80968691c7SJustin Iurman#        | Ingress Wide ID     | 201201                              |
81968691c7SJustin Iurman#        +-----------------------------------------------------------+
82968691c7SJustin Iurman#        | Egress ID           | 202                                 |
83968691c7SJustin Iurman#        +-----------------------------------------------------------+
84968691c7SJustin Iurman#        | Egress Wide ID      | 202202                              |
85968691c7SJustin Iurman#        +-----------------------------------------------------------+
86968691c7SJustin Iurman#        | Namespace Data      | 0xdeadbee1                          |
87968691c7SJustin Iurman#        +-----------------------------------------------------------+
88968691c7SJustin Iurman#        | Namespace Wide Data | 0xcafec0caf11dc0de                  |
89968691c7SJustin Iurman#        +-----------------------------------------------------------+
90752be297SJustin Iurman#        | Schema ID           | 666                                 |
91968691c7SJustin Iurman#        +-----------------------------------------------------------+
92752be297SJustin Iurman#        | Schema Data         | Hello there -Obi                    |
93968691c7SJustin Iurman#        +-----------------------------------------------------------+
94968691c7SJustin Iurman#
95752be297SJustin Iurman#
96752be297SJustin Iurman#        =============================================================
97752be297SJustin Iurman#        |                Gamma - IOAM configuration                 |
98752be297SJustin Iurman#        +===========================================================+
99968691c7SJustin Iurman#        | Node ID             | 3                                   |
100968691c7SJustin Iurman#        +-----------------------------------------------------------+
101968691c7SJustin Iurman#        | Node Wide ID        | 33333333                            |
102968691c7SJustin Iurman#        +-----------------------------------------------------------+
103968691c7SJustin Iurman#        | Ingress ID          | 301                                 |
104968691c7SJustin Iurman#        +-----------------------------------------------------------+
105968691c7SJustin Iurman#        | Ingress Wide ID     | 301301                              |
106968691c7SJustin Iurman#        +-----------------------------------------------------------+
107968691c7SJustin Iurman#        | Egress ID           | 0xffff (default value)              |
108968691c7SJustin Iurman#        +-----------------------------------------------------------+
109968691c7SJustin Iurman#        | Egress Wide ID      | 0xffffffff (default value)          |
110968691c7SJustin Iurman#        +-----------------------------------------------------------+
111968691c7SJustin Iurman#        | Namespace Data      | 0xdeadbee2                          |
112968691c7SJustin Iurman#        +-----------------------------------------------------------+
113968691c7SJustin Iurman#        | Namespace Wide Data | 0xcafec0caf22dc0de                  |
114968691c7SJustin Iurman#        +-----------------------------------------------------------+
115968691c7SJustin Iurman#        | Schema ID           | 0xffffff (= None)                   |
116968691c7SJustin Iurman#        +-----------------------------------------------------------+
117968691c7SJustin Iurman#        | Schema Data         |                                     |
118968691c7SJustin Iurman#        +-----------------------------------------------------------+
119968691c7SJustin Iurman
120*1995943cSKleber Sacilotto de Souza# Kselftest framework requirement - SKIP code is 4.
121*1995943cSKleber Sacilotto de Souzaksft_skip=4
122752be297SJustin Iurman
123752be297SJustin Iurman################################################################################
124752be297SJustin Iurman#                                                                              #
125752be297SJustin Iurman# WARNING: Be careful if you modify the block below - it MUST be kept          #
126752be297SJustin Iurman#          synchronized with configurations inside ioam6_parser.c and always   #
127752be297SJustin Iurman#          reflect the same.                                                   #
128752be297SJustin Iurman#                                                                              #
129752be297SJustin Iurman################################################################################
130968691c7SJustin Iurman
131968691c7SJustin IurmanALPHA=(
132968691c7SJustin Iurman	1					# ID
133968691c7SJustin Iurman	11111111				# Wide ID
134968691c7SJustin Iurman	0xffff					# Ingress ID
135968691c7SJustin Iurman	0xffffffff				# Ingress Wide ID
136968691c7SJustin Iurman	101					# Egress ID
137968691c7SJustin Iurman	101101					# Egress Wide ID
138968691c7SJustin Iurman	0xdeadbee0				# Namespace Data
139968691c7SJustin Iurman	0xcafec0caf00dc0de			# Namespace Wide Data
140968691c7SJustin Iurman	777					# Schema ID (0xffffff = None)
141968691c7SJustin Iurman	"something that will be 4n-aligned"	# Schema Data
142968691c7SJustin Iurman)
143968691c7SJustin Iurman
144968691c7SJustin IurmanBETA=(
145968691c7SJustin Iurman	2
146968691c7SJustin Iurman	22222222
147968691c7SJustin Iurman	201
148968691c7SJustin Iurman	201201
149968691c7SJustin Iurman	202
150968691c7SJustin Iurman	202202
151968691c7SJustin Iurman	0xdeadbee1
152968691c7SJustin Iurman	0xcafec0caf11dc0de
153752be297SJustin Iurman	666
154752be297SJustin Iurman	"Hello there -Obi"
155968691c7SJustin Iurman)
156968691c7SJustin Iurman
157968691c7SJustin IurmanGAMMA=(
158968691c7SJustin Iurman	3
159968691c7SJustin Iurman	33333333
160968691c7SJustin Iurman	301
161968691c7SJustin Iurman	301301
162968691c7SJustin Iurman	0xffff
163968691c7SJustin Iurman	0xffffffff
164968691c7SJustin Iurman	0xdeadbee2
165968691c7SJustin Iurman	0xcafec0caf22dc0de
166968691c7SJustin Iurman	0xffffff
167968691c7SJustin Iurman	""
168968691c7SJustin Iurman)
169968691c7SJustin Iurman
170752be297SJustin IurmanTESTS_OUTPUT="
171752be297SJustin Iurman	out_undef_ns
172752be297SJustin Iurman	out_no_room
173752be297SJustin Iurman	out_bits
174752be297SJustin Iurman	out_full_supp_trace
175752be297SJustin Iurman"
176752be297SJustin Iurman
177752be297SJustin IurmanTESTS_INPUT="
178752be297SJustin Iurman	in_undef_ns
179752be297SJustin Iurman	in_no_room
180752be297SJustin Iurman	in_oflag
181752be297SJustin Iurman	in_bits
182752be297SJustin Iurman	in_full_supp_trace
183752be297SJustin Iurman"
184752be297SJustin Iurman
185752be297SJustin IurmanTESTS_GLOBAL="
186752be297SJustin Iurman	fwd_full_supp_trace
187752be297SJustin Iurman"
188752be297SJustin Iurman
189752be297SJustin Iurman
190752be297SJustin Iurman################################################################################
191752be297SJustin Iurman#                                                                              #
192752be297SJustin Iurman#                                   LIBRARY                                    #
193752be297SJustin Iurman#                                                                              #
194752be297SJustin Iurman################################################################################
195752be297SJustin Iurman
196752be297SJustin Iurmancheck_kernel_compatibility()
197752be297SJustin Iurman{
198752be297SJustin Iurman  ip netns add ioam-tmp-node
199752be297SJustin Iurman  ip link add name veth0 netns ioam-tmp-node type veth \
200752be297SJustin Iurman         peer name veth1 netns ioam-tmp-node
201752be297SJustin Iurman
202752be297SJustin Iurman  ip -netns ioam-tmp-node link set veth0 up
203752be297SJustin Iurman  ip -netns ioam-tmp-node link set veth1 up
204752be297SJustin Iurman
205bf77b140SJustin Iurman  ip -netns ioam-tmp-node ioam namespace add 0
206752be297SJustin Iurman  ns_ad=$?
207752be297SJustin Iurman
208752be297SJustin Iurman  ip -netns ioam-tmp-node ioam namespace show | grep -q "namespace 0"
209752be297SJustin Iurman  ns_sh=$?
210752be297SJustin Iurman
211752be297SJustin Iurman  if [[ $ns_ad != 0 || $ns_sh != 0 ]]
212752be297SJustin Iurman  then
213752be297SJustin Iurman    echo "SKIP: kernel version probably too old, missing ioam support"
214752be297SJustin Iurman    ip link del veth0 2>/dev/null || true
215752be297SJustin Iurman    ip netns del ioam-tmp-node || true
216*1995943cSKleber Sacilotto de Souza    exit $ksft_skip
217968691c7SJustin Iurman  fi
218968691c7SJustin Iurman
219bf77b140SJustin Iurman  ip -netns ioam-tmp-node route add db02::/64 encap ioam6 mode inline \
220bf77b140SJustin Iurman         trace prealloc type 0x800000 ns 0 size 4 dev veth0
221752be297SJustin Iurman  tr_ad=$?
222752be297SJustin Iurman
223bf77b140SJustin Iurman  ip -netns ioam-tmp-node -6 route | grep -q "encap ioam6"
224752be297SJustin Iurman  tr_sh=$?
225752be297SJustin Iurman
226752be297SJustin Iurman  if [[ $tr_ad != 0 || $tr_sh != 0 ]]
227752be297SJustin Iurman  then
228752be297SJustin Iurman    echo "SKIP: cannot attach an ioam trace to a route, did you compile" \
229752be297SJustin Iurman         "without CONFIG_IPV6_IOAM6_LWTUNNEL?"
230752be297SJustin Iurman    ip link del veth0 2>/dev/null || true
231752be297SJustin Iurman    ip netns del ioam-tmp-node || true
232*1995943cSKleber Sacilotto de Souza    exit $ksft_skip
233968691c7SJustin Iurman  fi
234968691c7SJustin Iurman
235752be297SJustin Iurman  ip link del veth0 2>/dev/null || true
236752be297SJustin Iurman  ip netns del ioam-tmp-node || true
237bf77b140SJustin Iurman
238bf77b140SJustin Iurman  lsmod | grep -q "ip6_tunnel"
239bf77b140SJustin Iurman  ip6tnl_loaded=$?
240bf77b140SJustin Iurman
241bf77b140SJustin Iurman  if [ $ip6tnl_loaded = 0 ]
242bf77b140SJustin Iurman  then
243bf77b140SJustin Iurman    encap_tests=0
244bf77b140SJustin Iurman  else
245bf77b140SJustin Iurman    modprobe ip6_tunnel &>/dev/null
246bf77b140SJustin Iurman    lsmod | grep -q "ip6_tunnel"
247bf77b140SJustin Iurman    encap_tests=$?
248bf77b140SJustin Iurman
249bf77b140SJustin Iurman    if [ $encap_tests != 0 ]
250bf77b140SJustin Iurman    then
251bf77b140SJustin Iurman      ip a | grep -q "ip6tnl0"
252bf77b140SJustin Iurman      encap_tests=$?
253bf77b140SJustin Iurman
254bf77b140SJustin Iurman      if [ $encap_tests != 0 ]
255bf77b140SJustin Iurman      then
256bf77b140SJustin Iurman        echo "Note: ip6_tunnel not found neither as a module nor inside the" \
257bf77b140SJustin Iurman             "kernel, tests that require it (encap mode) will be omitted"
258bf77b140SJustin Iurman      fi
259bf77b140SJustin Iurman    fi
260bf77b140SJustin Iurman  fi
261752be297SJustin Iurman}
262968691c7SJustin Iurman
263968691c7SJustin Iurmancleanup()
264968691c7SJustin Iurman{
265968691c7SJustin Iurman  ip link del ioam-veth-alpha 2>/dev/null || true
266968691c7SJustin Iurman  ip link del ioam-veth-gamma 2>/dev/null || true
267968691c7SJustin Iurman
268968691c7SJustin Iurman  ip netns del ioam-node-alpha || true
269968691c7SJustin Iurman  ip netns del ioam-node-beta || true
270968691c7SJustin Iurman  ip netns del ioam-node-gamma || true
271bf77b140SJustin Iurman
272bf77b140SJustin Iurman  if [ $ip6tnl_loaded != 0 ]
273bf77b140SJustin Iurman  then
274bf77b140SJustin Iurman    modprobe -r ip6_tunnel 2>/dev/null || true
275bf77b140SJustin Iurman  fi
276968691c7SJustin Iurman}
277968691c7SJustin Iurman
278968691c7SJustin Iurmansetup()
279968691c7SJustin Iurman{
280968691c7SJustin Iurman  ip netns add ioam-node-alpha
281968691c7SJustin Iurman  ip netns add ioam-node-beta
282968691c7SJustin Iurman  ip netns add ioam-node-gamma
283968691c7SJustin Iurman
284752be297SJustin Iurman  ip link add name ioam-veth-alpha netns ioam-node-alpha type veth \
285752be297SJustin Iurman         peer name ioam-veth-betaL netns ioam-node-beta
286752be297SJustin Iurman  ip link add name ioam-veth-betaR netns ioam-node-beta type veth \
287752be297SJustin Iurman         peer name ioam-veth-gamma netns ioam-node-gamma
288968691c7SJustin Iurman
289968691c7SJustin Iurman  ip -netns ioam-node-alpha link set ioam-veth-alpha name veth0
290968691c7SJustin Iurman  ip -netns ioam-node-beta link set ioam-veth-betaL name veth0
291968691c7SJustin Iurman  ip -netns ioam-node-beta link set ioam-veth-betaR name veth1
292968691c7SJustin Iurman  ip -netns ioam-node-gamma link set ioam-veth-gamma name veth0
293968691c7SJustin Iurman
294968691c7SJustin Iurman  ip -netns ioam-node-alpha addr add db01::2/64 dev veth0
295968691c7SJustin Iurman  ip -netns ioam-node-alpha link set veth0 up
296968691c7SJustin Iurman  ip -netns ioam-node-alpha link set lo up
297752be297SJustin Iurman  ip -netns ioam-node-alpha route add db02::/64 via db01::1 dev veth0
298752be297SJustin Iurman  ip -netns ioam-node-alpha route del db01::/64
299752be297SJustin Iurman  ip -netns ioam-node-alpha route add db01::/64 dev veth0
300968691c7SJustin Iurman
301968691c7SJustin Iurman  ip -netns ioam-node-beta addr add db01::1/64 dev veth0
302968691c7SJustin Iurman  ip -netns ioam-node-beta addr add db02::1/64 dev veth1
303968691c7SJustin Iurman  ip -netns ioam-node-beta link set veth0 up
304968691c7SJustin Iurman  ip -netns ioam-node-beta link set veth1 up
305968691c7SJustin Iurman  ip -netns ioam-node-beta link set lo up
306968691c7SJustin Iurman
307968691c7SJustin Iurman  ip -netns ioam-node-gamma addr add db02::2/64 dev veth0
308968691c7SJustin Iurman  ip -netns ioam-node-gamma link set veth0 up
309968691c7SJustin Iurman  ip -netns ioam-node-gamma link set lo up
310752be297SJustin Iurman  ip -netns ioam-node-gamma route add db01::/64 via db02::1 dev veth0
311968691c7SJustin Iurman
312968691c7SJustin Iurman  # - IOAM config -
313968691c7SJustin Iurman  ip netns exec ioam-node-alpha sysctl -wq net.ipv6.ioam6_id=${ALPHA[0]}
314968691c7SJustin Iurman  ip netns exec ioam-node-alpha sysctl -wq net.ipv6.ioam6_id_wide=${ALPHA[1]}
315968691c7SJustin Iurman  ip netns exec ioam-node-alpha sysctl -wq net.ipv6.conf.veth0.ioam6_id=${ALPHA[4]}
316968691c7SJustin Iurman  ip netns exec ioam-node-alpha sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${ALPHA[5]}
317752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace add 123 data ${ALPHA[6]} wide ${ALPHA[7]}
318968691c7SJustin Iurman  ip -netns ioam-node-alpha ioam schema add ${ALPHA[8]} "${ALPHA[9]}"
319752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace set 123 schema ${ALPHA[8]}
320968691c7SJustin Iurman
321968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.all.forwarding=1
322968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.ioam6_id=${BETA[0]}
323968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.ioam6_id_wide=${BETA[1]}
324968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1
325968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_id=${BETA[2]}
326968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${BETA[3]}
327968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth1.ioam6_id=${BETA[4]}
328968691c7SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth1.ioam6_id_wide=${BETA[5]}
329752be297SJustin Iurman  ip -netns ioam-node-beta ioam namespace add 123 data ${BETA[6]} wide ${BETA[7]}
330752be297SJustin Iurman  ip -netns ioam-node-beta ioam schema add ${BETA[8]} "${BETA[9]}"
331752be297SJustin Iurman  ip -netns ioam-node-beta ioam namespace set 123 schema ${BETA[8]}
332968691c7SJustin Iurman
333968691c7SJustin Iurman  ip netns exec ioam-node-gamma sysctl -wq net.ipv6.ioam6_id=${GAMMA[0]}
334968691c7SJustin Iurman  ip netns exec ioam-node-gamma sysctl -wq net.ipv6.ioam6_id_wide=${GAMMA[1]}
335968691c7SJustin Iurman  ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1
336968691c7SJustin Iurman  ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_id=${GAMMA[2]}
337968691c7SJustin Iurman  ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${GAMMA[3]}
338752be297SJustin Iurman  ip -netns ioam-node-gamma ioam namespace add 123 data ${GAMMA[6]} wide ${GAMMA[7]}
339752be297SJustin Iurman
340752be297SJustin Iurman  sleep 1
341752be297SJustin Iurman
342752be297SJustin Iurman  ip netns exec ioam-node-alpha ping6 -c 5 -W 1 db02::2 &>/dev/null
343752be297SJustin Iurman  if [ $? != 0 ]
344752be297SJustin Iurman  then
345752be297SJustin Iurman    echo "Setup FAILED"
346752be297SJustin Iurman    cleanup &>/dev/null
347752be297SJustin Iurman    exit 0
348752be297SJustin Iurman  fi
349752be297SJustin Iurman}
350752be297SJustin Iurman
351752be297SJustin Iurmanlog_test_passed()
352752be297SJustin Iurman{
353752be297SJustin Iurman  local desc=$1
354752be297SJustin Iurman  printf "TEST: %-60s  [ OK ]\n" "${desc}"
355752be297SJustin Iurman}
356752be297SJustin Iurman
357752be297SJustin Iurmanlog_test_failed()
358752be297SJustin Iurman{
359752be297SJustin Iurman  local desc=$1
360752be297SJustin Iurman  printf "TEST: %-60s  [FAIL]\n" "${desc}"
361752be297SJustin Iurman}
362752be297SJustin Iurman
363bf77b140SJustin Iurmanlog_results()
364bf77b140SJustin Iurman{
365bf77b140SJustin Iurman  echo "- Tests passed: ${npassed}"
366bf77b140SJustin Iurman  echo "- Tests failed: ${nfailed}"
367bf77b140SJustin Iurman}
368bf77b140SJustin Iurman
369752be297SJustin Iurmanrun_test()
370752be297SJustin Iurman{
371752be297SJustin Iurman  local name=$1
372752be297SJustin Iurman  local desc=$2
373752be297SJustin Iurman  local node_src=$3
374752be297SJustin Iurman  local node_dst=$4
375752be297SJustin Iurman  local ip6_src=$5
376752be297SJustin Iurman  local ip6_dst=$6
377752be297SJustin Iurman  local if_dst=$7
378752be297SJustin Iurman  local trace_type=$8
379752be297SJustin Iurman  local ioam_ns=$9
380752be297SJustin Iurman
381752be297SJustin Iurman  ip netns exec $node_dst ./ioam6_parser $if_dst $name $ip6_src $ip6_dst \
382752be297SJustin Iurman         $trace_type $ioam_ns &
383752be297SJustin Iurman  local spid=$!
384752be297SJustin Iurman  sleep 0.1
385752be297SJustin Iurman
386752be297SJustin Iurman  ip netns exec $node_src ping6 -t 64 -c 1 -W 1 $ip6_dst &>/dev/null
387752be297SJustin Iurman  if [ $? != 0 ]
388752be297SJustin Iurman  then
389bf77b140SJustin Iurman    nfailed=$((nfailed+1))
390752be297SJustin Iurman    log_test_failed "${desc}"
391752be297SJustin Iurman    kill -2 $spid &>/dev/null
392752be297SJustin Iurman  else
393752be297SJustin Iurman    wait $spid
394bf77b140SJustin Iurman    if [ $? = 0 ]
395bf77b140SJustin Iurman    then
396bf77b140SJustin Iurman      npassed=$((npassed+1))
397bf77b140SJustin Iurman      log_test_passed "${desc}"
398bf77b140SJustin Iurman    else
399bf77b140SJustin Iurman      nfailed=$((nfailed+1))
400bf77b140SJustin Iurman      log_test_failed "${desc}"
401bf77b140SJustin Iurman    fi
402752be297SJustin Iurman  fi
403968691c7SJustin Iurman}
404968691c7SJustin Iurman
405968691c7SJustin Iurmanrun()
406968691c7SJustin Iurman{
407752be297SJustin Iurman  echo
408bf77b140SJustin Iurman  printf "%0.s-" {1..74}
409bf77b140SJustin Iurman  echo
410752be297SJustin Iurman  echo "OUTPUT tests"
411752be297SJustin Iurman  printf "%0.s-" {1..74}
412752be297SJustin Iurman  echo
413968691c7SJustin Iurman
414752be297SJustin Iurman  # set OUTPUT settings
415752be297SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=0
416752be297SJustin Iurman
417752be297SJustin Iurman  for t in $TESTS_OUTPUT
418752be297SJustin Iurman  do
419bf77b140SJustin Iurman    $t "inline"
420bf77b140SJustin Iurman    [ $encap_tests = 0 ] && $t "encap"
421752be297SJustin Iurman  done
422752be297SJustin Iurman
423752be297SJustin Iurman  # clean OUTPUT settings
424752be297SJustin Iurman  ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1
425752be297SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 dev veth0
426752be297SJustin Iurman
427752be297SJustin Iurman
428752be297SJustin Iurman  echo
429bf77b140SJustin Iurman  printf "%0.s-" {1..74}
430bf77b140SJustin Iurman  echo
431752be297SJustin Iurman  echo "INPUT tests"
432752be297SJustin Iurman  printf "%0.s-" {1..74}
433752be297SJustin Iurman  echo
434752be297SJustin Iurman
435752be297SJustin Iurman  # set INPUT settings
436752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace del 123
437752be297SJustin Iurman
438752be297SJustin Iurman  for t in $TESTS_INPUT
439752be297SJustin Iurman  do
440bf77b140SJustin Iurman    $t "inline"
441bf77b140SJustin Iurman    [ $encap_tests = 0 ] && $t "encap"
442752be297SJustin Iurman  done
443752be297SJustin Iurman
444752be297SJustin Iurman  # clean INPUT settings
445752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace add 123 \
446752be297SJustin Iurman         data ${ALPHA[6]} wide ${ALPHA[7]}
447752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace set 123 schema ${ALPHA[8]}
448752be297SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 dev veth0
449752be297SJustin Iurman
450bf77b140SJustin Iurman  echo
451bf77b140SJustin Iurman  printf "%0.s-" {1..74}
452752be297SJustin Iurman  echo
453752be297SJustin Iurman  echo "GLOBAL tests"
454752be297SJustin Iurman  printf "%0.s-" {1..74}
455752be297SJustin Iurman  echo
456752be297SJustin Iurman
457752be297SJustin Iurman  for t in $TESTS_GLOBAL
458752be297SJustin Iurman  do
459bf77b140SJustin Iurman    $t "inline"
460bf77b140SJustin Iurman    [ $encap_tests = 0 ] && $t "encap"
461752be297SJustin Iurman  done
462bf77b140SJustin Iurman
463bf77b140SJustin Iurman  echo
464bf77b140SJustin Iurman  log_results
465752be297SJustin Iurman}
466752be297SJustin Iurman
467752be297SJustin Iurmanbit2type=(
468752be297SJustin Iurman  0x800000 0x400000 0x200000 0x100000 0x080000 0x040000 0x020000 0x010000
469752be297SJustin Iurman  0x008000 0x004000 0x002000 0x001000 0x000800 0x000400 0x000200 0x000100
470752be297SJustin Iurman  0x000080 0x000040 0x000020 0x000010 0x000008 0x000004 0x000002
471752be297SJustin Iurman)
472752be297SJustin Iurmanbit2size=( 4 4 4 4 4 4 4 4 8 8 8 4 4 4 4 4 4 4 4 4 4 4 4 )
473752be297SJustin Iurman
474752be297SJustin Iurman
475752be297SJustin Iurman################################################################################
476752be297SJustin Iurman#                                                                              #
477752be297SJustin Iurman#                              OUTPUT tests                                    #
478752be297SJustin Iurman#                                                                              #
479752be297SJustin Iurman#   Two nodes (sender/receiver), IOAM disabled on ingress for the receiver.    #
480752be297SJustin Iurman################################################################################
481752be297SJustin Iurman
482752be297SJustin Iurmanout_undef_ns()
483752be297SJustin Iurman{
484752be297SJustin Iurman  ##############################################################################
485752be297SJustin Iurman  # Make sure that the encap node won't fill the trace if the chosen IOAM      #
486752be297SJustin Iurman  # namespace is not configured locally.                                       #
487752be297SJustin Iurman  ##############################################################################
488752be297SJustin Iurman  local desc="Unknown IOAM namespace"
489752be297SJustin Iurman
490bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
491bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
492752be297SJustin Iurman
493bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
494bf77b140SJustin Iurman         trace prealloc type 0x800000 ns 0 size 4 dev veth0
495bf77b140SJustin Iurman
496bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
497bf77b140SJustin Iurman         db01::2 db01::1 veth0 0x800000 0
498bf77b140SJustin Iurman
499bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
500752be297SJustin Iurman}
501752be297SJustin Iurman
502752be297SJustin Iurmanout_no_room()
503752be297SJustin Iurman{
504752be297SJustin Iurman  ##############################################################################
505752be297SJustin Iurman  # Make sure that the encap node won't fill the trace and will set the        #
506752be297SJustin Iurman  # Overflow flag since there is no room enough for its data.                  #
507752be297SJustin Iurman  ##############################################################################
508752be297SJustin Iurman  local desc="Missing trace room"
509752be297SJustin Iurman
510bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
511bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
512752be297SJustin Iurman
513bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
514bf77b140SJustin Iurman         trace prealloc type 0xc00000 ns 123 size 4 dev veth0
515bf77b140SJustin Iurman
516bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
517bf77b140SJustin Iurman         db01::2 db01::1 veth0 0xc00000 123
518bf77b140SJustin Iurman
519bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
520752be297SJustin Iurman}
521752be297SJustin Iurman
522752be297SJustin Iurmanout_bits()
523752be297SJustin Iurman{
524752be297SJustin Iurman  ##############################################################################
525752be297SJustin Iurman  # Make sure that, for each trace type bit, the encap node will either:       #
526752be297SJustin Iurman  #  (i)  fill the trace with its data when it is a supported bit              #
527752be297SJustin Iurman  #  (ii) not fill the trace with its data when it is an unsupported bit       #
528752be297SJustin Iurman  ##############################################################################
529752be297SJustin Iurman  local desc="Trace type with bit <n> only"
530752be297SJustin Iurman
531752be297SJustin Iurman  local tmp=${bit2size[22]}
532752be297SJustin Iurman  bit2size[22]=$(( $tmp + ${#ALPHA[9]} + ((4 - (${#ALPHA[9]} % 4)) % 4) ))
533752be297SJustin Iurman
534bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
535bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
536bf77b140SJustin Iurman
537752be297SJustin Iurman  for i in {0..22}
538752be297SJustin Iurman  do
539bf77b140SJustin Iurman    ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
540bf77b140SJustin Iurman           trace prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} \
5417b1700e0SJustin Iurman           dev veth0 &>/dev/null
542752be297SJustin Iurman
5437b1700e0SJustin Iurman    local cmd_res=$?
5447b1700e0SJustin Iurman    local descr="${desc/<n>/$i}"
5457b1700e0SJustin Iurman
5467b1700e0SJustin Iurman    if [[ $i -ge 12 && $i -le 21 ]]
5477b1700e0SJustin Iurman    then
5487b1700e0SJustin Iurman      if [ $cmd_res != 0 ]
5497b1700e0SJustin Iurman      then
5507b1700e0SJustin Iurman        npassed=$((npassed+1))
5517b1700e0SJustin Iurman        log_test_passed "$descr"
5527b1700e0SJustin Iurman      else
5537b1700e0SJustin Iurman        nfailed=$((nfailed+1))
5547b1700e0SJustin Iurman        log_test_failed "$descr"
5557b1700e0SJustin Iurman      fi
5567b1700e0SJustin Iurman    else
557e15f5972SJakub Kicinski	run_test "out_bit$i" "$descr ($1 mode)" ioam-node-alpha \
558bf77b140SJustin Iurman           ioam-node-beta db01::2 db01::1 veth0 ${bit2type[$i]} 123
5597b1700e0SJustin Iurman    fi
560752be297SJustin Iurman  done
561752be297SJustin Iurman
562bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
563bf77b140SJustin Iurman
564752be297SJustin Iurman  bit2size[22]=$tmp
565752be297SJustin Iurman}
566752be297SJustin Iurman
567752be297SJustin Iurmanout_full_supp_trace()
568752be297SJustin Iurman{
569752be297SJustin Iurman  ##############################################################################
570752be297SJustin Iurman  # Make sure that the encap node will correctly fill a full trace. Be careful,#
571752be297SJustin Iurman  # "full trace" here does NOT mean all bits (only supported ones).            #
572752be297SJustin Iurman  ##############################################################################
573752be297SJustin Iurman  local desc="Full supported trace"
574752be297SJustin Iurman
575bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
576bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
577752be297SJustin Iurman
578bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
579bf77b140SJustin Iurman         trace prealloc type 0xfff002 ns 123 size 100 dev veth0
580bf77b140SJustin Iurman
581bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
582bf77b140SJustin Iurman         db01::2 db01::1 veth0 0xfff002 123
583bf77b140SJustin Iurman
584bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
585752be297SJustin Iurman}
586752be297SJustin Iurman
587752be297SJustin Iurman
588752be297SJustin Iurman################################################################################
589752be297SJustin Iurman#                                                                              #
590752be297SJustin Iurman#                               INPUT tests                                    #
591752be297SJustin Iurman#                                                                              #
592752be297SJustin Iurman#     Two nodes (sender/receiver), the sender MUST NOT fill the trace upon     #
593752be297SJustin Iurman#     insertion -> the IOAM namespace configured on the sender is removed      #
594752be297SJustin Iurman#     and is used in the inserted trace to force the sender not to fill it.    #
595752be297SJustin Iurman################################################################################
596752be297SJustin Iurman
597752be297SJustin Iurmanin_undef_ns()
598752be297SJustin Iurman{
599752be297SJustin Iurman  ##############################################################################
600752be297SJustin Iurman  # Make sure that the receiving node won't fill the trace if the related IOAM #
601752be297SJustin Iurman  # namespace is not configured locally.                                       #
602752be297SJustin Iurman  ##############################################################################
603752be297SJustin Iurman  local desc="Unknown IOAM namespace"
604752be297SJustin Iurman
605bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
606bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
607752be297SJustin Iurman
608bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
609bf77b140SJustin Iurman         trace prealloc type 0x800000 ns 0 size 4 dev veth0
610bf77b140SJustin Iurman
611bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
612bf77b140SJustin Iurman         db01::2 db01::1 veth0 0x800000 0
613bf77b140SJustin Iurman
614bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
615752be297SJustin Iurman}
616752be297SJustin Iurman
617752be297SJustin Iurmanin_no_room()
618752be297SJustin Iurman{
619752be297SJustin Iurman  ##############################################################################
620752be297SJustin Iurman  # Make sure that the receiving node won't fill the trace and will set the    #
621752be297SJustin Iurman  # Overflow flag if there is no room enough for its data.                     #
622752be297SJustin Iurman  ##############################################################################
623752be297SJustin Iurman  local desc="Missing trace room"
624752be297SJustin Iurman
625bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
626bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
627752be297SJustin Iurman
628bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
629bf77b140SJustin Iurman         trace prealloc type 0xc00000 ns 123 size 4 dev veth0
630bf77b140SJustin Iurman
631bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
632bf77b140SJustin Iurman         db01::2 db01::1 veth0 0xc00000 123
633bf77b140SJustin Iurman
634bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
635752be297SJustin Iurman}
636752be297SJustin Iurman
637752be297SJustin Iurmanin_bits()
638752be297SJustin Iurman{
639752be297SJustin Iurman  ##############################################################################
640752be297SJustin Iurman  # Make sure that, for each trace type bit, the receiving node will either:   #
641752be297SJustin Iurman  #  (i)  fill the trace with its data when it is a supported bit              #
642752be297SJustin Iurman  #  (ii) not fill the trace with its data when it is an unsupported bit       #
643752be297SJustin Iurman  ##############################################################################
644752be297SJustin Iurman  local desc="Trace type with bit <n> only"
645752be297SJustin Iurman
646752be297SJustin Iurman  local tmp=${bit2size[22]}
647752be297SJustin Iurman  bit2size[22]=$(( $tmp + ${#BETA[9]} + ((4 - (${#BETA[9]} % 4)) % 4) ))
648752be297SJustin Iurman
649bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
650bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
651bf77b140SJustin Iurman
6527b1700e0SJustin Iurman  for i in {0..11} {22..22}
653752be297SJustin Iurman  do
654bf77b140SJustin Iurman    ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
655bf77b140SJustin Iurman           trace prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} \
656bf77b140SJustin Iurman           dev veth0
657752be297SJustin Iurman
658bf77b140SJustin Iurman    run_test "in_bit$i" "${desc/<n>/$i} ($1 mode)" ioam-node-alpha \
659bf77b140SJustin Iurman           ioam-node-beta db01::2 db01::1 veth0 ${bit2type[$i]} 123
660752be297SJustin Iurman  done
661752be297SJustin Iurman
662bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
663bf77b140SJustin Iurman
664752be297SJustin Iurman  bit2size[22]=$tmp
665752be297SJustin Iurman}
666752be297SJustin Iurman
667752be297SJustin Iurmanin_oflag()
668752be297SJustin Iurman{
669752be297SJustin Iurman  ##############################################################################
670752be297SJustin Iurman  # Make sure that the receiving node won't fill the trace since the Overflow  #
671752be297SJustin Iurman  # flag is set.                                                               #
672752be297SJustin Iurman  ##############################################################################
673752be297SJustin Iurman  local desc="Overflow flag is set"
674752be297SJustin Iurman
675752be297SJustin Iurman  # Exception:
676752be297SJustin Iurman  #   Here, we need the sender to set the Overflow flag. For that, we will add
677752be297SJustin Iurman  #   back the IOAM namespace that was previously configured on the sender.
678752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace add 123
679752be297SJustin Iurman
680bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
681bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
682752be297SJustin Iurman
683bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
684bf77b140SJustin Iurman         trace prealloc type 0xc00000 ns 123 size 4 dev veth0
685bf77b140SJustin Iurman
686bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
687bf77b140SJustin Iurman         db01::2 db01::1 veth0 0xc00000 123
688bf77b140SJustin Iurman
689bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
690752be297SJustin Iurman
691752be297SJustin Iurman  # And we clean the exception for this test to get things back to normal for
692752be297SJustin Iurman  # other INPUT tests
693752be297SJustin Iurman  ip -netns ioam-node-alpha ioam namespace del 123
694752be297SJustin Iurman}
695752be297SJustin Iurman
696752be297SJustin Iurmanin_full_supp_trace()
697752be297SJustin Iurman{
698752be297SJustin Iurman  ##############################################################################
699752be297SJustin Iurman  # Make sure that the receiving node will correctly fill a full trace. Be     #
700752be297SJustin Iurman  # careful, "full trace" here does NOT mean all bits (only supported ones).   #
701752be297SJustin Iurman  ##############################################################################
702752be297SJustin Iurman  local desc="Full supported trace"
703752be297SJustin Iurman
704bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
705bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
706752be297SJustin Iurman
707bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
708bf77b140SJustin Iurman         trace prealloc type 0xfff002 ns 123 size 80 dev veth0
709bf77b140SJustin Iurman
710bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
711bf77b140SJustin Iurman         db01::2 db01::1 veth0 0xfff002 123
712bf77b140SJustin Iurman
713bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
714752be297SJustin Iurman}
715752be297SJustin Iurman
716752be297SJustin Iurman
717752be297SJustin Iurman################################################################################
718752be297SJustin Iurman#                                                                              #
719752be297SJustin Iurman#                              GLOBAL tests                                    #
720752be297SJustin Iurman#                                                                              #
721752be297SJustin Iurman#   Three nodes (sender/router/receiver), IOAM fully enabled on every node.    #
722752be297SJustin Iurman################################################################################
723752be297SJustin Iurman
724752be297SJustin Iurmanfwd_full_supp_trace()
725752be297SJustin Iurman{
726752be297SJustin Iurman  ##############################################################################
727752be297SJustin Iurman  # Make sure that all three nodes correctly filled the full supported trace   #
728752be297SJustin Iurman  # by checking that the trace data is consistent with the predefined config.  #
729752be297SJustin Iurman  ##############################################################################
730752be297SJustin Iurman  local desc="Forward - Full supported trace"
731752be297SJustin Iurman
732bf77b140SJustin Iurman  [ "$1" = "encap" ] && mode="$1 tundst db02::2" || mode="$1"
733bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-gamma link set ip6tnl0 up
734752be297SJustin Iurman
735bf77b140SJustin Iurman  ip -netns ioam-node-alpha route change db02::/64 encap ioam6 mode $mode \
736bf77b140SJustin Iurman         trace prealloc type 0xfff002 ns 123 size 244 via db01::1 dev veth0
737bf77b140SJustin Iurman
738bf77b140SJustin Iurman  run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-gamma \
739bf77b140SJustin Iurman         db01::2 db02::2 veth0 0xfff002 123
740bf77b140SJustin Iurman
741bf77b140SJustin Iurman  [ "$1" = "encap" ] && ip -netns ioam-node-gamma link set ip6tnl0 down
742752be297SJustin Iurman}
743752be297SJustin Iurman
744752be297SJustin Iurman
745752be297SJustin Iurman################################################################################
746752be297SJustin Iurman#                                                                              #
747752be297SJustin Iurman#                                     MAIN                                     #
748752be297SJustin Iurman#                                                                              #
749752be297SJustin Iurman################################################################################
750752be297SJustin Iurman
751bf77b140SJustin Iurmannpassed=0
752bf77b140SJustin Iurmannfailed=0
753bf77b140SJustin Iurman
754752be297SJustin Iurmanif [ "$(id -u)" -ne 0 ]
755752be297SJustin Iurmanthen
756752be297SJustin Iurman  echo "SKIP: Need root privileges"
757*1995943cSKleber Sacilotto de Souza  exit $ksft_skip
758968691c7SJustin Iurmanfi
759968691c7SJustin Iurman
760752be297SJustin Iurmanif [ ! -x "$(command -v ip)" ]
761752be297SJustin Iurmanthen
762752be297SJustin Iurman  echo "SKIP: Could not run test without ip tool"
763*1995943cSKleber Sacilotto de Souza  exit $ksft_skip
764752be297SJustin Iurmanfi
765968691c7SJustin Iurman
766752be297SJustin Iurmanip ioam &>/dev/null
767752be297SJustin Iurmanif [ $? = 1 ]
768752be297SJustin Iurmanthen
769752be297SJustin Iurman  echo "SKIP: iproute2 too old, missing ioam command"
770*1995943cSKleber Sacilotto de Souza  exit $ksft_skip
771752be297SJustin Iurmanfi
772968691c7SJustin Iurman
773752be297SJustin Iurmancheck_kernel_compatibility
774968691c7SJustin Iurman
775968691c7SJustin Iurmancleanup &>/dev/null
776968691c7SJustin Iurmansetup
777968691c7SJustin Iurmanrun
778968691c7SJustin Iurmancleanup &>/dev/null
779