1 # $NetBSD: t_ldp_regen.sh,v 1.2 2013/07/27 14:36:39 kefren Exp $
3 # Copyright (c) 2013 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
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.
28 # IP/MPLS & LDP label reallocation test
29 # Create 4 routers connected like this: R1--R2--R3--R4--
30 # The goal is to push packets from R1 to the R4 shmif1 (the right one) interface
31 # Enable MPLS forwarding on R2
32 # Disable IP forwarding and enable MPLS forwarding on R3
33 # Start ldpd and wait for adjancencies to come up
34 # Add an alias on shmif1 on R4 for which we already have a route on R3
35 # Now: * R4 should install label IMPLNULL for that prefix
36 # * R3 should realloc the target label from IMPLNULL to something else
39 RUMP_SERVER1
=unix
://.
/r1
40 RUMP_SERVER2
=unix
://.
/r2
41 RUMP_SERVER3
=unix
://.
/r3
42 RUMP_SERVER4
=unix
://.
/r4
44 RUMP_LIBS
="-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_shmif"
47 atf_test_case ldp_regen cleanup
50 atf_set
"descr" "IP/MPLS and LDP label regeneration test"
51 atf_set
"require.progs" "rump_server"
52 atf_set
"use.fs" "true"
57 # Add new address on R4
58 RUMP_SERVER
=${RUMP_SERVER4} atf_check
-s exit:0 \
59 rump.ifconfig shmif1
10.0.5.1/24 alias
61 # Now ldpd on R5 should take notice of the new route and announce it
62 # to R4's ldpd. ldpd on R4 should verify that the next hop
63 # corresponds to its routing table and change its tag entry
64 RUMP_SERVER
=${RUMP_SERVER1} atf_check
-s exit:0 -o ignore
-e ignore \
65 rump.
ping -n -o -w 5 10.0.5.1
70 # allows us to run as normal user
73 atf_check
-s exit:0 rump_server
${RUMP_LIBS} ${RUMP_SERVER1}
74 atf_check
-s exit:0 rump_server
${RUMP_LIBS} ${RUMP_SERVER2}
75 atf_check
-s exit:0 rump_server
${RUMP_LIBS} ${RUMP_SERVER3}
76 atf_check
-s exit:0 rump_server
${RUMP_LIBS} ${RUMP_SERVER4}
79 export RUMPHIJACK
=path
=/rump
,socket
=all
,sysctl
=yes
80 export LD_PRELOAD
=/usr
/lib
/librumphijack.so
83 export RUMP_SERVER
=${RUMP_SERVER1}
84 atf_check
-s exit:0 rump.ifconfig shmif0 create
85 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom1
86 atf_check
-s exit:0 rump.ifconfig shmif0
10.0.1.1/24
87 atf_check
-s exit:0 rump.ifconfig mpls0 create up
88 atf_check
-s exit:0 rump.sysctl
-q -w net.inet.ip.forwarding
=0
89 atf_check
-s exit:0 rump.route
-q add
10.0.4.0/24 10.0.1.2
90 atf_check
-s exit:0 rump.route
-q add
10.0.5.0/24 10.0.1.2
91 atf_check
-s exit:0 /usr
/sbin
/ldpd
${LDP_FLAGS}
94 export RUMP_SERVER
=${RUMP_SERVER2}
95 atf_check
-s exit:0 rump.ifconfig shmif0 create
96 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom1
97 atf_check
-s exit:0 rump.ifconfig shmif0
10.0.1.2/24
98 atf_check
-s exit:0 rump.ifconfig shmif1 create
99 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr .
/shdom2
100 atf_check
-s exit:0 rump.ifconfig shmif1
10.0.2.1/24
101 atf_check
-s exit:0 rump.ifconfig mpls0 create up
102 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.accept
=1
103 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.forwarding
=1
104 # This one should still do ip forwarding because it announces IMPLNULL
105 # for the 10.0.1.0/24 subnet
106 atf_check
-s exit:0 rump.route
-q add
10.0.4.0/24 10.0.2.2
107 atf_check
-s exit:0 rump.route
-q add
10.0.5.0/24 10.0.2.2
108 atf_check
-s exit:0 /usr
/sbin
/ldpd
${LDP_FLAGS}
111 export RUMP_SERVER
=${RUMP_SERVER3}
112 atf_check
-s exit:0 rump.ifconfig shmif0 create
113 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom2
114 atf_check
-s exit:0 rump.ifconfig shmif0
10.0.2.2/24
115 atf_check
-s exit:0 rump.ifconfig shmif1 create
116 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr .
/shdom3
117 atf_check
-s exit:0 rump.ifconfig shmif1
10.0.3.1/24
118 atf_check
-s exit:0 rump.ifconfig mpls0 create up
119 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.accept
=1
120 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.forwarding
=1
121 atf_check
-s exit:0 rump.sysctl
-q -w net.inet.ip.forwarding
=0
122 atf_check
-s exit:0 rump.route
-q add
10.0.1.0/24 10.0.2.1
123 atf_check
-s exit:0 rump.route
-q add
10.0.4.0/24 10.0.3.2
124 atf_check
-s exit:0 rump.route
-q add
10.0.5.0/24 10.0.3.2
125 atf_check
-s exit:0 /usr
/sbin
/ldpd
${LDP_FLAGS}
127 # Setup fourth server
128 export RUMP_SERVER
=${RUMP_SERVER4}
129 atf_check
-s exit:0 rump.ifconfig shmif0 create
130 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom3
131 atf_check
-s exit:0 rump.ifconfig shmif0
10.0.3.2/24
132 atf_check
-s exit:0 rump.ifconfig shmif1 create
133 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr .
/shdom4
134 atf_check
-s exit:0 rump.ifconfig shmif1
10.0.4.1/24
135 atf_check
-s exit:0 rump.sysctl
-q -w net.inet.ip.forwarding
=0
136 atf_check
-s exit:0 rump.ifconfig mpls0 create up
137 atf_check
-s exit:0 rump.route
-q add
10.0.1.0/24 10.0.3.1
138 atf_check
-s exit:0 /usr
/sbin
/ldpd
${LDP_FLAGS}
147 RUMP_SERVER
=${RUMP_SERVER1} atf_check
-s exit:0 -o ignore
-e ignore \
148 rump.
ping -o -w 60 10.0.4.1
153 RUMP_SERVER
=${RUMP_SERVER1} rump.halt
154 RUMP_SERVER
=${RUMP_SERVER2} rump.halt
155 RUMP_SERVER
=${RUMP_SERVER3} rump.halt
156 RUMP_SERVER
=${RUMP_SERVER4} rump.halt
166 ldp_regen_cleanup
() {
171 atf_init_test_cases
() {
173 atf_add_test_case ldp_regen