Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/net/ndp tests: test state transitions of neighbor caches



details:   https://anonhg.NetBSD.org/src/rev/64b1753b7df0
branches:  trunk
changeset: 999988:64b1753b7df0
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Jun 28 06:46:04 2019 +0000

description:
tests: test state transitions of neighbor caches

diffstat:

 tests/net/ndp/t_ndp.sh |  78 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 77 insertions(+), 1 deletions(-)

diffs (97 lines):

diff -r 84d362ed05f3 -r 64b1753b7df0 tests/net/ndp/t_ndp.sh
--- a/tests/net/ndp/t_ndp.sh    Fri Jun 28 06:45:16 2019 +0000
+++ b/tests/net/ndp/t_ndp.sh    Fri Jun 28 06:46:04 2019 +0000
@@ -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 @@
        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_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
 }



Home | Main Index | Thread Index | Old Index