Source-Changes-HG archive

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

[src/trunk]: src/tests/net/ndp Add tests for expiration of default router and...



details:   https://anonhg.NetBSD.org/src/rev/8cc588f8faa3
branches:  trunk
changeset: 821922:8cc588f8faa3
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Feb 22 03:03:37 2017 +0000

description:
Add tests for expiration of default router and prefix entries

diffstat:

 tests/net/ndp/t_ra.sh |  157 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 156 insertions(+), 1 deletions(-)

diffs (183 lines):

diff -r 2f557bfc3de6 -r 8cc588f8faa3 tests/net/ndp/t_ra.sh
--- a/tests/net/ndp/t_ra.sh     Wed Feb 22 03:02:55 2017 +0000
+++ b/tests/net/ndp/t_ra.sh     Wed Feb 22 03:03:37 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ra.sh,v 1.24 2017/01/13 08:11:01 ozaki-r Exp $
+#      $NetBSD: t_ra.sh,v 1.25 2017/02/22 03:03:37 ozaki-r Exp $
 #
 # Copyright (c) 2015 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -94,6 +94,29 @@
 _EOF
 }
 
+create_rtadvdconfig_rltime()
+{
+       local time=$1
+
+       cat << _EOF > ${CONFIG}
+shmif0:\
+       :mtu#1300:maxinterval#4:mininterval#3:rltime#$time:
+_EOF
+       $DEBUG && cat ${CONFIG}
+}
+
+create_rtadvdconfig_vltime()
+{
+       local addr=$1
+       local time=$2
+
+       cat << _EOF > ${CONFIG}
+shmif0:\
+       :mtu#1300:maxinterval#4:mininterval#3:addr="$addr":vltime#$time:
+_EOF
+       $DEBUG && cat ${CONFIG}
+}
+
 start_rtadvd()
 {
        local sock=$1
@@ -689,6 +712,136 @@
        cleanup
 }
 
+atf_test_case ra_defrouter_expiration cleanup
+ra_defrouter_expiration_head()
+{
+
+       atf_set "descr" "Tests for default router expiration"
+       atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_defrouter_expiration_body()
+{
+       local expire_time=5
+
+       rump_server_fs_start $RUMPSRV netinet6
+       rump_server_start $RUMPCLI netinet6
+
+       setup_shmif0 ${RUMPSRV} ${IP6SRV}
+       setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+       init_server $RUMPSRV
+
+       create_rtadvdconfig_rltime $expire_time
+
+       export RUMP_SERVER=${RUMPCLI}
+       atf_check -s exit:0 -o match:'0.->.1' \
+           rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+       unset RUMP_SERVER
+
+       start_rtadvd $RUMPSRV $PIDFILE
+       sleep $WAITTIME
+
+       check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+       export RUMP_SERVER=${RUMPCLI}
+
+       # Terminate rtadvd to prevent new RA messages from coming
+       # Note that ifconfig down; kill -TERM doesn't work
+       kill -KILL `cat ${PIDFILE}`
+
+       # Wait until the default routers and prefix entries are expired
+       sleep $expire_time
+
+       $DEBUG && dump_entries
+
+       # Give nd6_timer a chance to sweep default routers and prefix entries
+       sleep 2
+
+       $DEBUG && dump_entries
+       atf_check -s exit:0 -o not-match:'if=shmif0' rump.ndp -r
+       atf_check -s exit:0 -o match:'No advertising router' rump.ndp -p
+       atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
+       atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
+       atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
+       atf_check -s exit:0 -o match:'fc00:1:' rump.ifconfig shmif0 inet6
+       unset RUMP_SERVER
+
+       rump_server_destroy_ifaces
+}
+
+ra_defrouter_expiration_cleanup()
+{
+
+       $DEBUG && dump
+       cleanup
+}
+
+atf_test_case ra_prefix_expiration cleanup
+ra_prefix_expiration_head()
+{
+
+       atf_set "descr" "Tests for prefix expiration"
+       atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_prefix_expiration_body()
+{
+       local expire_time=5
+
+       rump_server_fs_start $RUMPSRV netinet6
+       rump_server_start $RUMPCLI netinet6
+
+       setup_shmif0 ${RUMPSRV} ${IP6SRV}
+       setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+       init_server $RUMPSRV
+
+       create_rtadvdconfig_vltime "${IP6SRV_PREFIX}:" $expire_time
+
+       export RUMP_SERVER=${RUMPCLI}
+       atf_check -s exit:0 -o match:'0.->.1' \
+           rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+       unset RUMP_SERVER
+
+       start_rtadvd $RUMPSRV $PIDFILE
+       sleep $WAITTIME
+
+       check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+       export RUMP_SERVER=${RUMPCLI}
+
+       # Terminate rtadvd to prevent new RA messages from coming
+       # Note that ifconfig down; kill -TERM doesn't work
+       kill -KILL `cat ${PIDFILE}`
+
+       # Wait until the default routers and prefix entries are expired
+       sleep $expire_time
+
+       $DEBUG && dump_entries
+
+       # Give nd6_timer a chance to sweep default routers and prefix entries
+       sleep 2
+
+       $DEBUG && dump_entries
+       atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r
+       atf_check -s exit:0 -o empty rump.ndp -p
+       atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
+       atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
+       atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
+       atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
+       unset RUMP_SERVER
+
+       rump_server_destroy_ifaces
+}
+
+ra_prefix_expiration_cleanup()
+{
+
+       $DEBUG && dump
+       cleanup
+}
+
 atf_init_test_cases()
 {
 
@@ -700,4 +853,6 @@
        atf_add_test_case ra_multiple_routers_single_prefix
        atf_add_test_case ra_multiple_routers_maxifprefixes
        atf_add_test_case ra_temporary_address
+       atf_add_test_case ra_defrouter_expiration
+       atf_add_test_case ra_prefix_expiration
 }



Home | Main Index | Thread Index | Old Index