Home | History | Annotate | Line # | Download | only in mpls
t_mpls_fw6.sh revision 1.3.14.2
      1  1.3.14.2  martin # $NetBSD: t_mpls_fw6.sh,v 1.3.14.2 2020/04/08 14:09:12 martin Exp $
      2       1.1  kefren #
      3       1.1  kefren # Copyright (c) 2015 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 MPLS encap/decap and forwarding using INET6 as encapsulated protocol
     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.inet6.ip6.forwarding, enable net.mpls.forwarding
     32       1.1  kefren # Add route on R1 in order to encapsulate into MPLS the IP6 packets with
     33       1.1  kefren #     destination equal to R4 right hand side interface
     34       1.1  kefren # Add MPLS routes on R2 in order to forward frames belonging to that FEC to R3
     35       1.1  kefren # Add MPLS "POP" route on R3 for that FEC, pointing to R4
     36       1.1  kefren # Do the same for the reverse direction (R4 to R1)
     37       1.1  kefren # ping6 from R1 to R4 right hand side interface
     38       1.1  kefren #
     39       1.1  kefren # redo the test using IPv6 explicit null label
     40       1.1  kefren 
     41       1.1  kefren atf_test_case mplsfw6 cleanup
     42       1.1  kefren mplsfw6_head()
     43       1.1  kefren {
     44       1.1  kefren 
     45       1.1  kefren 	atf_set "descr" "IP6/MPLS forwarding test using PHP"
     46       1.1  kefren 	atf_set "require.progs" "rump_server"
     47       1.1  kefren }
     48       1.1  kefren 
     49       1.1  kefren configservers()
     50       1.1  kefren {
     51       1.1  kefren 
     52       1.1  kefren 	# Setup the first server
     53       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER1}
     54       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
     55       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     56       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::1/64 alias
     57       1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     58       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     59       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
     60       1.1  kefren 	atf_check -s exit:0 rump.route -q add -inet6 fd00:1234:0:3::/64 \
     61       1.1  kefren 	    -ifa fd00:1234::1 \
     62       1.1  kefren 	    -ifp mpls0 -tag 25 -inet6 fd00:1234::2
     63       1.1  kefren 
     64       1.1  kefren 	# Setup the second server
     65       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER2}
     66       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
     67       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     68       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::2/64 alias
     69       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 create
     70       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
     71       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:1::1/64 alias
     72       1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     73       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     74       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
     75       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
     76       1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30 \
     77       1.1  kefren 	    -inet6 fd00:1234:0:1::2
     78       1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 27 -tag ${1} -inet6 \
     79       1.1  kefren 	    fd00:1234::1
     80       1.1  kefren 
     81       1.1  kefren 	# Setup the third server
     82       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER3}
     83       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
     84       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
     85       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:1::2/64 alias
     86       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 create
     87       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
     88       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:2::1/64 alias
     89       1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     90       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     91       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
     92       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
     93       1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 30 -tag ${1} \
     94       1.1  kefren 	    -inet6 fd00:1234:0:2::2
     95       1.1  kefren 	atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27 \
     96       1.1  kefren 	    -inet6 fd00:1234:0:1::1
     97       1.1  kefren 
     98       1.1  kefren 	# Setup the fourth server
     99       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER4}
    100       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 create
    101       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
    102       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:2::2/64 alias
    103       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 create
    104       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
    105       1.1  kefren 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:3::1/64 alias
    106       1.1  kefren 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    107       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
    108       1.1  kefren 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
    109       1.1  kefren 	atf_check -s exit:0 rump.route -q add -inet6 fd00:1234::/64 \
    110       1.1  kefren 	    -ifa fd00:1234:0:2::2 \
    111       1.1  kefren 	    -ifp mpls0 -tag 26 -inet6 fd00:1234:0:2::1
    112       1.1  kefren 
    113       1.1  kefren 	unset RUMP_SERVER
    114       1.1  kefren }
    115       1.1  kefren 
    116       1.1  kefren doping()
    117       1.1  kefren {
    118       1.1  kefren 
    119       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER1}
    120       1.1  kefren 	atf_check -s exit:0 \
    121       1.1  kefren 	    -o match:" bytes from fd00:1234::2, icmp_seq=" \
    122       1.2   ozaki 	    rump.ping6 -n -o -X 2 fd00:1234::2
    123       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER2}
    124       1.1  kefren 	atf_check -s exit:0 \
    125       1.1  kefren 	    -o match:" bytes from fd00:1234:0:1::2, icmp_seq=" \
    126       1.2   ozaki 	    rump.ping6 -n -o -X 2 fd00:1234:0:1::2
    127       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER3}
    128       1.1  kefren 	atf_check -s exit:0 \
    129       1.1  kefren 	    -o match:" bytes from fd00:1234:0:2::2, icmp_seq=" \
    130       1.2   ozaki 	    rump.ping6 -n -o -X 2 fd00:1234:0:2::2
    131       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER1}
    132       1.1  kefren 	atf_check -s exit:0 \
    133       1.1  kefren 	    -o match:" bytes from fd00:1234:0:3::1, icmp_seq=" \
    134       1.2   ozaki 	    rump.ping6 -n -o -X 2 fd00:1234:0:3::1
    135       1.1  kefren 	unset RUMP_SERVER
    136       1.1  kefren }
    137       1.1  kefren 
    138       1.1  kefren do_check_route()
    139       1.1  kefren {
    140       1.1  kefren 
    141       1.1  kefren 	export RUMP_SERVER=${RUMP_SERVER1}
    142       1.1  kefren 	atf_check -s exit:0 \
    143       1.1  kefren 	    -o match:"^fd00:1234:0:3::/64.+fd00:1234::2.+25.+mpls0" \
    144       1.1  kefren 	    rump.netstat -nrT
    145       1.1  kefren 	unset RUMP_SERVER
    146       1.1  kefren }
    147       1.1  kefren 
    148       1.1  kefren mplsfw6_body()
    149       1.1  kefren {
    150       1.1  kefren 
    151  1.3.14.2  martin 	dostart
    152       1.1  kefren 	configservers 3
    153       1.1  kefren 	do_check_route
    154       1.1  kefren 	doping
    155       1.1  kefren }
    156       1.1  kefren 
    157       1.1  kefren mplsfw6_cleanup()
    158       1.1  kefren {
    159       1.1  kefren 
    160       1.1  kefren 	docleanup
    161       1.1  kefren }
    162       1.1  kefren 
    163       1.1  kefren 
    164       1.1  kefren atf_test_case mplsfw6_expl cleanup
    165       1.1  kefren mplsfw4_expl_head()
    166       1.1  kefren {
    167       1.1  kefren 
    168       1.1  kefren 	atf_set "descr" "IP6/MPLS forwarding test using explicit NULL labels"
    169       1.1  kefren 	atf_set "require.progs" "rump_server"
    170       1.1  kefren }
    171       1.1  kefren 
    172       1.1  kefren mplsfw6_expl_body()
    173       1.1  kefren {
    174       1.1  kefren 
    175  1.3.14.2  martin 	dostart
    176       1.1  kefren 	configservers 2
    177       1.1  kefren 	do_check_route
    178       1.1  kefren 	doping
    179       1.1  kefren }
    180       1.1  kefren 
    181       1.1  kefren mplsfw6_expl_cleanup()
    182       1.1  kefren {
    183       1.1  kefren 
    184       1.1  kefren 	docleanup
    185       1.1  kefren }
    186       1.1  kefren 
    187       1.1  kefren 
    188       1.1  kefren atf_init_test_cases()
    189       1.1  kefren { 
    190       1.1  kefren 
    191       1.1  kefren 	atf_add_test_case mplsfw6
    192       1.1  kefren 	atf_add_test_case mplsfw6_expl
    193       1.1  kefren } 
    194