Source-Changes-HG archive

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

[src/trunk]: src/tests/net/net Add tests of ping6 hops optional argument (Typ...



details:   https://anonhg.NetBSD.org/src/rev/570df5079fd3
branches:  trunk
changeset: 348780:570df5079fd3
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Nov 07 04:43:14 2016 +0000

description:
Add tests of ping6 hops optional argument (Type 0 Routing Headers)

Note that ping6 with the argument can send packets with routing headers
but the kernel doesn't support receiving the packets so that ping6 fails.
Nevertheless, we can test whether sent packets are correct or not.

diffstat:

 tests/net/net/t_ping6_opts.sh |  77 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 76 insertions(+), 1 deletions(-)

diffs (102 lines):

diff -r 14383597b3f1 -r 570df5079fd3 tests/net/net/t_ping6_opts.sh
--- a/tests/net/net/t_ping6_opts.sh     Mon Nov 07 03:12:54 2016 +0000
+++ b/tests/net/net/t_ping6_opts.sh     Mon Nov 07 04:43:14 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_ping6_opts.sh,v 1.1 2016/10/31 10:38:25 ozaki-r Exp $
+#      $NetBSD: t_ping6_opts.sh,v 1.2 2016/11/07 04:43:14 ozaki-r Exp $
 #
 # Copyright (c) 2016 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -160,6 +160,20 @@
        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
+}
+
 dump()
 {
 
@@ -333,10 +347,71 @@
        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
+
+       export RUMP_SERVER=$SOCKFWD
+       atf_check -s exit:0 rump.ifconfig shmif2 create
+       atf_check -s exit:0 rump.ifconfig shmif2 linkstr $BUS_SRCGW
+       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_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
 }



Home | Main Index | Thread Index | Old Index