diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2018-03-16 21:31:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-17 20:15:14 -0400 |
commit | 719e121574497436e39536c2a888b901fbe30cfe (patch) | |
tree | 95b48ec74497be02738edebf295fa5dc27fce181 /tools | |
parent | 5e84430bb83e8241c485ccce728ff5e5e80789eb (diff) |
selftests: pmtu: Add pmtu_vti4_link_add_mtu test
This test checks that MTU given on vti link creation is actually
configured, and that tunnel is not created with an invalid MTU
value.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/selftests/net/pmtu.sh | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index ba11433d17d8..d9f7ef2c213d 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh | |||
@@ -29,12 +29,17 @@ | |||
29 | # | 29 | # |
30 | # - pmtu_vti6_default_mtu | 30 | # - pmtu_vti6_default_mtu |
31 | # Same as above, for IPv6 | 31 | # Same as above, for IPv6 |
32 | # | ||
33 | # - pmtu_vti4_link_add_mtu | ||
34 | # Set up vti4 interface passing MTU value at link creation, check MTU is | ||
35 | # configured, and that link is not created with invalid MTU values | ||
32 | 36 | ||
33 | tests=" | 37 | tests=" |
34 | pmtu_vti6_exception vti6: PMTU exceptions | 38 | pmtu_vti6_exception vti6: PMTU exceptions |
35 | pmtu_vti4_exception vti4: PMTU exceptions | 39 | pmtu_vti4_exception vti4: PMTU exceptions |
36 | pmtu_vti4_default_mtu vti4: default MTU assignment | 40 | pmtu_vti4_default_mtu vti4: default MTU assignment |
37 | pmtu_vti6_default_mtu vti6: default MTU assignment" | 41 | pmtu_vti6_default_mtu vti6: default MTU assignment |
42 | pmtu_vti4_link_add_mtu vti4: MTU setting on link creation" | ||
38 | 43 | ||
39 | NS_A="ns-$(mktemp -u XXXXXX)" | 44 | NS_A="ns-$(mktemp -u XXXXXX)" |
40 | NS_B="ns-$(mktemp -u XXXXXX)" | 45 | NS_B="ns-$(mktemp -u XXXXXX)" |
@@ -301,6 +306,44 @@ test_pmtu_vti6_default_mtu() { | |||
301 | fi | 306 | fi |
302 | } | 307 | } |
303 | 308 | ||
309 | test_pmtu_vti4_link_add_mtu() { | ||
310 | setup namespaces || return 2 | ||
311 | |||
312 | ${ns_a} ip link add vti4_a type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 | ||
313 | [ $? -ne 0 ] && err " vti not supported" && return 2 | ||
314 | ${ns_a} ip link del vti4_a | ||
315 | |||
316 | fail=0 | ||
317 | |||
318 | min=68 | ||
319 | max=$((65528 - 20)) | ||
320 | # Check invalid values first | ||
321 | for v in $((min - 1)) $((max + 1)); do | ||
322 | ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 2>/dev/null | ||
323 | # This can fail, or MTU can be adjusted to a proper value | ||
324 | [ $? -ne 0 ] && continue | ||
325 | mtu="$(link_get_mtu "${ns_a}" vti4_a)" | ||
326 | if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then | ||
327 | err " vti tunnel created with invalid MTU ${mtu}" | ||
328 | fail=1 | ||
329 | fi | ||
330 | ${ns_a} ip link del vti4_a | ||
331 | done | ||
332 | |||
333 | # Now check valid values | ||
334 | for v in ${min} 1300 ${max}; do | ||
335 | ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10 | ||
336 | mtu="$(link_get_mtu "${ns_a}" vti4_a)" | ||
337 | ${ns_a} ip link del vti4_a | ||
338 | if [ "${mtu}" != "${v}" ]; then | ||
339 | err " vti MTU ${mtu} doesn't match configured value ${v}" | ||
340 | fail=1 | ||
341 | fi | ||
342 | done | ||
343 | |||
344 | return ${fail} | ||
345 | } | ||
346 | |||
304 | trap cleanup EXIT | 347 | trap cleanup EXIT |
305 | 348 | ||
306 | exitcode=0 | 349 | exitcode=0 |