Commit 1e0a7207 authored by Stefano Brivio's avatar Stefano Brivio Committed by David S. Miller

selftests: pmtu: Introduce check_pmtu_value()

Introduce and use a function that checks PMTU values against
expected values and logs error messages, to remove some clutter.
Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 062f97a3
...@@ -229,6 +229,19 @@ route_get_dst_pmtu_from_exception() { ...@@ -229,6 +229,19 @@ route_get_dst_pmtu_from_exception() {
mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})" mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})"
} }
check_pmtu_value() {
expected="${1}"
value="${2}"
event="${3}"
[ "${expected}" = "any" ] && [ -n "${value}" ] && return 0
[ "${value}" = "${expected}" ] && return 0
[ -z "${value}" ] && err " PMTU exception wasn't created after ${event}" && return 1
[ -z "${expected}" ] && err " PMTU exception shouldn't exist after ${event}" && return 1
err " found PMTU exception with incorrect MTU ${value}, expected ${expected}, after ${event}"
return 1
}
test_pmtu_vti4_exception() { test_pmtu_vti4_exception() {
setup namespaces veth vti4 xfrm4 || return 2 setup namespaces veth vti4 xfrm4 || return 2
...@@ -248,24 +261,13 @@ test_pmtu_vti4_exception() { ...@@ -248,24 +261,13 @@ test_pmtu_vti4_exception() {
# exception is created # exception is created
${ns_a} ping -q -M want -i 0.1 -w 2 -s ${ping_payload} ${vti4_b_addr} > /dev/null ${ns_a} ping -q -M want -i 0.1 -w 2 -s ${ping_payload} ${vti4_b_addr} > /dev/null
pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})" pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})"
if [ "${pmtu}" != "" ]; then check_pmtu_value "" "${pmtu}" "sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106})" || return 1
err " unexpected exception created with PMTU ${pmtu} for IP payload length ${esp_payload_rfc4106}"
return 1
fi
# Now exceed link layer MTU by one byte, check that exception is created # Now exceed link layer MTU by one byte, check that exception is created
# with the right PMTU value
${ns_a} ping -q -M want -i 0.1 -w 2 -s $((ping_payload + 1)) ${vti4_b_addr} > /dev/null ${ns_a} ping -q -M want -i 0.1 -w 2 -s $((ping_payload + 1)) ${vti4_b_addr} > /dev/null
pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})" pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti4_b_addr})"
if [ "${pmtu}" = "" ]; then check_pmtu_value "${esp_payload_rfc4106}" "${pmtu}" "exceeding PMTU (IP payload length $((esp_payload_rfc4106 + 1)))"
err " exception not created for IP payload length $((esp_payload_rfc4106 + 1))"
return 1
fi
# ...with the right PMTU value
if [ ${pmtu} -ne ${esp_payload_rfc4106} ]; then
err " wrong PMTU ${pmtu} in exception, expected: ${esp_payload_rfc4106}"
return 1
fi
} }
test_pmtu_vti6_exception() { test_pmtu_vti6_exception() {
...@@ -280,25 +282,18 @@ test_pmtu_vti6_exception() { ...@@ -280,25 +282,18 @@ test_pmtu_vti6_exception() {
${ns_a} ${ping6} -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null ${ns_a} ${ping6} -q -i 0.1 -w 2 -s 60000 ${vti6_b_addr} > /dev/null
# Check that exception was created # Check that exception was created
if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" = "" ]; then pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})"
err " tunnel exceeding link layer MTU didn't create route exception" check_pmtu_value any "${pmtu}" "creating tunnel exceeding link layer MTU" || return 1
return 1
fi
# Decrease tunnel MTU, check for PMTU decrease in route exception # Decrease tunnel MTU, check for PMTU decrease in route exception
mtu "${ns_a}" vti6_a 3000 mtu "${ns_a}" vti6_a 3000
pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})"
if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 3000 ]; then check_pmtu_value "3000" "${pmtu}" "decreasing tunnel MTU" || fail=1
err " decreasing tunnel MTU didn't decrease route exception PMTU"
fail=1
fi
# Increase tunnel MTU, check for PMTU increase in route exception # Increase tunnel MTU, check for PMTU increase in route exception
mtu "${ns_a}" vti6_a 9000 mtu "${ns_a}" vti6_a 9000
if [ "$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})" -ne 9000 ]; then pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${vti6_b_addr})"
err " increasing tunnel MTU didn't increase route exception PMTU" check_pmtu_value "9000" "${pmtu}" "increasing tunnel MTU" || fail=1
fail=1
fi
return ${fail} return ${fail}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment