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