Module Name: src
Committed By: ozaki-r
Date: Thu Feb 16 08:12:47 UTC 2017
Modified Files:
src/tests/net: net_common.sh
src/tests/net/net: t_mtudisc.sh
Log Message:
Use nc instead of ftp/httpd
ftp with rumphijack is unstable probably because ftp uses siglongjmp from
a signal hander. So stop using ftp and use nc instead. This fixes test
failures of t_mtudisc on some environments such as my development machine
(amd64) and anita on sparc64.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/net/net_common.sh
cvs rdiff -u -r1.8 -r1.9 src/tests/net/net/t_mtudisc.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/net/net_common.sh
diff -u src/tests/net/net_common.sh:1.11 src/tests/net/net_common.sh:1.12
--- src/tests/net/net_common.sh:1.11 Tue Jan 10 05:55:34 2017
+++ src/tests/net/net_common.sh Thu Feb 16 08:12:47 2017
@@ -1,4 +1,4 @@
-# $NetBSD: net_common.sh,v 1.11 2017/01/10 05:55:34 ozaki-r Exp $
+# $NetBSD: net_common.sh,v 1.12 2017/02/16 08:12:47 ozaki-r Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -29,7 +29,8 @@
# Common utility functions for tests/net
#
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
+HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so \
+ RUMPHIJACK=path=/rump,socket=all:nolocal,sysctl=yes"
extract_new_packets()
{
@@ -132,6 +133,39 @@ stop_httpd()
fi
}
+NC_PID=./.__nc.pid
+start_nc_server()
+{
+ local sock=$1
+ local port=$2
+ local outfile=$3
+ local backup=$RUMP_SERVER
+ local pid=
+
+ export RUMP_SERVER=$sock
+
+ env LD_PRELOAD=/usr/lib/librumphijack.so \
+ nc -l $port > $outfile &
+ pid=$!
+ echo $pid > $NC_PID
+
+ $DEBUG && rump.netstat -a -f inet
+
+ export RUMP_SERVER=$backup
+
+ sleep 1
+}
+
+stop_nc_server()
+{
+
+ if [ -f $NC_PID ]; then
+ kill -9 $(cat $NC_PID)
+ rm -f $NC_PID
+ sleep 1
+ fi
+}
+
BASIC_LIBS="-lrumpnet -lrumpnet_net -lrumpnet_netinet \
-lrumpnet_shmif -lrumpdev"
FS_LIBS="$BASIC_LIBS -lrumpvfs -lrumpfs_ffs"
Index: src/tests/net/net/t_mtudisc.sh
diff -u src/tests/net/net/t_mtudisc.sh:1.8 src/tests/net/net/t_mtudisc.sh:1.9
--- src/tests/net/net/t_mtudisc.sh:1.8 Wed Dec 21 01:16:18 2016
+++ src/tests/net/net/t_mtudisc.sh Thu Feb 16 08:12:47 2017
@@ -1,4 +1,4 @@
-# $NetBSD: t_mtudisc.sh,v 1.8 2016/12/21 01:16:18 ozaki-r Exp $
+# $NetBSD: t_mtudisc.sh,v 1.9 2017/02/16 08:12:47 ozaki-r Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -28,7 +28,6 @@
SOCKLOCAL=unix://commsock1
SOCKGATEWAY=unix://commsock2
SOCKREMOTE=unix://commsock3
-HTML_FILE=index.html
DEBUG=${DEBUG:-false}
@@ -37,7 +36,7 @@ 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"
+ atf_set "require.progs" "rump_server nc"
}
setup_server()
@@ -57,7 +56,7 @@ setup_server()
$DEBUG && rump.ifconfig $if
}
-prepare_download_file()
+prepare_file()
{
local file=$1
local data="0123456789"
@@ -69,17 +68,6 @@ prepare_download_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=
@@ -88,6 +76,10 @@ mtudisc_basic_body()
local gateway_remote_ip=10.0.1.1
local remote_ip=10.0.1.2
local prefixlen=24
+ local port=1234
+ local pid=
+ local file_send=./file.send
+ local file_recv=./file.recv
rump_server_start $SOCKLOCAL
rump_server_start $SOCKGATEWAY
@@ -96,9 +88,9 @@ mtudisc_basic_body()
#
# Setup servers
#
- # [local server] [gateway server] [remote server with httpd]
+ # [local server] [gateway server] [remote server]
# | 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)
+ # shmif0(mtu=1500) ----- shmif0(mtu=1500) shmif1(mtu=1280) ----- shmif0(mtu=1500)
#
# Assign IP addresses
@@ -111,8 +103,7 @@ mtudisc_basic_body()
export RUMP_SERVER=$SOCKGATEWAY
# Set mtu of shmif0 to 1280
- export RUMP_SERVER=$SOCKGATEWAY
- atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
+ atf_check -s exit:0 rump.ifconfig shmif1 mtu 1280
# Enable IPv4 forwarding
atf_check -s exit:0 rump.sysctl -w -q net.inet.ip.forwarding=1
@@ -123,58 +114,61 @@ mtudisc_basic_body()
# 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)
+ # Teach the peer thar 10.0.0.2(local server) is behind 10.0.1.1(gateway server)
atf_check -s exit:0 -o ignore rump.route add $local_ip/32 $gateway_remote_ip
+ # Don't accept fragmented packets
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.maxfragpackets=0
+
### 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)
+ # Teach the peer thar 10.0.1.2(remote server) 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
+ prepare_file $file_send
+
+ # Start nc server
+ start_nc_server $SOCKREMOTE $port $file_recv
- # Get the webpage (expect: failed)
export RUMP_SERVER=$SOCKLOCAL
- do_http_get $remote_ip 1
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=0
+
+ # Send a file to the server
+ atf_check -s exit:0 $HIJACKING nc -N -w 3 $remote_ip $port < $file_send
$DEBUG && extract_new_packets bus2 > ./out
$DEBUG && cat ./out
+ stop_nc_server
+ atf_check -s not-exit:0 -o match:"differ" diff -q $file_send $file_recv
- # Check path mtu size on remote server
- export RUMP_SERVER=$SOCKREMOTE
+ # Check path mtu size on the local server
atf_check -s exit:0 \
- -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +- +shmif0" \
- rump.netstat -nr -f inet
+ -o match:"^10.0.1.2 +10.0.0.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
+ # Start nc server
+ start_nc_server $SOCKREMOTE $port $file_recv
- # Get the webpage (expect: success)
export RUMP_SERVER=$SOCKLOCAL
- do_http_get $remote_ip 0
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=1
+
+ # Send a file to the server
+ atf_check -s exit:0 $HIJACKING nc -N -w 3 $remote_ip $port < $file_send
$DEBUG && extract_new_packets bus2 > ./out
$DEBUG && cat ./out
+ stop_nc_server
+ atf_check -s exit:0 diff -q $file_send $file_recv
- # Check path mtu size on remote server
- export RUMP_SERVER=$SOCKREMOTE
+ # Check path mtu size on the local server
atf_check -s exit:0 \
- -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +1280 +shmif0" \
- rump.netstat -nr -f inet
+ -o match:"^10.0.1.2 +10.0.0.1 +UGHS +- +- +1280 +shmif0" \
+ rump.netstat -nr -f inet
rump_server_destroy_ifaces
}
@@ -182,7 +176,7 @@ mtudisc_basic_body()
mtudisc_basic_cleanup()
{
$DEBUG && dump
- stop_httpd
+ stop_nc_server
cleanup
}