Source-Changes-HG archive

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

[src/trunk]: src/tests/net Add tests on activating a new MAC address



details:   https://anonhg.NetBSD.org/src/rev/2a0ffffb4ecb
branches:  trunk
changeset: 343867:2a0ffffb4ecb
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Feb 29 09:35:16 2016 +0000

description:
Add tests on activating a new MAC address

diffstat:

 tests/net/arp/t_arp.sh |  54 +++++++++++++++++++++++++++++++-
 tests/net/ndp/t_ndp.sh |  83 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 135 insertions(+), 2 deletions(-)

diffs (216 lines):

diff -r 5f8e7aeff901 -r 2a0ffffb4ecb tests/net/arp/t_arp.sh
--- a/tests/net/arp/t_arp.sh    Mon Feb 29 08:13:41 2016 +0000
+++ b/tests/net/arp/t_arp.sh    Mon Feb 29 09:35:16 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_arp.sh,v 1.11 2016/02/25 03:23:15 ozaki-r Exp $
+#      $NetBSD: t_arp.sh,v 1.12 2016/02/29 09:35:16 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -46,6 +46,7 @@
 atf_test_case garp cleanup
 atf_test_case cache_overwriting cleanup
 atf_test_case pubproxy_arp cleanup
+atf_test_case link_activation cleanup
 
 cache_expiration_5s_head()
 {
@@ -83,6 +84,12 @@
        atf_set "require.progs" "rump_server"
 }
 
+link_activation_head()
+{
+       atf_set "descr" "Tests for activating a new MAC address"
+       atf_set "require.progs" "rump_server"
+}
+
 setup_dst_server()
 {
        export RUMP_SERVER=$SOCKDST
@@ -408,6 +415,44 @@
        return 0
 }
 
+link_activation_body()
+{
+       local arp_keep=5
+       local bonus=2
+
+       atf_check -s exit:0 ${inetserver} $SOCKSRC
+       atf_check -s exit:0 ${inetserver} $SOCKDST
+
+       setup_dst_server
+       setup_src_server $arp_keep
+
+       # flush old packets
+       extract_new_packets > ./out
+
+       export RUMP_SERVER=$SOCKSRC
+
+       atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
+           b2:a1:00:00:00:01
+
+       atf_check -s exit:0 sleep 1
+       extract_new_packets > ./out
+       $DEBUG && cat ./out
+
+       pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
+       atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+
+       atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
+           b2:a1:00:00:00:02 active
+
+       atf_check -s exit:0 sleep 1
+       extract_new_packets > ./out
+       $DEBUG && cat ./out
+
+       pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
+       atf_check -s exit:0 -x \
+           "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'"
+}
+
 cleanup()
 {
        env RUMP_SERVER=$SOCKSRC rump.halt
@@ -476,6 +521,12 @@
        cleanup
 }
 
+link_activation_cleanup()
+{
+       $DEBUG && dump
+       cleanup
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case cache_expiration_5s
@@ -484,4 +535,5 @@
        atf_add_test_case garp
        atf_add_test_case cache_overwriting
        atf_add_test_case pubproxy_arp
+       atf_add_test_case link_activation
 }
diff -r 5f8e7aeff901 -r 2a0ffffb4ecb tests/net/ndp/t_ndp.sh
--- a/tests/net/ndp/t_ndp.sh    Mon Feb 29 08:13:41 2016 +0000
+++ b/tests/net/ndp/t_ndp.sh    Mon Feb 29 09:35:16 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ndp.sh,v 1.8 2015/11/18 04:13:01 ozaki-r Exp $
+#      $NetBSD: t_ndp.sh,v 1.9 2016/02/29 09:35:16 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -41,6 +41,7 @@
 atf_test_case command cleanup
 atf_test_case cache_overwriting cleanup
 atf_test_case neighborgcthresh cleanup
+atf_test_case link_activation cleanup
 
 cache_expiration_head()
 {
@@ -66,6 +67,12 @@
        atf_set "require.progs" "rump_server"
 }
 
+link_activation_head()
+{
+       atf_set "descr" "Tests for activating a new MAC address"
+       atf_set "require.progs" "rump_server"
+}
+
 setup_dst_server()
 {
        local assign_ip=$1
@@ -303,6 +310,73 @@
        return 0
 }
 
+make_pkt_str_na()
+{
+       local ip=$1
+       local mac=$2
+       local pkt=
+       pkt="$mac > 33:33:00:00:00:01, ethertype IPv6 (0x86dd), length 86:"
+       pkt="$pkt $ip > ff02::1: ICMP6, neighbor advertisement"
+       echo $pkt
+}
+
+extract_new_packets()
+{
+       local old=./old
+
+       if [ ! -f $old ]; then
+               old=/dev/null
+       fi
+
+       shmif_dumpbus -p - bus1 2>/dev/null| \
+           tcpdump -n -e -r - 2>/dev/null > ./new
+       diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
+       mv -f ./new ./old
+       cat ./diff
+}
+
+link_activation_body()
+{
+       local linklocal=
+
+       atf_check -s exit:0 ${inetserver} $SOCKSRC
+       atf_check -s exit:0 ${inetserver} $SOCKDST
+
+       setup_dst_server
+       setup_src_server
+
+       # flush old packets
+       extract_new_packets > ./out
+
+       export RUMP_SERVER=$SOCKSRC
+
+       atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
+           b2:a1:00:00:00:01
+
+       atf_check -s exit:0 sleep 1
+       extract_new_packets > ./out
+       $DEBUG && cat ./out
+
+       linklocal=$(rump.ifconfig shmif0 |awk '/fe80/ {print $2;}' |awk -F % '{print $1;}')
+       $DEBUG && echo $linklocal
+
+       pkt=$(make_pkt_str_na $linklocal b2:a1:00:00:00:01)
+       atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+
+       atf_check -s exit:0 -o ignore rump.ifconfig shmif0 link \
+           b2:a1:00:00:00:02 active
+
+       atf_check -s exit:0 sleep 1
+       extract_new_packets > ./out
+       $DEBUG && cat ./out
+
+       linklocal=$(rump.ifconfig shmif0 |awk '/fe80/ {print $2;}' |awk -F % '{print $1;}')
+       $DEBUG && echo $linklocal
+
+       pkt=$(make_pkt_str_na $linklocal b2:a1:00:00:00:02)
+       atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
+}
+
 cleanup()
 {
        env RUMP_SERVER=$SOCKSRC rump.halt
@@ -360,10 +434,17 @@
        cleanup
 }
 
+link_activation_cleanup()
+{
+       $DEBUG && dump
+       cleanup
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case cache_expiration
        atf_add_test_case command
        atf_add_test_case cache_overwriting
        atf_add_test_case neighborgcthresh
+       atf_add_test_case link_activation
 }



Home | Main Index | Thread Index | Old Index