Skip to content

Commit de755a8

Browse files
sbrivio-rhdavem330
authored andcommitted
selftests: pmtu: Introduce list_flush_ipv4_exception test case
This test checks that route exceptions can be successfully listed and flushed using ip -6 route {list,flush} cache. v7: No changes v6: - Merge this patch into series including fix, as it's also targeted for net-next - Drop left-over print of 'ip route list cache | wc -l' Signed-off-by: Stefano Brivio <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 40cb35d commit de755a8

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

tools/testing/selftests/net/pmtu.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
# - cleanup_ipv6_exception
113113
# Same as above, but use IPv6 transport from A to B
114114
#
115+
# - list_flush_ipv4_exception
116+
# Using the same topology as in pmtu_ipv4, create exceptions, and check
117+
# they are shown when listing exception caches, gone after flushing them
118+
#
115119
# - list_flush_ipv6_exception
116120
# Using the same topology as in pmtu_ipv6, create exceptions, and check
117121
# they are shown when listing exception caches, gone after flushing them
@@ -156,6 +160,7 @@ tests="
156160
pmtu_vti6_link_change_mtu vti6: MTU changes on link changes 0
157161
cleanup_ipv4_exception ipv4: cleanup of cached exceptions 1
158162
cleanup_ipv6_exception ipv6: cleanup of cached exceptions 1
163+
list_flush_ipv4_exception ipv4: list and flush cached exceptions 1
159164
list_flush_ipv6_exception ipv6: list and flush cached exceptions 1"
160165

161166
NS_A="ns-A"
@@ -1207,6 +1212,61 @@ run_test_nh() {
12071212
USE_NH=no
12081213
}
12091214

1215+
test_list_flush_ipv4_exception() {
1216+
setup namespaces routing || return 2
1217+
trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
1218+
"${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
1219+
"${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
1220+
"${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
1221+
1222+
dst_prefix1="${prefix4}.${b_r1}."
1223+
dst2="${prefix4}.${b_r2}.1"
1224+
1225+
# Set up initial MTU values
1226+
mtu "${ns_a}" veth_A-R1 2000
1227+
mtu "${ns_r1}" veth_R1-A 2000
1228+
mtu "${ns_r1}" veth_R1-B 1500
1229+
mtu "${ns_b}" veth_B-R1 1500
1230+
1231+
mtu "${ns_a}" veth_A-R2 2000
1232+
mtu "${ns_r2}" veth_R2-A 2000
1233+
mtu "${ns_r2}" veth_R2-B 1500
1234+
mtu "${ns_b}" veth_B-R2 1500
1235+
1236+
fail=0
1237+
1238+
# Add 100 addresses for veth endpoint on B reached by default A route
1239+
for i in $(seq 100 199); do
1240+
run_cmd ${ns_b} ip addr add "${dst_prefix1}${i}" dev veth_B-R1
1241+
done
1242+
1243+
# Create 100 cached route exceptions for path via R1, one via R2. Note
1244+
# that with IPv4 we need to actually cause a route lookup that matches
1245+
# the exception caused by ICMP, in order to actually have a cached
1246+
# route, so we need to ping each destination twice
1247+
for i in $(seq 100 199); do
1248+
run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst_prefix1}${i}"
1249+
done
1250+
run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst2}"
1251+
1252+
# Each exception is printed as two lines
1253+
if [ "$(${ns_a} ip route list cache | wc -l)" -ne 202 ]; then
1254+
err " can't list cached exceptions"
1255+
fail=1
1256+
fi
1257+
1258+
run_cmd ${ns_a} ip route flush cache
1259+
pmtu1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst_prefix}1)"
1260+
pmtu2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst_prefix}2)"
1261+
if [ -n "${pmtu1}" ] || [ -n "${pmtu2}" ] || \
1262+
[ -n "$(${ns_a} ip route list cache)" ]; then
1263+
err " can't flush cached exceptions"
1264+
fail=1
1265+
fi
1266+
1267+
return ${fail}
1268+
}
1269+
12101270
test_list_flush_ipv6_exception() {
12111271
setup namespaces routing || return 2
12121272
trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \

0 commit comments

Comments
 (0)