Skip to content

Commit df40e39

Browse files
sbrivio-rhdavem330
authored andcommitted
selftests: pmtu.sh: Add tests for bridged UDP tunnels
The new tests check that IP and IPv6 packets exceeding the local PMTU estimate, both locally generated and forwarded by a bridge from another node, result in the correct route exceptions being created, and that communication with end-to-end fragmentation over VXLAN and GENEVE tunnels is now possible as a result of PMTU discovery. Part of the existing setup functions aren't generic enough to simply add a namespace and a bridge to the existing routing setup. This rework is in progress and we can easily shrink this once more generic topology functions are available. Signed-off-by: Stefano Brivio <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c1a800e commit df40e39

File tree

1 file changed

+159
-7
lines changed

1 file changed

+159
-7
lines changed

tools/testing/selftests/net/pmtu.sh

Lines changed: 159 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@
5959
# Same as pmtu_ipv6_vxlan6_exception, but using a GENEVE tunnel instead of
6060
# VXLAN
6161
#
62+
# - pmtu_ipv{4,6}_br_vxlan{4,6}_exception
63+
# Set up three namespaces, A, B, and C, with routing between A and B over
64+
# R1. R2 is unused in these tests. A has a veth connection to C, and is
65+
# connected to B via a VXLAN endpoint, which is directly bridged to C.
66+
# MTU on the B-R1 link is lower than other MTUs.
67+
#
68+
# Check that both C and A are able to communicate with B over the VXLAN
69+
# tunnel, and that PMTU exceptions with the correct values are created.
70+
#
71+
# segment a_r1 segment b_r1 b_r1: 4000
72+
# .--------------R1--------------. everything
73+
# C---veth A B else: 5000
74+
# ' bridge |
75+
# '---- - - - - - VXLAN - - - - - - - '
76+
#
77+
# - pmtu_ipv{4,6}_br_geneve{4,6}_exception
78+
# Same as pmtu_ipv{4,6}_br_vxlan{4,6}_exception, with a GENEVE tunnel
79+
# instead.
80+
#
6281
# - pmtu_ipv{4,6}_fou{4,6}_exception
6382
# Same as pmtu_ipv4_vxlan4, but using a direct IPv4/IPv6 encapsulation
6483
# (FoU) over IPv4/IPv6, instead of VXLAN
@@ -147,6 +166,14 @@ tests="
147166
pmtu_ipv6_geneve4_exception IPv6 over geneve4: PMTU exceptions 1
148167
pmtu_ipv4_geneve6_exception IPv4 over geneve6: PMTU exceptions 1
149168
pmtu_ipv6_geneve6_exception IPv6 over geneve6: PMTU exceptions 1
169+
pmtu_ipv4_br_vxlan4_exception IPv4, bridged vxlan4: PMTU exceptions 1
170+
pmtu_ipv6_br_vxlan4_exception IPv6, bridged vxlan4: PMTU exceptions 1
171+
pmtu_ipv4_br_vxlan6_exception IPv4, bridged vxlan6: PMTU exceptions 1
172+
pmtu_ipv6_br_vxlan6_exception IPv6, bridged vxlan6: PMTU exceptions 1
173+
pmtu_ipv4_br_geneve4_exception IPv4, bridged geneve4: PMTU exceptions 1
174+
pmtu_ipv6_br_geneve4_exception IPv6, bridged geneve4: PMTU exceptions 1
175+
pmtu_ipv4_br_geneve6_exception IPv4, bridged geneve6: PMTU exceptions 1
176+
pmtu_ipv6_br_geneve6_exception IPv6, bridged geneve6: PMTU exceptions 1
150177
pmtu_ipv4_fou4_exception IPv4 over fou4: PMTU exceptions 1
151178
pmtu_ipv6_fou4_exception IPv6 over fou4: PMTU exceptions 1
152179
pmtu_ipv4_fou6_exception IPv4 over fou6: PMTU exceptions 1
@@ -173,10 +200,12 @@ tests="
173200

174201
NS_A="ns-A"
175202
NS_B="ns-B"
203+
NS_C="ns-C"
176204
NS_R1="ns-R1"
177205
NS_R2="ns-R2"
178206
ns_a="ip netns exec ${NS_A}"
179207
ns_b="ip netns exec ${NS_B}"
208+
ns_c="ip netns exec ${NS_C}"
180209
ns_r1="ip netns exec ${NS_R1}"
181210
ns_r2="ip netns exec ${NS_R2}"
182211

@@ -239,9 +268,11 @@ routes_nh="
239268

240269
veth4_a_addr="192.168.1.1"
241270
veth4_b_addr="192.168.1.2"
271+
veth4_c_addr="192.168.2.10"
242272
veth4_mask="24"
243273
veth6_a_addr="fd00:1::a"
244274
veth6_b_addr="fd00:1::b"
275+
veth6_c_addr="fd00:2::c"
245276
veth6_mask="64"
246277

247278
tunnel4_a_addr="192.168.2.1"
@@ -428,7 +459,7 @@ setup_ip6ip6() {
428459
}
429460

430461
setup_namespaces() {
431-
for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
462+
for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
432463
ip netns add ${n} || return 1
433464

434465
# Disable DAD, so that we don't have to wait to use the
@@ -484,6 +515,7 @@ setup_vxlan_or_geneve() {
484515
a_addr="${2}"
485516
b_addr="${3}"
486517
opts="${4}"
518+
br_if_a="${5}"
487519

488520
if [ "${type}" = "vxlan" ]; then
489521
opts="${opts} ttl 64 dstport 4789"
@@ -497,10 +529,16 @@ setup_vxlan_or_geneve() {
497529
run_cmd ${ns_a} ip link add ${type}_a type ${type} id 1 ${opts_a} remote ${b_addr} ${opts} || return 1
498530
run_cmd ${ns_b} ip link add ${type}_b type ${type} id 1 ${opts_b} remote ${a_addr} ${opts}
499531

500-
run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${type}_a
501-
run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
532+
if [ -n "${br_if_a}" ]; then
533+
run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${br_if_a}
534+
run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${br_if_a}
535+
run_cmd ${ns_a} ip link set ${type}_a master ${br_if_a}
536+
else
537+
run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${type}_a
538+
run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${type}_a
539+
fi
502540

503-
run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${type}_a
541+
run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
504542
run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${type}_b
505543

506544
run_cmd ${ns_a} ip link set ${type}_a up
@@ -516,11 +554,27 @@ setup_vxlan4() {
516554
}
517555

518556
setup_geneve6() {
519-
setup_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
557+
setup_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 ""
520558
}
521559

522560
setup_vxlan6() {
523-
setup_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
561+
setup_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 ""
562+
}
563+
564+
setup_bridged_geneve4() {
565+
setup_vxlan_or_geneve geneve ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set" "br0"
566+
}
567+
568+
setup_bridged_vxlan4() {
569+
setup_vxlan_or_geneve vxlan ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set" "br0"
570+
}
571+
572+
setup_bridged_geneve6() {
573+
setup_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 "" "br0"
574+
}
575+
576+
setup_bridged_vxlan6() {
577+
setup_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 "" "br0"
524578
}
525579

526580
setup_xfrm() {
@@ -630,6 +684,20 @@ setup_routing() {
630684
return 0
631685
}
632686

687+
setup_bridge() {
688+
run_cmd ${ns_a} ip link add br0 type bridge || return 2
689+
run_cmd ${ns_a} ip link set br0 up
690+
691+
run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C
692+
run_cmd ${ns_c} ip link set veth_A-C netns ns-A
693+
694+
run_cmd ${ns_a} ip link set veth_A-C up
695+
run_cmd ${ns_c} ip link set veth_C-A up
696+
run_cmd ${ns_c} ip addr add ${veth4_c_addr}/${veth4_mask} dev veth_C-A
697+
run_cmd ${ns_c} ip addr add ${veth6_c_addr}/${veth6_mask} dev veth_C-A
698+
run_cmd ${ns_a} ip link set veth_A-C master br0
699+
}
700+
633701
setup() {
634702
[ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
635703

@@ -657,7 +725,7 @@ cleanup() {
657725
done
658726
tcpdump_pids=
659727

660-
for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
728+
for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
661729
ip netns del ${n} 2> /dev/null
662730
done
663731
}
@@ -892,6 +960,90 @@ test_pmtu_ipv6_geneve6_exception() {
892960
test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 6 6
893961
}
894962

963+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception() {
964+
type=${1}
965+
family=${2}
966+
outer_family=${3}
967+
ll_mtu=4000
968+
969+
if [ ${outer_family} -eq 4 ]; then
970+
setup namespaces routing bridge bridged_${type}4 || return 2
971+
# IPv4 header UDP header VXLAN/GENEVE header Ethernet header
972+
exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
973+
else
974+
setup namespaces routing bridge bridged_${type}6 || return 2
975+
# IPv6 header UDP header VXLAN/GENEVE header Ethernet header
976+
exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
977+
fi
978+
979+
trace "${ns_a}" ${type}_a "${ns_b}" ${type}_b \
980+
"${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
981+
"${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B \
982+
"${ns_a}" br0 "${ns_a}" veth-A-C \
983+
"${ns_c}" veth_C-A
984+
985+
if [ ${family} -eq 4 ]; then
986+
ping=ping
987+
dst=${tunnel4_b_addr}
988+
else
989+
ping=${ping6}
990+
dst=${tunnel6_b_addr}
991+
fi
992+
993+
# Create route exception by exceeding link layer MTU
994+
mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
995+
mtu "${ns_a}" br0 $((${ll_mtu} + 1000))
996+
mtu "${ns_a}" veth_A-C $((${ll_mtu} + 1000))
997+
mtu "${ns_c}" veth_C-A $((${ll_mtu} + 1000))
998+
mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
999+
mtu "${ns_b}" veth_B-R1 ${ll_mtu}
1000+
mtu "${ns_r1}" veth_R1-B ${ll_mtu}
1001+
1002+
mtu "${ns_a}" ${type}_a $((${ll_mtu} + 1000))
1003+
mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
1004+
1005+
run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1
1006+
run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst} || return 1
1007+
1008+
# Check that exceptions were created
1009+
pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
1010+
check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on bridged ${type} interface"
1011+
pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
1012+
check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on locally bridged ${type} interface"
1013+
}
1014+
1015+
test_pmtu_ipv4_br_vxlan4_exception() {
1016+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 4 4
1017+
}
1018+
1019+
test_pmtu_ipv6_br_vxlan4_exception() {
1020+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 6 4
1021+
}
1022+
1023+
test_pmtu_ipv4_br_geneve4_exception() {
1024+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 4 4
1025+
}
1026+
1027+
test_pmtu_ipv6_br_geneve4_exception() {
1028+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 6 4
1029+
}
1030+
1031+
test_pmtu_ipv4_br_vxlan6_exception() {
1032+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 4 6
1033+
}
1034+
1035+
test_pmtu_ipv6_br_vxlan6_exception() {
1036+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 6 6
1037+
}
1038+
1039+
test_pmtu_ipv4_br_geneve6_exception() {
1040+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 4 6
1041+
}
1042+
1043+
test_pmtu_ipv6_br_geneve6_exception() {
1044+
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 6 6
1045+
}
1046+
8951047
test_pmtu_ipvX_over_fouY_or_gueY() {
8961048
inner_family=${1}
8971049
outer_family=${2}

0 commit comments

Comments
 (0)