Source-Changes-HG archive

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

[src/trunk]: src/tests/net/arp Add a test case for static ARP



details:   https://anonhg.NetBSD.org/src/rev/910c243720e3
branches:  trunk
changeset: 344766:910c243720e3
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Apr 18 02:27:34 2016 +0000

description:
Add a test case for static ARP

It tests receiving an ARP request that has a spa (i.e., IP address) whose
ARP entry already exists in the table as a static ARP entry.

diffstat:

 tests/net/arp/t_arp.sh |  42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)

diffs (82 lines):

diff -r e7ea57677a7b -r 910c243720e3 tests/net/arp/t_arp.sh
--- a/tests/net/arp/t_arp.sh    Mon Apr 18 02:24:42 2016 +0000
+++ b/tests/net/arp/t_arp.sh    Mon Apr 18 02:27:34 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_arp.sh,v 1.14 2016/04/04 07:37:08 ozaki-r Exp $
+#      $NetBSD: t_arp.sh,v 1.15 2016/04/18 02:27:34 ozaki-r Exp $
 #
 # Copyright (c) 2015 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -47,6 +47,7 @@
 atf_test_case proxy_arp_pub cleanup
 atf_test_case proxy_arp_pubproxy cleanup
 atf_test_case link_activation cleanup
+atf_test_case static_arp cleanup
 
 cache_expiration_5s_head()
 {
@@ -96,6 +97,13 @@
        atf_set "require.progs" "rump_server"
 }
 
+static_arp_head()
+{
+
+       atf_set "descr" "Tests for static ARP entries"
+       atf_set "require.progs" "rump_server"
+}
+
 setup_dst_server()
 {
        export RUMP_SERVER=$SOCKDST
@@ -520,6 +528,31 @@
            "cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'"
 }
 
+static_arp_body()
+{
+       local arp_keep=5
+       local macaddr_src=
+
+       atf_check -s exit:0 ${inetserver} $SOCKSRC
+       atf_check -s exit:0 ${inetserver} $SOCKDST
+
+       setup_dst_server
+       setup_src_server $arp_keep
+
+       export RUMP_SERVER=$SOCKSRC
+       macaddr_src=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}')
+
+       # Set a (valid) static ARP entry for the src server
+       export RUMP_SERVER=$SOCKDST
+       $DEBUG && rump.arp -n -a
+       atf_check -s exit:0 -o ignore rump.arp -s $IP4SRC $macaddr_src
+       $DEBUG && rump.arp -n -a
+
+       # Test receiving an ARP request with the static ARP entry (as spa/sha)
+       export RUMP_SERVER=$SOCKSRC
+       atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST
+}
+
 cleanup()
 {
        env RUMP_SERVER=$SOCKSRC rump.halt
@@ -600,6 +633,12 @@
        cleanup
 }
 
+static_arp_cleanup()
+{
+       $DEBUG && dump
+       cleanup
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case cache_expiration_5s
@@ -610,4 +649,5 @@
        atf_add_test_case proxy_arp_pub
        atf_add_test_case proxy_arp_pubproxy
        atf_add_test_case link_activation
+       atf_add_test_case static_arp
 }



Home | Main Index | Thread Index | Old Index