1*8a006adbSBjoern A. Zeeb#!/bin/sh 2*8a006adbSBjoern A. Zeeb#- 3*8a006adbSBjoern A. Zeeb# Copyright (c) 2010, "Bjoern A. Zeeb" <bz@FreeBSD.org> 4*8a006adbSBjoern A. Zeeb# Copyright (c) 2011, Sandvine Incorporated ULC. 5*8a006adbSBjoern A. Zeeb# All rights reserved. 6*8a006adbSBjoern A. Zeeb# 7*8a006adbSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without 8*8a006adbSBjoern A. Zeeb# modification, are permitted provided that the following conditions 9*8a006adbSBjoern A. Zeeb# are met: 10*8a006adbSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright 11*8a006adbSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer. 12*8a006adbSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright 13*8a006adbSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer in the 14*8a006adbSBjoern A. Zeeb# documentation and/or other materials provided with the distribution. 15*8a006adbSBjoern A. Zeeb# 16*8a006adbSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*8a006adbSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8a006adbSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*8a006adbSBjoern A. Zeeb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*8a006adbSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*8a006adbSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*8a006adbSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*8a006adbSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*8a006adbSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*8a006adbSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*8a006adbSBjoern A. Zeeb# SUCH DAMAGE. 27*8a006adbSBjoern A. Zeeb# 28*8a006adbSBjoern A. Zeeb# 29*8a006adbSBjoern A. Zeeb 30*8a006adbSBjoern A. Zeeb# 31*8a006adbSBjoern A. Zeeb# Test ipfw fwd for IPv4 and IPv6 using VIMAGE, testing that as well. 32*8a006adbSBjoern A. Zeeb# For no test the packet header contents must be changed but always 33*8a006adbSBjoern A. Zeeb# keeping the original destination. 34*8a006adbSBjoern A. Zeeb# 35*8a006adbSBjoern A. Zeeb 36*8a006adbSBjoern A. Zeebcase `id -u` in 37*8a006adbSBjoern A. Zeeb0) ;; 38*8a006adbSBjoern A. Zeeb*) echo "ERROR: Must be run as superuser." >&2 39*8a006adbSBjoern A. Zeeb exit 2 40*8a006adbSBjoern A. Zeebesac 41*8a006adbSBjoern A. Zeeb 42*8a006adbSBjoern A. Zeebepair_base() 43*8a006adbSBjoern A. Zeeb{ 44*8a006adbSBjoern A. Zeeb local ep 45*8a006adbSBjoern A. Zeeb 46*8a006adbSBjoern A. Zeeb ep=`ifconfig epair create` 47*8a006adbSBjoern A. Zeeb expr ${ep} : '\(.*\).' 48*8a006adbSBjoern A. Zeeb} 49*8a006adbSBjoern A. Zeeb 50*8a006adbSBjoern A. Zeebdebug_err() 51*8a006adbSBjoern A. Zeeb{ 52*8a006adbSBjoern A. Zeeb local _p 53*8a006adbSBjoern A. Zeeb _p="$1" 54*8a006adbSBjoern A. Zeeb 55*8a006adbSBjoern A. Zeeb case "${DEBUG}" in 56*8a006adbSBjoern A. Zeeb "") ;; 57*8a006adbSBjoern A. Zeeb *) 58*8a006adbSBjoern A. Zeeb echo " ~~ start of debug ~~" 59*8a006adbSBjoern A. Zeeb echo " ~~ left:" 60*8a006adbSBjoern A. Zeeb jexec ${ljid} /sbin/ipfw show 61*8a006adbSBjoern A. Zeeb echo " ~~ middle:" 62*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw show 63*8a006adbSBjoern A. Zeeb echo " ~~ right:" 64*8a006adbSBjoern A. Zeeb jexec ${rjid} /sbin/ipfw show 65*8a006adbSBjoern A. Zeeb echo " ~~ result file:" 66*8a006adbSBjoern A. Zeeb cat ${_p}.1 67*8a006adbSBjoern A. Zeeb echo " ~~ log file:" 68*8a006adbSBjoern A. Zeeb cat ${_p} 69*8a006adbSBjoern A. Zeeb echo " ~~ end of debug ~~" 70*8a006adbSBjoern A. Zeeb ;; 71*8a006adbSBjoern A. Zeeb esac 72*8a006adbSBjoern A. Zeeb} 73*8a006adbSBjoern A. Zeeb 74*8a006adbSBjoern A. Zeebcheck_cleanup_result_file() 75*8a006adbSBjoern A. Zeeb{ 76*8a006adbSBjoern A. Zeeb local _p 77*8a006adbSBjoern A. Zeeb _p="$1" 78*8a006adbSBjoern A. Zeeb 79*8a006adbSBjoern A. Zeeb if test ! -s ${_p}.1; then 80*8a006adbSBjoern A. Zeeb echo "FAIL (output file empty)." 81*8a006adbSBjoern A. Zeeb debug_err ${_p} 82*8a006adbSBjoern A. Zeeb else 83*8a006adbSBjoern A. Zeeb read line < ${_p}.1 84*8a006adbSBjoern A. Zeeb # Netcat adds 'X's in udp mode. 85*8a006adbSBjoern A. Zeeb l="/${line#*/}" 86*8a006adbSBjoern A. Zeeb if test "${l}" = "${_p}"; then 87*8a006adbSBjoern A. Zeeb echo "PASS." 88*8a006adbSBjoern A. Zeeb else 89*8a006adbSBjoern A. Zeeb echo "FAIL (expected: '${_p}' got '${l}')." 90*8a006adbSBjoern A. Zeeb debug_err ${_p} 91*8a006adbSBjoern A. Zeeb fi 92*8a006adbSBjoern A. Zeeb fi 93*8a006adbSBjoern A. Zeeb 94*8a006adbSBjoern A. Zeeb rm -f ${_p}.1 95*8a006adbSBjoern A. Zeeb rm -f ${_p} 96*8a006adbSBjoern A. Zeeb} 97*8a006adbSBjoern A. Zeeb 98*8a006adbSBjoern A. Zeeb# Transparent proxy scenario (local address). 99*8a006adbSBjoern A. Zeebrun_test_tp() 100*8a006adbSBjoern A. Zeeb{ 101*8a006adbSBjoern A. Zeeb local _descr 102*8a006adbSBjoern A. Zeeb local _sip _dip _fip _fport _dport _p 103*8a006adbSBjoern A. Zeeb local _nc_af _nc_p 104*8a006adbSBjoern A. Zeeb local _lport 105*8a006adbSBjoern A. Zeeb descr="$1" 106*8a006adbSBjoern A. Zeeb _sip="$2" 107*8a006adbSBjoern A. Zeeb _dip="$3" 108*8a006adbSBjoern A. Zeeb _fip="$4" 109*8a006adbSBjoern A. Zeeb _fport="$5" 110*8a006adbSBjoern A. Zeeb _dport="$6" 111*8a006adbSBjoern A. Zeeb _p="$7" 112*8a006adbSBjoern A. Zeeb _nc_af="$8" 113*8a006adbSBjoern A. Zeeb 114*8a006adbSBjoern A. Zeeb _lport=${_dport} 115*8a006adbSBjoern A. Zeeb case "${_fport}" in 116*8a006adbSBjoern A. Zeeb "") _lport="${_dport}" ;; 117*8a006adbSBjoern A. Zeeb *) _lport="${_fport#,}" ;; 118*8a006adbSBjoern A. Zeeb esac 119*8a006adbSBjoern A. Zeeb 120*8a006adbSBjoern A. Zeeb case "${_p}" in 121*8a006adbSBjoern A. Zeeb udp) _nc_p="-u" ;; 122*8a006adbSBjoern A. Zeeb esac 123*8a006adbSBjoern A. Zeeb 124*8a006adbSBjoern A. Zeeb OUT=`mktemp -t "ipfwfwd$$-XXXXXX"` 125*8a006adbSBjoern A. Zeeb echo -n "${descr} (${OUT}).." 126*8a006adbSBjoern A. Zeeb ( 127*8a006adbSBjoern A. Zeeb jexec ${ljid} /sbin/ipfw -f flush 128*8a006adbSBjoern A. Zeeb jexec ${ljid} /sbin/ipfw -f zero 129*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw -f flush 130*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw -f zero 131*8a006adbSBjoern A. Zeeb jexec ${rjid} /sbin/ipfw -f flush 132*8a006adbSBjoern A. Zeeb jexec ${rjid} /sbin/ipfw -f zero 133*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw add 100 fwd ${_fip}${_fport} ${_p} from ${_sip} to ${_dip} 134*8a006adbSBjoern A. Zeeb 135*8a006adbSBjoern A. Zeeb jexec ${mjid} /bin/sh -c "nc -w 10 ${_nc_af} -n ${_nc_p} -l ${_fip} ${_lport} > ${OUT}.1 &" 136*8a006adbSBjoern A. Zeeb jexec ${rjid} /bin/sh -c "echo '${OUT}' | nc -w 1 -v ${_nc_af} -n ${_nc_p} ${_dip} ${_dport}" 137*8a006adbSBjoern A. Zeeb ) > ${OUT} 2>&1 138*8a006adbSBjoern A. Zeeb check_cleanup_result_file "${OUT}" 139*8a006adbSBjoern A. Zeeb} 140*8a006adbSBjoern A. Zeeb 141*8a006adbSBjoern A. Zeeb# Transparent redirect scenario (non-local address). 142*8a006adbSBjoern A. Zeebrun_test_nh() 143*8a006adbSBjoern A. Zeeb{ 144*8a006adbSBjoern A. Zeeb local _descr 145*8a006adbSBjoern A. Zeeb local _sip _dip _fip _fport _dport _p 146*8a006adbSBjoern A. Zeeb local _nc_af _nc_p 147*8a006adbSBjoern A. Zeeb local _lport 148*8a006adbSBjoern A. Zeeb descr="$1" 149*8a006adbSBjoern A. Zeeb _sip="$2" 150*8a006adbSBjoern A. Zeeb _dip="$3" 151*8a006adbSBjoern A. Zeeb _fip="$4" 152*8a006adbSBjoern A. Zeeb _fport="$5" 153*8a006adbSBjoern A. Zeeb _dport="$6" 154*8a006adbSBjoern A. Zeeb _p="$7" 155*8a006adbSBjoern A. Zeeb _nc_af="$8" 156*8a006adbSBjoern A. Zeeb 157*8a006adbSBjoern A. Zeeb _lport=${_dport} 158*8a006adbSBjoern A. Zeeb case "${_fport}" in 159*8a006adbSBjoern A. Zeeb "") _lport="${_dport}" ;; 160*8a006adbSBjoern A. Zeeb *) _lport="${_fport#,}" ;; 161*8a006adbSBjoern A. Zeeb esac 162*8a006adbSBjoern A. Zeeb 163*8a006adbSBjoern A. Zeeb case "${_p}" in 164*8a006adbSBjoern A. Zeeb udp) _nc_p="-u" ;; 165*8a006adbSBjoern A. Zeeb esac 166*8a006adbSBjoern A. Zeeb 167*8a006adbSBjoern A. Zeeb OUT=`mktemp -t "ipfwfwd$$-XXXXXX"` 168*8a006adbSBjoern A. Zeeb echo -n "${descr} (${OUT}).." 169*8a006adbSBjoern A. Zeeb ( 170*8a006adbSBjoern A. Zeeb jexec ${ljid} /sbin/ipfw -f flush 171*8a006adbSBjoern A. Zeeb jexec ${ljid} /sbin/ipfw -f zero 172*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw -f flush 173*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw -f zero 174*8a006adbSBjoern A. Zeeb jexec ${rjid} /sbin/ipfw -f flush 175*8a006adbSBjoern A. Zeeb jexec ${rjid} /sbin/ipfw -f zero 176*8a006adbSBjoern A. Zeeb jexec ${mjid} /sbin/ipfw add 100 fwd ${_fip} ${_p} from ${_sip} to ${_dip} 177*8a006adbSBjoern A. Zeeb 178*8a006adbSBjoern A. Zeeb jexec ${ljid} /bin/sh -c "nc -w 10 ${_nc_af} -n ${_nc_p} -l ${_dip} ${_lport} > ${OUT}.1 &" 179*8a006adbSBjoern A. Zeeb jexec ${rjid} /bin/sh -c "echo '${OUT}' | nc -w 1 -v ${_nc_af} -n ${_nc_p} ${_dip} ${_dport}" 180*8a006adbSBjoern A. Zeeb ) > ${OUT} 2>&1 181*8a006adbSBjoern A. Zeeb check_cleanup_result_file "${OUT}" 182*8a006adbSBjoern A. Zeeb} 183*8a006adbSBjoern A. Zeeb 184*8a006adbSBjoern A. Zeebecho "==> Setting up test network" 185*8a006adbSBjoern A. Zeebkldload -q ipfw > /dev/null 2>&1 186*8a006adbSBjoern A. Zeeb 187*8a006adbSBjoern A. Zeeb# Start left (sender) jail. 188*8a006adbSBjoern A. Zeebljid=`jail -i -c -n lef$$ host.hostname=left.example.net vnet persist` 189*8a006adbSBjoern A. Zeeb 190*8a006adbSBjoern A. Zeeb# Start middle (ipfw) jail. 191*8a006adbSBjoern A. Zeebmjid=`jail -i -c -n mid$$ host.hostname=center.example.net vnet persist` 192*8a006adbSBjoern A. Zeeb 193*8a006adbSBjoern A. Zeeb# Start right (non-local ip redirects go to here) jail. 194*8a006adbSBjoern A. Zeebrjid=`jail -i -c -n right$$ host.hostname=right.example.net vnet persist` 195*8a006adbSBjoern A. Zeeb 196*8a006adbSBjoern A. Zeebecho "left ${ljid} middle ${mjid} right ${rjid}" 197*8a006adbSBjoern A. Zeeb 198*8a006adbSBjoern A. Zeeb# Create networking. 199*8a006adbSBjoern A. Zeeb# 200*8a006adbSBjoern A. Zeeb# jail: left middle right 201*8a006adbSBjoern A. Zeeb# ifaces: lmep:a ---- lmep:b mrep:a ---- mrep:b 202*8a006adbSBjoern A. Zeeb# 203*8a006adbSBjoern A. Zeeb 204*8a006adbSBjoern A. Zeebjexec ${mjid} sysctl net.inet.ip.forwarding=1 205*8a006adbSBjoern A. Zeebjexec ${mjid} sysctl net.inet6.ip6.forwarding=1 206*8a006adbSBjoern A. Zeebjexec ${mjid} sysctl net.inet6.ip6.accept_rtadv=0 207*8a006adbSBjoern A. Zeeb 208*8a006adbSBjoern A. Zeeblmep=$(epair_base) 209*8a006adbSBjoern A. Zeebifconfig ${lmep}a vnet ${ljid} 210*8a006adbSBjoern A. Zeebifconfig ${lmep}b vnet ${mjid} 211*8a006adbSBjoern A. Zeeb 212*8a006adbSBjoern A. Zeebjexec ${ljid} ifconfig lo0 inet 127.0.0.1/8 213*8a006adbSBjoern A. Zeebjexec ${ljid} ifconfig lo0 inet 192.0.2.5/32 alias # Test 9-10 214*8a006adbSBjoern A. Zeebjexec ${ljid} ifconfig lo0 inet6 2001:db8:1::1/128 alias # Test 11-12 215*8a006adbSBjoern A. Zeebjexec ${ljid} ifconfig ${lmep}a inet 192.0.2.1/30 up 216*8a006adbSBjoern A. Zeebjexec ${ljid} ifconfig ${lmep}a inet6 2001:db8::1/64 alias 217*8a006adbSBjoern A. Zeeb 218*8a006adbSBjoern A. Zeebjexec ${ljid} route add default 192.0.2.2 219*8a006adbSBjoern A. Zeebjexec ${ljid} route add -inet6 default 2001:db8::2 220*8a006adbSBjoern A. Zeeb 221*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig lo0 inet 127.0.0.1/8 222*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig lo0 inet 192.0.2.255/32 alias # Test 1-4 223*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig lo0 inet6 2001:db8:ffff::1/128 alias # Test 5-8 224*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig ${lmep}b inet 192.0.2.2/30 up 225*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig ${lmep}b inet6 2001:db8::2/64 alias 226*8a006adbSBjoern A. Zeebjexec ${mjid} route add default 192.0.2.1 227*8a006adbSBjoern A. Zeeb 228*8a006adbSBjoern A. Zeebmrep=$(epair_base) 229*8a006adbSBjoern A. Zeebifconfig ${mrep}a vnet ${mjid} 230*8a006adbSBjoern A. Zeebifconfig ${mrep}b vnet ${rjid} 231*8a006adbSBjoern A. Zeeb 232*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig ${mrep}a inet 192.0.2.5/30 up 233*8a006adbSBjoern A. Zeebjexec ${mjid} ifconfig ${mrep}a inet6 2001:db8:1::1/64 alias 234*8a006adbSBjoern A. Zeeb 235*8a006adbSBjoern A. Zeebjexec ${rjid} ifconfig lo0 inet 127.0.0.1/8 236*8a006adbSBjoern A. Zeebjexec ${rjid} ifconfig ${mrep}b inet 192.0.2.6/30 up 237*8a006adbSBjoern A. Zeebjexec ${rjid} ifconfig ${mrep}b inet6 2001:db8:1::2/64 alias 238*8a006adbSBjoern A. Zeeb 239*8a006adbSBjoern A. Zeebjexec ${rjid} route add default 192.0.2.5 240*8a006adbSBjoern A. Zeebjexec ${rjid} route add -inet6 default 2001:db8:1::1 241*8a006adbSBjoern A. Zeeb 242*8a006adbSBjoern A. Zeeb# ------------------------------------------------------------------------------ 243*8a006adbSBjoern A. Zeeb# Tests 244*8a006adbSBjoern A. Zeeb# 245*8a006adbSBjoern A. Zeeb# The jails are not chrooted to they all share the same base filesystem. 246*8a006adbSBjoern A. Zeeb# This means we can put results into /tmp and just collect them from here. 247*8a006adbSBjoern A. Zeeb# 248*8a006adbSBjoern A. Zeebecho "==> Running tests" 249*8a006adbSBjoern A. Zeeb 250*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 251*8a006adbSBjoern A. Zeebi=1 252*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 UDP redirect local to other local address, same port" \ 253*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.5 192.0.2.255 "" 12345 udp "-4" 254*8a006adbSBjoern A. Zeeb 255*8a006adbSBjoern A. Zeebi=$((i + 1)) 256*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 UDP redirect local to other local address, different port" \ 257*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.5 192.0.2.255 ",65534" 12345 udp "-4" 258*8a006adbSBjoern A. Zeeb 259*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 260*8a006adbSBjoern A. Zeebi=$((i + 1)) 261*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 TCP redirect local to other local address, same port" \ 262*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.5 192.0.2.255 "" 12345 tcp "-4" 263*8a006adbSBjoern A. Zeeb 264*8a006adbSBjoern A. Zeebi=$((i + 1)) 265*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 TCP redirect local to other local address, different port" \ 266*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.5 192.0.2.255 ",65534" 12345 tcp "-4" 267*8a006adbSBjoern A. Zeeb 268*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 269*8a006adbSBjoern A. Zeebi=$((i + 1)) 270*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 UDP redirect foreign to local address, same port" \ 271*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.1 192.0.2.255 "" 12345 udp "-4" 272*8a006adbSBjoern A. Zeeb 273*8a006adbSBjoern A. Zeebi=$((i + 1)) 274*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 UDP redirect foreign to local address, different port" \ 275*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.1 192.0.2.255 ",65534" 12345 udp "-4" 276*8a006adbSBjoern A. Zeeb 277*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 278*8a006adbSBjoern A. Zeebi=$((i + 1)) 279*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 TCP redirect foreign to local address, same port" \ 280*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.1 192.0.2.255 "" 12345 tcp "-4" 281*8a006adbSBjoern A. Zeeb 282*8a006adbSBjoern A. Zeebi=$((i + 1)) 283*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv4 TCP redirect foreign to local address, different port" \ 284*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.1 192.0.2.255 ",65534" 12345 tcp "-4" 285*8a006adbSBjoern A. Zeeb 286*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 287*8a006adbSBjoern A. Zeebi=$((i + 1)) 288*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 UDP redirect local to other local address, same port" \ 289*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 "" 12345 udp "-6" 290*8a006adbSBjoern A. Zeeb 291*8a006adbSBjoern A. Zeebi=$((i + 1)) 292*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 UDP redirect local to other local address, different port" \ 293*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 ",65534" 12345 udp "-6" 294*8a006adbSBjoern A. Zeeb 295*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 296*8a006adbSBjoern A. Zeebi=$((i + 1)) 297*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 TCP redirect local to other local address, same port" \ 298*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 "" 12345 tcp "-6" 299*8a006adbSBjoern A. Zeeb 300*8a006adbSBjoern A. Zeebi=$((i + 1)) 301*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 TCP redirect local to other local address, different port" \ 302*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 ",65534" 12345 tcp "-6" 303*8a006adbSBjoern A. Zeeb 304*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 305*8a006adbSBjoern A. Zeebi=$((i + 1)) 306*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 UDP redirect foreign to local address, same port" \ 307*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 "" 12345 udp "-6" 308*8a006adbSBjoern A. Zeeb 309*8a006adbSBjoern A. Zeebi=$((i + 1)) 310*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 UDP redirect foreign to local address, different port" \ 311*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 ",65534" 12345 udp "-6" 312*8a006adbSBjoern A. Zeeb 313*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 314*8a006adbSBjoern A. Zeebi=$((i + 1)) 315*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 TCP redirect foreign to local address, same port" \ 316*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 "" 12345 tcp "-6" 317*8a006adbSBjoern A. Zeeb 318*8a006adbSBjoern A. Zeebi=$((i + 1)) 319*8a006adbSBjoern A. Zeebrun_test_tp "TEST ${i} IPv6 TCP redirect foreign to local address, different port" \ 320*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8::1 2001:db8:ffff::1 ",65534" 12345 tcp "-6" 321*8a006adbSBjoern A. Zeeb 322*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 323*8a006adbSBjoern A. Zeebi=$((i + 1)) 324*8a006adbSBjoern A. Zeebrun_test_nh "TEST ${i} IPv4 UDP redirect to foreign address" \ 325*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.5 192.0.2.1 "" 12345 udp "-4" 326*8a006adbSBjoern A. Zeeb 327*8a006adbSBjoern A. Zeebi=$((i + 1)) 328*8a006adbSBjoern A. Zeebrun_test_nh "TEST ${i} IPv4 TCP redirect to foreign address" \ 329*8a006adbSBjoern A. Zeeb 192.0.2.6 192.0.2.5 192.0.2.1 "" 12345 tcp "-4" 330*8a006adbSBjoern A. Zeeb 331*8a006adbSBjoern A. Zeeb#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 332*8a006adbSBjoern A. Zeebi=$((i + 1)) 333*8a006adbSBjoern A. Zeebrun_test_nh "TEST ${i} IPv6 UDP redirect to foreign address" \ 334*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8:1::1 2001:db8::1 "" 12345 udp "-6" 335*8a006adbSBjoern A. Zeeb 336*8a006adbSBjoern A. Zeebi=$((i + 1)) 337*8a006adbSBjoern A. Zeebrun_test_nh "TEST ${i} IPv6 TCP redirect to foreign address" \ 338*8a006adbSBjoern A. Zeeb 2001:db8:1::2 2001:db8:1::1 2001:db8::1 "" 12345 tcp "-6" 339*8a006adbSBjoern A. Zeeb 340*8a006adbSBjoern A. Zeeb################################################################################ 341*8a006adbSBjoern A. Zeeb# 342*8a006adbSBjoern A. Zeeb# Cleanup 343*8a006adbSBjoern A. Zeeb# 344*8a006adbSBjoern A. Zeebecho "==> Cleaning up in 3 seconds" 345*8a006adbSBjoern A. Zeeb# Let VIMAGE network stacks settle to avoid panics while still "experimental". 346*8a006adbSBjoern A. Zeebsleep 3 347*8a006adbSBjoern A. Zeeb 348*8a006adbSBjoern A. Zeebjail -r ${rjid} 349*8a006adbSBjoern A. Zeebjail -r ${mjid} 350*8a006adbSBjoern A. Zeebjail -r ${ljid} 351*8a006adbSBjoern A. Zeeb 352*8a006adbSBjoern A. Zeebfor jid in ${rjid} ${mjid} ${ljid}; do 353*8a006adbSBjoern A. Zeeb while : ; do 354*8a006adbSBjoern A. Zeeb x=`jls -as -j ${jid} jid 2>/dev/null` 355*8a006adbSBjoern A. Zeeb case "${x}" in 356*8a006adbSBjoern A. Zeeb jid=*) echo "Waiting for jail ${jid} to stop." >&2 357*8a006adbSBjoern A. Zeeb sleep 1 358*8a006adbSBjoern A. Zeeb continue 359*8a006adbSBjoern A. Zeeb ;; 360*8a006adbSBjoern A. Zeeb esac 361*8a006adbSBjoern A. Zeeb break 362*8a006adbSBjoern A. Zeeb done 363*8a006adbSBjoern A. Zeebdone 364*8a006adbSBjoern A. Zeeb 365*8a006adbSBjoern A. Zeebifconfig ${lmep}a destroy 366*8a006adbSBjoern A. Zeebifconfig ${mrep}a destroy 367*8a006adbSBjoern A. Zeeb 368*8a006adbSBjoern A. Zeeb# end 369