Skip to content

Commit 968691c

Browse files
IurmanJdavem330
authored andcommitted
selftests: net: Test for the IOAM insertion with IPv6
This test evaluates the IOAM insertion for IPv6 by checking the IOAM data integrity on the receiver. The topology is formed by 3 nodes: Alpha (sender), Beta (router in-between) and Gamma (receiver). An IOAM domain is configured from Alpha to Gamma only, which means not on the reverse path. When Gamma is the destination, Alpha adds an IOAM option (Pre-allocated Trace) inside a Hop-by-hop and fills the trace with its own IOAM data. Beta and Gamma also fill the trace. The IOAM data integrity is checked on Gamma, by comparing with the pre-defined IOAM configuration (see below). +-------------------+ +-------------------+ | | | | | alpha netns | | gamma netns | | | | | | +-------------+ | | +-------------+ | | | veth0 | | | | veth0 | | | | db01::2/64 | | | | db02::2/64 | | | +-------------+ | | +-------------+ | | . | | . | +-------------------+ +-------------------+ . . . . . . +----------------------------------------------------+ | . . | | +-------------+ +-------------+ | | | veth0 | | veth1 | | | | db01::1/64 | ................ | db02::1/64 | | | +-------------+ +-------------+ | | | | beta netns | | | +--------------------------+-------------------------+ ~~~~~~~~~~~~~~~~~~~~~~ | IOAM configuration | ~~~~~~~~~~~~~~~~~~~~~~ Alpha +-----------------------------------------------------------+ | Type | Value | +-----------------------------------------------------------+ | Node ID | 1 | +-----------------------------------------------------------+ | Node Wide ID | 11111111 | +-----------------------------------------------------------+ | Ingress ID | 0xffff (default value) | +-----------------------------------------------------------+ | Ingress Wide ID | 0xffffffff (default value) | +-----------------------------------------------------------+ | Egress ID | 101 | +-----------------------------------------------------------+ | Egress Wide ID | 101101 | +-----------------------------------------------------------+ | Namespace Data | 0xdeadbee0 | +-----------------------------------------------------------+ | Namespace Wide Data | 0xcafec0caf00dc0de | +-----------------------------------------------------------+ | Schema ID | 777 | +-----------------------------------------------------------+ | Schema Data | something that will be 4n-aligned | +-----------------------------------------------------------+ Note: When Gamma is the destination, Alpha adds an IOAM Pre-allocated Trace option inside a Hop-by-hop, where 164 bytes are pre-allocated for the trace, with 123 as the IOAM-Namespace and with 0xfff00200 as the trace type (= all available options at this time). As a result, and based on IOAM configurations here, only both Alpha and Beta should be capable of inserting their IOAM data while Gamma won't have enough space and will set the overflow bit. Beta +-----------------------------------------------------------+ | Type | Value | +-----------------------------------------------------------+ | Node ID | 2 | +-----------------------------------------------------------+ | Node Wide ID | 22222222 | +-----------------------------------------------------------+ | Ingress ID | 201 | +-----------------------------------------------------------+ | Ingress Wide ID | 201201 | +-----------------------------------------------------------+ | Egress ID | 202 | +-----------------------------------------------------------+ | Egress Wide ID | 202202 | +-----------------------------------------------------------+ | Namespace Data | 0xdeadbee1 | +-----------------------------------------------------------+ | Namespace Wide Data | 0xcafec0caf11dc0de | +-----------------------------------------------------------+ | Schema ID | 0xffffff (= None) | +-----------------------------------------------------------+ | Schema Data | | +-----------------------------------------------------------+ Gamma +-----------------------------------------------------------+ | Type | Value | +-----------------------------------------------------------+ | Node ID | 3 | +-----------------------------------------------------------+ | Node Wide ID | 33333333 | +-----------------------------------------------------------+ | Ingress ID | 301 | +-----------------------------------------------------------+ | Ingress Wide ID | 301301 | +-----------------------------------------------------------+ | Egress ID | 0xffff (default value) | +-----------------------------------------------------------+ | Egress Wide ID | 0xffffffff (default value) | +-----------------------------------------------------------+ | Namespace Data | 0xdeadbee2 | +-----------------------------------------------------------+ | Namespace Wide Data | 0xcafec0caf22dc0de | +-----------------------------------------------------------+ | Schema ID | 0xffffff (= None) | +-----------------------------------------------------------+ | Schema Data | | +-----------------------------------------------------------+ Signed-off-by: Justin Iurman <justin.iurman@uliege.be> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent de8e80a commit 968691c

File tree

4 files changed

+702
-0
lines changed

4 files changed

+702
-0
lines changed

tools/testing/selftests/net/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ TEST_PROGS += bareudp.sh
2525
TEST_PROGS += unicast_extensions.sh
2626
TEST_PROGS += udpgro_fwd.sh
2727
TEST_PROGS += veth.sh
28+
TEST_PROGS += ioam6.sh
2829
TEST_PROGS_EXTENDED := in_netns.sh
2930
TEST_GEN_FILES = socket nettest
3031
TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
@@ -36,6 +37,7 @@ TEST_GEN_FILES += fin_ack_lat
3637
TEST_GEN_FILES += reuseaddr_ports_exhausted
3738
TEST_GEN_FILES += hwtstamp_config rxtimestamp timestamping txtimestamp
3839
TEST_GEN_FILES += ipsec
40+
TEST_GEN_FILES += ioam6_parser
3941
TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
4042
TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls
4143

tools/testing/selftests/net/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ CONFIG_NET_CLS_FLOWER=m
4242
CONFIG_NET_ACT_TUNNEL_KEY=m
4343
CONFIG_NET_ACT_MIRRED=m
4444
CONFIG_BAREUDP=m
45+
CONFIG_IPV6_IOAM6_LWTUNNEL=y
Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
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+
#
134+
IOAM_NAMESPACE=123
135+
IOAM_TRACE_TYPE=0xfff00200
136+
IOAM_PREALLOC_DATA_SIZE=164
137+
138+
ALPHA=(
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+
151+
BETA=(
152+
2
153+
22222222
154+
201
155+
201201
156+
202
157+
202202
158+
0xdeadbee1
159+
0xcafec0caf11dc0de
160+
0xffffff
161+
""
162+
)
163+
164+
GAMMA=(
165+
3
166+
33333333
167+
301
168+
301301
169+
0xffff
170+
0xffffffff
171+
0xdeadbee2
172+
0xcafec0caf22dc0de
173+
0xffffff
174+
""
175+
)
176+
#===============================================================================
177+
178+
if [ "$(id -u)" -ne 0 ]; then
179+
echo "SKIP: Need root privileges"
180+
exit 1
181+
fi
182+
183+
if [ ! -x "$(command -v ip)" ]; then
184+
echo "SKIP: Could not run test without ip tool"
185+
exit 1
186+
fi
187+
188+
ip ioam &>/dev/null
189+
if [ $? = 1 ]; then
190+
echo "SKIP: ip tool must include IOAM"
191+
exit 1
192+
fi
193+
194+
if [ ! -e /proc/sys/net/ipv6/ioam6_id ]; then
195+
echo "SKIP: ioam6 sysctls do not exist"
196+
exit 1
197+
fi
198+
199+
cleanup()
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+
209+
setup()
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+
272+
run()
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+
294+
cleanup &>/dev/null
295+
setup
296+
run
297+
cleanup &>/dev/null

0 commit comments

Comments
 (0)