Home | History | Annotate | Line # | Download | only in route
t_change.sh revision 1.4.12.2
      1  1.4.12.2  pgoyette #	$NetBSD: t_change.sh,v 1.4.12.2 2017/01/07 08:56:56 pgoyette Exp $
      2       1.1     pooka #
      3       1.1     pooka # Copyright (c) 2011 The NetBSD Foundation, Inc.
      4       1.1     pooka # All rights reserved.
      5       1.1     pooka #
      6       1.1     pooka # Redistribution and use in source and binary forms, with or without
      7       1.1     pooka # modification, are permitted provided that the following conditions
      8       1.1     pooka # are met:
      9       1.1     pooka # 1. Redistributions of source code must retain the above copyright
     10       1.1     pooka #    notice, this list of conditions and the following disclaimer.
     11       1.1     pooka # 2. Redistributions in binary form must reproduce the above copyright
     12       1.1     pooka #    notice, this list of conditions and the following disclaimer in the
     13       1.1     pooka #    documentation and/or other materials provided with the distribution.
     14       1.1     pooka #
     15       1.1     pooka # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16       1.1     pooka # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17       1.1     pooka # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18       1.1     pooka # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19       1.1     pooka # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20       1.1     pooka # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21       1.1     pooka # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22       1.1     pooka # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23       1.1     pooka # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24       1.1     pooka # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25       1.1     pooka # POSSIBILITY OF SUCH DAMAGE.
     26       1.1     pooka #
     27       1.1     pooka 
     28       1.1     pooka netserver=\
     29  1.4.12.1  pgoyette "rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
     30       1.1     pooka export RUMP_SERVER=unix://commsock
     31       1.1     pooka 
     32  1.4.12.2  pgoyette DEBUG=${DEBUG:-false}
     33  1.4.12.1  pgoyette 
     34  1.4.12.1  pgoyette atf_test_case route_change_reject2blackhole cleanup
     35  1.4.12.1  pgoyette route_change_reject2blackhole_head()
     36       1.1     pooka {
     37       1.1     pooka 
     38       1.1     pooka 	atf_set "descr" "Change a reject route to blackhole"
     39       1.4     joerg 	atf_set "require.progs" "rump_server"
     40       1.1     pooka }
     41       1.1     pooka 
     42  1.4.12.1  pgoyette route_change_reject2blackhole_body()
     43       1.1     pooka {
     44       1.1     pooka 
     45       1.1     pooka 	atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
     46       1.1     pooka 
     47       1.1     pooka 	atf_check -s exit:0 -o ignore \
     48       1.1     pooka 	    rump.route add 207.46.197.32 127.0.0.1 -reject
     49       1.3      jmmv 	atf_check -s exit:0 -o match:UGHR -x \
     50       1.1     pooka 	    "rump.route -n show -inet | grep ^207.46"
     51       1.1     pooka 	atf_check -s exit:0 -o ignore \
     52       1.1     pooka 	    rump.route change 207.46.197.32 127.0.0.1 -blackhole
     53       1.3      jmmv 	atf_check -s exit:0 -o match:' UGHBS ' -e ignore -x \
     54  1.4.12.1  pgoyette 	    "rump.netstat -rn -f inet | grep ^207.46"
     55  1.4.12.1  pgoyette }
     56  1.4.12.1  pgoyette 
     57  1.4.12.1  pgoyette route_change_reject2blackhole_cleanup()
     58  1.4.12.1  pgoyette {
     59  1.4.12.1  pgoyette 
     60  1.4.12.1  pgoyette 	env RUMP_SERVER=unix://commsock rump.halt
     61  1.4.12.1  pgoyette }
     62  1.4.12.1  pgoyette 
     63  1.4.12.1  pgoyette atf_test_case route_change_gateway cleanup
     64  1.4.12.1  pgoyette route_change_gateway_head()
     65  1.4.12.1  pgoyette {
     66  1.4.12.1  pgoyette 
     67  1.4.12.1  pgoyette 	atf_set "descr" "Change the gateway of a route"
     68  1.4.12.1  pgoyette 	atf_set "require.progs" "rump_server"
     69  1.4.12.1  pgoyette }
     70  1.4.12.1  pgoyette 
     71  1.4.12.1  pgoyette route_change_gateway_body()
     72  1.4.12.1  pgoyette {
     73  1.4.12.1  pgoyette 
     74  1.4.12.1  pgoyette 	atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
     75  1.4.12.1  pgoyette 
     76  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 create
     77  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
     78  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24 up
     79  1.4.12.1  pgoyette 
     80  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
     81  1.4.12.1  pgoyette 	    rump.route add -net 192.168.0.0/24 10.0.0.1
     82  1.4.12.1  pgoyette 	atf_check -s exit:0 -o match:'10.0.0.1' -x \
     83  1.4.12.1  pgoyette 	    "rump.route -n show -inet | grep ^192.168"
     84  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
     85  1.4.12.1  pgoyette 	    rump.route change -net 192.168.0.0/24 10.0.0.254
     86  1.4.12.1  pgoyette 	atf_check -s exit:0 -o match:'10.0.0.254' -x \
     87  1.4.12.1  pgoyette 	    "rump.route -n show -inet | grep ^192.168"
     88  1.4.12.1  pgoyette }
     89  1.4.12.1  pgoyette 
     90  1.4.12.1  pgoyette route_change_gateway_cleanup()
     91  1.4.12.1  pgoyette {
     92  1.4.12.1  pgoyette 
     93  1.4.12.1  pgoyette 	env RUMP_SERVER=unix://commsock rump.halt
     94  1.4.12.1  pgoyette }
     95  1.4.12.1  pgoyette 
     96  1.4.12.1  pgoyette atf_test_case route_change_ifa cleanup
     97  1.4.12.1  pgoyette route_change_ifa_head()
     98  1.4.12.1  pgoyette {
     99  1.4.12.1  pgoyette 
    100  1.4.12.1  pgoyette 	atf_set "descr" "Change the ifa (local address) of a route"
    101  1.4.12.1  pgoyette 	atf_set "require.progs" "rump_server"
    102  1.4.12.1  pgoyette }
    103  1.4.12.1  pgoyette 
    104  1.4.12.1  pgoyette route_change_ifa_body()
    105  1.4.12.1  pgoyette {
    106  1.4.12.1  pgoyette 
    107  1.4.12.1  pgoyette 	atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
    108  1.4.12.1  pgoyette 
    109  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 create
    110  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
    111  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24
    112  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 alias 10.0.0.11/24
    113  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 up
    114  1.4.12.1  pgoyette 
    115  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
    116  1.4.12.1  pgoyette 	    rump.route add -net 192.168.0.0/24 10.0.0.1
    117  1.4.12.1  pgoyette 	atf_check -s exit:0 -o match:'10.0.0.1' -x \
    118  1.4.12.1  pgoyette 	    "rump.route -n show -inet | grep ^192.168"
    119  1.4.12.1  pgoyette 	$DEBUG && rump.route -n show -inet
    120  1.4.12.1  pgoyette 	cat >./expect <<-EOF
    121  1.4.12.1  pgoyette    route to: 192.168.0.1
    122  1.4.12.1  pgoyette destination: 192.168.0.0
    123  1.4.12.1  pgoyette        mask: 255.255.255.0
    124  1.4.12.1  pgoyette     gateway: 10.0.0.1
    125  1.4.12.1  pgoyette  local addr: 10.0.0.10
    126  1.4.12.1  pgoyette   interface: shmif0
    127  1.4.12.1  pgoyette       flags: <UP,GATEWAY,DONE,STATIC>
    128  1.4.12.1  pgoyette  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
    129  1.4.12.1  pgoyette 	EOF
    130  1.4.12.1  pgoyette 	rump.route -n get 192.168.0.1 > ./output
    131  1.4.12.1  pgoyette 	$DEBUG && cat ./expect ./output
    132  1.4.12.1  pgoyette 	sed -i '$d' ./output
    133  1.4.12.1  pgoyette 	atf_check -s exit:0 diff ./expect ./output
    134  1.4.12.1  pgoyette 
    135  1.4.12.1  pgoyette 	# Change the local address of the route
    136  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
    137  1.4.12.1  pgoyette 	    rump.route change -net 192.168.0.0/24 10.0.0.1 -ifa 10.0.0.11
    138  1.4.12.1  pgoyette 	$DEBUG && rump.route -n show -inet
    139  1.4.12.1  pgoyette 	cat >./expect <<-EOF
    140  1.4.12.1  pgoyette    route to: 192.168.0.1
    141  1.4.12.1  pgoyette destination: 192.168.0.0
    142  1.4.12.1  pgoyette        mask: 255.255.255.0
    143  1.4.12.1  pgoyette     gateway: 10.0.0.1
    144  1.4.12.1  pgoyette  local addr: 10.0.0.11
    145  1.4.12.1  pgoyette   interface: shmif0
    146  1.4.12.1  pgoyette       flags: <UP,GATEWAY,DONE,STATIC>
    147  1.4.12.1  pgoyette  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
    148  1.4.12.1  pgoyette 	EOF
    149  1.4.12.1  pgoyette 	rump.route -n get 192.168.0.1 > ./output
    150  1.4.12.1  pgoyette 	$DEBUG && cat ./expect ./output
    151  1.4.12.1  pgoyette 	sed -i '$d' ./output
    152  1.4.12.1  pgoyette 	atf_check -s exit:0 diff ./expect ./output
    153  1.4.12.1  pgoyette }
    154  1.4.12.1  pgoyette 
    155  1.4.12.1  pgoyette route_change_ifa_cleanup()
    156  1.4.12.1  pgoyette {
    157  1.4.12.1  pgoyette 
    158  1.4.12.1  pgoyette 	env RUMP_SERVER=unix://commsock rump.halt
    159  1.4.12.1  pgoyette }
    160  1.4.12.1  pgoyette 
    161  1.4.12.1  pgoyette atf_test_case route_change_ifp cleanup
    162  1.4.12.1  pgoyette route_change_ifp_head()
    163  1.4.12.1  pgoyette {
    164  1.4.12.1  pgoyette 
    165  1.4.12.1  pgoyette 	atf_set "descr" "Change a route based on an interface (ifp)"
    166  1.4.12.1  pgoyette 	atf_set "require.progs" "rump_server"
    167  1.4.12.1  pgoyette }
    168  1.4.12.1  pgoyette 
    169  1.4.12.1  pgoyette route_change_ifp_body()
    170  1.4.12.1  pgoyette {
    171  1.4.12.1  pgoyette 
    172  1.4.12.1  pgoyette 	atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
    173  1.4.12.1  pgoyette 
    174  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 create
    175  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
    176  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24 up
    177  1.4.12.1  pgoyette 
    178  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif1 create
    179  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus
    180  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24 up
    181  1.4.12.1  pgoyette 
    182  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
    183  1.4.12.1  pgoyette 	    rump.route add -net 192.168.0.0/24 10.0.0.1
    184  1.4.12.1  pgoyette 	atf_check -s exit:0 -o match:'10.0.0.1' -x \
    185  1.4.12.1  pgoyette 	    "rump.route -n show -inet | grep ^192.168"
    186  1.4.12.1  pgoyette 	$DEBUG && rump.route -n show -inet
    187  1.4.12.1  pgoyette 	cat >./expect <<-EOF
    188  1.4.12.1  pgoyette    route to: 192.168.0.1
    189  1.4.12.1  pgoyette destination: 192.168.0.0
    190  1.4.12.1  pgoyette        mask: 255.255.255.0
    191  1.4.12.1  pgoyette     gateway: 10.0.0.1
    192  1.4.12.1  pgoyette  local addr: 10.0.0.10
    193  1.4.12.1  pgoyette   interface: shmif0
    194  1.4.12.1  pgoyette       flags: <UP,GATEWAY,DONE,STATIC>
    195  1.4.12.1  pgoyette  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
    196  1.4.12.1  pgoyette 	EOF
    197  1.4.12.1  pgoyette 	rump.route -n get 192.168.0.1 > ./output
    198  1.4.12.1  pgoyette 	$DEBUG && cat ./expect ./output
    199  1.4.12.1  pgoyette 	sed -i '$d' ./output
    200  1.4.12.1  pgoyette 	atf_check -s exit:0 diff ./expect ./output
    201  1.4.12.1  pgoyette 
    202  1.4.12.1  pgoyette 	# Change a route based on an interface
    203  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
    204  1.4.12.1  pgoyette 	    rump.route change -net 192.168.0.0/24 10.0.0.1 -ifp shmif1
    205  1.4.12.1  pgoyette 	$DEBUG && rump.route -n show -inet
    206  1.4.12.1  pgoyette 	cat >./expect <<-EOF
    207  1.4.12.1  pgoyette    route to: 192.168.0.1
    208  1.4.12.1  pgoyette destination: 192.168.0.0
    209  1.4.12.1  pgoyette        mask: 255.255.255.0
    210  1.4.12.1  pgoyette     gateway: 10.0.0.1
    211  1.4.12.1  pgoyette  local addr: 10.0.0.11
    212  1.4.12.1  pgoyette   interface: shmif1
    213  1.4.12.1  pgoyette       flags: <UP,GATEWAY,DONE,STATIC>
    214  1.4.12.1  pgoyette  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
    215  1.4.12.1  pgoyette 	EOF
    216  1.4.12.1  pgoyette 	rump.route -n get 192.168.0.1 > ./output
    217  1.4.12.1  pgoyette 	$DEBUG && cat ./expect ./output
    218  1.4.12.1  pgoyette 	sed -i '$d' ./output
    219  1.4.12.1  pgoyette 	atf_check -s exit:0 diff ./expect ./output
    220  1.4.12.1  pgoyette }
    221  1.4.12.1  pgoyette 
    222  1.4.12.1  pgoyette route_change_ifp_cleanup()
    223  1.4.12.1  pgoyette {
    224  1.4.12.1  pgoyette 
    225  1.4.12.1  pgoyette 	env RUMP_SERVER=unix://commsock rump.halt
    226  1.4.12.1  pgoyette }
    227  1.4.12.1  pgoyette 
    228  1.4.12.1  pgoyette atf_test_case route_change_ifp_ifa cleanup
    229  1.4.12.1  pgoyette route_change_ifp_head()
    230  1.4.12.1  pgoyette {
    231  1.4.12.1  pgoyette 
    232  1.4.12.1  pgoyette 	atf_set "descr" "Change a route with -ifp and -ifa"
    233  1.4.12.1  pgoyette 	atf_set "require.progs" "rump_server"
    234  1.4.12.1  pgoyette }
    235  1.4.12.1  pgoyette 
    236  1.4.12.1  pgoyette route_change_ifp_ifa_body()
    237  1.4.12.1  pgoyette {
    238  1.4.12.1  pgoyette 
    239  1.4.12.1  pgoyette 	atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
    240  1.4.12.1  pgoyette 
    241  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 create
    242  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus
    243  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.10/24 up
    244  1.4.12.1  pgoyette 
    245  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif1 create
    246  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus
    247  1.4.12.1  pgoyette 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.0.11/24 up
    248  1.4.12.1  pgoyette 
    249  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
    250  1.4.12.1  pgoyette 	    rump.route add -net 192.168.0.0/24 10.0.0.1
    251  1.4.12.1  pgoyette 	atf_check -s exit:0 -o match:'10.0.0.1' -x \
    252  1.4.12.1  pgoyette 	    "rump.route -n show -inet | grep ^192.168"
    253  1.4.12.1  pgoyette 	$DEBUG && rump.route -n show -inet
    254  1.4.12.1  pgoyette 	cat >./expect <<-EOF
    255  1.4.12.1  pgoyette    route to: 192.168.0.1
    256  1.4.12.1  pgoyette destination: 192.168.0.0
    257  1.4.12.1  pgoyette        mask: 255.255.255.0
    258  1.4.12.1  pgoyette     gateway: 10.0.0.1
    259  1.4.12.1  pgoyette  local addr: 10.0.0.10
    260  1.4.12.1  pgoyette   interface: shmif0
    261  1.4.12.1  pgoyette       flags: <UP,GATEWAY,DONE,STATIC>
    262  1.4.12.1  pgoyette  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
    263  1.4.12.1  pgoyette 	EOF
    264  1.4.12.1  pgoyette 	rump.route -n get 192.168.0.1 > ./output
    265  1.4.12.1  pgoyette 	$DEBUG && cat ./expect ./output
    266  1.4.12.1  pgoyette 	sed -i '$d' ./output
    267  1.4.12.1  pgoyette 	atf_check -s exit:0 diff ./expect ./output
    268  1.4.12.1  pgoyette 
    269  1.4.12.1  pgoyette 	# Change a route with -ifa and -ifp
    270  1.4.12.1  pgoyette 	atf_check -s exit:0 -o ignore \
    271  1.4.12.1  pgoyette 	    rump.route change -net 192.168.0.0/24 -ifa 10.0.0.1 -ifp shmif1
    272  1.4.12.1  pgoyette 	$DEBUG && rump.route -n show -inet
    273  1.4.12.1  pgoyette 	cat >./expect <<-EOF
    274  1.4.12.1  pgoyette    route to: 192.168.0.1
    275  1.4.12.1  pgoyette destination: 192.168.0.0
    276  1.4.12.1  pgoyette        mask: 255.255.255.0
    277  1.4.12.1  pgoyette     gateway: 10.0.0.1
    278  1.4.12.1  pgoyette  local addr: 10.0.0.11
    279  1.4.12.1  pgoyette   interface: shmif1
    280  1.4.12.1  pgoyette       flags: <UP,GATEWAY,DONE,STATIC>
    281  1.4.12.1  pgoyette  recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
    282  1.4.12.1  pgoyette 	EOF
    283  1.4.12.1  pgoyette 	rump.route -n get 192.168.0.1 > ./output
    284  1.4.12.1  pgoyette 	$DEBUG && cat ./expect ./output
    285  1.4.12.1  pgoyette 	sed -i '$d' ./output
    286  1.4.12.1  pgoyette 	atf_check -s exit:0 diff ./expect ./output
    287       1.1     pooka }
    288       1.1     pooka 
    289  1.4.12.1  pgoyette route_change_ifp_ifa_cleanup()
    290       1.1     pooka {
    291       1.1     pooka 
    292       1.1     pooka 	env RUMP_SERVER=unix://commsock rump.halt
    293       1.1     pooka }
    294       1.1     pooka 
    295       1.1     pooka atf_init_test_cases()
    296       1.1     pooka {
    297       1.1     pooka 
    298  1.4.12.1  pgoyette 	atf_add_test_case route_change_reject2blackhole
    299  1.4.12.1  pgoyette 	atf_add_test_case route_change_gateway
    300  1.4.12.1  pgoyette 	atf_add_test_case route_change_ifa
    301  1.4.12.1  pgoyette 	atf_add_test_case route_change_ifp
    302  1.4.12.1  pgoyette 	atf_add_test_case route_change_ifp_ifa
    303       1.1     pooka }
    304