Skip to content

Commit 7b53682

Browse files
sbrivio-rhdavem330
authored andcommitted
selftests: pmtu.sh: Add tests for UDP tunnels handled by Open vSwitch
The new tests check that IP and IPv6 packets exceeding the local PMTU estimate, forwarded by an Open vSwitch instance from another node, result in the correct route exceptions being created, and that communication with end-to-end fragmentation, over GENEVE and VXLAN Open vSwitch ports, is now possible as a result of PMTU discovery. Signed-off-by: Stefano Brivio <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent df40e39 commit 7b53682

File tree

1 file changed

+180
-0
lines changed

1 file changed

+180
-0
lines changed

tools/testing/selftests/net/pmtu.sh

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@
7878
# Same as pmtu_ipv{4,6}_br_vxlan{4,6}_exception, with a GENEVE tunnel
7979
# instead.
8080
#
81+
# - pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception
82+
# Set up two namespaces, B, and C, with routing between the init namespace
83+
# and B over R1. A and R2 are unused in these tests. The init namespace
84+
# has a veth connection to C, and is connected to B via a VXLAN endpoint,
85+
# which is handled by Open vSwitch and bridged to C. MTU on the B-R1 link
86+
# is lower than other MTUs.
87+
#
88+
# Check that C is able to communicate with B over the VXLAN tunnel, and
89+
# that PMTU exceptions with the correct values are created.
90+
#
91+
# segment a_r1 segment b_r1 b_r1: 4000
92+
# .--------------R1--------------. everything
93+
# C---veth init B else: 5000
94+
# '- ovs |
95+
# '---- - - - - - VXLAN - - - - - - - '
96+
#
97+
# - pmtu_ipv{4,6}_ovs_geneve{4,6}_exception
98+
# Same as pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception, with a GENEVE tunnel
99+
# instead.
100+
#
81101
# - pmtu_ipv{4,6}_fou{4,6}_exception
82102
# Same as pmtu_ipv4_vxlan4, but using a direct IPv4/IPv6 encapsulation
83103
# (FoU) over IPv4/IPv6, instead of VXLAN
@@ -174,6 +194,14 @@ tests="
174194
pmtu_ipv6_br_geneve4_exception IPv6, bridged geneve4: PMTU exceptions 1
175195
pmtu_ipv4_br_geneve6_exception IPv4, bridged geneve6: PMTU exceptions 1
176196
pmtu_ipv6_br_geneve6_exception IPv6, bridged geneve6: PMTU exceptions 1
197+
pmtu_ipv4_ovs_vxlan4_exception IPv4, OVS vxlan4: PMTU exceptions 1
198+
pmtu_ipv6_ovs_vxlan4_exception IPv6, OVS vxlan4: PMTU exceptions 1
199+
pmtu_ipv4_ovs_vxlan6_exception IPv4, OVS vxlan6: PMTU exceptions 1
200+
pmtu_ipv6_ovs_vxlan6_exception IPv6, OVS vxlan6: PMTU exceptions 1
201+
pmtu_ipv4_ovs_geneve4_exception IPv4, OVS geneve4: PMTU exceptions 1
202+
pmtu_ipv6_ovs_geneve4_exception IPv6, OVS geneve4: PMTU exceptions 1
203+
pmtu_ipv4_ovs_geneve6_exception IPv4, OVS geneve6: PMTU exceptions 1
204+
pmtu_ipv6_ovs_geneve6_exception IPv6, OVS geneve6: PMTU exceptions 1
177205
pmtu_ipv4_fou4_exception IPv4 over fou4: PMTU exceptions 1
178206
pmtu_ipv6_fou4_exception IPv6 over fou4: PMTU exceptions 1
179207
pmtu_ipv4_fou6_exception IPv4 over fou6: PMTU exceptions 1
@@ -698,6 +726,66 @@ setup_bridge() {
698726
run_cmd ${ns_a} ip link set veth_A-C master br0
699727
}
700728

