aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2019-06-21 11:45:29 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-24 13:18:49 -0400
commitde755a85130ede40a988dbc04e449eb56fb998db (patch)
tree2fe853bdb45a3869bb5ccb1da6f9364383802efe
parent40cb35d5dc04e7f89cbc7b1fc9b4b48d9f1e5343 (diff)
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 <sbrivio@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rwxr-xr-xtools/testing/selftests/net/pmtu.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
index 269e839b747e..f5004a9df229 100755
--- a/tools/testing/selftests/net/pmtu.sh
+++ b/tools/testing/selftests/net/pmtu.sh
@@ -112,6 +112,10 @@
112# - cleanup_ipv6_exception 112# - cleanup_ipv6_exception
113# Same as above, but use IPv6 transport from A to B 113# Same as above, but use IPv6 transport from A to B
114# 114#
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#
115# - list_flush_ipv6_exception 119# - list_flush_ipv6_exception
116# Using the same topology as in pmtu_ipv6, create exceptions, and check 120# Using the same topology as in pmtu_ipv6, create exceptions, and check
117# they are shown when listing exception caches, gone after flushing them 121# they are shown when listing exception caches, gone after flushing them
@@ -156,6 +160,7 @@ tests="
156 pmtu_vti6_link_change_mtu vti6: MTU changes on link changes 0 160 pmtu_vti6_link_change_mtu vti6: MTU changes on link changes 0
157 cleanup_ipv4_exception ipv4: cleanup of cached exceptions 1 161 cleanup_ipv4_exception ipv4: cleanup of cached exceptions 1
158 cleanup_ipv6_exception ipv6: cleanup of cached exceptions 1 162 cleanup_ipv6_exception ipv6: cleanup of cached exceptions 1
163 list_flush_ipv4_exception ipv4: list and flush cached exceptions 1
159 list_flush_ipv6_exception ipv6: list and flush cached exceptions 1" 164 list_flush_ipv6_exception ipv6: list and flush cached exceptions 1"
160 165
161NS_A="ns-A" 166NS_A="ns-A"
@@ -1207,6 +1212,61 @@ run_test_nh() {
1207 USE_NH=no 1212 USE_NH=no
1208} 1213}
1209 1214
1215test_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
1210test_list_flush_ipv6_exception() { 1270test_list_flush_ipv6_exception() {
1211 setup namespaces routing || return 2 1271 setup namespaces routing || return 2
1212 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \ 1272 trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \