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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/ioam6.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/net/ioam6.sh (Version linux-6.11.5) and /tools/testing/selftests/net/ioam6.sh (Version linux-5.17.15)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0+                 2 # SPDX-License-Identifier: GPL-2.0+
  3 #                                                   3 #
  4 # Author: Justin Iurman <justin.iurman@uliege.b      4 # Author: Justin Iurman <justin.iurman@uliege.be>
  5 #                                                   5 #
  6 # This script evaluates the IOAM insertion for      6 # This script evaluates the IOAM insertion for IPv6 by checking the IOAM data
  7 # consistency directly inside packets on the r      7 # consistency directly inside packets on the receiver side. Tests are divided
  8 # into three categories: OUTPUT (evaluates the      8 # into three categories: OUTPUT (evaluates the IOAM processing by the sender),
  9 # INPUT (evaluates the IOAM processing by a re      9 # INPUT (evaluates the IOAM processing by a receiver) and GLOBAL (evaluates
 10 # wider use cases that do not fall into the ot     10 # wider use cases that do not fall into the other two categories). Both OUTPUT
 11 # and INPUT tests only use a two-node topology     11 # and INPUT tests only use a two-node topology (alpha and beta), while GLOBAL
 12 # tests use the entire three-node topology (al     12 # tests use the entire three-node topology (alpha, beta, gamma). Each test is
 13 # documented inside its own handler in the cod     13 # documented inside its own handler in the code below.
 14 #                                                  14 #
 15 # An IOAM domain is configured from Alpha to G     15 # An IOAM domain is configured from Alpha to Gamma but not on the reverse path.
 16 # When either Beta or Gamma is the destination     16 # When either Beta or Gamma is the destination (depending on the test category),
 17 # Alpha adds an IOAM option (Pre-allocated Tra     17 # Alpha adds an IOAM option (Pre-allocated Trace) inside a Hop-by-hop.
 18 #                                                  18 #
 19 #                                                  19 #
 20 #            +-------------------+                 20 #            +-------------------+            +-------------------+
 21 #            |                   |                 21 #            |                   |            |                   |
 22 #            |    Alpha netns    |                 22 #            |    Alpha netns    |            |    Gamma netns    |
 23 #            |                   |                 23 #            |                   |            |                   |
 24 #            |  +-------------+  |                 24 #            |  +-------------+  |            |  +-------------+  |
 25 #            |  |    veth0    |  |                 25 #            |  |    veth0    |  |            |  |    veth0    |  |
 26 #            |  |  db01::2/64 |  |                 26 #            |  |  db01::2/64 |  |            |  |  db02::2/64 |  |
 27 #            |  +-------------+  |                 27 #            |  +-------------+  |            |  +-------------+  |
 28 #            |         .         |                 28 #            |         .         |            |         .         |
 29 #            +-------------------+                 29 #            +-------------------+            +-------------------+
 30 #                      .                           30 #                      .                                .
 31 #                      .                           31 #                      .                                .
 32 #                      .                           32 #                      .                                .
 33 #            +--------------------------------     33 #            +----------------------------------------------------+
 34 #            |         .                           34 #            |         .                                .         |
 35 #            |  +-------------+                    35 #            |  +-------------+                  +-------------+  |
 36 #            |  |    veth0    |                    36 #            |  |    veth0    |                  |    veth1    |  |
 37 #            |  |  db01::1/64 | ..............     37 #            |  |  db01::1/64 | ................ |  db02::1/64 |  |
 38 #            |  +-------------+                    38 #            |  +-------------+                  +-------------+  |
 39 #            |                                     39 #            |                                                    |
 40 #            |                      Beta netns     40 #            |                      Beta netns                    |
 41 #            |                                     41 #            |                                                    |
 42 #            +--------------------------------     42 #            +----------------------------------------------------+
 43 #                                                  43 #
 44 #                                                  44 #
 45 #                                                  45 #
 46 #        =====================================     46 #        =============================================================
 47 #        |                Alpha - IOAM configu     47 #        |                Alpha - IOAM configuration                 |
 48 #        +====================================     48 #        +===========================================================+
 49 #        | Node ID             | 1                 49 #        | Node ID             | 1                                   |
 50 #        +------------------------------------     50 #        +-----------------------------------------------------------+
 51 #        | Node Wide ID        | 11111111          51 #        | Node Wide ID        | 11111111                            |
 52 #        +------------------------------------     52 #        +-----------------------------------------------------------+
 53 #        | Ingress ID          | 0xffff (defau     53 #        | Ingress ID          | 0xffff (default value)              |
 54 #        +------------------------------------     54 #        +-----------------------------------------------------------+
 55 #        | Ingress Wide ID     | 0xffffffff (d     55 #        | Ingress Wide ID     | 0xffffffff (default value)          |
 56 #        +------------------------------------     56 #        +-----------------------------------------------------------+
 57 #        | Egress ID           | 101               57 #        | Egress ID           | 101                                 |
 58 #        +------------------------------------     58 #        +-----------------------------------------------------------+
 59 #        | Egress Wide ID      | 101101            59 #        | Egress Wide ID      | 101101                              |
 60 #        +------------------------------------     60 #        +-----------------------------------------------------------+
 61 #        | Namespace Data      | 0xdeadbee0        61 #        | Namespace Data      | 0xdeadbee0                          |
 62 #        +------------------------------------     62 #        +-----------------------------------------------------------+
 63 #        | Namespace Wide Data | 0xcafec0caf00     63 #        | Namespace Wide Data | 0xcafec0caf00dc0de                  |
 64 #        +------------------------------------     64 #        +-----------------------------------------------------------+
 65 #        | Schema ID           | 777               65 #        | Schema ID           | 777                                 |
 66 #        +------------------------------------     66 #        +-----------------------------------------------------------+
 67 #        | Schema Data         | something tha     67 #        | Schema Data         | something that will be 4n-aligned   |
 68 #        +------------------------------------     68 #        +-----------------------------------------------------------+
 69 #                                                  69 #
 70 #                                                  70 #
 71 #        =====================================     71 #        =============================================================
 72 #        |                 Beta - IOAM configu     72 #        |                 Beta - IOAM configuration                 |
 73 #        +====================================     73 #        +===========================================================+
 74 #        | Node ID             | 2                 74 #        | Node ID             | 2                                   |
 75 #        +------------------------------------     75 #        +-----------------------------------------------------------+
 76 #        | Node Wide ID        | 22222222          76 #        | Node Wide ID        | 22222222                            |
 77 #        +------------------------------------     77 #        +-----------------------------------------------------------+
 78 #        | Ingress ID          | 201               78 #        | Ingress ID          | 201                                 |
 79 #        +------------------------------------     79 #        +-----------------------------------------------------------+
 80 #        | Ingress Wide ID     | 201201            80 #        | Ingress Wide ID     | 201201                              |
 81 #        +------------------------------------     81 #        +-----------------------------------------------------------+
 82 #        | Egress ID           | 202               82 #        | Egress ID           | 202                                 |
 83 #        +------------------------------------     83 #        +-----------------------------------------------------------+
 84 #        | Egress Wide ID      | 202202            84 #        | Egress Wide ID      | 202202                              |
 85 #        +------------------------------------     85 #        +-----------------------------------------------------------+
 86 #        | Namespace Data      | 0xdeadbee1        86 #        | Namespace Data      | 0xdeadbee1                          |
 87 #        +------------------------------------     87 #        +-----------------------------------------------------------+
 88 #        | Namespace Wide Data | 0xcafec0caf11     88 #        | Namespace Wide Data | 0xcafec0caf11dc0de                  |
 89 #        +------------------------------------     89 #        +-----------------------------------------------------------+
 90 #        | Schema ID           | 666               90 #        | Schema ID           | 666                                 |
 91 #        +------------------------------------     91 #        +-----------------------------------------------------------+
 92 #        | Schema Data         | Hello there -     92 #        | Schema Data         | Hello there -Obi                    |
 93 #        +------------------------------------     93 #        +-----------------------------------------------------------+
 94 #                                                  94 #
 95 #                                                  95 #
 96 #        =====================================     96 #        =============================================================
 97 #        |                Gamma - IOAM configu     97 #        |                Gamma - IOAM configuration                 |
 98 #        +====================================     98 #        +===========================================================+
 99 #        | Node ID             | 3                 99 #        | Node ID             | 3                                   |
