Skip to content

Commit

Permalink
selftests: pmtu: implement IPIP, SIT and ip6tnl PMTU discovery tests
Browse files Browse the repository at this point in the history
Add PMTU discovery tests for these encapsulations:

- IPIP
- SIT, mode ip6ip
- ip6tnl, modes ip6ip6 and ipip6

Signed-off-by: Lourdes Pedrajas <lu@pplo.net>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Lourdes Pedrajas authored and David S. Miller committed Apr 20, 2020
1 parent cceadc8 commit b66c9b8
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions tools/testing/selftests/net/pmtu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
# Same as pmtu_ipv4_vxlan4, but using a generic UDP IPv4/IPv6
# encapsulation (GUE) over IPv4/IPv6, instead of VXLAN
#
# - pmtu_ipv{4,6}_ipv{4,6}_exception
# Same as pmtu_ipv4_vxlan4, but using a IPv4/IPv6 tunnel over IPv4/IPv6,
# instead of VXLAN
#
# - pmtu_vti4_exception
# Set up vti tunnel on top of veth, with xfrm states and policies, in two
# namespaces with matching endpoints. Check that route exception is not
Expand Down Expand Up @@ -151,6 +155,10 @@ tests="
pmtu_ipv6_gue4_exception IPv6 over gue4: PMTU exceptions 1
pmtu_ipv4_gue6_exception IPv4 over gue6: PMTU exceptions 1
pmtu_ipv6_gue6_exception IPv6 over gue6: PMTU exceptions 1
pmtu_ipv4_ipv4_exception IPv4 over IPv4: PMTU exceptions 1
pmtu_ipv6_ipv4_exception IPv6 over IPv4: PMTU exceptions 1
pmtu_ipv4_ipv6_exception IPv4 over IPv6: PMTU exceptions 1
pmtu_ipv6_ipv6_exception IPv6 over IPv6: PMTU exceptions 1
pmtu_vti6_exception vti6: PMTU exceptions 0
pmtu_vti4_exception vti4: PMTU exceptions 0
pmtu_vti4_default_mtu vti4: default MTU assignment 0
Expand Down Expand Up @@ -363,6 +371,62 @@ setup_gue66() {
setup_fou_or_gue 6 6 gue
}

setup_ipvX_over_ipvY() {
inner=${1}
outer=${2}

if [ "${outer}" -eq 4 ]; then
a_addr="${prefix4}.${a_r1}.1"
b_addr="${prefix4}.${b_r1}.1"
if [ "${inner}" -eq 4 ]; then
type="ipip"
mode="ipip"
else
type="sit"
mode="ip6ip"
fi
else
a_addr="${prefix6}:${a_r1}::1"
b_addr="${prefix6}:${b_r1}::1"
type="ip6tnl"
if [ "${inner}" -eq 4 ]; then
mode="ipip6"
else
mode="ip6ip6"
fi
fi

run_cmd ${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} || return 2
run_cmd ${ns_b} ip link add ip_b type ${type} local ${b_addr} remote ${a_addr} mode ${mode}

run_cmd ${ns_a} ip link set ip_a up
run_cmd ${ns_b} ip link set ip_b up

if [ "${inner}" = "4" ]; then
run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ip_a
run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ip_b
else
run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ip_a
run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ip_b
fi
}

setup_ip4ip4() {
setup_ipvX_over_ipvY 4 4
}

setup_ip6ip4() {
setup_ipvX_over_ipvY 6 4
}

setup_ip4ip6() {
setup_ipvX_over_ipvY 4 6
}

setup_ip6ip6() {
setup_ipvX_over_ipvY 6 6
}

setup_namespaces() {
for n in ${NS_A} ${NS_B} ${NS_R1} ${NS_R2}; do
ip netns add ${n} || return 1
Expand Down Expand Up @@ -908,6 +972,64 @@ test_pmtu_ipv6_gue6_exception() {
test_pmtu_ipvX_over_fouY_or_gueY 6 6 gue
}

test_pmtu_ipvX_over_ipvY_exception() {
inner=${1}
outer=${2}
ll_mtu=4000

setup namespaces routing ip${inner}ip${outer} || return 2

trace "${ns_a}" ip_a "${ns_b}" ip_b \
"${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
"${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B

if [ ${inner} -eq 4 ]; then
ping=ping
dst=${tunnel4_b_addr}
else
ping=${ping6}
dst=${tunnel6_b_addr}
fi

if [ ${outer} -eq 4 ]; then
# IPv4 header
exp_mtu=$((${ll_mtu} - 20))
else
# IPv6 header Option 4
exp_mtu=$((${ll_mtu} - 40 - 8))
fi

# Create route exception by exceeding link layer MTU
mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
mtu "${ns_b}" veth_B-R1 ${ll_mtu}
mtu "${ns_r1}" veth_R1-B ${ll_mtu}

mtu "${ns_a}" ip_a $((${ll_mtu} + 1000)) || return
mtu "${ns_b}" ip_b $((${ll_mtu} + 1000)) || return
run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}

# Check that exception was created
pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on ip${inner}ip${outer} interface"
}

test_pmtu_ipv4_ipv4_exception() {
test_pmtu_ipvX_over_ipvY_exception 4 4
}

test_pmtu_ipv6_ipv4_exception() {
test_pmtu_ipvX_over_ipvY_exception 6 4
}

test_pmtu_ipv4_ipv6_exception() {
test_pmtu_ipvX_over_ipvY_exception 4 6
}

test_pmtu_ipv6_ipv6_exception() {
test_pmtu_ipvX_over_ipvY_exception 6 6
}

test_pmtu_vti4_exception() {
setup namespaces veth vti4 xfrm4 || return 2
trace "${ns_a}" veth_a "${ns_b}" veth_b \
Expand Down

0 comments on commit b66c9b8

Please sign in to comment.