Source-Changes-HG archive

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

[src/trunk]: src Add tests of IPv6 link local address



details:   https://anonhg.NetBSD.org/src/rev/61823cbb536b
branches:  trunk
changeset: 811711:61823cbb536b
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Nov 12 05:05:24 2015 +0000

description:
Add tests of IPv6 link local address

>From s-yamaguchi@IIJ

diffstat:

 distrib/sets/lists/tests/mi    |    3 +-
 tests/net/net/Makefile         |    3 +-
 tests/net/net/t_ipv6address.sh |  310 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 314 insertions(+), 2 deletions(-)

diffs (truncated from 348 to 300 lines):

diff -r 2ad4cf09b2fa -r 61823cbb536b distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Nov 12 05:01:28 2015 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Nov 12 05:05:24 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.652 2015/11/11 07:52:57 ozaki-r Exp $
+# $NetBSD: mi,v 1.653 2015/11/12 05:05:24 ozaki-r Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3192,6 +3192,7 @@
 ./usr/tests/net/net/Kyuafile                   tests-net-tests         compattestfile,atf,kyua
 ./usr/tests/net/net/t_forwarding               tests-net-tests         atf,rump
 ./usr/tests/net/net/t_ipaddress                        tests-net-tests         atf,rump
+./usr/tests/net/net/t_ipv6address              tests-net-tests         atf,rump
 ./usr/tests/net/net/t_ipv6_lifetime            tests-net-tests         atf,rump
 ./usr/tests/net/net/t_pktinfo                  tests-net-tests         compattestfile,atf
 ./usr/tests/net/net/t_raw                      tests-net-tests         atf,rump
diff -r 2ad4cf09b2fa -r 61823cbb536b tests/net/net/Makefile
--- a/tests/net/net/Makefile    Thu Nov 12 05:01:28 2015 +0000
+++ b/tests/net/net/Makefile    Thu Nov 12 05:05:24 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2015/10/07 05:24:41 ozaki-r Exp $
+# $NetBSD: Makefile,v 1.14 2015/11/12 05:05:25 ozaki-r Exp $
 #
 
 .include <bsd.own.mk>
@@ -13,6 +13,7 @@
 TESTS_C+=      t_raw
 TESTS_SH=      t_forwarding
 TESTS_SH+=     t_ipaddress
+TESTS_SH+=     t_ipv6address
 TESTS_SH+=     t_ipv6_lifetime
 .endif
 