100 #        +------------------------------------    100 #        +-----------------------------------------------------------+
101 #        | Node Wide ID        | 33333333         101 #        | Node Wide ID        | 33333333                            |
102 #        +------------------------------------    102 #        +-----------------------------------------------------------+
103 #        | Ingress ID          | 301              103 #        | Ingress ID          | 301                                 |
104 #        +------------------------------------    104 #        +-----------------------------------------------------------+
105 #        | Ingress Wide ID     | 301301           105 #        | Ingress Wide ID     | 301301                              |
106 #        +------------------------------------    106 #        +-----------------------------------------------------------+
107 #        | Egress ID           | 0xffff (defau    107 #        | Egress ID           | 0xffff (default value)              |
108 #        +------------------------------------    108 #        +-----------------------------------------------------------+
109 #        | Egress Wide ID      | 0xffffffff (d    109 #        | Egress Wide ID      | 0xffffffff (default value)          |
110 #        +------------------------------------    110 #        +-----------------------------------------------------------+
111 #        | Namespace Data      | 0xdeadbee2       111 #        | Namespace Data      | 0xdeadbee2                          |
112 #        +------------------------------------    112 #        +-----------------------------------------------------------+
113 #        | Namespace Wide Data | 0xcafec0caf22    113 #        | Namespace Wide Data | 0xcafec0caf22dc0de                  |
114 #        +------------------------------------    114 #        +-----------------------------------------------------------+
115 #        | Schema ID           | 0xffffff (= N    115 #        | Schema ID           | 0xffffff (= None)                   |
116 #        +------------------------------------    116 #        +-----------------------------------------------------------+
117 #        | Schema Data         |                  117 #        | Schema Data         |                                     |
118 #        +------------------------------------    118 #        +-----------------------------------------------------------+
119                                                   119 
120 source lib.sh                                  << 
121                                                   120 
122 ##############################################    121 ################################################################################
123 #                                                 122 #                                                                              #
124 # WARNING: Be careful if you modify the block     123 # WARNING: Be careful if you modify the block below - it MUST be kept          #
125 #          synchronized with configurations in    124 #          synchronized with configurations inside ioam6_parser.c and always   #
126 #          reflect the same.                      125 #          reflect the same.                                                   #
127 #                                                 126 #                                                                              #
128 ##############################################    127 ################################################################################
129                                                   128 
130 ALPHA=(                                           129 ALPHA=(
131         1                                         130         1                                       # ID
132         11111111                                  131         11111111                                # Wide ID
133         0xffff                                    132         0xffff                                  # Ingress ID
134         0xffffffff                                133         0xffffffff                              # Ingress Wide ID
135         101                                       134         101                                     # Egress ID
136         101101                                    135         101101                                  # Egress Wide ID
137         0xdeadbee0                                136         0xdeadbee0                              # Namespace Data
138         0xcafec0caf00dc0de                        137         0xcafec0caf00dc0de                      # Namespace Wide Data
139         777                                       138         777                                     # Schema ID (0xffffff = None)
140         "something that will be 4n-aligned"       139         "something that will be 4n-aligned"     # Schema Data
141 )                                                 140 )
142                                                   141 
143 BETA=(                                            142 BETA=(
144         2                                         143         2
145         22222222                                  144         22222222
146         201                                       145         201
147         201201                                    146         201201
148         202                                       147         202
149         202202                                    148         202202
150         0xdeadbee1                                149         0xdeadbee1
151         0xcafec0caf11dc0de                        150         0xcafec0caf11dc0de
152         666                                       151         666
153         "Hello there -Obi"                        152         "Hello there -Obi"
154 )                                                 153 )
155                                                   154 
156 GAMMA=(                                           155 GAMMA=(
157         3                                         156         3
158         33333333                                  157         33333333
159         301                                       158         301
160         301301                                    159         301301
161         0xffff                                    160         0xffff
162         0xffffffff                                161         0xffffffff
163         0xdeadbee2                                162         0xdeadbee2
164         0xcafec0caf22dc0de                        163         0xcafec0caf22dc0de
165         0xffffff                                  164         0xffffff
166         ""                                        165         ""
167 )                                                 166 )
168                                                   167 
169 TESTS_OUTPUT="                                    168 TESTS_OUTPUT="
170         out_undef_ns                              169         out_undef_ns
171         out_no_room                               170         out_no_room
172         out_bits                                  171         out_bits
173         out_full_supp_trace                       172         out_full_supp_trace
174 "                                                 173 "
175                                                   174 
176 TESTS_INPUT="                                     175 TESTS_INPUT="
177         in_undef_ns                               176         in_undef_ns
178         in_no_room                                177         in_no_room
179         in_oflag                                  178         in_oflag
180         in_bits                                   179         in_bits
181         in_full_supp_trace                        180         in_full_supp_trace
182 "                                                 181 "
183                                                   182 
184 TESTS_GLOBAL="                                    183 TESTS_GLOBAL="
185         fwd_full_supp_trace                       184         fwd_full_supp_trace
186 "                                                 185 "
187                                                   186 
188                                                   187 
189 ##############################################    188 ################################################################################
190 #                                                 189 #                                                                              #
191 #                                   LIBRARY       190 #                                   LIBRARY                                    #
192 #                                                 191 #                                                                              #
193 ##############################################    192 ################################################################################
194                                                   193 
195 check_kernel_compatibility()                      194 check_kernel_compatibility()
196 {                                                 195 {
197   setup_ns ioam_tmp_node                       !! 196   ip netns add ioam-tmp-node
198   ip link add name veth0 netns $ioam_tmp_node  !! 197   ip link add name veth0 netns ioam-tmp-node type veth \
199          peer name veth1 netns $ioam_tmp_node  !! 198          peer name veth1 netns ioam-tmp-node
200                                                   199 
201   ip -netns $ioam_tmp_node link set veth0 up   !! 200   ip -netns ioam-tmp-node link set veth0 up
202   ip -netns $ioam_tmp_node link set veth1 up   !! 201   ip -netns ioam-tmp-node link set veth1 up
203                                                   202 
204   ip -netns $ioam_tmp_node ioam namespace add  !! 203   ip -netns ioam-tmp-node ioam namespace add 0
205   ns_ad=$?                                        204   ns_ad=$?
206                                                   205 
207   ip -netns $ioam_tmp_node ioam namespace show !! 206   ip -netns ioam-tmp-node ioam namespace show | grep -q "namespace 0"
208   ns_sh=$?                                        207   ns_sh=$?
209                                                   208 
210   if [[ $ns_ad != 0 || $ns_sh != 0 ]]             209   if [[ $ns_ad != 0 || $ns_sh != 0 ]]
211   then                                            210   then
212     echo "SKIP: kernel version probably too ol    211     echo "SKIP: kernel version probably too old, missing ioam support"
213     ip link del veth0 2>/dev/null || true         212     ip link del veth0 2>/dev/null || true
214     cleanup_ns $ioam_tmp_node || true          !! 213     ip netns del ioam-tmp-node || true
215     exit $ksft_skip                            !! 214     exit 1
216   fi                                              215   fi
217                                                   216 
218   ip -netns $ioam_tmp_node route add db02::/64 !! 217   ip -netns ioam-tmp-node route add db02::/64 encap ioam6 mode inline \
219          trace prealloc type 0x800000 ns 0 siz    218          trace prealloc type 0x800000 ns 0 size 4 dev veth0
220   tr_ad=$?                                        219   tr_ad=$?
221                                                   220 
222   ip -netns $ioam_tmp_node -6 route | grep -q  !! 221   ip -netns ioam-tmp-node -6 route | grep -q "encap ioam6"
223   tr_sh=$?                                        222   tr_sh=$?
224                                                   223 
225   if [[ $tr_ad != 0 || $tr_sh != 0 ]]             224   if [[ $tr_ad != 0 || $tr_sh != 0 ]]
226   then                                            225   then
227     echo "SKIP: cannot attach an ioam trace to    226     echo "SKIP: cannot attach an ioam trace to a route, did you compile" \
228          "without CONFIG_IPV6_IOAM6_LWTUNNEL?"    227          "without CONFIG_IPV6_IOAM6_LWTUNNEL?"
229     ip link del veth0 2>/dev/null || true         228     ip link del veth0 2>/dev/null || true
230     cleanup_ns $ioam_tmp_node || true          !! 229     ip netns del ioam-tmp-node || true
231     exit $ksft_skip                            !! 230     exit 1
232   fi                                              231   fi
233                                                   232 
234   ip link del veth0 2>/dev/null || true           233   ip link del veth0 2>/dev/null || true
235   cleanup_ns $ioam_tmp_node || true            !! 234   ip netns del ioam-tmp-node || true
236                                                   235 
237   lsmod | grep -q "ip6_tunnel"                    236   lsmod | grep -q "ip6_tunnel"
238   ip6tnl_loaded=$?                                237   ip6tnl_loaded=$?
239                                                   238 
240   if [ $ip6tnl_loaded = 0 ]                       239   if [ $ip6tnl_loaded = 0 ]
241   then                                            240   then
242     encap_tests=0                                 241     encap_tests=0
243   else                                            242   else
244     modprobe ip6_tunnel &>/dev/null               243     modprobe ip6_tunnel &>/dev/null
245     lsmod | grep -q "ip6_tunnel"                  244     lsmod | grep -q "ip6_tunnel"
246     encap_tests=$?                                245     encap_tests=$?
247                                                   246 
248     if [ $encap_tests != 0 ]                      247     if [ $encap_tests != 0 ]
249     then                                          248     then
250       ip a | grep -q "ip6tnl0"                    249       ip a | grep -q "ip6tnl0"
251       encap_tests=$?                              250       encap_tests=$?
252                                                   251 
253       if [ $encap_tests != 0 ]                    252       if [ $encap_tests != 0 ]
254       then                                        253       then
255         echo "Note: ip6_tunnel not found neith    254         echo "Note: ip6_tunnel not found neither as a module nor inside the" \
256              "kernel, tests that require it (e    255              "kernel, tests that require it (encap mode) will be omitted"
257       fi                                          256       fi
258     fi                                            257     fi
259   fi                                              258   fi
260 }                                                 259 }
261                                                   260 
262 cleanup()                                         261 cleanup()
263 {                                                 262 {
264   ip link del ioam-veth-alpha 2>/dev/null || t    263   ip link del ioam-veth-alpha 2>/dev/null || true
265   ip link del ioam-veth-gamma 2>/dev/null || t    264   ip link del ioam-veth-gamma 2>/dev/null || true
266                                                   265 
267   cleanup_ns $ioam_node_alpha $ioam_node_beta  !! 266   ip netns del ioam-node-alpha || true
                                                   >> 267   ip netns del ioam-node-beta || true
                                                   >> 268   ip netns del ioam-node-gamma || true
268                                                   269 
269   if [ $ip6tnl_loaded != 0 ]                      270   if [ $ip6tnl_loaded != 0 ]
270   then                                            271   then
271     modprobe -r ip6_tunnel 2>/dev/null || true    272     modprobe -r ip6_tunnel 2>/dev/null || true
272   fi                                              273   fi
273 }                                                 274 }
274                                                   275 
275 setup()                                           276 setup()
276 {                                                 277 {
277   setup_ns ioam_node_alpha ioam_node_beta ioam !! 278   ip netns add ioam-node-alpha
278                                                !! 279   ip netns add ioam-node-beta
279   ip link add name ioam-veth-alpha netns $ioam !! 280   ip netns add ioam-node-gamma
280          peer name ioam-veth-betaL netns $ioam !! 281 
281   ip link add name ioam-veth-betaR netns $ioam !! 282   ip link add name ioam-veth-alpha netns ioam-node-alpha type veth \
282          peer name ioam-veth-gamma netns $ioam !! 283          peer name ioam-veth-betaL netns ioam-node-beta
283                                                !! 284   ip link add name ioam-veth-betaR netns ioam-node-beta type veth \
284   ip -netns $ioam_node_alpha link set ioam-vet !! 285          peer name ioam-veth-gamma netns ioam-node-gamma
285   ip -netns $ioam_node_beta link set ioam-veth !! 286 
286   ip -netns $ioam_node_beta link set ioam-veth !! 287   ip -netns ioam-node-alpha link set ioam-veth-alpha name veth0
287   ip -netns $ioam_node_gamma link set ioam-vet !! 288   ip -netns ioam-node-beta link set ioam-veth-betaL name veth0
288                                                !! 289   ip -netns ioam-node-beta link set ioam-veth-betaR name veth1
289   ip -netns $ioam_node_alpha addr add db01::2/ !! 290   ip -netns ioam-node-gamma link set ioam-veth-gamma name veth0
290   ip -netns $ioam_node_alpha link set veth0 up !! 291 
291   ip -netns $ioam_node_alpha link set lo up    !! 292   ip -netns ioam-node-alpha addr add db01::2/64 dev veth0
292   ip -netns $ioam_node_alpha route add db02::/ !! 293   ip -netns ioam-node-alpha link set veth0 up
293   ip -netns $ioam_node_alpha route del db01::/ !! 294   ip -netns ioam-node-alpha link set lo up
294   ip -netns $ioam_node_alpha route add db01::/ !! 295   ip -netns ioam-node-alpha route add db02::/64 via db01::1 dev veth0
295                                                !! 296   ip -netns ioam-node-alpha route del db01::/64
296   ip -netns $ioam_node_beta addr add db01::1/6 !! 297   ip -netns ioam-node-alpha route add db01::/64 dev veth0
297   ip -netns $ioam_node_beta addr add db02::1/6 !! 298 
298   ip -netns $ioam_node_beta link set veth0 up  !! 299   ip -netns ioam-node-beta addr add db01::1/64 dev veth0
299   ip -netns $ioam_node_beta link set veth1 up  !! 300   ip -netns ioam-node-beta addr add db02::1/64 dev veth1
300   ip -netns $ioam_node_beta link set lo up     !! 301   ip -netns ioam-node-beta link set veth0 up
301                                                !! 302   ip -netns ioam-node-beta link set veth1 up
302   ip -netns $ioam_node_gamma addr add db02::2/ !! 303   ip -netns ioam-node-beta link set lo up
303   ip -netns $ioam_node_gamma link set veth0 up !! 304 
304   ip -netns $ioam_node_gamma link set lo up    !! 305   ip -netns ioam-node-gamma addr add db02::2/64 dev veth0
305   ip -netns $ioam_node_gamma route add db01::/ !! 306   ip -netns ioam-node-gamma link set veth0 up
                                                   >> 307   ip -netns ioam-node-gamma link set lo up
                                                   >> 308   ip -netns ioam-node-gamma route add db01::/64 via db02::1 dev veth0
306                                                   309 
307   # - IOAM config -                               310   # - IOAM config -
308   ip netns exec $ioam_node_alpha sysctl -wq ne !! 311   ip netns exec ioam-node-alpha sysctl -wq net.ipv6.ioam6_id=${ALPHA[0]}
309   ip netns exec $ioam_node_alpha sysctl -wq ne !! 312   ip netns exec ioam-node-alpha sysctl -wq net.ipv6.ioam6_id_wide=${ALPHA[1]}
310   ip netns exec $ioam_node_alpha sysctl -wq ne !! 313   ip netns exec ioam-node-alpha sysctl -wq net.ipv6.conf.veth0.ioam6_id=${ALPHA[4]}
311   ip netns exec $ioam_node_alpha sysctl -wq ne !! 314   ip netns exec ioam-node-alpha sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${ALPHA[5]}
312   ip -netns $ioam_node_alpha ioam namespace ad !! 315   ip -netns ioam-node-alpha ioam namespace add 123 data ${ALPHA[6]} wide ${ALPHA[7]}
313   ip -netns $ioam_node_alpha ioam schema add $ !! 316   ip -netns ioam-node-alpha ioam schema add ${ALPHA[8]} "${ALPHA[9]}"
314   ip -netns $ioam_node_alpha ioam namespace se !! 317   ip -netns ioam-node-alpha ioam namespace set 123 schema ${ALPHA[8]}
315                                                !! 318 
316   ip netns exec $ioam_node_beta sysctl -wq net !! 319   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.all.forwarding=1
317   ip netns exec $ioam_node_beta sysctl -wq net !! 320   ip netns exec ioam-node-beta sysctl -wq net.ipv6.ioam6_id=${BETA[0]}
318   ip netns exec $ioam_node_beta sysctl -wq net !! 321   ip netns exec ioam-node-beta sysctl -wq net.ipv6.ioam6_id_wide=${BETA[1]}
319   ip netns exec $ioam_node_beta sysctl -wq net !! 322   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1
320   ip netns exec $ioam_node_beta sysctl -wq net !! 323   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_id=${BETA[2]}
321   ip netns exec $ioam_node_beta sysctl -wq net !! 324   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${BETA[3]}
322   ip netns exec $ioam_node_beta sysctl -wq net !! 325   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth1.ioam6_id=${BETA[4]}
323   ip netns exec $ioam_node_beta sysctl -wq net !! 326   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth1.ioam6_id_wide=${BETA[5]}
324   ip -netns $ioam_node_beta ioam namespace add !! 327   ip -netns ioam-node-beta ioam namespace add 123 data ${BETA[6]} wide ${BETA[7]}
325   ip -netns $ioam_node_beta ioam schema add ${ !! 328   ip -netns ioam-node-beta ioam schema add ${BETA[8]} "${BETA[9]}"
326   ip -netns $ioam_node_beta ioam namespace set !! 329   ip -netns ioam-node-beta ioam namespace set 123 schema ${BETA[8]}
327                                                !! 330 
328   ip netns exec $ioam_node_gamma sysctl -wq ne !! 331   ip netns exec ioam-node-gamma sysctl -wq net.ipv6.ioam6_id=${GAMMA[0]}
329   ip netns exec $ioam_node_gamma sysctl -wq ne !! 332   ip netns exec ioam-node-gamma sysctl -wq net.ipv6.ioam6_id_wide=${GAMMA[1]}
330   ip netns exec $ioam_node_gamma sysctl -wq ne !! 333   ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1
331   ip netns exec $ioam_node_gamma sysctl -wq ne !! 334   ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_id=${GAMMA[2]}
332   ip netns exec $ioam_node_gamma sysctl -wq ne !! 335   ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${GAMMA[3]}
333   ip -netns $ioam_node_gamma ioam namespace ad !! 336   ip -netns ioam-node-gamma ioam namespace add 123 data ${GAMMA[6]} wide ${GAMMA[7]}
334                                                   337 
335   sleep 1                                         338   sleep 1
336                                                   339 
337   ip netns exec $ioam_node_alpha ping6 -c 5 -W !! 340   ip netns exec ioam-node-alpha ping6 -c 5 -W 1 db02::2 &>/dev/null
338   if [ $? != 0 ]                                  341   if [ $? != 0 ]
339   then                                            342   then
340     echo "Setup FAILED"                           343     echo "Setup FAILED"
341     cleanup &>/dev/null                           344     cleanup &>/dev/null
342     exit 0                                        345     exit 0
343   fi                                              346   fi
344 }                                                 347 }
345                                                   348 
346 log_test_passed()                                 349 log_test_passed()
347 {                                                 350 {
348   local desc=$1                                   351   local desc=$1
349   printf "TEST: %-60s  [ OK ]\n" "${desc}"        352   printf "TEST: %-60s  [ OK ]\n" "${desc}"
350 }                                                 353 }
351                                                   354 
352 log_test_failed()                                 355 log_test_failed()
353 {                                                 356 {
354   local desc=$1                                   357   local desc=$1
355   printf "TEST: %-60s  [FAIL]\n" "${desc}"        358   printf "TEST: %-60s  [FAIL]\n" "${desc}"
356 }                                                 359 }
357                                                   360 
358 log_results()                                     361 log_results()
359 {                                                 362 {
360   echo "- Tests passed: ${npassed}"               363   echo "- Tests passed: ${npassed}"
361   echo "- Tests failed: ${nfailed}"               364   echo "- Tests failed: ${nfailed}"
362 }                                                 365 }
363                                                   366 
364 run_test()                                        367 run_test()
365 {                                                 368 {
366   local name=$1                                   369   local name=$1
367   local desc=$2                                   370   local desc=$2
368   local node_src=$3                               371   local node_src=$3
369   local node_dst=$4                               372   local node_dst=$4
370   local ip6_dst=$5                             !! 373   local ip6_src=$5
371   local trace_type=$6                          !! 374   local ip6_dst=$6
372   local ioam_ns=$7                             !! 375   local if_dst=$7
373   local type=$8                                !! 376   local trace_type=$8
                                                   >> 377   local ioam_ns=$9
374                                                   378 
375   ip netns exec $node_dst ./ioam6_parser $name !! 379   ip netns exec $node_dst ./ioam6_parser $if_dst $name $ip6_src $ip6_dst \
                                                   >> 380          $trace_type $ioam_ns &
376   local spid=$!                                   381   local spid=$!
377   sleep 0.1                                       382   sleep 0.1
378                                                   383 
379   ip netns exec $node_src ping6 -t 64 -c 1 -W     384   ip netns exec $node_src ping6 -t 64 -c 1 -W 1 $ip6_dst &>/dev/null
380   if [ $? != 0 ]                                  385   if [ $? != 0 ]
381   then                                            386   then
382     nfailed=$((nfailed+1))                        387     nfailed=$((nfailed+1))
383     log_test_failed "${desc}"                     388     log_test_failed "${desc}"
384     kill -2 $spid &>/dev/null                     389     kill -2 $spid &>/dev/null
385   else                                            390   else
386     wait $spid                                    391     wait $spid
387     if [ $? = 0 ]                                 392     if [ $? = 0 ]
388     then                                          393     then
389       npassed=$((npassed+1))                      394       npassed=$((npassed+1))
390       log_test_passed "${desc}"                   395       log_test_passed "${desc}"
391     else                                          396     else
392       nfailed=$((nfailed+1))                      397       nfailed=$((nfailed+1))
393       log_test_failed "${desc}"                   398       log_test_failed "${desc}"
394     fi                                            399     fi
395   fi                                              400   fi
396 }                                                 401 }
397                                                   402 
398 run()                                             403 run()
399 {                                                 404 {
400   echo                                            405   echo
401   printf "%0.s-" {1..74}                          406   printf "%0.s-" {1..74}
402   echo                                            407   echo
403   echo "OUTPUT tests"                             408   echo "OUTPUT tests"
404   printf "%0.s-" {1..74}                          409   printf "%0.s-" {1..74}
405   echo                                            410   echo
406                                                   411 
407   # set OUTPUT settings                           412   # set OUTPUT settings
408   ip netns exec $ioam_node_beta sysctl -wq net !! 413   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=0
409                                                   414 
410   for t in $TESTS_OUTPUT                          415   for t in $TESTS_OUTPUT
411   do                                              416   do
412     $t "inline"                                   417     $t "inline"
413     [ $encap_tests = 0 ] && $t "encap"            418     [ $encap_tests = 0 ] && $t "encap"
414   done                                            419   done
415                                                   420 
416   # clean OUTPUT settings                         421   # clean OUTPUT settings
417   ip netns exec $ioam_node_beta sysctl -wq net !! 422   ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1
418   ip -netns $ioam_node_alpha route change db01 !! 423   ip -netns ioam-node-alpha route change db01::/64 dev veth0
419                                                   424 
420                                                   425 
421   echo                                            426   echo
422   printf "%0.s-" {1..74}                          427   printf "%0.s-" {1..74}
423   echo                                            428   echo
424   echo "INPUT tests"                              429   echo "INPUT tests"
425   printf "%0.s-" {1..74}                          430   printf "%0.s-" {1..74}
426   echo                                            431   echo
427                                                   432 
428   # set INPUT settings                            433   # set INPUT settings
429   ip -netns $ioam_node_alpha ioam namespace de !! 434   ip -netns ioam-node-alpha ioam namespace del 123
430                                                   435 
431   for t in $TESTS_INPUT                           436   for t in $TESTS_INPUT
432   do                                              437   do
433     $t "inline"                                   438     $t "inline"
434     [ $encap_tests = 0 ] && $t "encap"            439     [ $encap_tests = 0 ] && $t "encap"
435   done                                            440   done
436                                                   441 
437   # clean INPUT settings                          442   # clean INPUT settings
438   ip -netns $ioam_node_alpha ioam namespace ad !! 443   ip -netns ioam-node-alpha ioam namespace add 123 \
439          data ${ALPHA[6]} wide ${ALPHA[7]}        444          data ${ALPHA[6]} wide ${ALPHA[7]}
440   ip -netns $ioam_node_alpha ioam namespace se !! 445   ip -netns ioam-node-alpha ioam namespace set 123 schema ${ALPHA[8]}
441   ip -netns $ioam_node_alpha route change db01 !! 446   ip -netns ioam-node-alpha route change db01::/64 dev veth0
442                                                   447 
443   echo                                            448   echo
444   printf "%0.s-" {1..74}                          449   printf "%0.s-" {1..74}
445   echo                                            450   echo
446   echo "GLOBAL tests"                             451   echo "GLOBAL tests"
447   printf "%0.s-" {1..74}                          452   printf "%0.s-" {1..74}
448   echo                                            453   echo
449                                                   454 
450   for t in $TESTS_GLOBAL                          455   for t in $TESTS_GLOBAL
451   do                                              456   do
452     $t "inline"                                   457     $t "inline"
453     [ $encap_tests = 0 ] && $t "encap"            458     [ $encap_tests = 0 ] && $t "encap"
454   done                                            459   done
455                                                   460 
456   echo                                            461   echo
457   log_results                                     462   log_results
458 }                                                 463 }
459                                                   464 
460 bit2type=(                                        465 bit2type=(
461   0x800000 0x400000 0x200000 0x100000 0x080000    466   0x800000 0x400000 0x200000 0x100000 0x080000 0x040000 0x020000 0x010000
462   0x008000 0x004000 0x002000 0x001000 0x000800    467   0x008000 0x004000 0x002000 0x001000 0x000800 0x000400 0x000200 0x000100
463   0x000080 0x000040 0x000020 0x000010 0x000008    468   0x000080 0x000040 0x000020 0x000010 0x000008 0x000004 0x000002
464 )                                                 469 )
465 bit2size=( 4 4 4 4 4 4 4 4 8 8 8 4 4 4 4 4 4 4    470 bit2size=( 4 4 4 4 4 4 4 4 8 8 8 4 4 4 4 4 4 4 4 4 4 4 4 )
466                                                   471 
467                                                   472 
468 ##############################################    473 ################################################################################
469 #                                                 474 #                                                                              #
470 #                              OUTPUT tests       475 #                              OUTPUT tests                                    #
471 #                                                 476 #                                                                              #
472 #   Two nodes (sender/receiver), IOAM disabled    477 #   Two nodes (sender/receiver), IOAM disabled on ingress for the receiver.    #
473 ##############################################    478 ################################################################################
474                                                   479 
475 out_undef_ns()                                    480 out_undef_ns()
476 {                                                 481 {
477   ############################################    482   ##############################################################################
478   # Make sure that the encap node won't fill t    483   # Make sure that the encap node won't fill the trace if the chosen IOAM      #
479   # namespace is not configured locally.          484   # namespace is not configured locally.                                       #
480   ############################################    485   ##############################################################################
481   local desc="Unknown IOAM namespace"             486   local desc="Unknown IOAM namespace"
482                                                   487 
483   [ "$1" = "encap" ] && mode="$1 tundst db01::    488   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
484   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 489   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
485                                                   490 
486   ip -netns $ioam_node_alpha route change db01 !! 491   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
487          trace prealloc type 0x800000 ns 0 siz    492          trace prealloc type 0x800000 ns 0 size 4 dev veth0
488                                                   493 
489   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 494   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
490          db01::1 0x800000 0 $1                 !! 495          db01::2 db01::1 veth0 0x800000 0
491                                                   496 
492   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 497   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
493 }                                                 498 }
494                                                   499 
495 out_no_room()                                     500 out_no_room()
496 {                                                 501 {
497   ############################################    502   ##############################################################################
498   # Make sure that the encap node won't fill t    503   # Make sure that the encap node won't fill the trace and will set the        #
499   # Overflow flag since there is no room enoug    504   # Overflow flag since there is no room enough for its data.                  #
500   ############################################    505   ##############################################################################
501   local desc="Missing trace room"                 506   local desc="Missing trace room"
502                                                   507 
503   [ "$1" = "encap" ] && mode="$1 tundst db01::    508   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
504   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 509   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
505                                                   510 
506   ip -netns $ioam_node_alpha route change db01 !! 511   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
507          trace prealloc type 0xc00000 ns 123 s    512          trace prealloc type 0xc00000 ns 123 size 4 dev veth0
508                                                   513 
509   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 514   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
510          db01::1 0xc00000 123 $1               !! 515          db01::2 db01::1 veth0 0xc00000 123
511                                                   516 
512   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 517   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
513 }                                                 518 }
514                                                   519 
515 out_bits()                                        520 out_bits()
516 {                                                 521 {
517   ############################################    522   ##############################################################################
518   # Make sure that, for each trace type bit, t    523   # Make sure that, for each trace type bit, the encap node will either:       #
519   #  (i)  fill the trace with its data when it    524   #  (i)  fill the trace with its data when it is a supported bit              #
520   #  (ii) not fill the trace with its data whe    525   #  (ii) not fill the trace with its data when it is an unsupported bit       #
521   ############################################    526   ##############################################################################
522   local desc="Trace type with bit <n> only"       527   local desc="Trace type with bit <n> only"
523                                                   528 
524   local tmp=${bit2size[22]}                       529   local tmp=${bit2size[22]}
525   bit2size[22]=$(( $tmp + ${#ALPHA[9]} + ((4 -    530   bit2size[22]=$(( $tmp + ${#ALPHA[9]} + ((4 - (${#ALPHA[9]} % 4)) % 4) ))
526                                                   531 
527   [ "$1" = "encap" ] && mode="$1 tundst db01::    532   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
528   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 533   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
529                                                   534 
530   for i in {0..22}                                535   for i in {0..22}
531   do                                              536   do
532     ip -netns $ioam_node_alpha route change db !! 537     ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
533            trace prealloc type ${bit2type[$i]}    538            trace prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} \
534            dev veth0 &>/dev/null                  539            dev veth0 &>/dev/null
535                                                   540 
536     local cmd_res=$?                              541     local cmd_res=$?
537     local descr="${desc/<n>/$i}"                  542     local descr="${desc/<n>/$i}"
538                                                   543 
539     if [[ $i -ge 12 && $i -le 21 ]]               544     if [[ $i -ge 12 && $i -le 21 ]]
540     then                                          545     then
541       if [ $cmd_res != 0 ]                        546       if [ $cmd_res != 0 ]
542       then                                        547       then
543         npassed=$((npassed+1))                    548         npassed=$((npassed+1))
544         log_test_passed "$descr ($1 mode)"     !! 549         log_test_passed "$descr"
545       else                                        550       else
546         nfailed=$((nfailed+1))                    551         nfailed=$((nfailed+1))
547         log_test_failed "$descr ($1 mode)"     !! 552         log_test_failed "$descr"
548       fi                                          553       fi
549     else                                          554     else
550         run_test "out_bit$i" "$descr ($1 mode) !! 555         run_test "out_bit$i" "$descr ($1 mode)" ioam-node-alpha \
551            $ioam_node_beta db01::1 ${bit2type[ !! 556            ioam-node-beta db01::2 db01::1 veth0 ${bit2type[$i]} 123
552     fi                                            557     fi
553   done                                            558   done
554                                                   559 
555   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 560   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
556                                                   561 
557   bit2size[22]=$tmp                               562   bit2size[22]=$tmp
558 }                                                 563 }
559                                                   564 
560 out_full_supp_trace()                             565 out_full_supp_trace()
561 {                                                 566 {
562   ############################################    567   ##############################################################################
563   # Make sure that the encap node will correct    568   # Make sure that the encap node will correctly fill a full trace. Be careful,#
564   # "full trace" here does NOT mean all bits (    569   # "full trace" here does NOT mean all bits (only supported ones).            #
565   ############################################    570   ##############################################################################
566   local desc="Full supported trace"               571   local desc="Full supported trace"
567                                                   572 
568   [ "$1" = "encap" ] && mode="$1 tundst db01::    573   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
569   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 574   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
570                                                   575 
571   ip -netns $ioam_node_alpha route change db01 !! 576   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
572          trace prealloc type 0xfff002 ns 123 s    577          trace prealloc type 0xfff002 ns 123 size 100 dev veth0
573                                                   578 
574   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 579   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
575          db01::1 0xfff002 123 $1               !! 580          db01::2 db01::1 veth0 0xfff002 123
576                                                   581 
577   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 582   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
578 }                                                 583 }
579                                                   584 
580                                                   585 
581 ##############################################    586 ################################################################################
582 #                                                 587 #                                                                              #
583 #                               INPUT tests       588 #                               INPUT tests                                    #
584 #                                                 589 #                                                                              #
585 #     Two nodes (sender/receiver), the sender     590 #     Two nodes (sender/receiver), the sender MUST NOT fill the trace upon     #
586 #     insertion -> the IOAM namespace configur    591 #     insertion -> the IOAM namespace configured on the sender is removed      #
587 #     and is used in the inserted trace to for    592 #     and is used in the inserted trace to force the sender not to fill it.    #
588 ##############################################    593 ################################################################################
589                                                   594 
590 in_undef_ns()                                     595 in_undef_ns()
591 {                                                 596 {
592   ############################################    597   ##############################################################################
593   # Make sure that the receiving node won't fi    598   # Make sure that the receiving node won't fill the trace if the related IOAM #
594   # namespace is not configured locally.          599   # namespace is not configured locally.                                       #
595   ############################################    600   ##############################################################################
596   local desc="Unknown IOAM namespace"             601   local desc="Unknown IOAM namespace"
597                                                   602 
598   [ "$1" = "encap" ] && mode="$1 tundst db01::    603   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
599   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 604   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
600                                                   605 
601   ip -netns $ioam_node_alpha route change db01 !! 606   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
602          trace prealloc type 0x800000 ns 0 siz    607          trace prealloc type 0x800000 ns 0 size 4 dev veth0
603                                                   608 
604   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 609   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
605          db01::1 0x800000 0 $1                 !! 610          db01::2 db01::1 veth0 0x800000 0
606                                                   611 
607   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 612   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
608 }                                                 613 }
609                                                   614 
610 in_no_room()                                      615 in_no_room()
611 {                                                 616 {
612   ############################################    617   ##############################################################################
613   # Make sure that the receiving node won't fi    618   # Make sure that the receiving node won't fill the trace and will set the    #
614   # Overflow flag if there is no room enough f    619   # Overflow flag if there is no room enough for its data.                     #
615   ############################################    620   ##############################################################################
616   local desc="Missing trace room"                 621   local desc="Missing trace room"
617                                                   622 
618   [ "$1" = "encap" ] && mode="$1 tundst db01::    623   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
619   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 624   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
620                                                   625 
621   ip -netns $ioam_node_alpha route change db01 !! 626   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
622          trace prealloc type 0xc00000 ns 123 s    627          trace prealloc type 0xc00000 ns 123 size 4 dev veth0
623                                                   628 
624   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 629   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
625          db01::1 0xc00000 123 $1               !! 630          db01::2 db01::1 veth0 0xc00000 123
626                                                   631 
627   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 632   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
628 }                                                 633 }
629                                                   634 
630 in_bits()                                         635 in_bits()
631 {                                                 636 {
632   ############################################    637   ##############################################################################
633   # Make sure that, for each trace type bit, t    638   # Make sure that, for each trace type bit, the receiving node will either:   #
634   #  (i)  fill the trace with its data when it    639   #  (i)  fill the trace with its data when it is a supported bit              #
635   #  (ii) not fill the trace with its data whe    640   #  (ii) not fill the trace with its data when it is an unsupported bit       #
636   ############################################    641   ##############################################################################
637   local desc="Trace type with bit <n> only"       642   local desc="Trace type with bit <n> only"
638                                                   643 
639   local tmp=${bit2size[22]}                       644   local tmp=${bit2size[22]}
640   bit2size[22]=$(( $tmp + ${#BETA[9]} + ((4 -     645   bit2size[22]=$(( $tmp + ${#BETA[9]} + ((4 - (${#BETA[9]} % 4)) % 4) ))
641                                                   646 
642   [ "$1" = "encap" ] && mode="$1 tundst db01::    647   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
643   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 648   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
644                                                   649 
645   for i in {0..11} {22..22}                       650   for i in {0..11} {22..22}
646   do                                              651   do
647     ip -netns $ioam_node_alpha route change db !! 652     ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
648            trace prealloc type ${bit2type[$i]}    653            trace prealloc type ${bit2type[$i]} ns 123 size ${bit2size[$i]} \
649            dev veth0                              654            dev veth0
650                                                   655 
651     run_test "in_bit$i" "${desc/<n>/$i} ($1 mo !! 656     run_test "in_bit$i" "${desc/<n>/$i} ($1 mode)" ioam-node-alpha \
652            $ioam_node_beta db01::1 ${bit2type[ !! 657            ioam-node-beta db01::2 db01::1 veth0 ${bit2type[$i]} 123
653   done                                            658   done
654                                                   659 
655   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 660   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
656                                                   661 
657   bit2size[22]=$tmp                               662   bit2size[22]=$tmp
658 }                                                 663 }
659                                                   664 
660 in_oflag()                                        665 in_oflag()
661 {                                                 666 {
662   ############################################    667   ##############################################################################
663   # Make sure that the receiving node won't fi    668   # Make sure that the receiving node won't fill the trace since the Overflow  #
664   # flag is set.                                  669   # flag is set.                                                               #
665   ############################################    670   ##############################################################################
666   local desc="Overflow flag is set"               671   local desc="Overflow flag is set"
667                                                   672 
668   # Exception:                                    673   # Exception:
669   #   Here, we need the sender to set the Over    674   #   Here, we need the sender to set the Overflow flag. For that, we will add
670   #   back the IOAM namespace that was previou    675   #   back the IOAM namespace that was previously configured on the sender.
671   ip -netns $ioam_node_alpha ioam namespace ad !! 676   ip -netns ioam-node-alpha ioam namespace add 123
672                                                   677 
673   [ "$1" = "encap" ] && mode="$1 tundst db01::    678   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
674   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 679   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
675                                                   680 
676   ip -netns $ioam_node_alpha route change db01 !! 681   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
677          trace prealloc type 0xc00000 ns 123 s    682          trace prealloc type 0xc00000 ns 123 size 4 dev veth0
678                                                   683 
679   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 684   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
680          db01::1 0xc00000 123 $1               !! 685          db01::2 db01::1 veth0 0xc00000 123
681                                                   686 
682   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 687   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
683                                                   688 
684   # And we clean the exception for this test t    689   # And we clean the exception for this test to get things back to normal for
685   # other INPUT tests                             690   # other INPUT tests
686   ip -netns $ioam_node_alpha ioam namespace de !! 691   ip -netns ioam-node-alpha ioam namespace del 123
687 }                                                 692 }
688                                                   693 
689 in_full_supp_trace()                              694 in_full_supp_trace()
690 {                                                 695 {
691   ############################################    696   ##############################################################################
692   # Make sure that the receiving node will cor    697   # Make sure that the receiving node will correctly fill a full trace. Be     #
693   # careful, "full trace" here does NOT mean a    698   # careful, "full trace" here does NOT mean all bits (only supported ones).   #
694   ############################################    699   ##############################################################################
695   local desc="Full supported trace"               700   local desc="Full supported trace"
696                                                   701 
697   [ "$1" = "encap" ] && mode="$1 tundst db01::    702   [ "$1" = "encap" ] && mode="$1 tundst db01::1" || mode="$1"
698   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 703   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 up
699                                                   704 
700   ip -netns $ioam_node_alpha route change db01 !! 705   ip -netns ioam-node-alpha route change db01::/64 encap ioam6 mode $mode \
701          trace prealloc type 0xfff002 ns 123 s    706          trace prealloc type 0xfff002 ns 123 size 80 dev veth0
702                                                   707 
703   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 708   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-beta \
704          db01::1 0xfff002 123 $1               !! 709          db01::2 db01::1 veth0 0xfff002 123
705                                                   710 
706   [ "$1" = "encap" ] && ip -netns $ioam_node_b !! 711   [ "$1" = "encap" ] && ip -netns ioam-node-beta link set ip6tnl0 down
707 }                                                 712 }
708                                                   713 
709                                                   714 
710 ##############################################    715 ################################################################################
711 #                                                 716 #                                                                              #
712 #                              GLOBAL tests       717 #                              GLOBAL tests                                    #
713 #                                                 718 #                                                                              #
714 #   Three nodes (sender/router/receiver), IOAM    719 #   Three nodes (sender/router/receiver), IOAM fully enabled on every node.    #
715 ##############################################    720 ################################################################################
716                                                   721 
717 fwd_full_supp_trace()                             722 fwd_full_supp_trace()
718 {                                                 723 {
719   ############################################    724   ##############################################################################
720   # Make sure that all three nodes correctly f    725   # Make sure that all three nodes correctly filled the full supported trace   #
721   # by checking that the trace data is consist    726   # by checking that the trace data is consistent with the predefined config.  #
722   ############################################    727   ##############################################################################
723   local desc="Forward - Full supported trace"     728   local desc="Forward - Full supported trace"
724                                                   729 
725   [ "$1" = "encap" ] && mode="$1 tundst db02::    730   [ "$1" = "encap" ] && mode="$1 tundst db02::2" || mode="$1"
726   [ "$1" = "encap" ] && ip -netns $ioam_node_g !! 731   [ "$1" = "encap" ] && ip -netns ioam-node-gamma link set ip6tnl0 up
727                                                   732 
728   ip -netns $ioam_node_alpha route change db02 !! 733   ip -netns ioam-node-alpha route change db02::/64 encap ioam6 mode $mode \
729          trace prealloc type 0xfff002 ns 123 s    734          trace prealloc type 0xfff002 ns 123 size 244 via db01::1 dev veth0
730                                                   735 
731   run_test ${FUNCNAME[0]} "${desc} ($1 mode)"  !! 736   run_test ${FUNCNAME[0]} "${desc} ($1 mode)" ioam-node-alpha ioam-node-gamma \
732          db02::2 0xfff002 123 $1               !! 737          db01::2 db02::2 veth0 0xfff002 123
733                                                   738 
734   [ "$1" = "encap" ] && ip -netns $ioam_node_g !! 739   [ "$1" = "encap" ] && ip -netns ioam-node-gamma link set ip6tnl0 down
735 }                                                 740 }
736                                                   741 
737                                                   742 
738 ##############################################    743 ################################################################################
739 #                                                 744 #                                                                              #
740 #                                     MAIN        745 #                                     MAIN                                     #
741 #                                                 746 #                                                                              #
742 ##############################################    747 ################################################################################
743                                                   748 
744 npassed=0                                         749 npassed=0
745 nfailed=0                                         750 nfailed=0
746                                                   751 
747 if [ "$(id -u)" -ne 0 ]                           752 if [ "$(id -u)" -ne 0 ]
748 then                                              753 then
749   echo "SKIP: Need root privileges"               754   echo "SKIP: Need root privileges"
750   exit $ksft_skip                              !! 755   exit 1
751 fi                                                756 fi
752                                                   757 
753 if [ ! -x "$(command -v ip)" ]                    758 if [ ! -x "$(command -v ip)" ]
754 then                                              759 then
755   echo "SKIP: Could not run test without ip to    760   echo "SKIP: Could not run test without ip tool"
756   exit $ksft_skip                              !! 761   exit 1
757 fi                                                762 fi
758                                                   763 
759 ip ioam &>/dev/null                               764 ip ioam &>/dev/null
760 if [ $? = 1 ]                                     765 if [ $? = 1 ]
761 then                                              766 then
762   echo "SKIP: iproute2 too old, missing ioam c    767   echo "SKIP: iproute2 too old, missing ioam command"
763   exit $ksft_skip                              !! 768   exit 1
764 fi                                                769 fi
765                                                   770 
766 check_kernel_compatibility                        771 check_kernel_compatibility
767                                                   772 
768 cleanup &>/dev/null                               773 cleanup &>/dev/null
769 setup                                             774 setup
770 run                                               775 run
771 cleanup &>/dev/null                               776 cleanup &>/dev/null
                                                      

~ [ 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