Same as pmtu_vti4_link_add_mtu test, but for IPv6.

Signed-off-by: Stefano Brivio <sbri...@redhat.com>
---
 tools/testing/selftests/net/pmtu.sh | 43 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/pmtu.sh 
b/tools/testing/selftests/net/pmtu.sh
index 2a7ada49d0c0..aad9f880c8ee 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -33,10 +33,13 @@
 # - pmtu_vti4_link_add_mtu
 #      Set up vti4 interface passing MTU value at link creation, check MTU is
 #      configured, and that link is not created with invalid MTU values
+#
+# - pmtu_vti6_link_add_mtu
+#      Same as above, for IPv6
 
 tests="pmtu_vti4_exception pmtu_vti6_exception
        pmtu_vti4_default_mtu pmtu_vti6_default_mtu
-       pmtu_vti4_link_add_mtu"
+       pmtu_vti4_link_add_mtu pmtu_vti6_link_add_mtu"
 
 NS_A="ns-$(mktemp -u XXXXXX)"
 NS_B="ns-$(mktemp -u XXXXXX)"
@@ -349,6 +352,44 @@ test_pmtu_vti4_link_add_mtu() {
        return ${pass}
 }
 
+test_pmtu_vti6_link_add_mtu() {
+       setup namespaces && return 2
+
+       ${ns_a} ip link add vti6_a type vti6 local ${veth6_a_addr} remote 
${veth6_b_addr} key 10
+       [ $? -ne 0 ] && echo "  vti6 not supported" && return 2
+       ${ns_a} ip link del vti6_a
+
+       pass=1
+
+       min=1280
+       max=$((65535 - 40))
+       # Check invalid values first
+       for v in $((min - 1)) $((max + 1)); do
+               ${ns_a} ip link add vti6_a mtu ${v} type vti6 local 
${veth6_a_addr} remote ${veth6_b_addr} key 10 2>/dev/null
+               # This can fail, or MTU can be adjusted to a proper value
+               [ $? -ne 0 ] && continue
+               mtu="$(link_get_mtu "${ns_a}" vti6_a)"
+               if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
+                       echo "  vti6 tunnel created with invalid MTU ${v}"
+                       pass=0
+               fi
+               ${ns_a} ip link del vti6_a
+       done
+
+       # Now check valid values
+       for v in 1280 1300 $((65535 - 40)); do
+               ${ns_a} ip link add vti6_a mtu ${v} type vti6 local 
${veth6_a_addr} remote ${veth6_b_addr} key 10
+               mtu="$(link_get_mtu "${ns_a}" vti6_a)"
+               ${ns_a} ip link del vti6_a
+               if [ "${mtu}" != "${v}" ]; then
+                       echo "  vti6 MTU ${mtu} doesn't match configured value 
${v}"
+                       pass=0
+               fi
+       done
+
+       return ${pass}
+}
+
 trap cleanup EXIT
 
 exitcode=0
-- 
2.15.1

Reply via email to