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 sysctl net.inet6.ip6.dad_count



details:   https://anonhg.NetBSD.org/src/rev/0e8d89ba6b79
branches:  trunk
changeset: 818220:0e8d89ba6b79
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Oct 04 03:41:33 2016 +0000

description:
Add tests for sysctl net.inet6.ip6.dad_count

>From suzu-ken@IIJ

diffstat:

 tests/net/ndp/t_dad.sh |  74 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 73 insertions(+), 1 deletions(-)

diffs (111 lines):

diff -r 025d925378f6 -r 0e8d89ba6b79 tests/net/ndp/t_dad.sh
--- a/tests/net/ndp/t_dad.sh    Mon Oct 03 21:36:32 2016 +0000
+++ b/tests/net/ndp/t_dad.sh    Tue Oct 04 03:41:33 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_dad.sh,v 1.7 2016/09/16 00:50:43 ozaki-r Exp $
+#      $NetBSD: t_dad.sh,v 1.8 2016/10/04 03:41:33 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -39,6 +39,7 @@
 
 atf_test_case dad_basic cleanup
 atf_test_case dad_duplicated cleanup
+atf_test_case dad_count cleanup
 
 dad_basic_head()
 {
@@ -52,6 +53,12 @@
        atf_set "require.progs" "rump_server"
 }
 
+dad_count_head()
+{
+       atf_set "descr" "Tests for IPv6 DAD count behavior"
+       atf_set "require.progs" "rump_server"
+}
+
 setup_server()
 {
        local sock=$1
@@ -202,6 +209,63 @@
            rump.ifconfig shmif0
 }
 
+dad_count_test()
+{
+       local pkt=
+       local count=$1
+       local id=$2
+       local target=$3
+
+       #
+       # Set DAD count to $count
+       #
+       atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.dad_count=$count
+
+       # Add a new address
+       atf_check -s exit:0 rump.ifconfig shmif0 inet6 $target
+
+       # Waiting for DAD complete
+       atf_check -s exit:0 rump.ifconfig -w 20
+
+       # Check the number of DAD probe packets (Neighbor Solicitation Message)
+       atf_check -s exit:0 sleep 2
+       extract_new_packets > ./out
+       $DEBUG && cat ./out
+       pkt=$(make_ns_pkt_str $id $target)
+       atf_check -s exit:0 -o match:"$count" \
+           -x "cat ./out |grep '$pkt' | wc -l | tr -d ' '"
+}
+
+dad_count_body()
+{
+       local localip1=fc00::1
+       local localip2=fc00::2
+
+       atf_check -s exit:0 ${inetserver} $SOCKLOCAL
+       export RUMP_SERVER=$SOCKLOCAL
+
+       # Check default value
+       atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.dad_count
+
+       # Setup interface
+       atf_check -s exit:0 rump.ifconfig shmif0 create
+       atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+       atf_check -s exit:0 rump.ifconfig shmif0 up
+       atf_check -s exit:0 sleep 2
+       rump.ifconfig shmif0 > ./out
+       $DEBUG && cat ./out
+
+       #
+       # Set and test DAD count (count=1)
+       #
+       dad_count_test 1 1 $localip1
+
+       #
+       # Set and test DAD count (count=8)
+       #
+       dad_count_test 8 2 $localip2
+}
+
 cleanup()
 {
        gdb -ex bt /usr/bin/rump_server rump_server.core
@@ -248,8 +312,16 @@
        cleanup
 }
 
+dad_count_cleanup()
+{
+       $DEBUG && dump_local
+       $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
+       env RUMP_SERVER=$SOCKLOCAL rump.halt
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case dad_basic
        atf_add_test_case dad_duplicated
+       atf_add_test_case dad_count
 }



Home | Main Index | Thread Index | Old Index