1 # $NetBSD: t_mpls_fw64.sh,v 1.2 2015/08/07 00:50:12 ozaki-r Exp $
3 # Copyright (c) 2015 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 # 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
45 RUMP_SERVER1
=unix
://.
/r1
46 RUMP_SERVER2
=unix
://.
/r2
47 RUMP_SERVER3
=unix
://.
/r3
48 RUMP_SERVER4
=unix
://.
/r4
51 "-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif"
57 atf_check
-s exit:0 rump_server
${RUMP_FLAGS6} ${RUMP_SERVER1}
58 atf_check
-s exit:0 rump_server
${RUMP_FLAGS6} ${RUMP_SERVER2}
59 atf_check
-s exit:0 rump_server
${RUMP_FLAGS6} ${RUMP_SERVER3}
60 atf_check
-s exit:0 rump_server
${RUMP_FLAGS6} ${RUMP_SERVER4}
66 # Setup the first server
67 export RUMP_SERVER
=${RUMP_SERVER1}
68 atf_check
-s exit:0 rump.ifconfig shmif0 create
69 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom1
70 atf_check
-s exit:0 rump.ifconfig shmif0 inet6 fd00
:1234::1/64 alias
71 atf_check
-s exit:0 rump.ifconfig mpls0 create up
72 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.accept
=1
73 atf_check
-s exit:0 rump.sysctl
-q -w net.inet6.ip6.forwarding
=0
74 atf_check
-s exit:0 rump.route
-q add
-inet6 fd00
:1234:0:3::/64 \
76 -ifp mpls0
-tag 25 -inet6 fd00
:1234::2
78 # Setup the second server
79 export RUMP_SERVER
=${RUMP_SERVER2}
80 atf_check
-s exit:0 rump.ifconfig shmif0 create
81 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom1
82 atf_check
-s exit:0 rump.ifconfig shmif0 inet6 fd00
:1234::2/64 alias
83 atf_check
-s exit:0 rump.ifconfig shmif1 create
84 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr .
/shdom2
85 atf_check
-s exit:0 rump.ifconfig shmif1 inet6 fd00
:1234:0:1::1/64 alias
86 atf_check
-s exit:0 rump.ifconfig mpls0 create up
87 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.accept
=1
88 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.forwarding
=1
89 atf_check
-s exit:0 rump.sysctl
-q -w net.inet6.ip6.forwarding
=0
90 atf_check
-s exit:0 rump.route
-q add
-mpls 25 -tag 30 \
91 -inet6 fd00
:1234:0:1::2
92 atf_check
-s exit:0 rump.route
-q add
-mpls 27 -tag ${1} -inet6 \
95 # Setup the third server
96 export RUMP_SERVER
=${RUMP_SERVER3}
97 atf_check
-s exit:0 rump.ifconfig shmif0 create
98 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom2
99 atf_check
-s exit:0 rump.ifconfig shmif0 inet6 fd00
:1234:0:1::2/64 alias
100 atf_check
-s exit:0 rump.ifconfig shmif1 create
101 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr .
/shdom3
102 atf_check
-s exit:0 rump.ifconfig shmif1 inet
10.0.3.1/24
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.mpls.forwarding
=1
106 atf_check
-s exit:0 rump.sysctl
-q -w net.inet6.ip6.forwarding
=0
107 atf_check
-s exit:0 rump.sysctl
-q -w net.inet.ip.forwarding
=0
108 atf_check
-s exit:0 rump.route
-q add
-mpls 30 -tag 2 \
110 atf_check
-s exit:0 rump.route
-q add
-mpls 26 -tag 27 \
111 -inet6 fd00
:1234:0:1::1
113 # Setup the fourth server
114 export RUMP_SERVER
=${RUMP_SERVER4}
115 atf_check
-s exit:0 rump.ifconfig shmif0 create
116 atf_check
-s exit:0 rump.ifconfig shmif0 linkstr .
/shdom3
117 atf_check
-s exit:0 rump.ifconfig shmif0 inet
10.0.3.2
118 atf_check
-s exit:0 rump.ifconfig shmif1 create
119 atf_check
-s exit:0 rump.ifconfig shmif1 linkstr .
/shdom4
120 atf_check
-s exit:0 rump.ifconfig shmif1 inet6 fd00
:1234:0:3::1/64 alias
121 atf_check
-s exit:0 rump.ifconfig mpls0 create up
122 atf_check
-s exit:0 rump.sysctl
-q -w net.mpls.accept
=1
123 atf_check
-s exit:0 rump.sysctl
-q -w net.inet6.ip6.forwarding
=0
124 atf_check
-s exit:0 rump.sysctl
-q -w net.inet.ip.forwarding
=0
125 atf_check
-s exit:0 rump.route
-q add
-inet6 fd00
:1234::/64 \
126 -ifa fd00
:1234:0:3::1 \
127 -ifp mpls0
-tag 26 -inet 10.0.3.1
135 export RUMP_SERVER
=${RUMP_SERVER1}
136 atf_check
-s exit:0 \
137 -o match
:" bytes from fd00:1234::2, icmp_seq=" \
138 rump.ping6
-n -o -X 2 fd00
:1234::2
139 export RUMP_SERVER
=${RUMP_SERVER2}
140 atf_check
-s exit:0 \
141 -o match
:" bytes from fd00:1234:0:1::2, icmp_seq=" \
142 rump.ping6
-n -o -X 2 fd00
:1234:0:1::2
143 export RUMP_SERVER
=${RUMP_SERVER3}
144 atf_check
-s exit:0 \
145 -o match
:" bytes from 10.0.3.2: icmp_seq" \
146 rump.
ping -n -o -w 2 10.0.3.2
147 export RUMP_SERVER
=${RUMP_SERVER1}
148 atf_check
-s exit:0 \
149 -o match
:" bytes from fd00:1234:0:3::1, icmp_seq=" \
150 rump.ping6
-n -o -X 2 fd00
:1234:0:3::1
157 export RUMP_SERVER
=${RUMP_SERVER1}
158 atf_check
-s exit:0 \
159 -o match
:"^fd00:1234:0:3::/64.+fd00:1234::2.+25.+mpls0" \
167 RUMP_SERVER
=${RUMP_SERVER1} rump.halt
168 RUMP_SERVER
=${RUMP_SERVER2} rump.halt
169 RUMP_SERVER
=${RUMP_SERVER3} rump.halt
170 RUMP_SERVER
=${RUMP_SERVER4} rump.halt
173 atf_test_case mplsfw64_impl cleanup
177 atf_set
"descr" "IP6/MPLS test using impl. NULL labels in mixed env."
178 atf_set
"require.progs" "rump_server"
190 mplsfw64_impl_cleanup
()
197 atf_test_case mplsfw64_expl cleanup
201 atf_set
"descr" "IP6/MPLS test using explicit NULL labels in mixed env."
202 atf_set
"require.progs" "rump_server"
214 mplsfw64_expl_cleanup
()
221 atf_init_test_cases
()
224 atf_add_test_case mplsfw64_impl
225 atf_add_test_case mplsfw64_expl