Module Name: src Committed By: ozaki-r Date: Fri Jun 28 06:46:04 UTC 2019
Modified Files: src/tests/net/ndp: t_ndp.sh Log Message: tests: test state transitions of neighbor caches To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/tests/net/ndp/t_ndp.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/net/ndp/t_ndp.sh diff -u src/tests/net/ndp/t_ndp.sh:1.31 src/tests/net/ndp/t_ndp.sh:1.32 --- src/tests/net/ndp/t_ndp.sh:1.31 Thu Mar 22 09:21:24 2018 +++ src/tests/net/ndp/t_ndp.sh Fri Jun 28 06:46:04 2019 @@ -1,4 +1,4 @@ -# $NetBSD: t_ndp.sh,v 1.31 2018/03/22 09:21:24 ozaki-r Exp $ +# $NetBSD: t_ndp.sh,v 1.32 2019/06/28 06:46:04 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -673,6 +673,81 @@ ndp_stray_entries_cleanup() cleanup } +atf_test_case ndp_cache_state cleanup +ndp_stray_entries_head() +{ + + atf_set "descr" "Tests states of neighbor cache entries" + atf_set "require.progs" "rump_server" +} + +check_cache_state() +{ + local dst=$1 + local state=$2 + + $DEBUG && rump.ndp -n $dst + atf_check -s exit:0 -o match:"^$dst.*$state " rump.ndp -n $dst +} + +wait_until_stalled() +{ + local dst=$1 + local state=$2 + + $DEBUG && rump.ndp -n $dst + while true; do + rump.ndp -n $dst | grep -q "^$dst.*S " && break + sleep 1 + done + $DEBUG && rump.ndp -n $dst +} + +ndp_cache_state_body() +{ + + rump_server_start $SOCKSRC netinet6 + rump_server_start $SOCKDST netinet6 + + setup_dst_server + setup_src_server + + export RUMP_SERVER=$SOCKSRC + + # + # Reachability confirmation (RFC 4861 7.3.3) + # + atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST + + # Receiving a solicited NA packet changes the state of the cache to REACHABLE + check_cache_state $IP6DST R + + # The state of the cache transits to STALE after a while + wait_until_stalled $IP6DST + + # Sending a packet on the cache will run a reachability confirmation + atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6DST + + sleep 1 + + # The state of the cache is changed to DELAY and stay for 5s, then + # send a NS packet and change the state to PROBE + check_cache_state $IP6DST D + + sleep $((5 + 1)) + + # If the reachability confirmation is success, the state of the cache + # is changed to REACHABLE + check_cache_state $IP6DST R +} + +ndp_cache_state_cleanup() +{ + + $DEBUG && dump + cleanup +} + atf_init_test_cases() { atf_add_test_case ndp_cache_expiration @@ -685,4 +760,5 @@ atf_init_test_cases() atf_add_test_case ndp_purge_on_route_delete atf_add_test_case ndp_purge_on_ifdown atf_add_test_case ndp_stray_entries + atf_add_test_case ndp_cache_state }