729+
setup_ovs_vxlan_or_geneve() {
730+
type="${1}"
731+
a_addr="${2}"
732+
b_addr="${3}"
733+
734+
if [ "${type}" = "vxlan" ]; then
735+
opts="${opts} ttl 64 dstport 4789"
736+
opts_b="local ${b_addr}"
737+
fi
738+
739+
run_cmd ovs-vsctl add-port ovs_br0 ${type}_a -- \
740+
set interface ${type}_a type=${type} \
741+
options:remote_ip=${b_addr} options:key=1 options:csum=true || return 1
742+
743+
run_cmd ${ns_b} ip link add ${type}_b type ${type} id 1 ${opts_b} remote ${a_addr} ${opts} || return 1
744+
745+
run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
746+
run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${type}_b
747+
748+
run_cmd ${ns_b} ip link set ${type}_b up
749+
}
750+
751+
setup_ovs_geneve4() {
752+
setup_ovs_vxlan_or_geneve geneve ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1
753+
}
754+
755+
setup_ovs_vxlan4() {
756+
setup_ovs_vxlan_or_geneve vxlan ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1
757+
}
758+
759+
setup_ovs_geneve6() {
760+
setup_ovs_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
761+
}
762+
763+
setup_ovs_vxlan6() {
764+
setup_ovs_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
765+
}
766+
767+
setup_ovs_bridge() {
768+
run_cmd ovs-vsctl add-br ovs_br0 || return 2
769+
run_cmd ip link set ovs_br0 up
770+
771+
run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C
772+
run_cmd ${ns_c} ip link set veth_A-C netns 1
773+
774+
run_cmd ip link set veth_A-C up
775+
run_cmd ${ns_c} ip link set veth_C-A up
776+
run_cmd ${ns_c} ip addr add ${veth4_c_addr}/${veth4_mask} dev veth_C-A
777+
run_cmd ${ns_c} ip addr add ${veth6_c_addr}/${veth6_mask} dev veth_C-A
778+
run_cmd ovs-vsctl add-port ovs_br0 veth_A-C
779+
780+
# Move veth_A-R1 to init
781+
run_cmd ${ns_a} ip link set veth_A-R1 netns 1
782+
run_cmd ip addr add ${prefix4}.${a_r1}.1/${veth4_mask} dev veth_A-R1
783+
run_cmd ip addr add ${prefix6}:${a_r1}::1/${veth6_mask} dev veth_A-R1
784+
run_cmd ip link set veth_A-R1 up
785+
run_cmd ip route add ${prefix4}.${b_r1}.1 via ${prefix4}.${a_r1}.2
786+
run_cmd ip route add ${prefix6}:${b_r1}::1 via ${prefix6}:${a_r1}::2
787+
}
788+
701789
setup() {
702790
[ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
703791

@@ -728,6 +816,11 @@ cleanup() {
728816
for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
729817
ip netns del ${n} 2> /dev/null
730818
done
819+
820+
ip link del veth_A-C 2>/dev/null
821+
ip link del veth_A-R1 2>/dev/null
822+
ovs-vsctl --if-exists del-port vxlan_a 2>/dev/null
823+
ovs-vsctl --if-exists del-br ovs_br0 2>/dev/null
731824
}
732825

733826
mtu() {
@@ -1044,6 +1137,93 @@ test_pmtu_ipv6_br_geneve6_exception() {
10441137
test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 6 6
10451138
}
10461139

1140+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception() {
1141+
type=${1}
1142+
family=${2}
1143+
outer_family=${3}
1144+
ll_mtu=4000
1145+
1146+
if [ ${outer_family} -eq 4 ]; then
1147+
setup namespaces routing ovs_bridge ovs_${type}4 || return 2
1148+
# IPv4 header UDP header VXLAN/GENEVE header Ethernet header
1149+
exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
1150+
else
1151+
setup namespaces routing ovs_bridge ovs_${type}6 || return 2
1152+
# IPv6 header UDP header VXLAN/GENEVE header Ethernet header
1153+
exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
1154+
fi
1155+
1156+
if [ "${type}" = "vxlan" ]; then
1157+
tun_a="vxlan_sys_4789"
1158+
elif [ "${type}" = "geneve" ]; then
1159+
tun_a="genev_sys_6081"
1160+
fi
1161+
1162+
trace "" "${tun_a}" "${ns_b}" ${type}_b \
1163+
"" veth_A-R1 "${ns_r1}" veth_R1-A \
1164+
"${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B \
1165+
"" ovs_br0 "" veth-A-C \
1166+
"${ns_c}" veth_C-A
1167+
1168+
if [ ${family} -eq 4 ]; then
1169+
ping=ping
1170+
dst=${tunnel4_b_addr}
1171+
else
1172+
ping=${ping6}
1173+
dst=${tunnel6_b_addr}
1174+
fi
1175+
1176+
# Create route exception by exceeding link layer MTU
1177+
mtu "" veth_A-R1 $((${ll_mtu} + 1000))
1178+
mtu "" ovs_br0 $((${ll_mtu} + 1000))
1179+
mtu "" veth_A-C $((${ll_mtu} + 1000))
1180+
mtu "${ns_c}" veth_C-A $((${ll_mtu} + 1000))
1181+
mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
1182+
mtu "${ns_b}" veth_B-R1 ${ll_mtu}
1183+
mtu "${ns_r1}" veth_R1-B ${ll_mtu}
1184+
1185+
mtu "" ${tun_a} $((${ll_mtu} + 1000))
1186+
mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
1187+
1188+
run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 20 -s $((${ll_mtu} + 500)) ${dst} || return 1
1189+
1190+
# Check that exceptions were created
1191+
pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
1192+
check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on Open vSwitch ${type} interface"
1193+
}
1194+
1195+
test_pmtu_ipv4_ovs_vxlan4_exception() {
1196+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 4 4
1197+
}
1198+
1199+
test_pmtu_ipv6_ovs_vxlan4_exception() {
1200+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 6 4
1201+
}
1202+
1203+
test_pmtu_ipv4_ovs_geneve4_exception() {
1204+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 4 4
1205+
}
1206+
1207+
test_pmtu_ipv6_ovs_geneve4_exception() {
1208+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 6 4
1209+
}
1210+
1211+
test_pmtu_ipv4_ovs_vxlan6_exception() {
1212+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 4 6
1213+
}
1214+
1215+
test_pmtu_ipv6_ovs_vxlan6_exception() {
1216+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 6 6
1217+
}
1218+
1219+
test_pmtu_ipv4_ovs_geneve6_exception() {
1220+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 4 6
1221+
}
1222+
1223+
test_pmtu_ipv6_ovs_geneve6_exception() {
1224+
test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 6 6
1225+
}
1226+
10471227
test_pmtu_ipvX_over_fouY_or_gueY() {
10481228
inner_family=${1}
10491229
outer_family=${2}

0 commit comments

Comments
 (0)