Home | History | Annotate | Line # | Download | only in mpls
t_rfc4182.sh revision 1.2
      1  1.2  kefren # $NetBSD: t_rfc4182.sh,v 1.2 2013/07/23 12:41:01 kefren Exp $
      2  1.1  kefren #
      3  1.1  kefren # Copyright (c) 2013 The NetBSD Foundation, Inc.
      4  1.1  kefren # All rights reserved.
      5  1.1  kefren #
      6  1.1  kefren # Redistribution and use in source and binary forms, with or without
      7  1.1  kefren # modification, are permitted provided that the following conditions
      8  1.1  kefren # are met:
      9  1.1  kefren # 1. Redistributions of source code must retain the above copyright
     10  1.1  kefren #    notice, this list of conditions and the following disclaimer.
     11  1.1  kefren # 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  kefren #    notice, this list of conditions and the following disclaimer in the
     13  1.1  kefren #    documentation and/or other materials provided with the distribution.
     14  1.1  kefren #
     15  1.1  kefren # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  kefren # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  kefren # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  kefren # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  kefren # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  kefren # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  kefren # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  kefren # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  kefren # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  kefren # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  kefren # POSSIBILITY OF SUCH DAMAGE.
     26  1.1  kefren #
     27  1.1  kefren 
     28  1.1  kefren # TEST RFC 4182
     29  1.1  kefren # Setup four routers connected like this: R1---R2---R3---R4--
     30  1.1  kefren # Goal is to be able to ping from R1 the outermost interface of R4
     31  1.1  kefren # Disable net.inet.ip.forwarding, enable net.mpls.forwarding
     32  1.1  kefren # Add route on R1 in order to encapsulate into MPLS the IP packets with
     33  1.1  kefren #     destination equal to R4 right hand side interface. Use two labels here:
     34  1.1  kefren #     25 and IPv6 Explicit NULL
     35  1.1  kefren # Add a double tagged MPLS route on R2 in order to forward frames belonging to
     36  1.1  kefren #     that FEC to R3, with IPv4 NULL being the most outermost one
     37  1.1  kefren # Add MPLS "POP" route on R3 for that FEC, pointing to R4
     38  1.1  kefren # Do the same for the reverse direction (R4 to R1)
     39  1.1  kefren # ping from R1 to R4 right hand side interface
     40  1.1  kefren 
     41  1.1  kefren 
     42  1.2  kefren RUMP_SERVER1=unix://./r1
     43  1.2  kefren RUMP_SERVER2=unix://./r2
     44  1.2  kefren RUMP_SERVER3=unix://./r3
     45  1.2  kefren RUMP_SERVER4=unix://./r4
     46  1.1  kefren 
     47  1.1  kefren RUMP_FLAGS=\
     48  1.1  kefren "-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_shmif"
     49  1.1  kefren 
     50  1.1  kefren atf_test_case rfc4182 cleanup
     51  1.1  kefren rfc4182_head()
     52  1.1  kefren {
     53  1.1  kefren 
     54  1.1  kefren 	atf_set "descr" "RFC 4182 conformance test"
     55  1.1  kefren 	atf_set "require.progs" "rump_server"
     56  1.1  kefren }
     57  1.1  kefren 
     58  1.1  kefren startservers()
     59  1.1  kefren {
     60  1.1  kefren 
     61  1.1  kefren 	ulimit -r 300
     62  1.1  kefren 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
     63  1.1  kefren 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2}
     64  1.1  kefren 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER3}
     65  1.1  kefren 	atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER4}
     66  1.1  kefren }
     67  1.1  kefren 
     68  1.1  kefren configservers()
     69  1.1  kefren {
     70  1.1  kefren 
     71  1.1  kefren 	# Setup the first server
     72  1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER1}
     73  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
     74  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     75  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
     76  1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     77  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     78  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
     79  1.1  kefren 	atf_check -s exit:0 rump.route -q add 10.0.4.0/24 -ifa 10.0.1.1 \
     80  1.1  kefren 	    -ifp mpls0 -tag 25,2 -inet 10.0.1.2
     81  1.1  kefren 
     82  1.1  kefren 	# Setup the second server
     83  1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER2}
     84  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
     85  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     86  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24
     87  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 create
     88  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
     89  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
     90  1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     91  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     92  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
     93  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
     94  1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30,0 -inet 10.0.2.2
     95  1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 27 -tag 3 -inet 10.0.1.1
     96  1.1  kefren 
     97  1.1  kefren 	# Setup the third server
     98  1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER3}
     99  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
    100  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
    101  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
    102  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 create
    103  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
    104  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
    105  1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    106  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
    107  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
    108  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
    109  1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 30 -tag 3 -inet 10.0.3.2
    110  1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27,0 -inet 10.0.2.1
    111  1.1  kefren 
    112  1.1  kefren 	# Setup the fourth server
    113  1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER4}
    114  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
    115  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
    116  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
    117  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 create
    118  1.2  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
    119  1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
    120  1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    121  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
    122  1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
    123  1.1  kefren 	atf_check -s exit:0 rump.route -q add 10.0.1.0/24 -ifa 10.0.3.2 \
    124  1.1  kefren 	    -ifp mpls0 -tag 26 -inet 10.0.3.1
    125  1.1  kefren 
    126  1.1  kefren 	unset RUMP_SERVER
    127  1.1  kefren }
    128  1.1  kefren 
    129  1.1  kefren doping()
    130  1.1  kefren {
    131  1.1  kefren 
    132  1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER1}
    133  1.1  kefren 	atf_check -s exit:0 -o match:"64 bytes from 10.0.4.1: icmp_seq=" \
    134  1.1  kefren 	    rump.ping -n -o -w 5 10.0.4.1
    135  1.1  kefren 	unset RUMP_SERVER
    136  1.1  kefren }
    137  1.1  kefren 
    138  1.1  kefren docleanup()
    139  1.1  kefren {
    140  1.1  kefren 
    141  1.1  kefren 	RUMP_SERVER=${RUMP_SERVER1} rump.halt
    142  1.1  kefren 	RUMP_SERVER=${RUMP_SERVER2} rump.halt
    143  1.1  kefren 	RUMP_SERVER=${RUMP_SERVER3} rump.halt
    144  1.1  kefren 	RUMP_SERVER=${RUMP_SERVER4} rump.halt
    145  1.1  kefren }
    146  1.1  kefren 
    147  1.1  kefren rfc4182_body()
    148  1.1  kefren {
    149  1.1  kefren 
    150  1.1  kefren 	startservers
    151  1.1  kefren 	configservers
    152  1.1  kefren 	doping
    153  1.1  kefren }
    154  1.1  kefren 
    155  1.1  kefren rfc4182_cleanup()
    156  1.1  kefren {
    157  1.1  kefren 
    158  1.1  kefren 	docleanup
    159  1.1  kefren }
    160  1.1  kefren 
    161  1.1  kefren atf_init_test_cases()
    162  1.1  kefren { 
    163  1.1  kefren 
    164  1.1  kefren 	atf_add_test_case rfc4182
    165  1.1  kefren } 
    166