Home | History | Annotate | Line # | Download | only in mpls
t_ldp_regen.sh revision 1.3.8.2
      1  1.3.8.2  tls # $NetBSD: t_ldp_regen.sh,v 1.3.8.2 2014/08/20 00:04:52 tls Exp $
      2  1.3.8.2  tls #
      3  1.3.8.2  tls # Copyright (c) 2013 The NetBSD Foundation, Inc.
      4  1.3.8.2  tls # All rights reserved.
      5  1.3.8.2  tls #
      6  1.3.8.2  tls # Redistribution and use in source and binary forms, with or without
      7  1.3.8.2  tls # modification, are permitted provided that the following conditions
      8  1.3.8.2  tls # are met:
      9  1.3.8.2  tls # 1. Redistributions of source code must retain the above copyright
     10  1.3.8.2  tls #    notice, this list of conditions and the following disclaimer.
     11  1.3.8.2  tls # 2. Redistributions in binary form must reproduce the above copyright
     12  1.3.8.2  tls #    notice, this list of conditions and the following disclaimer in the
     13  1.3.8.2  tls #    documentation and/or other materials provided with the distribution.
     14  1.3.8.2  tls #
     15  1.3.8.2  tls # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.3.8.2  tls # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.3.8.2  tls # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.3.8.2  tls # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.3.8.2  tls # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.3.8.2  tls # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.3.8.2  tls # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.3.8.2  tls # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.3.8.2  tls # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.3.8.2  tls # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.3.8.2  tls # POSSIBILITY OF SUCH DAMAGE.
     26  1.3.8.2  tls #
     27  1.3.8.2  tls 
     28  1.3.8.2  tls # IP/MPLS & LDP label reallocation test
     29  1.3.8.2  tls # Create 4 routers connected like this: R1--R2--R3--R4--
     30  1.3.8.2  tls # The goal is to push packets from R1 to the R4 shmif1 (the right one) interface
     31  1.3.8.2  tls # Enable MPLS forwarding on R2
     32  1.3.8.2  tls # Disable IP forwarding and enable MPLS forwarding on R3
     33  1.3.8.2  tls # Start ldpd and wait for adjancencies to come up
     34  1.3.8.2  tls # Add an alias on shmif1 on R4 for which we already have a route on R3
     35  1.3.8.2  tls # Now: * R4 should install label IMPLNULL for that prefix
     36  1.3.8.2  tls #      * R3 should realloc the target label from IMPLNULL to something else
     37  1.3.8.2  tls 
     38  1.3.8.2  tls 
     39  1.3.8.2  tls RUMP_SERVER1=unix://./r1
     40  1.3.8.2  tls RUMP_SERVER2=unix://./r2
     41  1.3.8.2  tls RUMP_SERVER3=unix://./r3
     42  1.3.8.2  tls RUMP_SERVER4=unix://./r4
     43  1.3.8.2  tls 
     44  1.3.8.2  tls RUMP_LIBS="-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif"
     45  1.3.8.2  tls LDP_FLAGS=""
     46  1.3.8.2  tls 
     47  1.3.8.2  tls atf_test_case ldp_regen cleanup
     48  1.3.8.2  tls ldp_regen_head() {
     49  1.3.8.2  tls 
     50  1.3.8.2  tls 	atf_set "descr" "IP/MPLS and LDP label regeneration test"
     51  1.3.8.2  tls 	atf_set "require.progs" "rump_server"
     52  1.3.8.2  tls 	atf_set "use.fs" "true"
     53  1.3.8.2  tls }
     54  1.3.8.2  tls 
     55  1.3.8.2  tls newaddr_and_ping() {
     56  1.3.8.2  tls 
     57  1.3.8.2  tls 	# Add new address on R4
     58  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER4} atf_check -s exit:0 \
     59  1.3.8.2  tls 		rump.ifconfig shmif1 10.0.5.1/24 alias
     60  1.3.8.2  tls 
     61  1.3.8.2  tls 	# Now ldpd on R5 should take notice of the new route and announce it
     62  1.3.8.2  tls 	# to R4's ldpd. ldpd on R4 should verify that the next hop
     63  1.3.8.2  tls 	# corresponds to its routing table and change its tag entry
     64  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \
     65  1.3.8.2  tls 		rump.ping -n -o -w 5 10.0.5.1
     66  1.3.8.2  tls }
     67  1.3.8.2  tls 
     68  1.3.8.2  tls create_servers() {
     69  1.3.8.2  tls 
     70  1.3.8.2  tls 	# allows us to run as normal user
     71  1.3.8.2  tls 	ulimit -r 400
     72  1.3.8.2  tls 
     73  1.3.8.2  tls 	atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER1}
     74  1.3.8.2  tls 	atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER2}
     75  1.3.8.2  tls 	atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER3}
     76  1.3.8.2  tls 	atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER4}
     77  1.3.8.2  tls 
     78  1.3.8.2  tls 	# LDP HIJACK
     79  1.3.8.2  tls 	export RUMPHIJACK=path=/rump,socket=all,sysctl=yes
     80  1.3.8.2  tls 	export LD_PRELOAD=/usr/lib/librumphijack.so
     81  1.3.8.2  tls 
     82  1.3.8.2  tls 	# Setup first server
     83  1.3.8.2  tls 	export RUMP_SERVER=${RUMP_SERVER1}
     84  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 create
     85  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     86  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
     87  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig mpls0 create up
     88  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
     89  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.1.2
     90  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.1.2
     91  1.3.8.2  tls 	atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
     92  1.3.8.2  tls 
     93  1.3.8.2  tls 	# Setup second server
     94  1.3.8.2  tls 	export RUMP_SERVER=${RUMP_SERVER2}
     95  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 create
     96  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
     97  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24
     98  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 create
     99  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
    100  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
    101  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    102  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
    103  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
    104  1.3.8.2  tls 	# This one should still do ip forwarding because it announces IMPLNULL
    105  1.3.8.2  tls 	# for the 10.0.1.0/24 subnet
    106  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.2.2
    107  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.2.2
    108  1.3.8.2  tls 	atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
    109  1.3.8.2  tls 
    110  1.3.8.2  tls 	# Setup third server
    111  1.3.8.2  tls 	export RUMP_SERVER=${RUMP_SERVER3}
    112  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 create
    113  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
    114  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
    115  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 create
    116  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
    117  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
    118  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    119  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
    120  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
    121  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
    122  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.1.0/24 10.0.2.1
    123  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.3.2
    124  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.3.2
    125  1.3.8.2  tls 	atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
    126  1.3.8.2  tls 
    127  1.3.8.2  tls 	# Setup fourth server
    128  1.3.8.2  tls 	export RUMP_SERVER=${RUMP_SERVER4}
    129  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 create
    130  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
    131  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
    132  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 create
    133  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
    134  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
    135  1.3.8.2  tls 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
    136  1.3.8.2  tls 	atf_check -s exit:0 rump.ifconfig mpls0 create up
    137  1.3.8.2  tls 	atf_check -s exit:0 rump.route -q add 10.0.1.0/24 10.0.3.1
    138  1.3.8.2  tls 	atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
    139  1.3.8.2  tls 
    140  1.3.8.2  tls 	unset RUMP_SERVER
    141  1.3.8.2  tls 	unset LD_PRELOAD
    142  1.3.8.2  tls 	unset RUMPHIJACK
    143  1.3.8.2  tls }
    144  1.3.8.2  tls 
    145  1.3.8.2  tls wait_ldp_ok() {
    146  1.3.8.2  tls 
    147  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \
    148  1.3.8.2  tls 		rump.ping -o -w 60 10.0.4.1
    149  1.3.8.2  tls }
    150  1.3.8.2  tls 
    151  1.3.8.2  tls docleanup() {
    152  1.3.8.2  tls 
    153  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER1} rump.halt
    154  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER2} rump.halt
    155  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER3} rump.halt
    156  1.3.8.2  tls 	RUMP_SERVER=${RUMP_SERVER4} rump.halt
    157  1.3.8.2  tls }
    158  1.3.8.2  tls 
    159  1.3.8.2  tls ldp_regen_body() {
    160  1.3.8.2  tls 
    161  1.3.8.2  tls 	create_servers
    162  1.3.8.2  tls 	wait_ldp_ok
    163  1.3.8.2  tls 	newaddr_and_ping
    164  1.3.8.2  tls }
    165  1.3.8.2  tls 
    166  1.3.8.2  tls ldp_regen_cleanup() {
    167  1.3.8.2  tls 
    168  1.3.8.2  tls 	docleanup
    169  1.3.8.2  tls }
    170  1.3.8.2  tls 
    171  1.3.8.2  tls atf_init_test_cases() {
    172  1.3.8.2  tls 
    173  1.3.8.2  tls 	atf_add_test_case ldp_regen
    174  1.3.8.2  tls }
    175