diff -r 2ad4cf09b2fa -r 61823cbb536b tests/net/net/t_ipv6address.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/net/net/t_ipv6address.sh    Thu Nov 12 05:05:24 2015 +0000
@@ -0,0 +1,310 @@
+#      $NetBSD: t_ipv6address.sh,v 1.1 2015/11/12 05:05:25 ozaki-r Exp $
+#
+# Copyright (c) 2015 Internet Initiative Japan Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
+SERVER6="$SERVER -lrumpnet_netinet6"
+
+SOCKSRC=unix://commsock1
+SOCKFWD=unix://commsock2
+SOCKDST=unix://commsock3
+IP6SRCNW=fc00:1::0/64
+IP6SRC=fc00:1::1
+IP6DSTNW=fc00:2::0/64
+IP6DST=fc00:2::1
+IP6FWD0=fc00:3::1
+BUS1=bus1
+BUS2=bus2
+BUSSRC=bus_src
+BUSDST=bus_dst
+
+DEBUG=false
+
+atf_test_case linklocal cleanup
+
+setup()
+{
+       atf_check -s exit:0 ${SERVER6} ${SOCKSRC}
+       atf_check -s exit:0 ${SERVER6} ${SOCKFWD}
+       atf_check -s exit:0 ${SERVER6} ${SOCKDST}
+
+       export RUMP_SERVER=${SOCKSRC}
+       atf_check -s exit:0 rump.ifconfig shmif0 create
+       atf_check -s exit:0 rump.ifconfig shmif1 create
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKDST}
+       atf_check -s exit:0 rump.ifconfig shmif0 create
+       atf_check -s exit:0 rump.ifconfig shmif1 create
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKFWD}
+       atf_check -s exit:0 rump.ifconfig shmif0 create
+       atf_check -s exit:0 rump.ifconfig shmif1 create
+       atf_check -s exit:0 -o match:"0 -> 1" rump.sysctl \
+           -w net.inet6.ip6.forwarding=1
+       unset RUMP_SERVER
+
+       setup_ifcfg
+
+       export RUMP_SERVER=${SOCKSRC}
+       $DEBUG && rump.ifconfig
+       $DEBUG && rump.netstat -rn -f inet6
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKDST}
+       $DEBUG && rump.ifconfig
+       $DEBUG && rump.netstat -rn -f inet6
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKFWD}
+       $DEBUG && rump.ifconfig
+       $DEBUG && rump.netstat -rn -f inet6
+       unset RUMP_SERVER
+}
+setup_ifcfg()
+{
+       export RUMP_SERVER=${SOCKSRC}
+       atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
+       atf_check -s exit:0 rump.ifconfig shmif0 up
+       atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUSSRC}
+       atf_check -s exit:0 rump.ifconfig shmif1 up
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKDST}
+       atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS2}
+       atf_check -s exit:0 rump.ifconfig shmif0 up
+       atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUSDST}
+       atf_check -s exit:0 rump.ifconfig shmif1 up
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKFWD}
+       atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
+       atf_check -s exit:0 rump.ifconfig shmif0 up
+
+       atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUS2}
+       atf_check -s exit:0 rump.ifconfig shmif1 up
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       unset RUMP_SERVER
+}
+
+setup_route()
+{
+       local tmp_rump_server=$RUMP_SERVER
+
+       local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
+       local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0`
+       local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0`
+       local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1`
+
+       export RUMP_SERVER=${SOCKSRC}
+       atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \
+           ${fwd_if0_lladdr}%shmif0
+       atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
+           ${fwd_if0_lladdr}%shmif0
+       atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6SRC}
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       $DEBUG && rump.netstat -rn -f inet6
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKDST}
+       atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \
+           ${fwd_if1_lladdr}%shmif0
+       atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
+           ${fwd_if1_lladdr}%shmif0
+       atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DST}
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       $DEBUG && rump.netstat -rn -f inet6
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKFWD}
+       atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6SRCNW} \
+           ${src_if0_lladdr}%shmif0
+       atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6SRCNW} \
+           ${src_if0_lladdr}%shmif0
+
+       atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6DSTNW} \
+           ${dst_if0_lladdr}%shmif1
+       atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6DSTNW} \
+           ${dst_if0_lladdr}%shmif1
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       $DEBUG && rump.netstat -rn -f inet6
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=$tmp_rump_server
+}
+
+cleanup_bus()
+{
+       local tmp_rump_server=$RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKSRC}
+       atf_check -s exit:0 rump.ifconfig shmif0 down
+       atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
+       atf_check -s exit:0 rump.ifconfig shmif1 down
+       atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKDST}
+       atf_check -s exit:0 rump.ifconfig shmif0 down
+       atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
+       atf_check -s exit:0 rump.ifconfig shmif1 down
+       atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKFWD}
+       atf_check -s exit:0 rump.ifconfig shmif0 down
+       atf_check -s exit:0 rump.ifconfig shmif0 -linkstr
+       atf_check -s exit:0 rump.ifconfig shmif1 down
+       atf_check -s exit:0 rump.ifconfig shmif1 -linkstr
+       unset RUMP_SERVER
+
+       atf_check -s exit:0 rm ${BUSSRC}
+       atf_check -s exit:0 rm ${BUSDST}
+       atf_check -s exit:0 rm ${BUS1}
+       atf_check -s exit:0 rm ${BUS2}
+
+       setup_ifcfg
+
+       export RUMP_SERVER=$tmp_rump_server
+}
+
+
+get_lladdr()
+{
+       export RUMP_SERVER=${1}
+       rump.ifconfig ${2} inet6 | grep "fe80" \
+           | awk '{print $2}' | sed -e "s/%$2//g"
+       unset RUMP_SERVER
+
+       return 0
+}
+
+linklocal_head()
+{
+       atf_set "descr" "Test for bassically function of the IPv6 linklocal address"
+       atf_set "require.progs" "rump_server rump.route rump.ifconfig rump.ping6"
+}
+
+linklocal_body()
+{
+       setup
+
+       local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
+       local src_if1_lladdr=`get_lladdr ${SOCKSRC} shmif1`
+       local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0`
+       local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0`
+       local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1`
+
+       export RUMP_SERVER=${SOCKSRC}
+       $DEBUG && rump.ifconfig
+       $DEBUG && rump.netstat -rn -f inet6
+
+       # link local address to link local address
+
+       atf_check -s not-exit:0 -e match:"No route to host" \
+               rump.ping6 -c 1 -n ${fwd_if0_lladdr}
+
+       atf_check -s exit:0 -o match:"0.0% packet loss" \
+           rump.ping6 -c 1 -n ${fwd_if0_lladdr}%shmif0
+
+       atf_check -s ignore -o empty -e ignore \
+           -x "shmif_dumpbus -p - ${BUSSRC} | tcpdump -r - -n -p icmp6"
+       atf_check -s ignore -o not-empty -e ignore \
+           -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
+
+       cleanup_bus
+
+       atf_check -s not-exit:0 -o ignore -e ignore \
+           rump.ping6 -c 1 -n -S ${src_if1_lladdr}%shmif1 ${fwd_if0_lladdr}%shmif0
+       atf_check -s ignore -o not-match:"${src_if1_lladdr}" -e ignore \
+           -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
+       $DEBUG && shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6
+       unset RUMP_SERVER
+
+       # link local address to host address
+       export RUMP_SERVER=${SOCKFWD}
+       atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6FWD0}
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+       unset RUMP_SERVER
+
+       export RUMP_SERVER=${SOCKSRC}
+       atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
+           ${fwd_if0_lladdr}%shmif0
+       atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+       $DEBUG && rump.ifconfig shmif0
+       atf_check -s exit:0 -o match:"0.0% packet loss" \
+           rump.ping6 -c 1 -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0}



Home | Main Index | Thread Index | Old Index