t_mpls_fw64.sh revision 1.5 1 # $NetBSD: t_mpls_fw64.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.inet[6].ip[6].forwarding, enable net.mpls.forwarding
32 # Use IPv6 between R1-R2-R3 and IPv4 between R3-R4
33 # As we use IPv4 on last link we should use only expl.null there
34 # because implicit null will assume IPv4 (as the next-hop)
35 # But we can use impl null on R2-R1 link because stack will correctly
36 # guess IPv6 (from next-hop)
37 # Add route on R1 in order to encapsulate into MPLS the IP6 packets with
38 # destination equal to R4 right hand side interface
39 # Add MPLS routes on R2 in order to forward frames belonging to that FEC to R3
40 # Add MPLS expl.null route on R3 for that FEC, pointing to R4
41 # Do the same for the reverse direction (R4 to R1)
42 # ping6 from R1 to R4 right hand side interface
43
44
45 configservers()
46 {
47
48 # Setup the first server
49 export RUMP_SERVER=${RUMP_SERVER1}
50 atf_check -s exit:0 rump.ifconfig shmif0 create
51 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
52 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::1/64 alias
53 atf_check -s exit:0 rump.ifconfig mpls0 create up
54 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
55 atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
56 atf_check -s exit:0 rump.route -q add -inet6 fd00:1234:0:3::/64 \
57 -ifa fd00:1234::1 \
58 -ifp mpls0 -tag 25 -inet6 fd00:1234::2
59
60 # Setup the second server
61 export RUMP_SERVER=${RUMP_SERVER2}
62 atf_check -s exit:0 rump.ifconfig shmif0 create
63 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
64 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234::2/64 alias
65 atf_check -s exit:0 rump.ifconfig shmif1 create
66 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
67 atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:1::1/64 alias
68 atf_check -s exit:0 rump.ifconfig mpls0 create up
69 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
70 atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
71 atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
72 atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30 \
73 -inet6 fd00:1234:0:1::2
74 atf_check -s exit:0 rump.route -q add -mpls 27 -tag ${1} -inet6 \
75 fd00:1234::1
76
77 # Setup the third server
78 export RUMP_SERVER=${RUMP_SERVER3}
79 atf_check -s exit:0 rump.ifconfig shmif0 create
80 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
81 atf_check -s exit:0 rump.ifconfig shmif0 inet6 fd00:1234:0:1::2/64 alias
82 atf_check -s exit:0 rump.ifconfig shmif1 create
83 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
84 atf_check -s exit:0 rump.ifconfig shmif1 inet 10.0.3.1/24
85 atf_check -s exit:0 rump.ifconfig mpls0 create up
86 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
87 atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
88 atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
89 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
90 atf_check -s exit:0 rump.route -q add -mpls 30 -tag 2 \
91 -inet 10.0.3.2
92 atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27 \
93 -inet6 fd00:1234:0:1::1
94
95 # Setup the fourth server
96 export RUMP_SERVER=${RUMP_SERVER4}
97 atf_check -s exit:0 rump.ifconfig shmif0 create
98 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
99 atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.3.2
100 atf_check -s exit:0 rump.ifconfig shmif1 create
101 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
102 atf_check -s exit:0 rump.ifconfig shmif1 inet6 fd00:1234:0:3::1/64 alias
103 atf_check -s exit:0 rump.ifconfig mpls0 create up
104 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
105 atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=0
106 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
107 atf_check -s exit:0 rump.route -q add -inet6 fd00:1234::/64 \
108 -ifa fd00:1234:0:3::1 \
109 -ifp mpls0 -tag 26 -inet 10.0.3.1
110
111 unset RUMP_SERVER
112 }
113
114 doping()
115 {
116
117 export RUMP_SERVER=${RUMP_SERVER1}
118 atf_check -s exit:0 \
119 -o match:" bytes from fd00:1234::2, icmp_seq=" \
120 rump.ping6 -n -o -X 2 fd00:1234::2
121 export RUMP_SERVER=${RUMP_SERVER2}
122 atf_check -s exit:0 \
123 -o match:" bytes from fd00:1234:0:1::2, icmp_seq=" \
124 rump.ping6 -n -o -X 2 fd00:1234:0:1::2
125 export RUMP_SERVER=${RUMP_SERVER3}
126 atf_check -s exit:0 \
127 -o match:" bytes from 10.0.3.2: icmp_seq" \
128 rump.ping -n -o -w 2 10.0.3.2
129 export RUMP_SERVER=${RUMP_SERVER1}
130 atf_check -s exit:0 \
131 -o match:" bytes from fd00:1234:0:3::1, icmp_seq=" \
132 rump.ping6 -n -o -X 2 fd00:1234:0:3::1
133 unset RUMP_SERVER
134 }
135
136 do_check_route()
137 {
138
139 export RUMP_SERVER=${RUMP_SERVER1}
140 atf_check -s exit:0 \
141 -o match:"^fd00:1234:0:3::/64.+fd00:1234::2.+25.+mpls0" \
142 rump.netstat -nrT
143 unset RUMP_SERVER
144 }
145
146 atf_test_case mplsfw64_impl cleanup
147 mplsfw64_impl_head()
148 {
149
150 atf_set "descr" "IP6/MPLS test using impl. NULL labels in mixed env."
151 atf_set "require.progs" "rump_server"
152 }
153
154 mplsfw64_impl_body()
155 {
156
157 dostart
158 configservers 3
159 do_check_route
160 doping
161 }
162
163 mplsfw64_impl_cleanup()
164 {
165
166 docleanup
167 }
168
169
170 atf_test_case mplsfw64_expl cleanup
171 mplsfw64_expl_head()
172 {
173
174 atf_set "descr" "IP6/MPLS test using explicit NULL labels in mixed env."
175 atf_set "require.progs" "rump_server"
176 }
177
178 mplsfw64_expl_body()
179 {
180
181 dostart
182 configservers 2
183 do_check_route
184 doping
185 }
186
187 mplsfw64_expl_cleanup()
188 {
189
190 docleanup
191 }
192
193
194 atf_init_test_cases()
195 {
196
197 atf_add_test_case mplsfw64_impl
198 atf_add_test_case mplsfw64_expl
199 }
200