summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/net/net
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/net/net')
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_forwarding.sh530
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ipaddress.sh193
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ipv6_lifetime.sh127
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ipv6address.sh387
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_mtudisc.sh192
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_mtudisc6.sh179
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ping6_opts.sh380
-rw-r--r--contrib/netbsd-tests/net/net/t_tcp.c15
8 files changed, 1999 insertions, 4 deletions
diff --git a/contrib/netbsd-tests/net/net/t_forwarding.sh b/contrib/netbsd-tests/net/net/t_forwarding.sh
new file mode 100755
index 0000000..fc30530
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_forwarding.sh
@@ -0,0 +1,530 @@
+# $NetBSD: t_forwarding.sh,v 1.19 2016/11/25 08:51:17 ozaki-r Exp $
+#
+# Copyright (c) 2015 The NetBSD Foundation, 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.
+#
+
+SOCKSRC=unix://commsock1
+SOCKFWD=unix://commsock2
+SOCKDST=unix://commsock3
+IP4SRC=10.0.1.2
+IP4SRCGW=10.0.1.1
+IP4DSTGW=10.0.2.1
+IP4DST=10.0.2.2
+IP4DST_BCAST=10.0.2.255
+IP6SRC=fc00:0:0:1::2
+IP6SRCGW=fc00:0:0:1::1
+IP6DSTGW=fc00:0:0:2::1
+IP6DST=fc00:0:0:2::2
+HTML_FILE=index.html
+
+DEBUG=${DEBUG:-false}
+TIMEOUT=5
+
+atf_test_case ipforwarding_v4 cleanup
+atf_test_case ipforwarding_v6 cleanup
+atf_test_case ipforwarding_fastforward_v4 cleanup
+atf_test_case ipforwarding_fastforward_v6 cleanup
+atf_test_case ipforwarding_misc cleanup
+
+ipforwarding_v4_head()
+{
+ atf_set "descr" "Does IPv4 forwarding tests"
+ atf_set "require.progs" "rump_server"
+}
+
+ipforwarding_v6_head()
+{
+ atf_set "descr" "Does IPv6 forwarding tests"
+ atf_set "require.progs" "rump_server"
+}
+
+ipforwarding_fastforward_v4_head()
+{
+ atf_set "descr" "Tests for IPv4 fastforward"
+ atf_set "require.progs" "rump_server"
+}
+
+ipforwarding_fastforward_v6_head()
+{
+ atf_set "descr" "Tests for IPv6 fastfoward"
+ atf_set "require.progs" "rump_server"
+}
+
+ipforwarding_misc_head()
+{
+ atf_set "descr" "Does IPv4 forwarding tests"
+ atf_set "require.progs" "rump_server"
+}
+
+setup_endpoint()
+{
+ sock=${1}
+ addr=${2}
+ bus=${3}
+ mode=${4}
+ gw=${5}
+
+ rump_server_add_iface $sock shmif0 $bus
+
+ export RUMP_SERVER=${sock}
+ if [ $mode = "ipv6" ]; then
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
+ atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw}
+ else
+ atf_check -s exit:0 rump.ifconfig shmif0 inet ${addr} netmask 0xffffff00
+ atf_check -s exit:0 -o ignore rump.route add default ${gw}
+ fi
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+
+ if $DEBUG; then
+ rump.ifconfig shmif0
+ rump.netstat -nr
+ fi
+}
+
+test_endpoint()
+{
+ sock=${1}
+ addr=${2}
+ bus=${3}
+ mode=${4}
+
+ export RUMP_SERVER=${sock}
+ atf_check -s exit:0 -o match:shmif0 rump.ifconfig
+ if [ $mode = "ipv6" ]; then
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${addr}
+ else
+ atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 ${addr}
+ fi
+}
+
+setup_forwarder()
+{
+ mode=${1}
+
+ rump_server_add_iface $SOCKFWD shmif0 bus1
+ rump_server_add_iface $SOCKFWD shmif1 bus2
+
+ export RUMP_SERVER=$SOCKFWD
+
+ if [ $mode = "ipv6" ]; then
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW}
+ atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DSTGW}
+ else
+ atf_check -s exit:0 rump.ifconfig shmif0 inet ${IP4SRCGW} netmask 0xffffff00
+ atf_check -s exit:0 rump.ifconfig shmif1 inet ${IP4DSTGW} netmask 0xffffff00
+ fi
+
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig shmif1 up
+
+ if $DEBUG; then
+ rump.netstat -nr
+ if [ $mode = "ipv6" ]; then
+ rump.sysctl net.inet6.ip6.forwarding
+ else
+ rump.sysctl net.inet.ip.forwarding
+ fi
+ fi
+}
+
+setup()
+{
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKFWD
+ rump_server_start $SOCKDST
+
+ setup_endpoint $SOCKSRC $IP4SRC bus1 ipv4 $IP4SRCGW
+ setup_endpoint $SOCKDST $IP4DST bus2 ipv4 $IP4DSTGW
+ setup_forwarder ipv4
+}
+
+setup6()
+{
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKFWD netinet6
+ rump_server_start $SOCKDST netinet6
+
+ setup_endpoint $SOCKSRC $IP6SRC bus1 ipv6 $IP6SRCGW
+ setup_endpoint $SOCKDST $IP6DST bus2 ipv6 $IP6DSTGW
+ setup_forwarder ipv6
+}
+
+test_http_get()
+{
+ local ip=$1
+
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 rump.arp -d -a
+
+ export RUMP_SERVER=$SOCKSRC
+
+ # get the webpage
+ atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $TIMEOUT -o out http://$ip/$HTML_FILE
+}
+
+test_setup()
+{
+ test_endpoint $SOCKSRC $IP4SRC bus1 ipv4
+ test_endpoint $SOCKDST $IP4DST bus2 ipv4
+
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o match:shmif0 rump.ifconfig
+ atf_check -s exit:0 -o match:shmif1 rump.ifconfig
+
+ atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 ${IP4SRCGW}
+ atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 ${IP4DSTGW}
+}
+
+test_setup6()
+{
+ test_endpoint $SOCKSRC $IP6SRC bus1 ipv6
+ test_endpoint $SOCKDST $IP6DST bus2 ipv6
+
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o match:shmif0 rump.ifconfig
+ atf_check -s exit:0 -o match:shmif1 rump.ifconfig
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${IP6SRCGW}
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT ${IP6DSTGW}
+}
+
+setup_forwarding()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1
+}
+
+setup_forwarding6()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet6.ip6.forwarding=1
+}
+
+setup_directed_broadcast()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.directed-broadcast=1
+}
+
+setup_icmp_bmcastecho()
+{
+ export RUMP_SERVER=$SOCKDST
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.icmp.bmcastecho=1
+}
+
+teardown_forwarding()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=0
+}
+
+teardown_forwarding6()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet6.ip6.forwarding=0
+}
+
+teardown_directed_broadcast()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.directed-broadcast=0
+}
+
+teardown_icmp_bmcastecho()
+{
+ export RUMP_SERVER=$SOCKDST
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.icmp.bmcastecho=0
+}
+
+teardown_interfaces()
+{
+
+ rump_server_destroy_ifaces
+}
+
+test_setup_forwarding()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o match:"net.inet.ip.forwarding = 1" \
+ rump.sysctl net.inet.ip.forwarding
+}
+test_setup_forwarding6()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o match:"net.inet6.ip6.forwarding = 1" \
+ rump.sysctl net.inet6.ip6.forwarding
+}
+
+test_teardown_forwarding()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o match:"net.inet.ip.forwarding = 0" \
+ rump.sysctl net.inet.ip.forwarding
+}
+test_teardown_forwarding6()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o match:"net.inet6.ip6.forwarding = 0" \
+ rump.sysctl net.inet6.ip6.forwarding
+}
+
+test_ping_failure()
+{
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4DST
+ export RUMP_SERVER=$SOCKDST
+ atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4SRC
+}
+
+test_ping_success()
+{
+ export RUMP_SERVER=$SOCKSRC
+ $DEBUG && rump.ifconfig -v shmif0
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4SRCGW
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4DST
+ $DEBUG && rump.ifconfig -v shmif0
+
+ export RUMP_SERVER=$SOCKDST
+ $DEBUG && rump.ifconfig -v shmif0
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4DSTGW
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4SRC
+ $DEBUG && rump.ifconfig -v shmif0
+}
+
+test_ping_ttl()
+{
+ export RUMP_SERVER=$SOCKSRC
+ $DEBUG && rump.ifconfig -v shmif0
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 -T 1 $IP4SRCGW
+ atf_check -s not-exit:0 -o match:'Time To Live exceeded' \
+ rump.ping -v -n -w $TIMEOUT -c 1 -T 1 $IP4DST
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 -T 2 $IP4DST
+ $DEBUG && rump.ifconfig -v shmif0
+}
+
+test_sysctl_ttl()
+{
+ local ip=$1
+
+ export RUMP_SERVER=$SOCKSRC
+ $DEBUG && rump.ifconfig -v shmif0
+
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.ttl=1
+ # get the webpage
+ atf_check -s not-exit:0 -e match:'timed out' \
+ env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $TIMEOUT -o out http://$ip/$HTML_FILE
+
+
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.ttl=2
+ # get the webpage
+ atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $TIMEOUT -o out http://$ip/$HTML_FILE
+
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.ttl=64
+ $DEBUG && rump.ifconfig -v shmif0
+}
+
+test_directed_broadcast()
+{
+ setup_icmp_bmcastecho
+
+ setup_directed_broadcast
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4DST_BCAST
+
+ teardown_directed_broadcast
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s not-exit:0 -o ignore rump.ping -q -n -w $TIMEOUT -c 1 $IP4DST_BCAST
+
+ teardown_icmp_bmcastecho
+}
+
+test_ping6_failure()
+{
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s not-exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP6DST
+ export RUMP_SERVER=$SOCKDST
+ atf_check -s not-exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP6SRC
+}
+
+test_ping6_success()
+{
+ export RUMP_SERVER=$SOCKSRC
+ $DEBUG && rump.ifconfig -v shmif0
+ atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP6SRCGW
+ atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP6DST
+ $DEBUG && rump.ifconfig -v shmif0
+
+ export RUMP_SERVER=$SOCKDST
+ $DEBUG && rump.ifconfig -v shmif0
+ atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP6DSTGW
+ atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -X $TIMEOUT $IP6SRC
+ $DEBUG && rump.ifconfig -v shmif0
+}
+
+test_hoplimit()
+{
+ export RUMP_SERVER=$SOCKSRC
+ $DEBUG && rump.ifconfig -v shmif0
+ atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -h 1 -X $TIMEOUT $IP6SRCGW
+ atf_check -s not-exit:0 -o match:'Time to live exceeded' \
+ rump.ping6 -v -n -c 1 -h 1 -X $TIMEOUT $IP6DST
+ atf_check -s exit:0 -o ignore rump.ping6 -q -n -c 1 -h 2 -X $TIMEOUT $IP6DST
+ $DEBUG && rump.ifconfig -v shmif0
+}
+
+ipforwarding_v4_body()
+{
+ setup
+ test_setup
+
+ setup_forwarding
+ test_setup_forwarding
+ test_ping_success
+
+ teardown_forwarding
+ test_teardown_forwarding
+ test_ping_failure
+
+ teardown_interfaces
+}
+
+ipforwarding_v6_body()
+{
+ setup6
+ test_setup6
+
+ setup_forwarding6
+ test_setup_forwarding6
+ test_ping6_success
+ test_hoplimit
+
+ teardown_forwarding6
+ test_teardown_forwarding6
+ test_ping6_failure
+
+ teardown_interfaces
+}
+
+ipforwarding_fastforward_v4_body()
+{
+ setup
+ test_setup
+
+ setup_forwarding
+ test_setup_forwarding
+
+ touch $HTML_FILE
+ start_httpd $SOCKDST $IP4DST
+ $DEBUG && rump.netstat -a
+
+ test_http_get $IP4DST
+
+ teardown_interfaces
+}
+
+ipforwarding_fastforward_v6_body()
+{
+ setup6
+ test_setup6
+
+ setup_forwarding6
+ test_setup_forwarding6
+
+ touch $HTML_FILE
+ start_httpd $SOCKDST $IP6DST
+ $DEBUG && rump.netstat -a
+
+ test_http_get "[$IP6DST]"
+
+ teardown_interfaces
+}
+
+ipforwarding_misc_body()
+{
+ setup
+ test_setup
+
+ setup_forwarding
+ test_setup_forwarding
+
+ test_ping_ttl
+
+ test_directed_broadcast
+
+ touch $HTML_FILE
+ start_httpd $SOCKDST $IP4DST
+ $DEBUG && rump.netstat -a
+
+ test_sysctl_ttl $IP4DST
+
+ teardown_interfaces
+ return 0
+}
+
+ipforwarding_v4_cleanup()
+{
+ $DEBUG && dump
+ cleanup
+}
+
+ipforwarding_v6_cleanup()
+{
+ $DEBUG && dump
+ cleanup
+}
+
+ipforwarding_fastforward_v4_cleanup()
+{
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+ipforwarding_fastforward_v6_cleanup()
+{
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+ipforwarding_misc_cleanup()
+{
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case ipforwarding_v4
+ atf_add_test_case ipforwarding_v6
+ atf_add_test_case ipforwarding_fastforward_v4
+ atf_add_test_case ipforwarding_fastforward_v6
+ atf_add_test_case ipforwarding_misc
+}
diff --git a/contrib/netbsd-tests/net/net/t_ipaddress.sh b/contrib/netbsd-tests/net/net/t_ipaddress.sh
new file mode 100755
index 0000000..4cdd954
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_ipaddress.sh
@@ -0,0 +1,193 @@
+# $NetBSD: t_ipaddress.sh,v 1.9 2016/12/15 02:43:56 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.
+#
+
+SOCK_LOCAL=unix://commsock1
+BUS=bus
+
+DEBUG=${DEBUG:-false}
+
+test_same_address()
+{
+ local ip=10.0.0.1
+ local net=10.0.0/24
+
+ rump_server_start $SOCK_LOCAL
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+
+ export RUMP_SERVER=$SOCK_LOCAL
+
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
+
+ # Delete the address
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ check_route_no_entry $ip
+ check_route_no_entry $net
+
+ # Assign the same address again
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
+
+ # Delete the address again
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ check_route_no_entry $ip
+ check_route_no_entry $net
+
+ rump_server_destroy_ifaces
+}
+
+test_same_address6()
+{
+ local ip=fc00::1
+ local net=fc00::/64
+
+ rump_server_start $SOCK_LOCAL netinet6
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+
+ export RUMP_SERVER=$SOCK_LOCAL
+
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet6
+
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
+
+ # Delete the address
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
+
+ $DEBUG && rump.netstat -nr -f inet6
+
+ check_route_no_entry $ip
+ check_route_no_entry $net
+
+ # Assign the same address again
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet6
+
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
+
+ # Delete the address again
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
+
+ $DEBUG && rump.netstat -nr -f inet6
+
+ check_route_no_entry $ip
+ check_route_no_entry $net
+
+ rump_server_destroy_ifaces
+}
+
+test_auto_linklocal()
+{
+
+ rump_server_start $SOCK_LOCAL netinet6
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+
+ export RUMP_SERVER=$SOCK_LOCAL
+
+ #
+ # Test enabled auto linklocal
+ #
+
+ # Check default value
+ atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.auto_linklocal
+
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ # IPv6 link-local address is set
+ atf_check -s exit:0 -o match:"inet6 fe80::" rump.ifconfig shmif0
+
+ #
+ # Test disabled auto linklocal
+ #
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet6.ip6.auto_linklocal=0
+
+ rump_server_add_iface $SOCK_LOCAL shmif1 $BUS
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ # IPv6 link-local address is not set
+ atf_check -s exit:0 -o not-match:"inet6 fe80::" rump.ifconfig shmif1
+
+ rump_server_destroy_ifaces
+}
+
+add_test()
+{
+ local name=$1
+ local desc="$2"
+
+ atf_test_case "ipaddr_${name}" cleanup
+ eval "ipaddr_${name}_head() { \
+ atf_set \"descr\" \"${desc}\"; \
+ atf_set \"require.progs\" \"rump_server\"; \
+ }; \
+ ipaddr_${name}_body() { \
+ test_${name}; \
+ }; \
+ ipaddr_${name}_cleanup() { \
+ $DEBUG && dump; \
+ cleanup; \
+ }"
+ atf_add_test_case "ipaddr_${name}"
+}
+
+atf_init_test_cases()
+{
+
+ add_test same_address "Assigning/deleting an IP address twice"
+ add_test same_address6 "Assigning/deleting an IPv6 address twice"
+ add_test auto_linklocal "Assigning an IPv6 link-local address automatically"
+}
diff --git a/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh
new file mode 100755
index 0000000..10e50fd
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh
@@ -0,0 +1,127 @@
+# $NetBSD: t_ipv6_lifetime.sh,v 1.6 2016/11/25 08:51:17 ozaki-r Exp $
+#
+# Copyright (c) 2015 The NetBSD Foundation, 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.
+#
+
+SOCK=unix://sock
+BUS=./bus
+
+DEBUG=${DEBUG:-false}
+
+deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]"
+
+atf_test_case basic cleanup
+
+basic_head()
+{
+ atf_set "descr" "Tests for IPv6 address lifetime"
+ atf_set "require.progs" "rump_server"
+}
+
+basic_body()
+{
+ local time=5
+ local bonus=2
+ local ip="fc00::1"
+
+ rump_server_start $SOCK netinet6
+ rump_server_add_iface $SOCK shmif0 $BUS
+
+ export RUMP_SERVER=$SOCK
+
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+
+ # A normal IP address doesn't contain preferred/valid lifetime
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip
+ $DEBUG && rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o not-match:'pltime' rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o not-match:'vltime' rump.ifconfig -L shmif0
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
+
+ # Setting only a preferred lifetime
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip pltime $time
+ $DEBUG && rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:'vltime infty' rump.ifconfig -L shmif0
+ atf_check -s exit:0 sleep $(($time + $bonus))
+ $DEBUG && rump.ifconfig -L shmif0
+ # Should remain but marked as deprecated
+ atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
+
+ # Setting only a valid lifetime (invalid)
+ atf_check -s not-exit:0 -e match:'Invalid argument' \
+ rump.ifconfig shmif0 inet6 $ip vltime $time
+
+ # Setting both preferred and valid lifetimes (same value)
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
+ pltime $time vltime $time
+ $DEBUG && rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
+ atf_check -s exit:0 sleep $(($time + $bonus))
+ $DEBUG && rump.ifconfig -L shmif0
+ # Shouldn't remain anymore
+ atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
+
+ # Setting both preferred and valid lifetimes (pltime > vltime)
+ atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \
+ shmif0 inet6 $ip pltime $(($time * 2)) vltime $time
+
+ # Setting both preferred and valid lifetimes (pltime < vltime)
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
+ pltime $time vltime $((time * 2))
+ $DEBUG && rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
+
+ if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
+ then
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
+ atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
+ fi
+
+ atf_check -s exit:0 sleep $(($time + $bonus))
+ $DEBUG && rump.ifconfig -L shmif0
+ # Should remain but marked as deprecated
+ atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0
+ atf_check -s exit:0 sleep $(($time + $bonus))
+ $DEBUG && rump.ifconfig -L shmif0
+ # Shouldn't remain anymore
+ atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
+
+ rump_server_destroy_ifaces
+}
+
+basic_cleanup()
+{
+ $DEBUG && dump
+ cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+}
diff --git a/contrib/netbsd-tests/net/net/t_ipv6address.sh b/contrib/netbsd-tests/net/net/t_ipv6address.sh
new file mode 100755
index 0000000..539a16d
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_ipv6address.sh
@@ -0,0 +1,387 @@
+# $NetBSD: t_ipv6address.sh,v 1.12 2016/12/14 02:50:42 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"
+SERVER="${SERVER} -lrumpnet_shmif -lrumpdev"
+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=${DEBUG:-true}
+TIMEOUT=3
+
+atf_test_case linklocal cleanup
+atf_test_case linklocal_ops 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_linklocal_addr ${SOCKSRC} shmif0`
+ local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0`
+ local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0`
+ local fwd_if1_lladdr=`get_linklocal_addr ${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
+
+ $DEBUG && dump_bus
+
+ 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
+}
+
+cleanup_rump_servers()
+{
+
+ env RUMP_SERVER=${SOCKSRC} rump.halt
+ env RUMP_SERVER=${SOCKDST} rump.halt
+ env RUMP_SERVER=${SOCKFWD} rump.halt
+}
+
+dump_bus()
+{
+
+ shmif_dumpbus -p - ${BUSSRC} 2>/dev/null| tcpdump -n -e -r -
+ shmif_dumpbus -p - ${BUSDST} 2>/dev/null| tcpdump -n -e -r -
+ shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r -
+ shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r -
+}
+
+_dump()
+{
+
+ export RUMP_SERVER=${SOCKSRC}
+ rump.ndp -n -a
+ rump.netstat -nr -f inet6
+ export RUMP_SERVER=${SOCKDST}
+ rump.ndp -n -a
+ rump.netstat -nr -f inet6
+ export RUMP_SERVER=${SOCKFWD}
+ rump.ndp -n -a
+ rump.netstat -nr -f inet6
+ unset RUMP_SERVER
+}
+
+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_linklocal_addr ${SOCKSRC} shmif0`
+ local src_if1_lladdr=`get_linklocal_addr ${SOCKSRC} shmif1`
+ local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0`
+ local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0`
+ local fwd_if1_lladdr=`get_linklocal_addr ${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 -X $TIMEOUT -n ${fwd_if0_lladdr}
+
+ atf_check -s exit:0 -o match:"0.0% packet loss" \
+ rump.ping6 -c 1 -X $TIMEOUT -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 -X $TIMEOUT -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
+ $DEBUG && _dump
+
+ export RUMP_SERVER=${SOCKSRC}
+ atf_check -s exit:0 -o match:"0.0% packet loss" \
+ rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0}
+ unset RUMP_SERVER
+
+ export RUMP_SERVER=${SOCKFWD}
+ # host address to link local address
+ atf_check -s exit:0 -o match:"0.0% packet loss" \
+ rump.ping6 -c 1 -X $TIMEOUT -n ${src_if0_lladdr}%shmif0
+ atf_check -s not-exit:0 -o match:"100.0% packet loss" \
+ rump.ping6 -c 1 -X $TIMEOUT -n ${src_if1_lladdr}%shmif0
+
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6FWD0} delete
+
+ unset RUMP_SERVER
+
+ # forwarding with link local address
+ setup_route
+
+ export RUMP_SERVER=${SOCKSRC}
+ atf_check -s exit:0 -o match:"0.0% packet loss" rump.ping6 -c 1 \
+ -X $TIMEOUT -n -S ${IP6SRC} ${IP6DST}
+
+ cleanup_bus
+ $DEBUG && rump.ifconfig shmif0
+ atf_check -s not-exit:0 -o match:"100.0% packet loss" rump.ping6 -c 1 \
+ -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6DST}
+ atf_check -s ignore -o not-match:"${src_if0_lladdr}" -e ignore \
+ -x "shmif_dumpbus -p - ${BUS2} | tcpdump -r - -n -p icmp6"
+
+ cleanup_bus
+ atf_check -s not-exit:0 -o match:"100.0% packet loss" rump.ping6 -c 1 \
+ -X $TIMEOUT -n -S ${IP6SRC} ${dst_if0_lladdr}%shmif0
+ atf_check -s ignore -o not-empty -e ignore \
+ -x "shmif_dumpbus -p - ${BUS2} | tcpdump -r - -n -p icmp6"
+
+ unset RUMP_SERVER
+
+}
+
+linklocal_cleanup()
+{
+
+ $DEBUG && _dump
+ $DEBUG && dump_bus
+ cleanup_rump_servers
+}
+
+linklocal_ops_head()
+{
+
+ atf_set "descr" \
+ "Test for various operations to IPv6 linklocal addresses"
+ atf_set "require.progs" "rump_server rump.route rump.ndp"
+}
+
+linklocal_ops_body()
+{
+ local src_if0_lladdr=
+
+ setup
+
+ src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
+
+ export RUMP_SERVER=${SOCKSRC}
+
+ # route get
+ atf_check -s exit:0 -o match:"${src_if0_lladdr}" \
+ rump.route get -inet6 ${src_if0_lladdr}%shmif0
+
+ # route get without an interface name (zone index)
+ atf_check -s not-exit:0 -e match:"not in table" \
+ rump.route get -inet6 ${src_if0_lladdr}
+
+ # ndp
+ atf_check -s exit:0 -o match:"${src_if0_lladdr}" \
+ rump.ndp -n ${src_if0_lladdr}%shmif0
+
+ # ndp without an interface name (zone index)
+ atf_check -s not-exit:0 -o ignore -e match:"no entry" \
+ rump.ndp -n ${src_if0_lladdr}
+}
+
+
+linklocal_ops_cleanup()
+{
+
+ cleanup_rump_servers
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case linklocal
+ atf_add_test_case linklocal_ops
+}
diff --git a/contrib/netbsd-tests/net/net/t_mtudisc.sh b/contrib/netbsd-tests/net/net/t_mtudisc.sh
new file mode 100755
index 0000000..a99d652
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_mtudisc.sh
@@ -0,0 +1,192 @@
+# $NetBSD: t_mtudisc.sh,v 1.8 2016/12/21 01:16:18 ozaki-r Exp $
+#
+# Copyright (c) 2016 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.
+#
+
+SOCKLOCAL=unix://commsock1
+SOCKGATEWAY=unix://commsock2
+SOCKREMOTE=unix://commsock3
+HTML_FILE=index.html
+
+DEBUG=${DEBUG:-false}
+
+atf_test_case mtudisc_basic cleanup
+
+mtudisc_basic_head()
+{
+ atf_set "descr" "Tests for IPv4 Path MTU Dicorvery basic behavior"
+ atf_set "require.progs" "rump_server"
+}
+
+setup_server()
+{
+ local sock=$1
+ local if=$2
+ local bus=$3
+ local ip=$4
+
+ rump_server_add_iface $sock $if $bus
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.ifconfig $if $ip
+ atf_check -s exit:0 rump.ifconfig $if up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ $DEBUG && rump.ifconfig $if
+}
+
+prepare_download_file()
+{
+ local file=$1
+ local data="0123456789"
+
+ touch $file
+ for i in `seq 1 512`
+ do
+ echo $data >> $file
+ done
+}
+
+do_http_get()
+{
+ local ip=$1
+ local ret=$2
+ local timeout=5
+
+ # get the webpage
+ atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $timeout -o ./out http://$ip/$HTML_FILE
+}
+
+mtudisc_basic_body()
+{
+ local pkt=
+ local local_ip=10.0.0.2
+ local gateway_local_ip=10.0.0.1
+ local gateway_remote_ip=10.0.1.1
+ local remote_ip=10.0.1.2
+ local prefixlen=24
+
+ rump_server_start $SOCKLOCAL
+ rump_server_start $SOCKGATEWAY
+ rump_server_start $SOCKREMOTE
+
+ #
+ # Setup servers
+ #
+ # [local server] [gateway server] [remote server with httpd]
+ # | 10.0.0.2 10.0.0.1 | | 10.0.1.1 10.0.1.2 |
+ # shmif0(mtu=1500) ----- shmif1(mtu=1280) shmif0(mtu=1500) ----- shmif0(mtu=1500)
+ #
+
+ # Assign IP addresses
+ setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen
+ setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen
+
+ ### Setup gateway server
+ export RUMP_SERVER=$SOCKGATEWAY
+
+ # Set mtu of shmif0 to 1280
+ export RUMP_SERVER=$SOCKGATEWAY
+ atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
+
+ # Enable IPv4 forwarding
+ atf_check -s exit:0 rump.sysctl -w -q net.inet.ip.forwarding=1
+
+ ### Setup remote server
+ export RUMP_SERVER=$SOCKREMOTE
+
+ # Check default value
+ atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet.ip.mtudisc
+
+ # Start httpd daemon
+ prepare_download_file $HTML_FILE
+ start_httpd $SOCKREMOTE $remote_ip
+ $DEBUG && rump.netstat -a -f inet
+
+ # Teach the peer thar 10.0.0.2(local serer) is behind 10.0.1.1(gateway server)
+ atf_check -s exit:0 -o ignore rump.route add $local_ip/32 $gateway_remote_ip
+
+ ### Setup local server
+ export RUMP_SERVER=$SOCKLOCAL
+
+ # Teach the peer thar 10.0.1.2(remote serer) is behind 10.0.0.1(gateway server)
+ atf_check -s exit:0 -o ignore rump.route add $remote_ip/32 $gateway_local_ip
+
+ # Don't accept fragmented packets
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.maxfragpackets=0
+
+ #
+ # Test disabled path mtu discorvery
+ #
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=0
+
+ # Get the webpage (expect: failed)
+ export RUMP_SERVER=$SOCKLOCAL
+ do_http_get $remote_ip 1
+ $DEBUG && extract_new_packets bus2 > ./out
+ $DEBUG && cat ./out
+
+ # Check path mtu size on remote server
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 \
+ -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +- +shmif0" \
+ rump.netstat -nr -f inet
+
+ #
+ # Test enabled path mtu discorvery
+ #
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=1
+
+ # Get the webpage (expect: success)
+ export RUMP_SERVER=$SOCKLOCAL
+ do_http_get $remote_ip 0
+ $DEBUG && extract_new_packets bus2 > ./out
+ $DEBUG && cat ./out
+
+ # Check path mtu size on remote server
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 \
+ -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +1280 +shmif0" \
+ rump.netstat -nr -f inet
+
+ rump_server_destroy_ifaces
+}
+
+mtudisc_basic_cleanup()
+{
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case mtudisc_basic
+}
diff --git a/contrib/netbsd-tests/net/net/t_mtudisc6.sh b/contrib/netbsd-tests/net/net/t_mtudisc6.sh
new file mode 100755
index 0000000..93bc12e
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_mtudisc6.sh
@@ -0,0 +1,179 @@
+# $NetBSD: t_mtudisc6.sh,v 1.5 2016/11/25 08:51:17 ozaki-r Exp $
+#
+# Copyright (c) 2016 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.
+#
+
+SOCKLOCAL=unix://commsock1
+SOCKGATEWAY=unix://commsock2
+SOCKREMOTE=unix://commsock3
+HTML_FILE=index.html
+
+DEBUG=${DEBUG:-false}
+
+atf_test_case mtudisc6_basic cleanup
+
+mtudisc6_basic_head()
+{
+
+ atf_set "descr" "Tests for IPv6 Path MTU Dicorvery basic behavior"
+ atf_set "require.progs" "rump_server"
+}
+
+setup_server()
+{
+ local sock=$1
+ local if=$2
+ local bus=$3
+ local ip=$4
+
+ rump_server_add_iface $sock $if $bus
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.ifconfig $if inet6 $ip
+ atf_check -s exit:0 rump.ifconfig $if up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ $DEBUG && rump.ifconfig $if
+}
+
+prepare_download_file()
+{
+ local file=$1
+ local data="0123456789"
+
+ touch $file
+ for i in `seq 1 512`
+ do
+ echo $data >> $file
+ done
+}
+
+do_http_get()
+{
+ local ip=$1
+ local ret=$2
+ local timeout=5
+
+ # get the webpage
+ atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $timeout -o ./out "http://[$ip]/$HTML_FILE"
+}
+
+mtudisc6_basic_body()
+{
+ local pkt=
+ local local_ip=fc00:0:0:1::2
+ local gateway_local_ip=fc00:0:0:1::1
+ local gateway_remote_ip=fc00:0:0:2::1
+ local remote_ip=fc00:0:0:2::2
+ local prefixlen=64
+
+ rump_server_start $SOCKLOCAL netinet6
+ rump_server_start $SOCKGATEWAY netinet6
+ rump_server_start $SOCKREMOTE netinet6
+
+ #
+ # Setup servers
+ #
+ # [local server] [gateway server] [remote server]
+ # | | | |
+ # shmif0(1500) -- shmif1(1280) shmif0(1500) -- shmif0(1500)
+ #
+
+ # Assign IP addresses
+ setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen
+ setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen
+
+ ### Setup gateway server
+ export RUMP_SERVER=$SOCKGATEWAY
+
+ # Set MTU of shmif0 to 1280
+ export RUMP_SERVER=$SOCKGATEWAY
+ atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
+
+ # Enable IPv6 forwarding
+ atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.forwarding=1
+
+ ### Setup remote server
+ export RUMP_SERVER=$SOCKREMOTE
+
+ # Start httpd daemon
+ prepare_download_file $HTML_FILE
+ start_httpd $SOCKREMOTE $remote_ip
+ $DEBUG && rump.netstat -a
+
+ # Teach the peer that local serer is behind gateway server
+ atf_check -s exit:0 -o ignore \
+ rump.route add -inet6 $local_ip/128 $gateway_remote_ip
+
+ # Check path MTU size on remote server
+ atf_check -s exit:0 \
+ -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +- +shmif0" \
+ rump.netstat -nr -f inet6
+
+ ### Setup local server
+ export RUMP_SERVER=$SOCKLOCAL
+
+ # Teach the peer that remote serer is behind gateway server
+ atf_check -s exit:0 -o ignore \
+ rump.route add -inet6 $remote_ip/128 $gateway_local_ip
+
+ # Don't accept fragmented packets
+ atf_check -s exit:0 -o ignore \
+ rump.sysctl -w -q net.inet6.ip6.maxfragpackets=0
+
+ #
+ # Test enabled path MTU discorvery
+ #
+ # Get the webpage (expect: success)
+ export RUMP_SERVER=$SOCKLOCAL
+ do_http_get $remote_ip 0
+ $DEBUG && extract_new_packets bus2 > ./out
+ $DEBUG && cat ./out
+
+ # Check path MTU size on remote server
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 \
+ -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +1280 +shmif0" \
+ rump.netstat -nr -f inet6
+
+ rump_server_destroy_ifaces
+}
+
+mtudisc6_basic_cleanup()
+{
+
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case mtudisc6_basic
+}
diff --git a/contrib/netbsd-tests/net/net/t_ping6_opts.sh b/contrib/netbsd-tests/net/net/t_ping6_opts.sh
new file mode 100755
index 0000000..e2e774e
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_ping6_opts.sh
@@ -0,0 +1,380 @@
+# $NetBSD: t_ping6_opts.sh,v 1.8 2016/11/25 08:51:17 ozaki-r Exp $
+#
+# Copyright (c) 2016 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.
+#
+
+SOCKSRC=unix://commsock1
+SOCKFWD=unix://commsock2
+SOCKDST=unix://commsock3
+IP6SRC=fc00:0:0:1::2
+IP6SRCGW=fc00:0:0:1::1
+IP6DSTGW=fc00:0:0:2::1
+IP6DST=fc00:0:0:2::2
+BUS_SRCGW=bus1
+BUS_DSTGW=bus2
+
+IP6SRC2=fc00:0:0:1::3
+IP6SRCGW2=fc00:0:0:1::254
+
+DEBUG=${DEBUG:-false}
+TIMEOUT=1
+
+#
+# Utility functions
+#
+setup_endpoint()
+{
+ local sock=${1}
+ local addr=${2}
+ local bus=${3}
+ local gw=${4}
+
+ rump_server_add_iface $sock shmif0 $bus
+
+ export RUMP_SERVER=${sock}
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
+ atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw}
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ if $DEBUG; then
+ rump.ifconfig shmif0
+ rump.netstat -nr
+ fi
+}
+
+setup_forwarder()
+{
+
+ rump_server_add_iface $SOCKFWD shmif0 $BUS_SRCGW
+ rump_server_add_iface $SOCKFWD shmif1 $BUS_DSTGW
+
+ export RUMP_SERVER=$SOCKFWD
+
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW}
+ atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DSTGW}
+
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig shmif1 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ if $DEBUG; then
+ rump.netstat -nr
+ rump.sysctl net.inet6.ip6.forwarding
+ fi
+}
+
+setup_forwarding6()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet6.ip6.forwarding=1
+}
+
+setup6()
+{
+
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKFWD netinet6
+ rump_server_start $SOCKDST netinet6
+
+ setup_endpoint $SOCKSRC $IP6SRC $BUS_SRCGW $IP6SRCGW
+ setup_endpoint $SOCKDST $IP6DST $BUS_DSTGW $IP6DSTGW
+ setup_forwarder
+}
+
+check_echo_request_pkt()
+{
+ local pkt="$1 > $2: .+ echo request"
+
+ extract_new_packets $BUS_SRCGW > ./out
+ $DEBUG && echo $pkt
+ $DEBUG && cat ./out
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
+check_echo_request_pkt_with_macaddr()
+{
+ local pkt="$1 > $2, .+ $3 > $4: .+ echo request"
+
+ extract_new_packets $BUS_SRCGW > ./out
+ $DEBUG && echo $pkt
+ $DEBUG && cat ./out
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
+check_echo_request_pkt_with_macaddr_and_rthdr0()
+{
+ local pkt=
+
+ pkt="$1 > $2, .+ $3 > $4:"
+ pkt="$pkt srcrt \\(len=2, type=0, segleft=1, \\[0\\]$5\\)"
+ pkt="$pkt .+ echo request"
+
+ extract_new_packets $BUS_SRCGW > ./out
+ $DEBUG && echo $pkt
+ $DEBUG && cat ./out
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
+#
+# Tests
+#
+atf_test_case ping6_opts_sourceaddr cleanup
+ping6_opts_sourceaddr_head()
+{
+
+ atf_set "descr" "tests of ping6 -S option"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_sourceaddr_body()
+{
+
+ setup6
+ setup_forwarding6
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt $IP6SRC $IP6DST
+
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6SRC2
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt $IP6SRC $IP6DST
+
+ # ping6 -S <sourceaddr>
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -S $IP6SRC $IP6DST
+ check_echo_request_pkt $IP6SRC $IP6DST
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -S $IP6SRC2 $IP6DST
+ check_echo_request_pkt $IP6SRC2 $IP6DST
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_sourceaddr_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ping6_opts_interface cleanup
+ping6_opts_interface_head()
+{
+
+ atf_set "descr" "tests of ping6 -I option"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_interface_body()
+{
+ local shmif0_lladdr=
+ local shmif1_lladdr=
+ local gw_lladdr=
+
+ setup6
+ setup_forwarding6
+
+ shmif0_lladdr=$(get_linklocal_addr ${SOCKSRC} shmif0)
+ gw_lladdr=$(get_linklocal_addr ${SOCKFWD} shmif0)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $gw_lladdr
+ check_echo_request_pkt $shmif0_lladdr $gw_lladdr
+
+ rump_server_add_iface $SOCKSRC shmif1 $BUS_SRCGW
+ atf_check -s exit:0 rump.ifconfig shmif1 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+ shmif1_lladdr=$(get_linklocal_addr ${SOCKSRC} shmif1)
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $gw_lladdr
+ check_echo_request_pkt $shmif0_lladdr $gw_lladdr
+
+ # ping6 -I <interface>
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -I shmif0 $gw_lladdr
+ check_echo_request_pkt $shmif0_lladdr $gw_lladdr
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -I shmif1 $gw_lladdr
+ check_echo_request_pkt $shmif1_lladdr $gw_lladdr
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_interface_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ping6_opts_gateway cleanup
+ping6_opts_gateway_head()
+{
+
+ atf_set "descr" "tests of ping6 -g option"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_gateway_body()
+{
+ local my_macaddr=
+ local gw_shmif0_macaddr=
+ local gw_shmif2_macaddr=
+
+ setup6
+ setup_forwarding6
+
+ my_macaddr=$(get_macaddr ${SOCKSRC} shmif0)
+ gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2
+ atf_check -s exit:0 rump.ifconfig -w 10
+ gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ # ping6 -g <gateway>
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6DST
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_gateway_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ping6_opts_hops cleanup
+ping6_opts_hops_head()
+{
+
+ atf_set "descr" "tests of ping6 hops (Type 0 Routing Header)"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_hops_body()
+{
+ local my_macaddr=
+ local gw_shmif0_macaddr=
+ local gw_shmif2_macaddr=
+
+ setup6
+ setup_forwarding6
+
+ my_macaddr=$(get_macaddr ${SOCKSRC} shmif0)
+ gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2
+ atf_check -s exit:0 rump.ifconfig -w 10
+ gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ # ping6 hops
+
+ # ping6 fails expectedly because the kernel doesn't support
+ # to receive packets with type 0 routing headers, but we can
+ # check whether a sent packet is correct.
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ $IP6SRCGW $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
+
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+ # ping6 -g <gateway> hops
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW $IP6SRCGW $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
+
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW2 $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+ # ping6 -g <gateway> hops, but different nexthops (is it valid?)
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_hops_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case ping6_opts_sourceaddr
+ atf_add_test_case ping6_opts_interface
+ atf_add_test_case ping6_opts_gateway
+ atf_add_test_case ping6_opts_hops
+}
diff --git a/contrib/netbsd-tests/net/net/t_tcp.c b/contrib/netbsd-tests/net/net/t_tcp.c
index 8972a0f..fd1f1e9 100644
--- a/contrib/netbsd-tests/net/net/t_tcp.c
+++ b/contrib/netbsd-tests/net/net/t_tcp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $ */
+/* $NetBSD: t_tcp.c,v 1.4 2016/03/04 18:52:01 christos Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#ifdef __RCSID
-__RCSID("$Id: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $");
+__RCSID("$Id: t_tcp.c,v 1.4 2016/03/04 18:52:01 christos Exp $");
#endif
/* Example code. Should block; does with accept not paccept. */
@@ -61,6 +61,10 @@ __RCSID("$Id: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $");
#define FAIL(msg, ...) ATF_CHECK_MSG(0, msg, ## __VA_ARGS__); goto fail
#endif
+#ifdef __linux__
+#define paccept(a, b, c, d, e) accept4((a), (b), (c), (e))
+#endif
+
static void
ding(int al)
{
@@ -70,7 +74,8 @@ static void
paccept_block(bool pacceptblock, bool fcntlblock)
{
int srvr = -1, clnt = -1, as = -1;
- int ok, fl, n;
+ int ok, fl;
+ ssize_t n;
char buf[10];
struct sockaddr_in sin, ba;
struct sigaction sa;
@@ -105,10 +110,12 @@ paccept_block(bool pacceptblock, bool fcntlblock)
/* may not connect first time */
ok = connect(clnt, (struct sockaddr *) &ba, addrlen);
+ if (ok != -1 || errno != EINPROGRESS)
+ FAIL("expected connect to fail");
as = paccept(srvr, NULL, NULL, NULL, pacceptblock ? 0 : SOCK_NONBLOCK);
ok = connect(clnt, (struct sockaddr *) &ba, addrlen);
if (ok == -1 && errno != EISCONN)
- FAIL("both connects failed");
+ FAIL("connect failed");
#if 0
fl = fcntl(srvr, F_GETFL, 0);
OpenPOWER on IntegriCloud