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