Home | History | Annotate | Line # | Download | only in mpls
      1 # $NetBSD: t_mpls_fw6.sh,v 1.5 2020/04/01 01:49:26 christos Exp $
      2 #
      3 # Copyright (c) 2015 The NetBSD Foundation, Inc.
      4 # All rights reserved.
      5 #
      6 # Redistribution and use in source and binary forms, with or without
      7 # modification, are permitted provided that the following conditions
      8 # are met:
      9 # 1. Redistributions of source code must retain the above copyright
     10 #    notice, this list of conditions and the following disclaimer.
     11 # 2. Redistributions in binary form must reproduce the above copyright
     12 #    notice, this list of conditions and the following disclaimer in the
     13 #    documentation and/or other materials provided with the distribution.
     14 #
     15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25 # POSSIBILITY OF SUCH DAMAGE.
     26 #
     27 
     28 # Test MPLS encap/decap and forwarding using INET6 as encapsulated protocol
     29 # Setup four routers connected like this: R1---R2---R3---R4--
     30 # Goal is to be able to ping from R1 the outermost interface of R4
     31 # Disable net.inet6.ip6.forwarding, enable net.mpls.forwarding
     32 # Add route on R1 in order to encapsulate into MPLS the IP6 packets with
     33 #     destination equal to R4 right hand side interface
     34 # Add MPLS routes on R2 in order to forward frames belonging to that FEC to R3
     35 # Add MPLS "POP" route on R3 for that FEC, pointing to R4
     36 # Do the same for the reverse direction (R4 to R1)
     37 # ping6 from R1 to R4 right hand side interface
     38 #
     39 # redo the test using IPv6 explicit null label
     40 
     41 atf_test_case mplsfw6 cleanup
     42 mplsfw6_head()
     43 {
     44 
     45 	atf_set "descr" "IP6/MPLS forwarding test using PHP"
     46 	atf_set "require.progs" "rump_server"
     47 }
     48 
     49 configservers()
     50 {
     51 
     52 	# Setup the first server
     53 	export RUMP_SERVER=${RUMP_SERVER1}
     54 	atf_check -s exit:0 rump.ifconfig shmif0 create
     55 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     56 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::1/64 alias
     57 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     58 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     59 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
     60 	atf_check -s exit:0 rump.route -q add -inet6 fd00:1234:0:3::/64 \
     61 	    -ifa fd00:1234::1 \
     62 	    -ifp mpls0 -tag 25 -inet6 fd00:1234::2
     63 
     64 	# Setup the second server
     65 	export RUMP_SERVER=${RUMP_SERVER2}
     66 	atf_check -s exit:0 rump.ifconfig shmif0 create
     67 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     68 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::2/64 alias
     69 	atf_check -s exit:0 rump.ifconfig shmif1 create
     70 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
     71 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:1::1/64 alias
     72 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     73 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     74 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
     75 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
     76 	atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30 \
     77 	    -inet6 fd00:1234:0:1::2
     78 	atf_check -s exit:0 rump.route -q add -mpls 27 -tag ${1} -inet6 \
     79 	    fd00:1234::1
     80 
     81 	# Setup the third server
     82 	export RUMP_SERVER=${RUMP_SERVER3}
     83 	atf_check -s exit:0 rump.ifconfig shmif0 create
     84 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
     85 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:1::2/64 alias
     86 	atf_check -s exit:0 rump.ifconfig shmif1 create
     87 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
     88 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:2::1/64 alias
     89 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     90 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
     91 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
     92 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
     93 	atf_check -s exit:0 rump.route -q add -mpls 30 -tag ${1} \
     94 	    -inet6 fd00:1234:0:2::2
     95 	atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27 \
     96 	    -inet6 fd00:1234:0:1::1
     97 
     98 	# Setup the fourth server
     99 	export RUMP_SERVER=${RUMP_SERVER4}
    100 	atf_check -s exit:0 rump.ifconfig shmif0 create
    101 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
    102 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:2::2/64 alias
    103 	atf_check -s exit:0 rump.ifconfig shmif1 create
    104 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
    105 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:3::1/64 alias
    106 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    107 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
    108 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
    109 	atf_check -s exit:0 rump.route -q add -inet6 fd00:1234::/64 \
    110 	    -ifa fd00:1234:0:2::2 \
    111 	    -ifp mpls0 -tag 26 -inet6 fd00:1234:0:2::1
    112 
    113 	unset RUMP_SERVER
    114 }
    115 
    116 doping()
    117 {
    118 
    119 	export RUMP_SERVER=${RUMP_SERVER1}
    120 	atf_check -s exit:0 \
    121 	    -o match:" bytes from fd00:1234::2, icmp_seq=" \
    122 	    rump.ping6 -n -o -X 2 fd00:1234::2
    123 	export RUMP_SERVER=${RUMP_SERVER2}
    124 	atf_check -s exit:0 \
    125 	    -o match:" bytes from fd00:1234:0:1::2, icmp_seq=" \
    126 	    rump.ping6 -n -o -X 2 fd00:1234:0:1::2
    127 	export RUMP_SERVER=${RUMP_SERVER3}
    128 	atf_check -s exit:0 \
    129 	    -o match:" bytes from fd00:1234:0:2::2, icmp_seq=" \
    130 	    rump.ping6 -n -o -X 2 fd00:1234:0:2::2
    131 	export RUMP_SERVER=${RUMP_SERVER1}
    132 	atf_check -s exit:0 \
    133 	    -o match:" bytes from fd00:1234:0:3::1, icmp_seq=" \
    134 	    rump.ping6 -n -o -X 2 fd00:1234:0:3::1
    135 	unset RUMP_SERVER
    136 }
    137 
    138 do_check_route()
    139 {
    140 
    141 	export RUMP_SERVER=${RUMP_SERVER1}
    142 	atf_check -s exit:0 \
    143 	    -o match:"^fd00:1234:0:3::/64.+fd00:1234::2.+25.+mpls0" \
    144 	    rump.netstat -nrT
    145 	unset RUMP_SERVER
    146 }
    147 
    148 mplsfw6_body()
    149 {
    150 
    151 	dostart
    152 	configservers 3
    153 	do_check_route
    154 	doping
    155 }
    156 
    157 mplsfw6_cleanup()
    158 {
    159 
    160 	docleanup
    161 }
    162 
    163 
    164 atf_test_case mplsfw6_expl cleanup
    165 mplsfw4_expl_head()
    166 {
    167 
    168 	atf_set "descr" "IP6/MPLS forwarding test using explicit NULL labels"
    169 	atf_set "require.progs" "rump_server"
    170 }
    171 
    172 mplsfw6_expl_body()
    173 {
    174 
    175 	dostart
    176 	configservers 2
    177 	do_check_route
    178 	doping
    179 }
    180 
    181 mplsfw6_expl_cleanup()
    182 {
    183 
    184 	docleanup
    185 }
    186 
    187 
    188 atf_init_test_cases()
    189 { 
    190 
    191 	atf_add_test_case mplsfw6
    192 	atf_add_test_case mplsfw6_expl
    193 } 
    194