]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/netbsd-tests/net/mpls/t_rfc4182.sh
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / netbsd-tests / net / mpls / t_rfc4182.sh
1 # $NetBSD: t_rfc4182.sh,v 1.3 2014/03/18 18:20:44 riastradh Exp $
2 #
3 # Copyright (c) 2013 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 RFC 4182
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.ip.forwarding, enable net.mpls.forwarding
32 # Add route on R1 in order to encapsulate into MPLS the IP packets with
33 #     destination equal to R4 right hand side interface. Use two labels here:
34 #     25 and IPv6 Explicit NULL
35 # Add a double tagged MPLS route on R2 in order to forward frames belonging to
36 #     that FEC to R3, with IPv4 NULL being the most outermost one
37 # Add MPLS "POP" route on R3 for that FEC, pointing to R4
38 # Do the same for the reverse direction (R4 to R1)
39 # ping from R1 to R4 right hand side interface
40
41
42 RUMP_SERVER1=unix://./r1
43 RUMP_SERVER2=unix://./r2
44 RUMP_SERVER3=unix://./r3
45 RUMP_SERVER4=unix://./r4
46
47 RUMP_FLAGS=\
48 "-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_shmif"
49
50 atf_test_case rfc4182 cleanup
51 rfc4182_head()
52 {
53
54         atf_set "descr" "RFC 4182 conformance test"
55         atf_set "require.progs" "rump_server"
56 }
57
58 startservers()
59 {
60
61         ulimit -r 300
62         atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
63         atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2}
64         atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER3}
65         atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER4}
66 }
67
68 configservers()
69 {
70
71         # Setup the first server
72         export RUMP_SERVER=${RUMP_SERVER1}
73         atf_check -s exit:0 rump.ifconfig shmif0 create
74         atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
75         atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
76         atf_check -s exit:0 rump.ifconfig mpls0 create up
77         atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
78         atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
79         atf_check -s exit:0 rump.route -q add 10.0.4.0/24 -ifa 10.0.1.1 \
80             -ifp mpls0 -tag 25,2 -inet 10.0.1.2
81
82         # Setup the second server
83         export RUMP_SERVER=${RUMP_SERVER2}
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.2/24
87         atf_check -s exit:0 rump.ifconfig shmif1 create
88         atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
89         atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
90         atf_check -s exit:0 rump.ifconfig mpls0 create up
91         atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
92         atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
93         atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
94         atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30,0 -inet 10.0.2.2
95         atf_check -s exit:0 rump.route -q add -mpls 27 -tag 3 -inet 10.0.1.1
96
97         # Setup the third server
98         export RUMP_SERVER=${RUMP_SERVER3}
99         atf_check -s exit:0 rump.ifconfig shmif0 create
100         atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
101         atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
102         atf_check -s exit:0 rump.ifconfig shmif1 create
103         atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
104         atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
105         atf_check -s exit:0 rump.ifconfig mpls0 create up
106         atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
107         atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
108         atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
109         atf_check -s exit:0 rump.route -q add -mpls 30 -tag 3 -inet 10.0.3.2
110         atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27,0 -inet 10.0.2.1
111
112         # Setup the fourth server
113         export RUMP_SERVER=${RUMP_SERVER4}
114         atf_check -s exit:0 rump.ifconfig shmif0 create
115         atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
116         atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
117         atf_check -s exit:0 rump.ifconfig shmif1 create
118         atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
119         atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
120         atf_check -s exit:0 rump.ifconfig mpls0 create up
121         atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
122         atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
123         atf_check -s exit:0 rump.route -q add 10.0.1.0/24 -ifa 10.0.3.2 \
124             -ifp mpls0 -tag 26 -inet 10.0.3.1
125
126         unset RUMP_SERVER
127 }
128
129 doping()
130 {
131
132         export RUMP_SERVER=${RUMP_SERVER1}
133         atf_check -s exit:0 -o match:"64 bytes from 10.0.4.1: icmp_seq=" \
134             rump.ping -n -o -w 5 10.0.4.1
135         unset RUMP_SERVER
136 }
137
138 docleanup()
139 {
140
141         RUMP_SERVER=${RUMP_SERVER1} rump.halt
142         RUMP_SERVER=${RUMP_SERVER2} rump.halt
143         RUMP_SERVER=${RUMP_SERVER3} rump.halt
144         RUMP_SERVER=${RUMP_SERVER4} rump.halt
145 }
146
147 rfc4182_body()
148 {
149
150         startservers
151         configservers
152         doping
153 }
154
155 rfc4182_cleanup()
156 {
157
158         docleanup
159 }
160
161 atf_init_test_cases()
162
163
164         atf_add_test_case rfc4182
165