t_mpls_fw.sh revision 1.7 1 # $NetBSD: t_mpls_fw.sh,v 1.7 2020/04/01 01:49:26 christos 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 MPLS encap/decap and forwarding using INET 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.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
34 # Add MPLS routes on R2 in order to forward frames belonging to that FEC to R3
35 # Add MPLS "POP" route on R3 for that FEC, pointing to R4
36 # Do the same for the reverse direction (R4 to R1)
37 # ping from R1 to R4 right hand side interface
38
39 atf_test_case mplsfw4 cleanup
40 mplsfw4_head()
41 {
42
43 atf_set "descr" "IP/MPLS forwarding test using PHP"
44 atf_set "require.progs" "rump_server"
45 }
46
47 configservers()
48 {
49
50 # Setup the first server
51 export RUMP_SERVER=${RUMP_SERVER1}
52 atf_check -s exit:0 rump.ifconfig shmif0 create
53 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
54 atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
55 atf_check -s exit:0 rump.ifconfig mpls0 create up
56 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
57 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
58 atf_check -s exit:0 rump.route -q add 10.0.4.0/24 -ifa 10.0.1.1 \
59 -ifp mpls0 -tag 25 -inet 10.0.1.2
60
61 # Setup the second server
62 export RUMP_SERVER=${RUMP_SERVER2}
63 atf_check -s exit:0 rump.ifconfig shmif0 create
64 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
65 atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24
66 atf_check -s exit:0 rump.ifconfig shmif1 create
67 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
68 atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
69 atf_check -s exit:0 rump.ifconfig mpls0 create up
70 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
71 atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
72 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
73 atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30 -inet 10.0.2.2
74 atf_check -s exit:0 rump.route -q add -mpls 27 -tag ${1} -inet 10.0.1.1
75
76 # Setup the third server
77 export RUMP_SERVER=${RUMP_SERVER3}
78 atf_check -s exit:0 rump.ifconfig shmif0 create
79 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
80 atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
81 atf_check -s exit:0 rump.ifconfig shmif1 create
82 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
83 atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
84 atf_check -s exit:0 rump.ifconfig mpls0 create up
85 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
86 atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
87 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
88 atf_check -s exit:0 rump.route -q add -mpls 30 -tag ${1} -inet 10.0.3.2
89 atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27 -inet 10.0.2.1
90
91 # Setup the fourth server
92 export RUMP_SERVER=${RUMP_SERVER4}
93 atf_check -s exit:0 rump.ifconfig shmif0 create
94 atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
95 atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
96 atf_check -s exit:0 rump.ifconfig shmif1 create
97 atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
98 atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
99 atf_check -s exit:0 rump.ifconfig mpls0 create up
100 atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
101 atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
102 atf_check -s exit:0 rump.route -q add 10.0.1.0/24 -ifa 10.0.3.2 \
103 -ifp mpls0 -tag 26 -inet 10.0.3.1
104
105 unset RUMP_SERVER
106 }
107
108 doping()
109 {
110
111 export RUMP_SERVER=${RUMP_SERVER1}
112 atf_check -s exit:0 -o match:"64 bytes from 10.0.4.1: icmp_seq=" \
113 rump.ping -n -o -w 5 10.0.4.1
114 unset RUMP_SERVER
115 }
116
117 mplsfw4_body()
118 {
119
120 dostart
121 configservers 3
122 doping
123 }
124
125 mplsfw4_cleanup()
126 {
127
128 docleanup
129 }
130
131
132 atf_test_case mplsfw4_expl cleanup
133 mplsfw4_expl_head()
134 {
135
136 atf_set "descr" "IP/MPLS forwarding test using explicit NULL labels"
137 atf_set "require.progs" "rump_server"
138 }
139
140 mplsfw4_expl_body()
141 {
142
143 dostart
144 configservers 0
145 doping
146 }
147
148 mplsfw4_expl_cleanup()
149 {
150
151 docleanup
152 }
153
154
155 atf_init_test_cases()
156 {
157
158 atf_add_test_case mplsfw4
159 atf_add_test_case mplsfw4_expl
160 }
161