1 # $NetBSD: t_mtudisc.sh,v 1.8 2016/12/21 01:16:18 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 mtudisc_basic cleanup
39 atf_set "descr" "Tests for IPv4 Path MTU Dicorvery basic behavior"
40 atf_set "require.progs" "rump_server"
50 rump_server_add_iface $sock $if $bus
52 export RUMP_SERVER=$sock
53 atf_check -s exit:0 rump.ifconfig $if $ip
54 atf_check -s exit:0 rump.ifconfig $if up
55 atf_check -s exit:0 rump.ifconfig -w 10
57 $DEBUG && rump.ifconfig $if
60 prepare_download_file()
63 local data="0123456789"
79 atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \
80 ftp -q $timeout -o ./out http://$ip/$HTML_FILE
86 local local_ip=10.0.0.2
87 local gateway_local_ip=10.0.0.1
88 local gateway_remote_ip=10.0.1.1
89 local remote_ip=10.0.1.2
92 rump_server_start $SOCKLOCAL
93 rump_server_start $SOCKGATEWAY
94 rump_server_start $SOCKREMOTE
99 # [local server] [gateway server] [remote server with httpd]
100 # | 10.0.0.2 10.0.0.1 | | 10.0.1.1 10.0.1.2 |
101 # shmif0(mtu=1500) ----- shmif1(mtu=1280) shmif0(mtu=1500) ----- shmif0(mtu=1500)
104 # Assign IP addresses
105 setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen
106 setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen
107 setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen
108 setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen
110 ### Setup gateway server
111 export RUMP_SERVER=$SOCKGATEWAY
113 # Set mtu of shmif0 to 1280
114 export RUMP_SERVER=$SOCKGATEWAY
115 atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
117 # Enable IPv4 forwarding
118 atf_check -s exit:0 rump.sysctl -w -q net.inet.ip.forwarding=1
120 ### Setup remote server
121 export RUMP_SERVER=$SOCKREMOTE
123 # Check default value
124 atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet.ip.mtudisc
127 prepare_download_file $HTML_FILE
128 start_httpd $SOCKREMOTE $remote_ip
129 $DEBUG && rump.netstat -a -f inet
131 # Teach the peer thar 10.0.0.2(local serer) is behind 10.0.1.1(gateway server)
132 atf_check -s exit:0 -o ignore rump.route add $local_ip/32 $gateway_remote_ip
134 ### Setup local server
135 export RUMP_SERVER=$SOCKLOCAL
137 # Teach the peer thar 10.0.1.2(remote serer) is behind 10.0.0.1(gateway server)
138 atf_check -s exit:0 -o ignore rump.route add $remote_ip/32 $gateway_local_ip
140 # Don't accept fragmented packets
141 atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.maxfragpackets=0
144 # Test disabled path mtu discorvery
146 export RUMP_SERVER=$SOCKREMOTE
147 atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=0
149 # Get the webpage (expect: failed)
150 export RUMP_SERVER=$SOCKLOCAL
151 do_http_get $remote_ip 1
152 $DEBUG && extract_new_packets bus2 > ./out
155 # Check path mtu size on remote server
156 export RUMP_SERVER=$SOCKREMOTE
157 atf_check -s exit:0 \
158 -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +- +shmif0" \
159 rump.netstat -nr -f inet
162 # Test enabled path mtu discorvery
164 export RUMP_SERVER=$SOCKREMOTE
165 atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=1
167 # Get the webpage (expect: success)
168 export RUMP_SERVER=$SOCKLOCAL
169 do_http_get $remote_ip 0
170 $DEBUG && extract_new_packets bus2 > ./out
173 # Check path mtu size on remote server
174 export RUMP_SERVER=$SOCKREMOTE
175 atf_check -s exit:0 \
176 -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +1280 +shmif0" \
177 rump.netstat -nr -f inet
179 rump_server_destroy_ifaces
182 mtudisc_basic_cleanup()
189 atf_init_test_cases()
191 atf_add_test_case mtudisc_basic