1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0+ 3# 4# Author: Justin Iurman <justin.iurman@uliege.be> 5# 6# This test evaluates the IOAM insertion for IPv6 by checking the IOAM data 7# integrity on the receiver. 8# 9# The topology is formed by 3 nodes: Alpha (sender), Beta (router in-between) 10# and Gamma (receiver). An IOAM domain is configured from Alpha to Gamma only, 11# which means not on the reverse path. When Gamma is the destination, Alpha 12# adds an IOAM option (Pre-allocated Trace) inside a Hop-by-hop and fills the 13# trace with its own IOAM data. Beta and Gamma also fill the trace. The IOAM 14# data integrity is checked on Gamma, by comparing with the pre-defined IOAM 15# configuration (see below). 16# 17# +-------------------+ +-------------------+ 18# | | | | 19# | alpha netns | | gamma netns | 20# | | | | 21# | +-------------+ | | +-------------+ | 22# | | veth0 | | | | veth0 | | 23# | | db01::2/64 | | | | db02::2/64 | | 24# | +-------------+ | | +-------------+ | 25# | . | | . | 26# +-------------------+ +-------------------+ 27# . . 28# . . 29# . . 30# +----------------------------------------------------+ 31# | . . | 32# | +-------------+ +-------------+ | 33# | | veth0 | | veth1 | | 34# | | db01::1/64 | ................ | db02::1/64 | | 35# | +-------------+ +-------------+ | 36# | | 37# | beta netns | 38# | | 39# +--------------------------+-------------------------+ 40# 41# 42# ~~~~~~~~~~~~~~~~~~~~~~ 43# | IOAM configuration | 44# ~~~~~~~~~~~~~~~~~~~~~~ 45# 46# Alpha 47# +-----------------------------------------------------------+ 48# | Type | Value | 49# +-----------------------------------------------------------+ 50# | Node ID | 1 | 51# +-----------------------------------------------------------+ 52# | Node Wide ID | 11111111 | 53# +-----------------------------------------------------------+ 54# | Ingress ID | 0xffff (default value) | 55# +-----------------------------------------------------------+ 56# | Ingress Wide ID | 0xffffffff (default value) | 57# +-----------------------------------------------------------+ 58# | Egress ID | 101 | 59# +-----------------------------------------------------------+ 60# | Egress Wide ID | 101101 | 61# +-----------------------------------------------------------+ 62# | Namespace Data | 0xdeadbee0 | 63# +-----------------------------------------------------------+ 64# | Namespace Wide Data | 0xcafec0caf00dc0de | 65# +-----------------------------------------------------------+ 66# | Schema ID | 777 | 67# +-----------------------------------------------------------+ 68# | Schema Data | something that will be 4n-aligned | 69# +-----------------------------------------------------------+ 70# 71# Note: When Gamma is the destination, Alpha adds an IOAM Pre-allocated Trace 72# option inside a Hop-by-hop, where 164 bytes are pre-allocated for the 73# trace, with 123 as the IOAM-Namespace and with 0xfff00200 as the trace 74# type (= all available options at this time). As a result, and based on 75# IOAM configurations here, only both Alpha and Beta should be capable of 76# inserting their IOAM data while Gamma won't have enough space and will 77# set the overflow bit. 78# 79# Beta 80# +-----------------------------------------------------------+ 81# | Type | Value | 82# +-----------------------------------------------------------+ 83# | Node ID | 2 | 84# +-----------------------------------------------------------+ 85# | Node Wide ID | 22222222 | 86# +-----------------------------------------------------------+ 87# | Ingress ID | 201 | 88# +-----------------------------------------------------------+ 89# | Ingress Wide ID | 201201 | 90# +-----------------------------------------------------------+ 91# | Egress ID | 202 | 92# +-----------------------------------------------------------+ 93# | Egress Wide ID | 202202 | 94# +-----------------------------------------------------------+ 95# | Namespace Data | 0xdeadbee1 | 96# +-----------------------------------------------------------+ 97# | Namespace Wide Data | 0xcafec0caf11dc0de | 98# +-----------------------------------------------------------+ 99# | Schema ID | 0xffffff (= None) | 100# +-----------------------------------------------------------+ 101# | Schema Data | | 102# +-----------------------------------------------------------+ 103# 104# Gamma 105# +-----------------------------------------------------------+ 106# | Type | Value | 107# +-----------------------------------------------------------+ 108# | Node ID | 3 | 109# +-----------------------------------------------------------+ 110# | Node Wide ID | 33333333 | 111# +-----------------------------------------------------------+ 112# | Ingress ID | 301 | 113# +-----------------------------------------------------------+ 114# | Ingress Wide ID | 301301 | 115# +-----------------------------------------------------------+ 116# | Egress ID | 0xffff (default value) | 117# +-----------------------------------------------------------+ 118# | Egress Wide ID | 0xffffffff (default value) | 119# +-----------------------------------------------------------+ 120# | Namespace Data | 0xdeadbee2 | 121# +-----------------------------------------------------------+ 122# | Namespace Wide Data | 0xcafec0caf22dc0de | 123# +-----------------------------------------------------------+ 124# | Schema ID | 0xffffff (= None) | 125# +-----------------------------------------------------------+ 126# | Schema Data | | 127# +-----------------------------------------------------------+ 128 129#=============================================================================== 130# 131# WARNING: 132# Do NOT modify the following configuration unless you know what you're doing. 133# 134IOAM_NAMESPACE=123 135IOAM_TRACE_TYPE=0xfff00200 136IOAM_PREALLOC_DATA_SIZE=164 137 138ALPHA=( 139 1 # ID 140 11111111 # Wide ID 141 0xffff # Ingress ID 142 0xffffffff # Ingress Wide ID 143 101 # Egress ID 144 101101 # Egress Wide ID 145 0xdeadbee0 # Namespace Data 146 0xcafec0caf00dc0de # Namespace Wide Data 147 777 # Schema ID (0xffffff = None) 148 "something that will be 4n-aligned" # Schema Data 149) 150 151BETA=( 152 2 153 22222222 154 201 155 201201 156 202 157 202202 158 0xdeadbee1 159 0xcafec0caf11dc0de 160 0xffffff 161 "" 162) 163 164GAMMA=( 165 3 166 33333333 167 301 168 301301 169 0xffff 170 0xffffffff 171 0xdeadbee2 172 0xcafec0caf22dc0de 173 0xffffff 174 "" 175) 176#=============================================================================== 177 178if [ "$(id -u)" -ne 0 ]; then 179 echo "SKIP: Need root privileges" 180 exit 1 181fi 182 183if [ ! -x "$(command -v ip)" ]; then 184 echo "SKIP: Could not run test without ip tool" 185 exit 1 186fi 187 188ip ioam &>/dev/null 189if [ $? = 1 ]; then 190 echo "SKIP: ip tool must include IOAM" 191 exit 1 192fi 193 194if [ ! -e /proc/sys/net/ipv6/ioam6_id ]; then 195 echo "SKIP: ioam6 sysctls do not exist" 196 exit 1 197fi 198 199cleanup() 200{ 201 ip link del ioam-veth-alpha 2>/dev/null || true 202 ip link del ioam-veth-gamma 2>/dev/null || true 203 204 ip netns del ioam-node-alpha || true 205 ip netns del ioam-node-beta || true 206 ip netns del ioam-node-gamma || true 207} 208 209setup() 210{ 211 ip netns add ioam-node-alpha 212 ip netns add ioam-node-beta 213 ip netns add ioam-node-gamma 214 215 ip link add name ioam-veth-alpha type veth peer name ioam-veth-betaL 216 ip link add name ioam-veth-betaR type veth peer name ioam-veth-gamma 217 218 ip link set ioam-veth-alpha netns ioam-node-alpha 219 ip link set ioam-veth-betaL netns ioam-node-beta 220 ip link set ioam-veth-betaR netns ioam-node-beta 221 ip link set ioam-veth-gamma netns ioam-node-gamma 222 223 ip -netns ioam-node-alpha link set ioam-veth-alpha name veth0 224 ip -netns ioam-node-beta link set ioam-veth-betaL name veth0 225 ip -netns ioam-node-beta link set ioam-veth-betaR name veth1 226 ip -netns ioam-node-gamma link set ioam-veth-gamma name veth0 227 228 ip -netns ioam-node-alpha addr add db01::2/64 dev veth0 229 ip -netns ioam-node-alpha link set veth0 up 230 ip -netns ioam-node-alpha link set lo up 231 ip -netns ioam-node-alpha route add default via db01::1 232 233 ip -netns ioam-node-beta addr add db01::1/64 dev veth0 234 ip -netns ioam-node-beta addr add db02::1/64 dev veth1 235 ip -netns ioam-node-beta link set veth0 up 236 ip -netns ioam-node-beta link set veth1 up 237 ip -netns ioam-node-beta link set lo up 238 239 ip -netns ioam-node-gamma addr add db02::2/64 dev veth0 240 ip -netns ioam-node-gamma link set veth0 up 241 ip -netns ioam-node-gamma link set lo up 242 ip -netns ioam-node-gamma route add default via db02::1 243 244 # - IOAM config - 245 ip netns exec ioam-node-alpha sysctl -wq net.ipv6.ioam6_id=${ALPHA[0]} 246 ip netns exec ioam-node-alpha sysctl -wq net.ipv6.ioam6_id_wide=${ALPHA[1]} 247 ip netns exec ioam-node-alpha sysctl -wq net.ipv6.conf.veth0.ioam6_id=${ALPHA[4]} 248 ip netns exec ioam-node-alpha sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${ALPHA[5]} 249 ip -netns ioam-node-alpha ioam namespace add ${IOAM_NAMESPACE} data ${ALPHA[6]} wide ${ALPHA[7]} 250 ip -netns ioam-node-alpha ioam schema add ${ALPHA[8]} "${ALPHA[9]}" 251 ip -netns ioam-node-alpha ioam namespace set ${IOAM_NAMESPACE} schema ${ALPHA[8]} 252 ip -netns ioam-node-alpha route add db02::/64 encap ioam6 trace type ${IOAM_TRACE_TYPE:0:-2} ns ${IOAM_NAMESPACE} size ${IOAM_PREALLOC_DATA_SIZE} via db01::1 dev veth0 253 254 ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.all.forwarding=1 255 ip netns exec ioam-node-beta sysctl -wq net.ipv6.ioam6_id=${BETA[0]} 256 ip netns exec ioam-node-beta sysctl -wq net.ipv6.ioam6_id_wide=${BETA[1]} 257 ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1 258 ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_id=${BETA[2]} 259 ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${BETA[3]} 260 ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth1.ioam6_id=${BETA[4]} 261 ip netns exec ioam-node-beta sysctl -wq net.ipv6.conf.veth1.ioam6_id_wide=${BETA[5]} 262 ip -netns ioam-node-beta ioam namespace add ${IOAM_NAMESPACE} data ${BETA[6]} wide ${BETA[7]} 263 264 ip netns exec ioam-node-gamma sysctl -wq net.ipv6.ioam6_id=${GAMMA[0]} 265 ip netns exec ioam-node-gamma sysctl -wq net.ipv6.ioam6_id_wide=${GAMMA[1]} 266 ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_enabled=1 267 ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_id=${GAMMA[2]} 268 ip netns exec ioam-node-gamma sysctl -wq net.ipv6.conf.veth0.ioam6_id_wide=${GAMMA[3]} 269 ip -netns ioam-node-gamma ioam namespace add ${IOAM_NAMESPACE} data ${GAMMA[6]} wide ${GAMMA[7]} 270} 271 272run() 273{ 274 echo -n "IOAM test... " 275 276 ip netns exec ioam-node-alpha ping6 -c 5 -W 1 db02::2 &>/dev/null 277 if [ $? != 0 ]; then 278 echo "FAILED" 279 cleanup &>/dev/null 280 exit 0 281 fi 282 283 ip netns exec ioam-node-gamma ./ioam6_parser veth0 2 ${IOAM_NAMESPACE} ${IOAM_TRACE_TYPE} 64 ${ALPHA[0]} ${ALPHA[1]} ${ALPHA[2]} ${ALPHA[3]} ${ALPHA[4]} ${ALPHA[5]} ${ALPHA[6]} ${ALPHA[7]} ${ALPHA[8]} "${ALPHA[9]}" 63 ${BETA[0]} ${BETA[1]} ${BETA[2]} ${BETA[3]} ${BETA[4]} ${BETA[5]} ${BETA[6]} ${BETA[7]} ${BETA[8]} & 284 285 local spid=$! 286 sleep 0.1 287 288 ip netns exec ioam-node-alpha ping6 -c 5 -W 1 db02::2 &>/dev/null 289 290 wait $spid 291 [ $? = 0 ] && echo "PASSED" || echo "FAILED" 292} 293 294cleanup &>/dev/null 295setup 296run 297cleanup &>/dev/null 298