1 # $NetBSD: t_mtudisc6.sh,v 1.5 2016/11/25 08:51:17 ozaki-r Exp $
3 # Copyright (c) 2016 Internet Initiative Japan Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 SOCKLOCAL=unix://commsock1
29 SOCKGATEWAY=unix://commsock2
30 SOCKREMOTE=unix://commsock3
35 atf_test_case mtudisc6_basic cleanup
40 atf_set "descr" "Tests for IPv6 Path MTU Dicorvery basic behavior"
41 atf_set "require.progs" "rump_server"
51 rump_server_add_iface $sock $if $bus
53 export RUMP_SERVER=$sock
54 atf_check -s exit:0 rump.ifconfig $if inet6 $ip
55 atf_check -s exit:0 rump.ifconfig $if up
56 atf_check -s exit:0 rump.ifconfig -w 10
58 $DEBUG && rump.ifconfig $if
61 prepare_download_file()
64 local data="0123456789"
80 atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \
81 ftp -q $timeout -o ./out "http://[$ip]/$HTML_FILE"
87 local local_ip=fc00:0:0:1::2
88 local gateway_local_ip=fc00:0:0:1::1
89 local gateway_remote_ip=fc00:0:0:2::1
90 local remote_ip=fc00:0:0:2::2
93 rump_server_start $SOCKLOCAL netinet6
94 rump_server_start $SOCKGATEWAY netinet6
95 rump_server_start $SOCKREMOTE netinet6
100 # [local server] [gateway server] [remote server]
102 # shmif0(1500) -- shmif1(1280) shmif0(1500) -- shmif0(1500)
105 # Assign IP addresses
106 setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen
107 setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen
108 setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen
109 setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen
111 ### Setup gateway server
112 export RUMP_SERVER=$SOCKGATEWAY
114 # Set MTU of shmif0 to 1280
115 export RUMP_SERVER=$SOCKGATEWAY
116 atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
118 # Enable IPv6 forwarding
119 atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.forwarding=1
121 ### Setup remote server
122 export RUMP_SERVER=$SOCKREMOTE
125 prepare_download_file $HTML_FILE
126 start_httpd $SOCKREMOTE $remote_ip
127 $DEBUG && rump.netstat -a
129 # Teach the peer that local serer is behind gateway server
130 atf_check -s exit:0 -o ignore \
131 rump.route add -inet6 $local_ip/128 $gateway_remote_ip
133 # Check path MTU size on remote server
134 atf_check -s exit:0 \
135 -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +- +shmif0" \
136 rump.netstat -nr -f inet6
138 ### Setup local server
139 export RUMP_SERVER=$SOCKLOCAL
141 # Teach the peer that remote serer is behind gateway server
142 atf_check -s exit:0 -o ignore \
143 rump.route add -inet6 $remote_ip/128 $gateway_local_ip
145 # Don't accept fragmented packets
146 atf_check -s exit:0 -o ignore \
147 rump.sysctl -w -q net.inet6.ip6.maxfragpackets=0
150 # Test enabled path MTU discorvery
152 # Get the webpage (expect: success)
153 export RUMP_SERVER=$SOCKLOCAL
154 do_http_get $remote_ip 0
155 $DEBUG && extract_new_packets bus2 > ./out
158 # Check path MTU size on remote server
159 export RUMP_SERVER=$SOCKREMOTE
160 atf_check -s exit:0 \
161 -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +1280 +shmif0" \
162 rump.netstat -nr -f inet6
164 rump_server_destroy_ifaces
167 mtudisc6_basic_cleanup()
175 atf_init_test_cases()
178 atf_add_test_case mtudisc6_basic