]>
Commit | Line | Data |
---|---|---|
d7c5426b | 1 | AT_BANNER([datapath-sanity]) |
69c2bdfe | 2 | |
d7c5426b | 3 | AT_SETUP([datapath - ping between two ports]) |
cf7659b6 JR |
4 | OVS_TRAFFIC_VSWITCHD_START() |
5 | ||
6 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
69c2bdfe AZ |
7 | |
8 | ADD_NAMESPACES(at_ns0, at_ns1) | |
9 | ||
10 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
11 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
12 | ||
de22d08f | 13 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 14 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
15 | ]) |
16 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 17 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
18 | ]) |
19 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
20 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
21 | ]) | |
22 | ||
d7c5426b | 23 | OVS_TRAFFIC_VSWITCHD_STOP |
cfe17b43 JS |
24 | AT_CLEANUP |
25 | ||
e0b92701 DDP |
26 | AT_SETUP([datapath - http between two ports]) |
27 | OVS_TRAFFIC_VSWITCHD_START() | |
28 | ||
29 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
30 | ||
31 | ADD_NAMESPACES(at_ns0, at_ns1) | |
32 | ||
33 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
34 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
35 | ||
36 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
37 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
38 | ]) | |
39 | ||
7ed40afe | 40 | OVS_START_L7([at_ns1], [http]) |
e0b92701 DDP |
41 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
42 | ||
43 | OVS_TRAFFIC_VSWITCHD_STOP | |
44 | AT_CLEANUP | |
45 | ||
d7c5426b | 46 | AT_SETUP([datapath - ping between two ports on vlan]) |
cf7659b6 JR |
47 | OVS_TRAFFIC_VSWITCHD_START() |
48 | ||
49 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
cfe17b43 JS |
50 | |
51 | ADD_NAMESPACES(at_ns0, at_ns1) | |
52 | ||
53 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
54 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
55 | ||
56 | ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24") | |
57 | ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24") | |
58 | ||
de22d08f | 59 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 60 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
61 | ]) |
62 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 63 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
64 | ]) |
65 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
66 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
67 | ]) | |
68 | ||
d7c5426b | 69 | OVS_TRAFFIC_VSWITCHD_STOP |
cfe17b43 JS |
70 | AT_CLEANUP |
71 | ||
c5abeef4 EG |
72 | AT_SETUP([datapath - ping between two ports on cvlan]) |
73 | OVS_TRAFFIC_VSWITCHD_START() | |
74 | ||
75 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
76 | ||
77 | ADD_NAMESPACES(at_ns0, at_ns1) | |
78 | ||
79 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
80 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
81 | ||
82 | ADD_SVLAN(p0, at_ns0, 4094, "10.255.2.1/24") | |
83 | ADD_SVLAN(p1, at_ns1, 4094, "10.255.2.2/24") | |
84 | ||
85 | ADD_CVLAN(p0.4094, at_ns0, 100, "10.2.2.1/24") | |
86 | ADD_CVLAN(p1.4094, at_ns1, 100, "10.2.2.2/24") | |
87 | ||
88 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
89 | ||
90 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
91 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
92 | ]) | |
93 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
94 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
95 | ]) | |
96 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
97 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
98 | ]) | |
99 | ||
100 | OVS_TRAFFIC_VSWITCHD_STOP | |
101 | AT_CLEANUP | |
102 | ||
d7c5426b | 103 | AT_SETUP([datapath - ping6 between two ports]) |
cf7659b6 JR |
104 | OVS_TRAFFIC_VSWITCHD_START() |
105 | ||
106 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
cfe17b43 JS |
107 | |
108 | ADD_NAMESPACES(at_ns0, at_ns1) | |
109 | ||
110 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
111 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
112 | ||
c10840ff JS |
113 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
114 | dnl waiting, we get occasional failures due to the following error: | |
cfe17b43 | 115 | dnl "connect: Cannot assign requested address" |
c10840ff | 116 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
cfe17b43 | 117 | |
de22d08f | 118 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 119 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
120 | ]) |
121 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 122 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
123 | ]) |
124 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
125 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
126 | ]) | |
127 | ||
d7c5426b | 128 | OVS_TRAFFIC_VSWITCHD_STOP |
cfe17b43 JS |
129 | AT_CLEANUP |
130 | ||
d7c5426b | 131 | AT_SETUP([datapath - ping6 between two ports on vlan]) |
cf7659b6 JR |
132 | OVS_TRAFFIC_VSWITCHD_START() |
133 | ||
134 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
cfe17b43 JS |
135 | |
136 | ADD_NAMESPACES(at_ns0, at_ns1) | |
137 | ||
138 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
139 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
140 | ||
141 | ADD_VLAN(p0, at_ns0, 100, "fc00:1::1/96") | |
142 | ADD_VLAN(p1, at_ns1, 100, "fc00:1::2/96") | |
143 | ||
c10840ff JS |
144 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
145 | dnl waiting, we get occasional failures due to the following error: | |
cfe17b43 | 146 | dnl "connect: Cannot assign requested address" |
68ffb694 | 147 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00:1::2]) |
cfe17b43 | 148 | |
de22d08f | 149 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 150 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
151 | ]) |
152 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 153 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
154 | ]) |
155 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
156 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
157 | ]) | |
158 | ||
d7c5426b | 159 | OVS_TRAFFIC_VSWITCHD_STOP |
69c2bdfe | 160 | AT_CLEANUP |
810e1785 | 161 | |
c5abeef4 EG |
162 | AT_SETUP([datapath - ping6 between two ports on cvlan]) |
163 | OVS_TRAFFIC_VSWITCHD_START() | |
164 | ||
165 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
166 | ||
167 | ADD_NAMESPACES(at_ns0, at_ns1) | |
168 | ||
169 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
170 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
171 | ||
172 | ADD_SVLAN(p0, at_ns0, 4094, "fc00:ffff::1/96") | |
173 | ADD_SVLAN(p1, at_ns1, 4094, "fc00:ffff::2/96") | |
174 | ||
175 | ADD_CVLAN(p0.4094, at_ns0, 100, "fc00:1::1/96") | |
176 | ADD_CVLAN(p1.4094, at_ns1, 100, "fc00:1::2/96") | |
177 | ||
178 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00:1::2]) | |
179 | ||
180 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
181 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
182 | ]) | |
183 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
184 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
185 | ]) | |
186 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
187 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
188 | ]) | |
189 | ||
190 | OVS_TRAFFIC_VSWITCHD_STOP | |
191 | AT_CLEANUP | |
192 | ||
ddb5f937 LR |
193 | AT_SETUP([datapath - ping over bond]) |
194 | OVS_TRAFFIC_VSWITCHD_START() | |
195 | ||
196 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
197 | ||
198 | ADD_NAMESPACES(at_ns0, at_ns1) | |
199 | ||
200 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
201 | ADD_VETH_BOND(p1 p2, at_ns1, br0, bond0, lacp=active bond_mode=balance-tcp, "10.1.1.2/24") | |
202 | ||
203 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.1.1.2]) | |
204 | ||
205 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
206 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
207 | ]) | |
208 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
209 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
210 | ]) | |
211 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
212 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
213 | ]) | |
214 | ||
215 | OVS_TRAFFIC_VSWITCHD_STOP | |
216 | AT_CLEANUP | |
217 | ||
810e1785 | 218 | AT_SETUP([datapath - ping over vxlan tunnel]) |
dfb21e96 | 219 | OVS_CHECK_VXLAN() |
810e1785 | 220 | |
cf7659b6 JR |
221 | OVS_TRAFFIC_VSWITCHD_START() |
222 | ADD_BR([br-underlay]) | |
223 | ||
224 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
225 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
226 | ||
810e1785 JS |
227 | ADD_NAMESPACES(at_ns0) |
228 | ||
229 | dnl Set up underlay link from host into the namespace using veth pair. | |
230 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
231 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
232 | AT_CHECK([ip link set dev br-underlay up]) | |
233 | ||
234 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
235 | dnl linux device inside the namespace. | |
236 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) | |
237 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], | |
238 | [id 0 dstport 4789]) | |
239 | ||
240 | dnl First, check the underlay | |
241 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
242 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
243 | ]) | |
244 | ||
245 | dnl Okay, now check the overlay with different packet sizes | |
246 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
247 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
248 | ]) | |
249 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
250 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
251 | ]) | |
252 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
523256cc JS |
253 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
254 | ]) | |
255 | ||
256 | OVS_TRAFFIC_VSWITCHD_STOP | |
257 | AT_CLEANUP | |
258 | ||
259 | AT_SETUP([datapath - ping over gre tunnel]) | |
260 | OVS_CHECK_GRE() | |
261 | ||
262 | OVS_TRAFFIC_VSWITCHD_START() | |
263 | ADD_BR([br-underlay]) | |
264 | ||
265 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
266 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
267 | ||
268 | ADD_NAMESPACES(at_ns0) | |
269 | ||
270 | dnl Set up underlay link from host into the namespace using veth pair. | |
271 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
272 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
273 | AT_CHECK([ip link set dev br-underlay up]) | |
274 | ||
275 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
276 | dnl linux device inside the namespace. | |
277 | ADD_OVS_TUNNEL([gre], [br0], [at_gre0], [172.31.1.1], [10.1.1.100/24]) | |
278 | ADD_NATIVE_TUNNEL([gretap], [ns_gre0], [at_ns0], [172.31.1.100], [10.1.1.1/24]) | |
279 | ||
280 | dnl First, check the underlay | |
281 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
282 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
283 | ]) | |
284 | ||
285 | dnl Okay, now check the overlay with different packet sizes | |
286 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
287 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
288 | ]) | |
289 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
290 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
291 | ]) | |
292 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
92b8af2c JS |
293 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
294 | ]) | |
295 | ||
296 | OVS_TRAFFIC_VSWITCHD_STOP | |
297 | AT_CLEANUP | |
298 | ||
299 | AT_SETUP([datapath - ping over geneve tunnel]) | |
300 | OVS_CHECK_GENEVE() | |
301 | ||
302 | OVS_TRAFFIC_VSWITCHD_START() | |
303 | ADD_BR([br-underlay]) | |
304 | ||
305 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
306 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
307 | ||
308 | ADD_NAMESPACES(at_ns0) | |
309 | ||
310 | dnl Set up underlay link from host into the namespace using veth pair. | |
311 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
312 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
313 | AT_CHECK([ip link set dev br-underlay up]) | |
314 | ||
315 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
316 | dnl linux device inside the namespace. | |
317 | ADD_OVS_TUNNEL([geneve], [br0], [at_gnv0], [172.31.1.1], [10.1.1.100/24]) | |
318 | ADD_NATIVE_TUNNEL([geneve], [ns_gnv0], [at_ns0], [172.31.1.100], [10.1.1.1/24], | |
319 | [vni 0]) | |
320 | ||
321 | dnl First, check the underlay | |
322 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
323 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
324 | ]) | |
325 | ||
326 | dnl Okay, now check the overlay with different packet sizes | |
327 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
328 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
329 | ]) | |
330 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
331 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
332 | ]) | |
333 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
810e1785 JS |
334 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
335 | ]) | |
336 | ||
337 | OVS_TRAFFIC_VSWITCHD_STOP | |
338 | AT_CLEANUP | |
07659514 | 339 | |
7ae62a67 WT |
340 | AT_SETUP([datapath - clone action]) |
341 | OVS_TRAFFIC_VSWITCHD_START() | |
342 | ||
343 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2) | |
344 | ||
345 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
346 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
7ae62a67 | 347 | |
88b5874e WT |
348 | AT_CHECK([ovs-vsctl -- set interface ovs-p0 ofport_request=1 \ |
349 | -- set interface ovs-p1 ofport_request=2]) | |
7ae62a67 | 350 | |
88b5874e WT |
351 | AT_DATA([flows.txt], [dnl |
352 | priority=1 actions=NORMAL | |
353 | priority=10 in_port=1,ip,actions=clone(mod_dl_dst(50:54:00:00:00:0a),set_field:192.168.3.3->ip_dst), output:2 | |
354 | priority=10 in_port=2,ip,actions=clone(mod_dl_src(ae:c6:7e:54:8d:4d),mod_dl_dst(50:54:00:00:00:0b),set_field:192.168.4.4->ip_dst, controller), output:1 | |
355 | ]) | |
356 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
7ae62a67 | 357 | |
88b5874e | 358 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) |
7ae62a67 WT |
359 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl |
360 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
361 | ]) | |
362 | ||
88b5874e WT |
363 | AT_CHECK([cat ofctl_monitor.log | STRIP_MONITOR_CSUM], [0], [dnl |
364 | icmp,vlan_tci=0x0000,dl_src=ae:c6:7e:54:8d:4d,dl_dst=50:54:00:00:00:0b,nw_src=10.1.1.2,nw_dst=192.168.4.4,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum: <skip> | |
365 | icmp,vlan_tci=0x0000,dl_src=ae:c6:7e:54:8d:4d,dl_dst=50:54:00:00:00:0b,nw_src=10.1.1.2,nw_dst=192.168.4.4,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum: <skip> | |
366 | icmp,vlan_tci=0x0000,dl_src=ae:c6:7e:54:8d:4d,dl_dst=50:54:00:00:00:0b,nw_src=10.1.1.2,nw_dst=192.168.4.4,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum: <skip> | |
367 | ]) | |
7ae62a67 WT |
368 | |
369 | OVS_TRAFFIC_VSWITCHD_STOP | |
370 | AT_CLEANUP | |
371 | ||
457402dc YHW |
372 | AT_SETUP([datapath - mpls actions]) |
373 | OVS_TRAFFIC_VSWITCHD_START([_ADD_BR([br1])]) | |
374 | ||
375 | ADD_NAMESPACES(at_ns0, at_ns1) | |
376 | ||
377 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
378 | ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24") | |
379 | ||
380 | AT_CHECK([ip link add patch0 type veth peer name patch1]) | |
381 | on_exit 'ip link del patch0' | |
382 | ||
383 | AT_CHECK([ip link set dev patch0 up]) | |
384 | AT_CHECK([ip link set dev patch1 up]) | |
385 | AT_CHECK([ovs-vsctl add-port br0 patch0]) | |
386 | AT_CHECK([ovs-vsctl add-port br1 patch1]) | |
387 | ||
388 | AT_DATA([flows.txt], [dnl | |
389 | table=0,priority=100,dl_type=0x0800 actions=push_mpls:0x8847,set_mpls_label:3,resubmit(,1) | |
390 | table=0,priority=100,dl_type=0x8847,mpls_label=3 actions=pop_mpls:0x0800,resubmit(,1) | |
391 | table=0,priority=10 actions=resubmit(,1) | |
392 | table=1,priority=10 actions=normal | |
393 | ]) | |
394 | ||
395 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
396 | AT_CHECK([ovs-ofctl add-flows br1 flows.txt]) | |
397 | ||
398 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
399 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
400 | ]) | |
401 | ||
402 | NS_CHECK_EXEC([at_ns1], [ping -q -c 3 -i 0.3 -w 2 10.1.1.1 | FORMAT_PING], [0], [dnl | |
403 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
404 | ]) | |
405 | ||
406 | OVS_TRAFFIC_VSWITCHD_STOP | |
407 | AT_CLEANUP | |
aaca4fe0 | 408 | AT_SETUP([datapath - basic truncate action]) |
9c1ab985 | 409 | AT_SKIP_IF([test $HAVE_NC = no]) |
aaca4fe0 WT |
410 | OVS_TRAFFIC_VSWITCHD_START() |
411 | AT_CHECK([ovs-ofctl del-flows br0]) | |
412 | ||
413 | dnl Create p0 and ovs-p0(1) | |
414 | ADD_NAMESPACES(at_ns0) | |
415 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
416 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address e6:66:c1:11:11:11]) | |
417 | NS_CHECK_EXEC([at_ns0], [arp -s 10.1.1.2 e6:66:c1:22:22:22]) | |
418 | ||
419 | dnl Create p1(3) and ovs-p1(2), packets received from ovs-p1 will appear in p1 | |
420 | AT_CHECK([ip link add p1 type veth peer name ovs-p1]) | |
421 | on_exit 'ip link del ovs-p1' | |
422 | AT_CHECK([ip link set dev ovs-p1 up]) | |
423 | AT_CHECK([ip link set dev p1 up]) | |
424 | AT_CHECK([ovs-vsctl add-port br0 ovs-p1 -- set interface ovs-p1 ofport_request=2]) | |
425 | dnl Use p1 to check the truncated packet | |
426 | AT_CHECK([ovs-vsctl add-port br0 p1 -- set interface p1 ofport_request=3]) | |
427 | ||
428 | dnl Create p2(5) and ovs-p2(4) | |
429 | AT_CHECK([ip link add p2 type veth peer name ovs-p2]) | |
430 | on_exit 'ip link del ovs-p2' | |
431 | AT_CHECK([ip link set dev ovs-p2 up]) | |
432 | AT_CHECK([ip link set dev p2 up]) | |
433 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2 -- set interface ovs-p2 ofport_request=4]) | |
434 | dnl Use p2 to check the truncated packet | |
435 | AT_CHECK([ovs-vsctl add-port br0 p2 -- set interface p2 ofport_request=5]) | |
436 | ||
437 | dnl basic test | |
438 | AT_CHECK([ovs-ofctl del-flows br0]) | |
439 | AT_DATA([flows.txt], [dnl | |
440 | in_port=3 dl_dst=e6:66:c1:22:22:22 actions=drop | |
441 | in_port=5 dl_dst=e6:66:c1:22:22:22 actions=drop | |
442 | in_port=1 dl_dst=e6:66:c1:22:22:22 actions=output(port=2,max_len=100),output:4 | |
443 | ]) | |
444 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
445 | ||
446 | dnl use this file as payload file for ncat | |
447 | AT_CHECK([dd if=/dev/urandom of=payload200.bin bs=200 count=1 2> /dev/null]) | |
448 | on_exit 'rm -f payload200.bin' | |
a037f175 | 449 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 1234 < payload200.bin]) |
aaca4fe0 WT |
450 | |
451 | dnl packet with truncated size | |
452 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
453 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=3" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
454 | n_bytes=100 | |
455 | ]) | |
456 | dnl packet with original size | |
457 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
458 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=5" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
459 | n_bytes=242 | |
460 | ]) | |
461 | ||
462 | dnl more complicated output actions | |
463 | AT_CHECK([ovs-ofctl del-flows br0]) | |
464 | AT_DATA([flows.txt], [dnl | |
465 | in_port=3 dl_dst=e6:66:c1:22:22:22 actions=drop | |
466 | in_port=5 dl_dst=e6:66:c1:22:22:22 actions=drop | |
467 | in_port=1 dl_dst=e6:66:c1:22:22:22 actions=output(port=2,max_len=100),output:4,output(port=2,max_len=100),output(port=4,max_len=100),output:2,output(port=4,max_len=200),output(port=2,max_len=65535) | |
468 | ]) | |
469 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
470 | ||
a037f175 | 471 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 1234 < payload200.bin]) |
aaca4fe0 WT |
472 | |
473 | dnl 100 + 100 + 242 + min(65535,242) = 684 | |
474 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
475 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=3" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
476 | n_bytes=684 | |
477 | ]) | |
478 | dnl 242 + 100 + min(242,200) = 542 | |
479 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=5" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
480 | n_bytes=542 | |
481 | ]) | |
482 | ||
483 | dnl SLOW_ACTION: disable kernel datapath truncate support | |
484 | dnl Repeat the test above, but exercise the SLOW_ACTION code path | |
485 | AT_CHECK([ovs-appctl dpif/disable-truncate], [0], | |
486 | [Datapath truncate action diabled | |
487 | ]) | |
488 | ||
489 | dnl SLOW_ACTION test1: check datapatch actions | |
490 | AT_CHECK([ovs-ofctl del-flows br0]) | |
491 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
492 | ||
3041e1fc | 493 | AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_type=0x800,dl_src=e6:66:c1:11:11:11,dl_dst=e6:66:c1:22:22:22,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,tp_src=8,tp_dst=9"], [0], [stdout]) |
aaca4fe0 WT |
494 | AT_CHECK([tail -3 stdout], [0], |
495 | [Datapath actions: trunc(100),3,5,trunc(100),3,trunc(100),5,3,trunc(200),5,trunc(65535),3 | |
496 | This flow is handled by the userspace slow path because it: | |
497 | - Uses action(s) not supported by datapath. | |
498 | ]) | |
aaca4fe0 WT |
499 | |
500 | dnl SLOW_ACTION test2: check actual packet truncate | |
501 | AT_CHECK([ovs-ofctl del-flows br0]) | |
502 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
a037f175 | 503 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 1234 < payload200.bin]) |
aaca4fe0 WT |
504 | |
505 | dnl 100 + 100 + 242 + min(65535,242) = 684 | |
506 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
507 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=3" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
508 | n_bytes=684 | |
509 | ]) | |
510 | ||
511 | dnl 242 + 100 + min(242,200) = 542 | |
512 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=5" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
513 | n_bytes=542 | |
514 | ]) | |
515 | ||
516 | OVS_TRAFFIC_VSWITCHD_STOP | |
517 | AT_CLEANUP | |
518 | ||
519 | dnl Create 2 bridges and 2 namespaces to test truncate over | |
520 | dnl GRE tunnel: | |
521 | dnl br0: overlay bridge | |
522 | dnl ns1: connect to br0, with IP:10.1.1.2 | |
523 | dnl br-underlay: with IP: 172.31.1.100 | |
524 | dnl ns0: connect to br-underlay, with IP: 10.1.1.1 | |
525 | AT_SETUP([datapath - truncate and output to gre tunnel]) | |
9c1ab985 | 526 | AT_SKIP_IF([test $HAVE_NC = no]) |
aaca4fe0 WT |
527 | OVS_CHECK_GRE() |
528 | OVS_TRAFFIC_VSWITCHD_START() | |
529 | ||
530 | ADD_BR([br-underlay]) | |
531 | ADD_NAMESPACES(at_ns0) | |
532 | ADD_NAMESPACES(at_ns1) | |
533 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
534 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
535 | ||
536 | dnl Set up underlay link from host into the namespace using veth pair. | |
537 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
538 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
539 | AT_CHECK([ip link set dev br-underlay up]) | |
540 | ||
541 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
542 | dnl linux device inside the namespace. | |
543 | ADD_OVS_TUNNEL([gre], [br0], [at_gre0], [172.31.1.1], [10.1.1.100/24]) | |
2b9f3924 WT |
544 | ADD_NATIVE_TUNNEL([gretap], [ns_gre0], [at_ns0], [172.31.1.100], [10.1.1.1/24], |
545 | [], [address e6:66:c1:11:11:11]) | |
aaca4fe0 | 546 | AT_CHECK([ovs-vsctl -- set interface at_gre0 ofport_request=1]) |
aaca4fe0 WT |
547 | NS_CHECK_EXEC([at_ns0], [arp -s 10.1.1.2 e6:66:c1:22:22:22]) |
548 | ||
549 | dnl Set up (p1 and ovs-p1) at br0 | |
550 | ADD_VETH(p1, at_ns1, br0, '10.1.1.2/24') | |
551 | AT_CHECK([ovs-vsctl -- set interface ovs-p1 ofport_request=2]) | |
552 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address e6:66:c1:22:22:22]) | |
553 | NS_CHECK_EXEC([at_ns1], [arp -s 10.1.1.1 e6:66:c1:11:11:11]) | |
554 | ||
555 | dnl Set up (p2 and ovs-p2) as loopback for verifying packet size | |
556 | AT_CHECK([ip link add p2 type veth peer name ovs-p2]) | |
557 | on_exit 'ip link del ovs-p2' | |
558 | AT_CHECK([ip link set dev ovs-p2 up]) | |
559 | AT_CHECK([ip link set dev p2 up]) | |
560 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2 -- set interface ovs-p2 ofport_request=3]) | |
561 | AT_CHECK([ovs-vsctl add-port br0 p2 -- set interface p2 ofport_request=4]) | |
562 | ||
563 | dnl use this file as payload file for ncat | |
564 | AT_CHECK([dd if=/dev/urandom of=payload200.bin bs=200 count=1 2> /dev/null]) | |
565 | on_exit 'rm -f payload200.bin' | |
566 | ||
567 | AT_CHECK([ovs-ofctl del-flows br0]) | |
568 | AT_DATA([flows.txt], [dnl | |
569 | priority=99,in_port=1,actions=output(port=2,max_len=100),output(port=3,max_len=100) | |
570 | priority=99,in_port=2,udp,actions=output(port=1,max_len=100) | |
571 | priority=1,in_port=4,ip,actions=drop | |
572 | priority=1,actions=drop | |
573 | ]) | |
574 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
575 | ||
576 | AT_CHECK([ovs-ofctl del-flows br-underlay]) | |
577 | AT_DATA([flows-underlay.txt], [dnl | |
578 | priority=99,dl_type=0x0800,nw_proto=47,in_port=1,actions=LOCAL | |
579 | priority=99,dl_type=0x0800,nw_proto=47,in_port=LOCAL,ip_dst=172.31.1.1/24,actions=1 | |
580 | priority=1,actions=drop | |
581 | ]) | |
582 | ||
583 | AT_CHECK([ovs-ofctl add-flows br-underlay flows-underlay.txt]) | |
584 | ||
585 | dnl check tunnel push path, from at_ns1 to at_ns0 | |
a037f175 | 586 | NS_CHECK_EXEC([at_ns1], [nc $NC_EOF_OPT -u 10.1.1.1 1234 < payload200.bin]) |
aaca4fe0 WT |
587 | AT_CHECK([ovs-appctl revalidator/purge], [0]) |
588 | ||
589 | dnl Before truncation = ETH(14) + IP(20) + UDP(8) + 200 = 242B | |
590 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=2" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
591 | n_bytes=242 | |
592 | ]) | |
593 | dnl After truncation = outer ETH(14) + outer IP(20) + GRE(4) + 100 = 138B | |
594 | AT_CHECK([ovs-ofctl dump-flows br-underlay | grep "in_port=LOCAL" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
595 | n_bytes=138 | |
596 | ]) | |
597 | ||
598 | dnl check tunnel pop path, from at_ns0 to at_ns1 | |
a037f175 | 599 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 5678 < payload200.bin]) |
aaca4fe0 WT |
600 | dnl After truncation = 100 byte at loopback device p2(4) |
601 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
32b0cc65 JS |
602 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=4" | ofctl_strip], [0], [dnl |
603 | n_packets=1, n_bytes=100, priority=1,ip,in_port=4 actions=drop | |
aaca4fe0 WT |
604 | ]) |
605 | ||
606 | dnl SLOW_ACTION: disable datapath truncate support | |
607 | dnl Repeat the test above, but exercise the SLOW_ACTION code path | |
608 | AT_CHECK([ovs-appctl dpif/disable-truncate], [0], | |
609 | [Datapath truncate action diabled | |
610 | ]) | |
611 | ||
612 | dnl SLOW_ACTION test1: check datapatch actions | |
613 | AT_CHECK([ovs-ofctl del-flows br0]) | |
614 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
615 | ||
aaca4fe0 WT |
616 | dnl SLOW_ACTION test2: check actual packet truncate |
617 | AT_CHECK([ovs-ofctl del-flows br0]) | |
618 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
619 | AT_CHECK([ovs-ofctl del-flows br-underlay]) | |
620 | AT_CHECK([ovs-ofctl add-flows br-underlay flows-underlay.txt]) | |
621 | ||
622 | dnl check tunnel push path, from at_ns1 to at_ns0 | |
a037f175 | 623 | NS_CHECK_EXEC([at_ns1], [nc $NC_EOF_OPT -u 10.1.1.1 1234 < payload200.bin]) |
aaca4fe0 WT |
624 | AT_CHECK([ovs-appctl revalidator/purge], [0]) |
625 | ||
626 | dnl Before truncation = ETH(14) + IP(20) + UDP(8) + 200 = 242B | |
627 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=2" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
628 | n_bytes=242 | |
629 | ]) | |
630 | dnl After truncation = outer ETH(14) + outer IP(20) + GRE(4) + 100 = 138B | |
631 | AT_CHECK([ovs-ofctl dump-flows br-underlay | grep "in_port=LOCAL" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
632 | n_bytes=138 | |
633 | ]) | |
634 | ||
635 | dnl check tunnel pop path, from at_ns0 to at_ns1 | |
a037f175 | 636 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 5678 < payload200.bin]) |
aaca4fe0 WT |
637 | dnl After truncation = 100 byte at loopback device p2(4) |
638 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
32b0cc65 JS |
639 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=4" | ofctl_strip], [0], [dnl |
640 | n_packets=1, n_bytes=100, priority=1,ip,in_port=4 actions=drop | |
aaca4fe0 WT |
641 | ]) |
642 | ||
643 | OVS_TRAFFIC_VSWITCHD_STOP | |
644 | AT_CLEANUP | |
645 | ||
ee8941ab JS |
646 | AT_BANNER([conntrack]) |
647 | ||
07659514 JS |
648 | AT_SETUP([conntrack - controller]) |
649 | CHECK_CONNTRACK() | |
cf7659b6 | 650 | OVS_TRAFFIC_VSWITCHD_START() |
daf4d3c1 | 651 | AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg ofproto_dpif_upcall:dbg]) |
07659514 JS |
652 | |
653 | ADD_NAMESPACES(at_ns0, at_ns1) | |
654 | ||
655 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
656 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
657 | ||
658 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
659 | AT_DATA([flows.txt], [dnl | |
660 | priority=1,action=drop | |
661 | priority=10,arp,action=normal | |
662 | priority=100,in_port=1,udp,action=ct(commit),controller | |
663 | priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0) | |
664 | priority=100,in_port=2,ct_state=+trk+est,udp,action=controller | |
665 | ]) | |
666 | ||
6cfa8ec3 | 667 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 JS |
668 | |
669 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
670 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
671 | ||
672 | dnl Send an unsolicited reply from port 2. This should be dropped. | |
4573c42e | 673 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000']) |
07659514 JS |
674 | |
675 | dnl OK, now start a new connection from port 1. | |
4573c42e | 676 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit\),controller '50540000000a50540000000908004500001c000000000011a4cd0a0101010a0101020001000200080000']) |
07659514 JS |
677 | |
678 | dnl Now try a reply from port 2. | |
4573c42e | 679 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000']) |
07659514 JS |
680 | |
681 | dnl Check this output. We only see the latter two packets, not the first. | |
682 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
f274a047 | 683 | NXT_PACKET_IN2 (xid=0x0): total_len=42 in_port=1 (via action) data_len=42 (unbuffered) |
07659514 | 684 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.1,nw_dst=10.1.1.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=1,tp_dst=2 udp_csum:0 |
daf4d3c1 | 685 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 ct_state=est|rpl|trk,ct_nw_src=10.1.1.1,ct_nw_dst=10.1.1.2,ct_nw_proto=17,ct_tp_src=1,ct_tp_dst=2,in_port=2 (via action) data_len=42 (unbuffered) |
07659514 JS |
686 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.2,nw_dst=10.1.1.1,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=2,tp_dst=1 udp_csum:0 |
687 | ]) | |
688 | ||
689 | OVS_TRAFFIC_VSWITCHD_STOP | |
690 | AT_CLEANUP | |
691 | ||
a76a37ef JR |
692 | AT_SETUP([conntrack - force commit]) |
693 | CHECK_CONNTRACK() | |
694 | OVS_TRAFFIC_VSWITCHD_START() | |
695 | AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg ofproto_dpif_upcall:dbg]) | |
696 | ||
697 | ADD_NAMESPACES(at_ns0, at_ns1) | |
698 | ||
699 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
700 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
701 | ||
702 | AT_DATA([flows.txt], [dnl | |
703 | priority=1,action=drop | |
704 | priority=10,arp,action=normal | |
705 | priority=100,in_port=1,udp,action=ct(commit),controller | |
706 | priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0) | |
707 | priority=100,in_port=2,ct_state=+trk+est,udp,action=ct(force,commit,table=1) | |
708 | table=1,in_port=2,ct_state=+trk,udp,action=controller | |
709 | ]) | |
710 | ||
711 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
712 | ||
713 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
714 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
715 | ||
716 | dnl Send an unsolicited reply from port 2. This should be dropped. | |
717 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 "in_port=2 packet=50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000 actions=resubmit(,0)"]) | |
718 | ||
719 | dnl OK, now start a new connection from port 1. | |
720 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 "in_port=1 packet=50540000000a50540000000908004500001c000000000011a4cd0a0101010a0101020001000200080000 actions=resubmit(,0)"]) | |
721 | ||
722 | dnl Now try a reply from port 2. | |
723 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 "in_port=2 packet=50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000 actions=resubmit(,0)"]) | |
724 | ||
725 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
726 | ||
727 | dnl Check this output. We only see the latter two packets, not the first. | |
728 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
729 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered) | |
730 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.1,nw_dst=10.1.1.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=1,tp_dst=2 udp_csum:0 | |
731 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=42 ct_state=new|trk,ct_nw_src=10.1.1.2,ct_nw_dst=10.1.1.1,ct_nw_proto=17,ct_tp_src=2,ct_tp_dst=1,in_port=2 (via action) data_len=42 (unbuffered) | |
732 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.2,nw_dst=10.1.1.1,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=2,tp_dst=1 udp_csum:0 | |
733 | ]) | |
734 | ||
735 | dnl | |
736 | dnl Check that the directionality has been changed by force commit. | |
737 | dnl | |
738 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep "orig=.src=10\.1\.1\.2,"], [], [dnl | |
739 | udp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=2,dport=1),reply=(src=10.1.1.1,dst=10.1.1.2,sport=1,dport=2) | |
740 | ]) | |
741 | ||
742 | OVS_TRAFFIC_VSWITCHD_STOP | |
743 | AT_CLEANUP | |
744 | ||
e5cf8cce DDP |
745 | AT_SETUP([conntrack - IPv4 ping]) |
746 | CHECK_CONNTRACK() | |
747 | OVS_TRAFFIC_VSWITCHD_START() | |
748 | ||
749 | ADD_NAMESPACES(at_ns0, at_ns1) | |
750 | ||
751 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
752 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
753 | ||
754 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
755 | AT_DATA([flows.txt], [dnl | |
756 | priority=1,action=drop | |
757 | priority=10,arp,action=normal | |
758 | priority=100,in_port=1,icmp,action=ct(commit),2 | |
759 | priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0) | |
760 | priority=100,in_port=2,icmp,ct_state=+trk+est,action=1 | |
761 | ]) | |
762 | ||
763 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
764 | ||
765 | dnl Pings from ns0->ns1 should work fine. | |
766 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
767 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
768 | ]) | |
769 | ||
770 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
771 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0) | |
772 | ]) | |
773 | ||
774 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
775 | ||
776 | dnl Pings from ns1->ns0 should fail. | |
777 | NS_CHECK_EXEC([at_ns1], [ping -q -c 3 -i 0.3 -w 2 10.1.1.1 | FORMAT_PING], [0], [dnl | |
778 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
779 | ]) | |
780 | ||
781 | OVS_TRAFFIC_VSWITCHD_STOP | |
782 | AT_CLEANUP | |
783 | ||
784 | AT_SETUP([conntrack - IPv6 ping]) | |
785 | CHECK_CONNTRACK() | |
786 | OVS_TRAFFIC_VSWITCHD_START() | |
787 | ||
788 | ADD_NAMESPACES(at_ns0, at_ns1) | |
789 | ||
790 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
791 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
792 | ||
793 | AT_DATA([flows.txt], [dnl | |
794 | ||
795 | dnl ICMPv6 echo request and reply go to table 1. The rest of the traffic goes | |
796 | dnl through normal action. | |
797 | table=0,priority=10,icmp6,icmp_type=128,action=goto_table:1 | |
798 | table=0,priority=10,icmp6,icmp_type=129,action=goto_table:1 | |
799 | table=0,priority=1,action=normal | |
800 | ||
801 | dnl Allow everything from ns0->ns1. Only allow return traffic from ns1->ns0. | |
802 | table=1,priority=100,in_port=1,icmp6,action=ct(commit),2 | |
803 | table=1,priority=100,in_port=2,icmp6,ct_state=-trk,action=ct(table=0) | |
804 | table=1,priority=100,in_port=2,icmp6,ct_state=+trk+est,action=1 | |
805 | table=1,priority=1,action=drop | |
806 | ]) | |
807 | ||
808 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
809 | ||
810 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) | |
811 | ||
027f7e84 DDP |
812 | dnl The above ping creates state in the connection tracker. We're not |
813 | dnl interested in that state. | |
814 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
815 | ||
e5cf8cce DDP |
816 | dnl Pings from ns1->ns0 should fail. |
817 | NS_CHECK_EXEC([at_ns1], [ping6 -q -c 3 -i 0.3 -w 2 fc00::1 | FORMAT_PING], [0], [dnl | |
818 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
819 | ]) | |
820 | ||
821 | dnl Pings from ns0->ns1 should work fine. | |
822 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
823 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
824 | ]) | |
825 | ||
826 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
827 | icmpv6,orig=(src=fc00::1,dst=fc00::2,id=<cleared>,type=128,code=0),reply=(src=fc00::2,dst=fc00::1,id=<cleared>,type=129,code=0) | |
828 | ]) | |
829 | ||
830 | OVS_TRAFFIC_VSWITCHD_STOP | |
831 | AT_CLEANUP | |
832 | ||
07659514 JS |
833 | AT_SETUP([conntrack - preserve registers]) |
834 | CHECK_CONNTRACK() | |
cf7659b6 | 835 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
836 | |
837 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
838 | ||
839 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
840 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
841 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
842 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
843 | ||
844 | dnl Allow any traffic from ns0->ns1, ns2->ns3. | |
845 | AT_DATA([flows.txt], [dnl | |
846 | priority=1,action=drop | |
847 | priority=10,arp,action=normal | |
848 | priority=10,icmp,action=normal | |
849 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0) | |
850 | priority=100,in_port=1,tcp,ct_state=+trk,action=2 | |
851 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0) | |
852 | priority=100,in_port=2,tcp,ct_state=+trk,action=1 | |
853 | priority=100,in_port=3,tcp,ct_state=-trk,action=load:0->NXM_NX_REG0[[]],ct(table=0) | |
854 | priority=100,in_port=3,tcp,ct_state=+trk,reg0=0,action=load:1->NXM_NX_REG0[[]],ct(commit,table=0) | |
855 | priority=100,in_port=3,tcp,ct_state=+trk,reg0=1,action=4 | |
856 | priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0) | |
857 | priority=100,in_port=4,tcp,ct_state=+trk,action=3 | |
858 | ]) | |
859 | ||
6cfa8ec3 | 860 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 861 | |
7ed40afe JS |
862 | OVS_START_L7([at_ns1], [http]) |
863 | OVS_START_L7([at_ns3], [http]) | |
864 | ||
07659514 | 865 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
866 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
867 | ||
868 | dnl HTTP requests from p2->p3 should work fine. | |
07659514 JS |
869 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
870 | ||
871 | OVS_TRAFFIC_VSWITCHD_STOP | |
872 | AT_CLEANUP | |
873 | ||
874 | AT_SETUP([conntrack - invalid]) | |
875 | CHECK_CONNTRACK() | |
cf7659b6 | 876 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
877 | |
878 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
879 | ||
880 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
881 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
882 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
883 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
884 | ||
885 | dnl Pass traffic from ns0->ns1 without committing, but attempt to track in | |
886 | dnl the opposite direction. This should fail. | |
887 | dnl Pass traffic from ns3->ns4 without committing, and this time match | |
888 | dnl invalid traffic and allow it through. | |
889 | AT_DATA([flows.txt], [dnl | |
890 | priority=1,action=drop | |
891 | priority=10,arp,action=normal | |
892 | priority=10,icmp,action=normal | |
893 | priority=100,in_port=1,tcp,action=ct(),2 | |
894 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
895 | priority=100,in_port=2,ct_state=+trk+new,tcp,action=1 | |
896 | priority=100,in_port=3,tcp,action=ct(),4 | |
897 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
898 | priority=100,in_port=4,ct_state=+trk+inv,tcp,action=3 | |
899 | priority=100,in_port=4,ct_state=+trk+new,tcp,action=3 | |
900 | ]) | |
901 | ||
6cfa8ec3 | 902 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 JS |
903 | |
904 | dnl We set up our rules to allow the request without committing. The return | |
905 | dnl traffic can't be identified, because the initial request wasn't committed. | |
906 | dnl For the first pair of ports, this means that the connection fails. | |
7ed40afe JS |
907 | OVS_START_L7([at_ns1], [http]) |
908 | OVS_START_L7([at_ns3], [http]) | |
07659514 JS |
909 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log], [4]) |
910 | ||
911 | dnl For the second pair, we allow packets from invalid connections, so it works. | |
07659514 JS |
912 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
913 | ||
914 | OVS_TRAFFIC_VSWITCHD_STOP | |
915 | AT_CLEANUP | |
916 | ||
917 | AT_SETUP([conntrack - zones]) | |
918 | CHECK_CONNTRACK() | |
cf7659b6 | 919 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
920 | |
921 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
922 | ||
923 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
924 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
925 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
926 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
927 | ||
928 | dnl Allow any traffic from ns0->ns1. Allow return traffic, matching on zone. | |
929 | dnl For ns2->ns3, use a different zone and see that the match fails. | |
930 | AT_DATA([flows.txt], [dnl | |
931 | priority=1,action=drop | |
932 | priority=10,arp,action=normal | |
933 | priority=10,icmp,action=normal | |
934 | priority=100,in_port=1,tcp,action=ct(commit,zone=1),2 | |
935 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1) | |
936 | priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
937 | priority=100,in_port=3,tcp,action=ct(commit,zone=2),4 | |
938 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0,zone=2) | |
939 | priority=100,in_port=4,ct_state=+trk,ct_zone=1,tcp,action=3 | |
940 | ]) | |
941 | ||
6cfa8ec3 | 942 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 943 | |
7ed40afe JS |
944 | OVS_START_L7([at_ns1], [http]) |
945 | OVS_START_L7([at_ns3], [http]) | |
946 | ||
07659514 | 947 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
948 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
949 | ||
ec3aa16c | 950 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 951 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
07659514 JS |
952 | ]) |
953 | ||
954 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
955 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
956 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
957 | ||
ec3aa16c | 958 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 959 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) |
07659514 JS |
960 | ]) |
961 | ||
962 | OVS_TRAFFIC_VSWITCHD_STOP | |
963 | AT_CLEANUP | |
964 | ||
965 | AT_SETUP([conntrack - zones from field]) | |
966 | CHECK_CONNTRACK() | |
cf7659b6 | 967 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
968 | |
969 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
970 | ||
971 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
972 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
973 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
974 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
975 | ||
976 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
977 | AT_DATA([flows.txt], [dnl | |
978 | priority=1,action=drop | |
979 | priority=10,arp,action=normal | |
980 | priority=10,icmp,action=normal | |
981 | priority=100,in_port=1,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),2 | |
982 | priority=100,in_port=2,ct_state=-trk,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(table=0,zone=NXM_NX_REG0[[0..15]]) | |
983 | priority=100,in_port=2,ct_state=+trk,ct_zone=0x1001,tcp,action=1 | |
984 | priority=100,in_port=3,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),4 | |
985 | priority=100,in_port=4,ct_state=-trk,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(table=0,zone=NXM_NX_REG0[[0..15]]) | |
986 | priority=100,in_port=4,ct_state=+trk,ct_zone=0x1001,tcp,action=3 | |
987 | ]) | |
988 | ||
6cfa8ec3 | 989 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 990 | |
7ed40afe JS |
991 | OVS_START_L7([at_ns1], [http]) |
992 | OVS_START_L7([at_ns3], [http]) | |
993 | ||
07659514 | 994 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
995 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
996 | ||
ec3aa16c | 997 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 998 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=4097,protoinfo=(state=<cleared>) |
07659514 JS |
999 | ]) |
1000 | ||
1001 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1002 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
1003 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
1004 | ||
ec3aa16c | 1005 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1006 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),zone=4098,protoinfo=(state=<cleared>) |
07659514 JS |
1007 | ]) |
1008 | ||
1009 | OVS_TRAFFIC_VSWITCHD_STOP | |
1010 | AT_CLEANUP | |
1011 | ||
1012 | AT_SETUP([conntrack - multiple bridges]) | |
1013 | CHECK_CONNTRACK() | |
1014 | OVS_TRAFFIC_VSWITCHD_START( | |
cf7659b6 | 1015 | [_ADD_BR([br1]) --\ |
07659514 JS |
1016 | add-port br0 patch+ -- set int patch+ type=patch options:peer=patch- --\ |
1017 | add-port br1 patch- -- set int patch- type=patch options:peer=patch+ --]) | |
1018 | ||
1019 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1020 | ||
1021 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1022 | ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24") | |
1023 | ||
1024 | dnl Allow any traffic from ns0->br1, allow established in reverse. | |
1025 | AT_DATA([flows-br0.txt], [dnl | |
1026 | priority=1,action=drop | |
1027 | priority=10,arp,action=normal | |
1028 | priority=10,icmp,action=normal | |
1029 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(commit,zone=1),1 | |
1030 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=1) | |
1031 | priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=1,action=2 | |
1032 | ]) | |
1033 | ||
1034 | dnl Allow any traffic from br0->ns1, allow established in reverse. | |
1035 | AT_DATA([flows-br1.txt], [dnl | |
1036 | priority=1,action=drop | |
1037 | priority=10,arp,action=normal | |
1038 | priority=10,icmp,action=normal | |
1039 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=2) | |
1040 | priority=100,in_port=1,tcp,ct_state=+trk+new,ct_zone=2,action=ct(commit,zone=2),2 | |
1041 | priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=2,action=2 | |
1042 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0,zone=2) | |
1043 | priority=100,in_port=2,tcp,ct_state=+trk+est,ct_zone=2,action=ct(commit,zone=2),1 | |
1044 | ]) | |
1045 | ||
6cfa8ec3 JR |
1046 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) |
1047 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-br1.txt]) | |
07659514 JS |
1048 | |
1049 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 1050 | OVS_START_L7([at_ns1], [http]) |
07659514 JS |
1051 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1052 | ||
1053 | OVS_TRAFFIC_VSWITCHD_STOP | |
1054 | AT_CLEANUP | |
1055 | ||
1056 | AT_SETUP([conntrack - multiple zones]) | |
1057 | CHECK_CONNTRACK() | |
cf7659b6 | 1058 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
1059 | |
1060 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1061 | ||
1062 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1063 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1064 | ||
1065 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1066 | AT_DATA([flows.txt], [dnl | |
1067 | priority=1,action=drop | |
1068 | priority=10,arp,action=normal | |
1069 | priority=10,icmp,action=normal | |
1070 | priority=100,in_port=1,tcp,action=ct(commit,zone=1),ct(commit,zone=2),2 | |
1071 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=2) | |
1072 | priority=100,in_port=2,ct_state=+trk,ct_zone=2,tcp,action=1 | |
1073 | ]) | |
1074 | ||
6cfa8ec3 | 1075 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 1076 | |
7ed40afe JS |
1077 | OVS_START_L7([at_ns1], [http]) |
1078 | ||
07659514 | 1079 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
1080 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1081 | ||
1082 | dnl (again) HTTP requests from p0->p1 should work fine. | |
1083 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1084 | ||
ec3aa16c | 1085 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 JR |
1086 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
1087 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
07659514 JS |
1088 | ]) |
1089 | ||
1090 | OVS_TRAFFIC_VSWITCHD_STOP | |
1091 | AT_CLEANUP | |
1092 | ||
0e27c629 JS |
1093 | AT_SETUP([conntrack - multiple namespaces, internal ports]) |
1094 | CHECK_CONNTRACK() | |
4573c42e | 1095 | CHECK_CONNTRACK_LOCAL_STACK() |
0e27c629 JS |
1096 | OVS_TRAFFIC_VSWITCHD_START( |
1097 | [set-fail-mode br0 secure -- ]) | |
1098 | ||
1099 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1100 | ||
1101 | ADD_INT(p0, at_ns0, br0, "10.1.1.1/24") | |
1102 | ADD_INT(p1, at_ns1, br0, "10.1.1.2/24") | |
1103 | ||
1104 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1105 | dnl | |
1106 | dnl If skb->nfct is leaking from inside the namespace, this test will fail. | |
1107 | AT_DATA([flows.txt], [dnl | |
1108 | priority=1,action=drop | |
1109 | priority=10,arp,action=normal | |
1110 | priority=10,icmp,action=normal | |
1111 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,zone=1),2 | |
1112 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1) | |
1113 | priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
1114 | ]) | |
1115 | ||
1116 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
1117 | ||
7ed40afe JS |
1118 | OVS_START_L7([at_ns1], [http]) |
1119 | ||
0e27c629 | 1120 | dnl HTTP requests from p0->p1 should work fine. |
0e27c629 JS |
1121 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1122 | ||
1123 | dnl (again) HTTP requests from p0->p1 should work fine. | |
1124 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1125 | ||
ec3aa16c | 1126 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 1127 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
0e27c629 JS |
1128 | ]) |
1129 | ||
1130 | OVS_TRAFFIC_VSWITCHD_STOP(["dnl | |
1131 | /ioctl(SIOCGIFINDEX) on .* device failed: No such device/d | |
1132 | /removing policing failed: No such device/d"]) | |
1133 | AT_CLEANUP | |
1134 | ||
8e53fe8c JS |
1135 | AT_SETUP([conntrack - ct_mark]) |
1136 | CHECK_CONNTRACK() | |
cf7659b6 | 1137 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1138 | |
1139 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1140 | ||
1141 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1142 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1143 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1144 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1145 | ||
1146 | dnl Allow traffic between ns0<->ns1 using the ct_mark. | |
1147 | dnl Check that different marks do not match for traffic between ns2<->ns3. | |
1148 | AT_DATA([flows.txt], [dnl | |
1149 | priority=1,action=drop | |
1150 | priority=10,arp,action=normal | |
1151 | priority=10,icmp,action=normal | |
1152 | priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:1->ct_mark)),2 | |
1153 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1154 | priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1 | |
1155 | priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:2->ct_mark)),4 | |
1156 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1157 | priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3 | |
1158 | ]) | |
1159 | ||
6cfa8ec3 | 1160 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1161 | |
7ed40afe JS |
1162 | OVS_START_L7([at_ns1], [http]) |
1163 | OVS_START_L7([at_ns3], [http]) | |
1164 | ||
8e53fe8c | 1165 | dnl HTTP requests from p0->p1 should work fine. |
8e53fe8c | 1166 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
420c73b2 JR |
1167 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1168 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),mark=1,protoinfo=(state=<cleared>) | |
8e53fe8c JS |
1169 | ]) |
1170 | ||
1171 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1172 | dnl Try 3 times, in 1 second intervals. | |
8e53fe8c | 1173 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
ec3aa16c | 1174 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1175 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),mark=2,protoinfo=(state=<cleared>) |
8e53fe8c JS |
1176 | ]) |
1177 | ||
1178 | OVS_TRAFFIC_VSWITCHD_STOP | |
1179 | AT_CLEANUP | |
1180 | ||
4d182934 JS |
1181 | AT_SETUP([conntrack - ct_mark bit-fiddling]) |
1182 | CHECK_CONNTRACK() | |
1183 | OVS_TRAFFIC_VSWITCHD_START() | |
1184 | ||
1185 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1186 | ||
1187 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1188 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1189 | ||
1190 | dnl Allow traffic between ns0<->ns1 using the ct_mark. Return traffic should | |
1191 | dnl cause an additional bit to be set in the connection (and be allowed). | |
1192 | AT_DATA([flows.txt], [dnl | |
1193 | table=0,priority=1,action=drop | |
1194 | table=0,priority=10,arp,action=normal | |
1195 | table=0,priority=10,icmp,action=normal | |
1196 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1197 | table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=1,commit,exec(set_field:0x2/0x6->ct_mark)) | |
723af132 JS |
1198 | table=1,in_port=1,ct_state=+new,tcp,action=ct(commit,exec(set_field:0x5/0x5->ct_mark)),2 |
1199 | table=1,in_port=1,ct_state=-new,tcp,action=2 | |
1200 | table=1,in_port=2,ct_state=+trk,ct_mark=3,tcp,action=1 | |
4d182934 JS |
1201 | ]) |
1202 | ||
1203 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1204 | ||
7ed40afe JS |
1205 | OVS_START_L7([at_ns1], [http]) |
1206 | ||
4d182934 | 1207 | dnl HTTP requests from p0->p1 should work fine. |
4d182934 JS |
1208 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1209 | ||
420c73b2 JR |
1210 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1211 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),mark=3,protoinfo=(state=<cleared>) | |
4d182934 JS |
1212 | ]) |
1213 | ||
1214 | OVS_TRAFFIC_VSWITCHD_STOP | |
1215 | AT_CLEANUP | |
1216 | ||
8e53fe8c JS |
1217 | AT_SETUP([conntrack - ct_mark from register]) |
1218 | CHECK_CONNTRACK() | |
cf7659b6 | 1219 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1220 | |
1221 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1222 | ||
1223 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1224 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1225 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1226 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1227 | ||
1228 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1229 | AT_DATA([flows.txt], [dnl | |
1230 | priority=1,action=drop | |
1231 | priority=10,arp,action=normal | |
1232 | priority=10,icmp,action=normal | |
1233 | priority=100,in_port=1,tcp,action=load:1->NXM_NX_REG0[[0..31]],ct(commit,exec(move:NXM_NX_REG0[[0..31]]->NXM_NX_CT_MARK[[]])),2 | |
1234 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1235 | priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1 | |
1236 | priority=100,in_port=3,tcp,action=load:2->NXM_NX_REG0[[0..31]],ct(commit,exec(move:NXM_NX_REG0[[0..31]]->NXM_NX_CT_MARK[[]])),4 | |
1237 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1238 | priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3 | |
1239 | ]) | |
1240 | ||
6cfa8ec3 | 1241 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1242 | |
7ed40afe JS |
1243 | OVS_START_L7([at_ns1], [http]) |
1244 | OVS_START_L7([at_ns3], [http]) | |
1245 | ||
8e53fe8c | 1246 | dnl HTTP requests from p0->p1 should work fine. |
8e53fe8c | 1247 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
420c73b2 JR |
1248 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1249 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),mark=1,protoinfo=(state=<cleared>) | |
8e53fe8c JS |
1250 | ]) |
1251 | ||
1252 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1253 | dnl Try 3 times, in 1 second intervals. | |
8e53fe8c | 1254 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
ec3aa16c | 1255 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1256 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),mark=2,protoinfo=(state=<cleared>) |
8e53fe8c JS |
1257 | ]) |
1258 | ||
1259 | OVS_TRAFFIC_VSWITCHD_STOP | |
1260 | AT_CLEANUP | |
1261 | ||
9daf2348 JS |
1262 | AT_SETUP([conntrack - ct_label]) |
1263 | CHECK_CONNTRACK() | |
cf7659b6 | 1264 | OVS_TRAFFIC_VSWITCHD_START() |
9daf2348 JS |
1265 | |
1266 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1267 | ||
1268 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1269 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1270 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1271 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1272 | ||
1273 | dnl Allow traffic between ns0<->ns1 using the ct_label. | |
1274 | dnl Check that different labels do not match for traffic between ns2<->ns3. | |
1275 | AT_DATA([flows.txt], [dnl | |
1276 | priority=1,action=drop | |
1277 | priority=10,arp,action=normal | |
1278 | priority=10,icmp,action=normal | |
1279 | priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:0x0a000d000005000001->ct_label)),2 | |
1280 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1281 | priority=100,in_port=2,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=1 | |
1282 | priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:0x2->ct_label)),4 | |
1283 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1284 | priority=100,in_port=4,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=3 | |
1285 | ]) | |
1286 | ||
6cfa8ec3 | 1287 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
9daf2348 | 1288 | |
7ed40afe JS |
1289 | OVS_START_L7([at_ns1], [http]) |
1290 | OVS_START_L7([at_ns3], [http]) | |
1291 | ||
9daf2348 | 1292 | dnl HTTP requests from p0->p1 should work fine. |
9daf2348 JS |
1293 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1294 | ||
1295 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1296 | dnl Try 3 times, in 1 second intervals. | |
9daf2348 JS |
1297 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
1298 | ||
1299 | OVS_TRAFFIC_VSWITCHD_STOP | |
1300 | AT_CLEANUP | |
1301 | ||
4d182934 JS |
1302 | AT_SETUP([conntrack - ct_label bit-fiddling]) |
1303 | CHECK_CONNTRACK() | |
1304 | OVS_TRAFFIC_VSWITCHD_START() | |
1305 | ||
1306 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1307 | ||
1308 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1309 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1310 | ||
1311 | dnl Allow traffic between ns0<->ns1 using the ct_labels. Return traffic should | |
1312 | dnl cause an additional bit to be set in the connection labels (and be allowed) | |
1313 | AT_DATA([flows.txt], [dnl | |
1314 | table=0,priority=1,action=drop | |
1315 | table=0,priority=10,arp,action=normal | |
1316 | table=0,priority=10,icmp,action=normal | |
1317 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1318 | table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=1,commit,exec(set_field:0x200000000/0x200000004->ct_label)) | |
723af132 JS |
1319 | table=1,in_port=1,tcp,ct_state=+new,action=ct(commit,exec(set_field:0x5/0x5->ct_label)),2 |
1320 | table=1,in_port=1,tcp,ct_state=-new,action=2 | |
1321 | table=1,in_port=2,ct_state=+trk,ct_label=0x200000001,tcp,action=1 | |
4d182934 JS |
1322 | ]) |
1323 | ||
1324 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1325 | ||
7ed40afe JS |
1326 | OVS_START_L7([at_ns1], [http]) |
1327 | ||
4d182934 | 1328 | dnl HTTP requests from p0->p1 should work fine. |
4d182934 JS |
1329 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1330 | ||
420c73b2 JR |
1331 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1332 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),labels=0x200000001,protoinfo=(state=<cleared>) | |
4d182934 JS |
1333 | ]) |
1334 | ||
1335 | OVS_TRAFFIC_VSWITCHD_STOP | |
1336 | AT_CLEANUP | |
1337 | ||
f2d105b5 JS |
1338 | AT_SETUP([conntrack - ct metadata, multiple zones]) |
1339 | CHECK_CONNTRACK() | |
1340 | OVS_TRAFFIC_VSWITCHD_START() | |
1341 | ||
1342 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1343 | ||
1344 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1345 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1346 | ||
1347 | dnl Allow traffic between ns0<->ns1 using the ct_mark and ct_labels in zone=1, | |
1348 | dnl but do *not* set any of these for the ct() in zone=2. Traffic should pass, | |
1349 | dnl and we should see that the conntrack entries only apply the ct_mark and | |
1350 | dnl ct_labels to the connection in zone=1. | |
1351 | AT_DATA([flows.txt], [dnl | |
1352 | table=0,priority=1,action=drop | |
1353 | table=0,priority=10,arp,action=normal | |
1354 | table=0,priority=10,icmp,action=normal | |
1355 | table=0,priority=100,in_port=1,tcp,action=ct(zone=1,table=1) | |
1356 | table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(zone=1,table=1,commit,exec(set_field:0x200000000/0x200000004->ct_label,set_field:0x2/0x6->ct_mark)) | |
723af132 JS |
1357 | table=1,in_port=1,tcp,ct_state=+new,action=ct(zone=1,commit,exec(set_field:0x5/0x5->ct_label,set_field:0x5/0x5->ct_mark)),ct(commit,zone=2),2 |
1358 | table=1,in_port=1,tcp,ct_state=-new,action=ct(zone=2),2 | |
1359 | table=1,in_port=2,tcp,action=ct(zone=2),1 | |
f2d105b5 JS |
1360 | ]) |
1361 | ||
1362 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1363 | ||
7ed40afe JS |
1364 | OVS_START_L7([at_ns1], [http]) |
1365 | ||
f2d105b5 | 1366 | dnl HTTP requests from p0->p1 should work fine. |
f2d105b5 JS |
1367 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1368 | ||
420c73b2 JR |
1369 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1370 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,mark=3,labels=0x200000001,protoinfo=(state=<cleared>) | |
1371 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
f2d105b5 JS |
1372 | ]) |
1373 | ||
1374 | OVS_TRAFFIC_VSWITCHD_STOP | |
1375 | AT_CLEANUP | |
1376 | ||
8e53fe8c | 1377 | AT_SETUP([conntrack - ICMP related]) |
9c1ab985 | 1378 | AT_SKIP_IF([test $HAVE_NC = no]) |
8e53fe8c | 1379 | CHECK_CONNTRACK() |
cf7659b6 | 1380 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1381 | |
1382 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1383 | ||
1384 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1385 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1386 | ||
1387 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
1388 | AT_DATA([flows.txt], [dnl | |
1389 | priority=1,action=drop | |
1390 | priority=10,arp,action=normal | |
1391 | priority=100,in_port=1,udp,action=ct(commit,exec(set_field:1->ct_mark)),2 | |
1392 | priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0) | |
1393 | priority=100,in_port=2,icmp,ct_state=+trk+rel,ct_mark=1,action=1 | |
1394 | ]) | |
1395 | ||
6cfa8ec3 | 1396 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1397 | |
bde2e7b5 | 1398 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. |
b54971f7 | 1399 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) |
8e53fe8c JS |
1400 | |
1401 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
1402 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
1403 | n_packets=1, n_bytes=44, priority=100,udp,in_port=1 actions=ct(commit,exec(load:0x1->NXM_NX_CT_MARK[[]])),output:2 | |
1404 | n_packets=1, n_bytes=72, priority=100,ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2 actions=output:1 | |
1405 | n_packets=1, n_bytes=72, priority=100,ct_state=-trk,icmp,in_port=2 actions=ct(table=0) | |
bde2e7b5 | 1406 | n_packets=2, n_bytes=84, priority=10,arp actions=NORMAL |
8e53fe8c JS |
1407 | NXST_FLOW reply: |
1408 | ]) | |
1409 | ||
1410 | OVS_TRAFFIC_VSWITCHD_STOP | |
1411 | AT_CLEANUP | |
1412 | ||
d0e42062 JR |
1413 | AT_SETUP([conntrack - ICMP related to original direction]) |
1414 | AT_SKIP_IF([test $HAVE_NC = no]) | |
1415 | CHECK_CONNTRACK() | |
1416 | OVS_TRAFFIC_VSWITCHD_START() | |
1417 | ||
1418 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1419 | ||
1420 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1421 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1422 | ||
1423 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
1424 | AT_DATA([flows.txt], [dnl | |
1425 | priority=1000,arp,action=normal | |
1426 | priority=100,ip,action=ct(table=1) | |
1427 | priority=1,action=drop | |
1428 | table=1,ip,action=ct(zone=34673,table=2) | |
1429 | table=2,in_port=2,udp,action=ct(commit,zone=34673),1 | |
1430 | table=2,in_port=1,udp,action=ct(commit,zone=34673),2 | |
1431 | table=2,in_port=2,ct_state=+rel,icmp,action=1 | |
1432 | ]) | |
1433 | ||
1434 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1435 | ||
1436 | dnl 1. Send and UDP packet to port 53 (src=192.100.1.8,dst=192.100.2.5) | |
1437 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) '00010200020400232211223308004500001c000100004011f6fac0640108c06402050035003500087b9e']) | |
1438 | ||
1439 | dnl 2. Send and UDP packet to port 53 (src=192.100.2.5,dst=192.100.1.8) | |
1440 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 resubmit\(,0\) '00232211223300010200020408004500001c000100004011f6fac0640205c06401080035003500087b9e']) | |
1441 | ||
1442 | dnl 3. Send an ICMP port unreach reply for port 53, related to the 2nd | |
1443 | dnl packet, but in the original direction of the conntrack entry created | |
1444 | dnl for the 1st packet. | |
1445 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) '000102000204002322112233080045000038000100003f01f7eec0640108c0640205030a80e5ffffffff4500001c000100003f11f7fac0640205c06401080035003500087b9e']) | |
1446 | ||
1447 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
1448 | ||
1449 | dnl 4. Repeat 3. | |
1450 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) '000102000204002322112233080045000038000100003f01f7eec0640108c0640205030a80e5ffffffff4500001c000100003f11f7fac0640205c06401080035003500087b9e']) | |
1451 | ||
1452 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
1453 | ||
1454 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
1455 | n_packets=4, n_bytes=224, priority=100,ip actions=ct(table=1) | |
1456 | priority=1000,arp actions=NORMAL | |
1457 | table=1, n_packets=4, n_bytes=224, ip actions=ct(table=2,zone=34673) | |
1458 | table=2, n_packets=1, n_bytes=42, udp,in_port=1 actions=ct(commit,zone=34673),output:2 | |
1459 | table=2, n_packets=1, n_bytes=42, udp,in_port=2 actions=ct(commit,zone=34673),output:1 | |
1460 | table=2, n_packets=2, n_bytes=140, ct_state=+rel,icmp,in_port=2 actions=output:1 | |
1461 | NXST_FLOW reply: | |
1462 | ]) | |
1463 | ||
1464 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(192.100.1.8)], [0], [dnl | |
1465 | udp,orig=(src=192.100.1.8,dst=192.100.2.5,sport=<cleared>,dport=<cleared>),reply=(src=192.100.2.5,dst=192.100.1.8,sport=<cleared>,dport=<cleared>),zone=34673 | |
1466 | ]) | |
1467 | ||
1468 | OVS_TRAFFIC_VSWITCHD_STOP | |
1469 | AT_CLEANUP | |
1470 | ||
07659514 JS |
1471 | AT_SETUP([conntrack - ICMP related 2]) |
1472 | CHECK_CONNTRACK() | |
cf7659b6 | 1473 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
1474 | |
1475 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1476 | ||
1477 | ADD_VETH(p0, at_ns0, br0, "172.16.0.1/24") | |
1478 | ADD_VETH(p1, at_ns1, br0, "172.16.0.2/24") | |
1479 | ||
1480 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1481 | AT_DATA([flows.txt], [dnl | |
5c2e106b DDP |
1482 | table=0,ip,action=ct(commit,table=1) |
1483 | table=1,ip,action=controller | |
07659514 JS |
1484 | ]) |
1485 | ||
6cfa8ec3 | 1486 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt]) |
07659514 JS |
1487 | |
1488 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
1489 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
1490 | ||
1491 | dnl 1. Send an ICMP port unreach reply for port 8738, without any previous request | |
5c2e106b | 1492 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) 'f64c473528c9c6f54ecb72db080045c0003d2e8700004001f351ac100004ac1000030303da490000000045000021317040004011b138ac100003ac10000411112222000d20966369616f0a']) |
07659514 JS |
1493 | |
1494 | dnl 2. Send and UDP packet to port 5555 | |
5c2e106b | 1495 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 resubmit\(,0\) 'c6f94ecb72dbe64c473528c9080045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a']) |
07659514 JS |
1496 | |
1497 | dnl 3. Send an ICMP port unreach reply for port 5555, related to the first packet | |
5c2e106b | 1498 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) 'e64c473528c9c6f94ecb72db080045c0003d2e8700004001f355ac100002ac1000010303553f0000000045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a']) |
07659514 JS |
1499 | |
1500 | dnl Check this output. We only see the latter two packets, not the first. | |
1501 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
5c2e106b DDP |
1502 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=75 ct_state=inv|trk,in_port=2 (via action) data_len=75 (unbuffered) |
1503 | icmp,vlan_tci=0x0000,dl_src=c6:f5:4e:cb:72:db,dl_dst=f6:4c:47:35:28:c9,nw_src=172.16.0.4,nw_dst=172.16.0.3,nw_tos=192,nw_ecn=0,nw_ttl=64,icmp_type=3,icmp_code=3 icmp_csum:da49 | |
daf4d3c1 | 1504 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=47 ct_state=new|trk,ct_nw_src=172.16.0.1,ct_nw_dst=172.16.0.2,ct_nw_proto=17,ct_tp_src=41614,ct_tp_dst=5555,in_port=1 (via action) data_len=47 (unbuffered) |
07659514 | 1505 | udp,vlan_tci=0x0000,dl_src=e6:4c:47:35:28:c9,dl_dst=c6:f9:4e:cb:72:db,nw_src=172.16.0.1,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=41614,tp_dst=5555 udp_csum:2096 |
daf4d3c1 | 1506 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=75 ct_state=rel|rpl|trk,ct_nw_src=172.16.0.1,ct_nw_dst=172.16.0.2,ct_nw_proto=17,ct_tp_src=41614,ct_tp_dst=5555,in_port=2 (via action) data_len=75 (unbuffered) |
07659514 JS |
1507 | icmp,vlan_tci=0x0000,dl_src=c6:f9:4e:cb:72:db,dl_dst=e6:4c:47:35:28:c9,nw_src=172.16.0.2,nw_dst=172.16.0.1,nw_tos=192,nw_ecn=0,nw_ttl=64,icmp_type=3,icmp_code=3 icmp_csum:553f |
1508 | ]) | |
1509 | ||
5c2e106b DDP |
1510 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.1)], [0], [dnl |
1511 | udp,orig=(src=172.16.0.1,dst=172.16.0.2,sport=<cleared>,dport=<cleared>),reply=(src=172.16.0.2,dst=172.16.0.1,sport=<cleared>,dport=<cleared>) | |
1512 | ]) | |
1513 | ||
1514 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.3)], [0], [dnl | |
1515 | ]) | |
1516 | ||
07659514 JS |
1517 | OVS_TRAFFIC_VSWITCHD_STOP |
1518 | AT_CLEANUP | |
d787ad39 | 1519 | |
daf4d3c1 | 1520 | AT_SETUP([conntrack - IPv4 fragmentation]) |
d787ad39 | 1521 | CHECK_CONNTRACK() |
1d768544 | 1522 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1523 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1524 | |
1525 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1526 | ||
1527 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1528 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1529 | ||
1530 | dnl Sending ping through conntrack | |
1531 | AT_DATA([flows.txt], [dnl | |
1532 | priority=1,action=drop | |
1533 | priority=10,arp,action=normal | |
1534 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1535 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1536 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1537 | ]) | |
1538 | ||
6cfa8ec3 | 1539 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1540 | |
27130224 AZ |
1541 | dnl Ipv4 fragmentation connectivity check. |
1542 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1543 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1544 | ]) | |
1545 | ||
1546 | dnl Ipv4 larger fragmentation connectivity check. | |
1547 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1548 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1549 | ]) | |
1550 | ||
1551 | OVS_TRAFFIC_VSWITCHD_STOP | |
1552 | AT_CLEANUP | |
1553 | ||
0cf28088 JS |
1554 | AT_SETUP([conntrack - IPv4 fragmentation expiry]) |
1555 | CHECK_CONNTRACK() | |
4573c42e | 1556 | CHECK_CONNTRACK_FRAG() |
0cf28088 JS |
1557 | OVS_TRAFFIC_VSWITCHD_START() |
1558 | ||
1559 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1560 | ||
1561 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1562 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1563 | ||
1564 | AT_DATA([flows.txt], [dnl | |
1565 | priority=1,action=drop | |
1566 | priority=10,arp,action=normal | |
1567 | ||
1568 | dnl Only allow non-fragmented messages and 1st fragments of each message | |
1569 | priority=100,in_port=1,icmp,ip_frag=no,action=ct(commit,zone=9),2 | |
1570 | priority=100,in_port=1,icmp,ip_frag=firstaction=ct(commit,zone=9),2 | |
1571 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1572 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1573 | ]) | |
1574 | ||
1575 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1576 | ||
0cf28088 JS |
1577 | dnl Ipv4 fragmentation connectivity check. |
1578 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 1 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1579 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1580 | ]) | |
1581 | ||
1582 | OVS_TRAFFIC_VSWITCHD_STOP | |
1583 | AT_CLEANUP | |
1584 | ||
27130224 AZ |
1585 | AT_SETUP([conntrack - IPv4 fragmentation + vlan]) |
1586 | CHECK_CONNTRACK() | |
4573c42e | 1587 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1588 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1589 | |
1590 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1591 | ||
1592 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1593 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1594 | ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24") | |
1595 | ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24") | |
1596 | ||
1597 | dnl Sending ping through conntrack | |
1598 | AT_DATA([flows.txt], [dnl | |
1599 | priority=1,action=drop | |
1600 | priority=10,arp,action=normal | |
1601 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1602 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1603 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1604 | ]) | |
1605 | ||
6cfa8ec3 | 1606 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1607 | |
27130224 AZ |
1608 | dnl Ipv4 fragmentation connectivity check. |
1609 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1610 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1611 | ]) | |
1612 | ||
1613 | dnl Ipv4 larger fragmentation connectivity check. | |
1614 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1615 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1616 | ]) | |
1617 | ||
1618 | OVS_TRAFFIC_VSWITCHD_STOP | |
1619 | AT_CLEANUP | |
1620 | ||
2526a3dc EG |
1621 | AT_SETUP([conntrack - IPv4 fragmentation + cvlan]) |
1622 | CHECK_CONNTRACK() | |
1623 | CHECK_CONNTRACK_FRAG() | |
1624 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
1625 | OVS_CHECK_8021AD() | |
1626 | ||
1627 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1628 | ||
1629 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1630 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1631 | ||
1632 | ADD_SVLAN(p0, at_ns0, 4094, "10.255.2.1/24") | |
1633 | ADD_SVLAN(p1, at_ns1, 4094, "10.255.2.2/24") | |
1634 | ||
1635 | ADD_CVLAN(p0.4094, at_ns0, 100, "10.2.2.1/24") | |
1636 | ADD_CVLAN(p1.4094, at_ns1, 100, "10.2.2.2/24") | |
1637 | ||
1638 | dnl Sending ping through conntrack | |
1639 | AT_DATA([flows.txt], [dnl | |
1640 | priority=1,action=drop | |
1641 | priority=10,arp,action=normal | |
1642 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1643 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1644 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1645 | ]) | |
1646 | ||
1647 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1648 | ||
1649 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
1650 | ||
1651 | dnl Ipv4 fragmentation connectivity check. | |
1652 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1653 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1654 | ]) | |
1655 | ||
1656 | dnl Ipv4 fragmentation connectivity check. (outer svlan) | |
1657 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.255.2.2 | FORMAT_PING], [0], [dnl | |
1658 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1659 | ]) | |
1660 | ||
1661 | dnl Ipv4 larger fragmentation connectivity check. | |
1662 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1663 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1664 | ]) | |
1665 | ||
1666 | dnl Ipv4 larger fragmentation connectivity check. (outer svlan) | |
1667 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.255.2.2 | FORMAT_PING], [0], [dnl | |
1668 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1669 | ]) | |
1670 | ||
1671 | OVS_TRAFFIC_VSWITCHD_STOP | |
1672 | AT_CLEANUP | |
1673 | ||
27130224 AZ |
1674 | AT_SETUP([conntrack - IPv6 fragmentation]) |
1675 | CHECK_CONNTRACK() | |
4573c42e | 1676 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1677 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1678 | |
1679 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1680 | ||
1681 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1682 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1683 | ||
1684 | dnl Sending ping through conntrack | |
1685 | AT_DATA([flows.txt], [dnl | |
1686 | priority=1,action=drop | |
1687 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1688 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1689 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1690 | priority=100,icmp6,icmp_type=135,action=normal | |
1691 | priority=100,icmp6,icmp_type=136,action=normal | |
1692 | ]) | |
1693 | ||
6cfa8ec3 | 1694 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1695 | |
c10840ff JS |
1696 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1697 | dnl waiting, we get occasional failures due to the following error: | |
27130224 | 1698 | dnl "connect: Cannot assign requested address" |
c10840ff | 1699 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
27130224 | 1700 | |
221a2668 | 1701 | dnl Ipv6 fragmentation connectivity check. |
27130224 AZ |
1702 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
1703 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1704 | ]) | |
1705 | ||
221a2668 | 1706 | dnl Ipv6 larger fragmentation connectivity check. |
27130224 AZ |
1707 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
1708 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1709 | ]) | |
1710 | ||
1711 | OVS_TRAFFIC_VSWITCHD_STOP | |
1712 | AT_CLEANUP | |
1713 | ||
0cf28088 JS |
1714 | AT_SETUP([conntrack - IPv6 fragmentation expiry]) |
1715 | CHECK_CONNTRACK() | |
4573c42e | 1716 | CHECK_CONNTRACK_FRAG() |
0cf28088 JS |
1717 | OVS_TRAFFIC_VSWITCHD_START() |
1718 | ||
1719 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1720 | ||
1721 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1722 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1723 | ||
1724 | AT_DATA([flows.txt], [dnl | |
1725 | priority=1,action=drop | |
1726 | ||
1727 | dnl Only allow non-fragmented messages and 1st fragments of each message | |
1728 | priority=10,in_port=1,ipv6,ip_frag=first,action=ct(commit,zone=9),2 | |
1729 | priority=10,in_port=1,ipv6,ip_frag=no,action=ct(commit,zone=9),2 | |
1730 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1731 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1732 | ||
1733 | dnl Neighbour Discovery | |
1734 | priority=100,icmp6,icmp_type=135,action=normal | |
1735 | priority=100,icmp6,icmp_type=136,action=normal | |
1736 | ]) | |
1737 | ||
1738 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1739 | ||
c10840ff JS |
1740 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1741 | dnl waiting, we get occasional failures due to the following error: | |
0cf28088 | 1742 | dnl "connect: Cannot assign requested address" |
c10840ff | 1743 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
0cf28088 | 1744 | |
0cf28088 JS |
1745 | dnl Send an IPv6 fragment. Some time later, it should expire. |
1746 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 1 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1747 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1748 | ]) | |
1749 | ||
1750 | dnl At this point, the kernel will either crash or everything is OK. | |
1751 | ||
1752 | OVS_TRAFFIC_VSWITCHD_STOP | |
1753 | AT_CLEANUP | |
1754 | ||
27130224 AZ |
1755 | AT_SETUP([conntrack - IPv6 fragmentation + vlan]) |
1756 | CHECK_CONNTRACK() | |
4573c42e | 1757 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1758 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1759 | |
1760 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1761 | ||
1762 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1763 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1764 | ||
1765 | ADD_VLAN(p0, at_ns0, 100, "fc00:1::3/96") | |
1766 | ADD_VLAN(p1, at_ns1, 100, "fc00:1::4/96") | |
1767 | ||
1768 | dnl Sending ping through conntrack | |
1769 | AT_DATA([flows.txt], [dnl | |
1770 | priority=1,action=drop | |
1771 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1772 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1773 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1774 | priority=100,icmp6,icmp_type=135,action=normal | |
1775 | priority=100,icmp6,icmp_type=136,action=normal | |
1776 | ]) | |
1777 | ||
6cfa8ec3 | 1778 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1779 | |
c10840ff JS |
1780 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1781 | dnl waiting, we get occasional failures due to the following error: | |
27130224 | 1782 | dnl "connect: Cannot assign requested address" |
c10840ff | 1783 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
27130224 | 1784 | |
27130224 AZ |
1785 | dnl Ipv4 fragmentation connectivity check. |
1786 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1787 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1788 | ]) | |
1789 | ||
1790 | dnl Ipv4 larger fragmentation connectivity check. | |
1791 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1792 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1793 | ]) | |
1794 | ||
1795 | OVS_TRAFFIC_VSWITCHD_STOP | |
1796 | AT_CLEANUP | |
1797 | ||
2526a3dc EG |
1798 | AT_SETUP([conntrack - IPv6 fragmentation + cvlan]) |
1799 | CHECK_CONNTRACK() | |
1800 | CHECK_CONNTRACK_FRAG() | |
1801 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
1802 | OVS_CHECK_8021AD() | |
1803 | ||
1804 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1805 | ||
1806 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1807 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1808 | ||
1809 | ADD_SVLAN(p0, at_ns0, 4094, "fc00:ffff::3/96") | |
1810 | ADD_SVLAN(p1, at_ns1, 4094, "fc00:ffff::4/96") | |
1811 | ||
1812 | ADD_CVLAN(p0.4094, at_ns0, 100, "fc00:1::3/96") | |
1813 | ADD_CVLAN(p1.4094, at_ns1, 100, "fc00:1::4/96") | |
1814 | ||
1815 | dnl Sending ping through conntrack | |
1816 | AT_DATA([flows.txt], [dnl | |
1817 | priority=1,action=drop | |
1818 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1819 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1820 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1821 | priority=100,icmp6,icmp_type=135,action=normal | |
1822 | priority=100,icmp6,icmp_type=136,action=normal | |
1823 | ]) | |
1824 | ||
1825 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1826 | ||
1827 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00:1::4]) | |
1828 | ||
1829 | dnl Ipv6 fragmentation connectivity check. | |
1830 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1831 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1832 | ]) | |
1833 | ||
1834 | dnl Ipv6 fragmentation connectivity check. (outer svlan) | |
1835 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:ffff::4 | FORMAT_PING], [0], [dnl | |
1836 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1837 | ]) | |
1838 | ||
1839 | dnl Ipv6 larger fragmentation connectivity check. | |
1840 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1841 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1842 | ]) | |
1843 | ||
1844 | dnl Ipv6 larger fragmentation connectivity check. (outer svlan) | |
1845 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:ffff::4 | FORMAT_PING], [0], [dnl | |
1846 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1847 | ]) | |
1848 | ||
1849 | OVS_TRAFFIC_VSWITCHD_STOP | |
1850 | AT_CLEANUP | |
1851 | ||
27130224 | 1852 | AT_SETUP([conntrack - Fragmentation over vxlan]) |
dfb21e96 | 1853 | OVS_CHECK_VXLAN() |
27130224 | 1854 | CHECK_CONNTRACK() |
4573c42e | 1855 | CHECK_CONNTRACK_FRAG() |
27130224 | 1856 | |
cf7659b6 JR |
1857 | OVS_TRAFFIC_VSWITCHD_START() |
1858 | ADD_BR([br-underlay]) | |
1859 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
1860 | ||
27130224 AZ |
1861 | ADD_NAMESPACES(at_ns0) |
1862 | ||
1863 | dnl Sending ping through conntrack | |
1864 | AT_DATA([flows.txt], [dnl | |
1865 | priority=1,action=drop | |
1866 | priority=10,arp,action=normal | |
1867 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),LOCAL | |
3a9eb803 | 1868 | priority=100,in_port=LOCAL,icmp,action=ct(table=1,zone=9) |
723af132 | 1869 | table=1,in_port=LOCAL,ct_state=+trk+est,icmp,action=1 |
27130224 AZ |
1870 | ]) |
1871 | ||
6cfa8ec3 | 1872 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 AZ |
1873 | |
1874 | dnl Set up underlay link from host into the namespace using veth pair. | |
1875 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
1876 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
1877 | AT_CHECK([ip link set dev br-underlay up]) | |
1878 | ||
1879 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
1880 | dnl linux device inside the namespace. | |
6e3a764c | 1881 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) |
27130224 AZ |
1882 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], |
1883 | [id 0 dstport 4789]) | |
1884 | ||
1885 | dnl First, check the underlay | |
1886 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
1887 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1888 | ]) | |
1889 | ||
1890 | dnl Okay, now check the overlay with different packet sizes | |
1891 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
1892 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1893 | ]) | |
1894 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
1895 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1896 | ]) | |
1897 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
1898 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1899 | ]) | |
1900 | ||
1901 | OVS_TRAFFIC_VSWITCHD_STOP | |
1902 | AT_CLEANUP | |
c4e34c61 | 1903 | |
84f646df | 1904 | AT_SETUP([conntrack - IPv6 Fragmentation over vxlan]) |
a9f70f3d | 1905 | OVS_CHECK_VXLAN() |
84f646df | 1906 | CHECK_CONNTRACK() |
4573c42e | 1907 | CHECK_CONNTRACK_FRAG() |
84f646df JS |
1908 | |
1909 | OVS_TRAFFIC_VSWITCHD_START() | |
1910 | ADD_BR([br-underlay]) | |
1911 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
1912 | ||
1913 | ADD_NAMESPACES(at_ns0) | |
1914 | ||
1915 | dnl Sending ping through conntrack | |
1916 | AT_DATA([flows.txt], [dnl | |
1917 | priority=1,action=drop | |
1918 | priority=100,in_port=1,ipv6,action=ct(commit,zone=9),LOCAL | |
1919 | priority=100,in_port=LOCAL,ipv6,action=ct(table=1,zone=9) | |
723af132 | 1920 | table=1,in_port=LOCAL,ct_state=+trk+est,ipv6,action=1 |
84f646df JS |
1921 | |
1922 | dnl Neighbour Discovery | |
1923 | priority=1000,icmp6,icmp_type=135,action=normal | |
1924 | priority=1000,icmp6,icmp_type=136,action=normal | |
1925 | ]) | |
1926 | ||
1927 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1928 | ||
1929 | dnl Set up underlay link from host into the namespace using veth pair. | |
1930 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
1931 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
1932 | AT_CHECK([ip link set dev br-underlay up]) | |
1933 | ||
1934 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
1935 | dnl linux device inside the namespace. | |
6e3a764c | 1936 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], ["fc00::2/96"]) |
84f646df JS |
1937 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], ["fc00::1/96"], |
1938 | [id 0 dstport 4789]) | |
1939 | ||
c10840ff JS |
1940 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1941 | dnl waiting, we get occasional failures due to the following error: | |
84f646df | 1942 | dnl "connect: Cannot assign requested address" |
c10840ff | 1943 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
84f646df JS |
1944 | |
1945 | dnl First, check the underlay | |
1946 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
1947 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1948 | ]) | |
1949 | ||
1950 | dnl Okay, now check the overlay with different packet sizes | |
1951 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1952 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1953 | ]) | |
1954 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1955 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1956 | ]) | |
1957 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1958 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1959 | ]) | |
1960 | ||
1961 | OVS_TRAFFIC_VSWITCHD_STOP | |
1962 | AT_CLEANUP | |
9ac0aada | 1963 | |
c4e34c61 RB |
1964 | AT_SETUP([conntrack - resubmit to ct multiple times]) |
1965 | CHECK_CONNTRACK() | |
1966 | ||
1967 | OVS_TRAFFIC_VSWITCHD_START( | |
1968 | [set-fail-mode br0 secure -- ]) | |
1969 | ||
1970 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1971 | ||
1972 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1973 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1974 | ||
1975 | AT_DATA([flows.txt], [dnl | |
1976 | table=0,priority=150,arp,action=normal | |
1977 | table=0,priority=100,ip,in_port=1,action=resubmit(,1),resubmit(,2) | |
1978 | ||
723af132 JS |
1979 | table=1,ip,action=ct(table=3) |
1980 | table=2,ip,action=ct(table=3) | |
c4e34c61 RB |
1981 | |
1982 | table=3,ip,action=drop | |
1983 | ]) | |
1984 | ||
1985 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
1986 | ||
1987 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1988 | 1 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1989 | ]) | |
1990 | ||
1991 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl | |
1992 | n_packets=1, n_bytes=98, priority=100,ip,in_port=1 actions=resubmit(,1),resubmit(,2) | |
1993 | n_packets=2, n_bytes=84, priority=150,arp actions=NORMAL | |
723af132 JS |
1994 | table=1, n_packets=1, n_bytes=98, ip actions=ct(table=3) |
1995 | table=2, n_packets=1, n_bytes=98, ip actions=ct(table=3) | |
c4e34c61 RB |
1996 | table=3, n_packets=2, n_bytes=196, ip actions=drop |
1997 | NXST_FLOW reply: | |
1998 | ]) | |
1999 | ||
2000 | OVS_TRAFFIC_VSWITCHD_STOP | |
2001 | AT_CLEANUP | |
9ac0aada | 2002 | |
1d768544 JS |
2003 | AT_BANNER([conntrack - L7]) |
2004 | ||
2005 | AT_SETUP([conntrack - IPv4 HTTP]) | |
2006 | CHECK_CONNTRACK() | |
2007 | OVS_TRAFFIC_VSWITCHD_START() | |
2008 | ||
2009 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2010 | ||
2011 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2012 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2013 | ||
2014 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2015 | AT_DATA([flows.txt], [dnl | |
2016 | priority=1,action=drop | |
2017 | priority=10,arp,action=normal | |
2018 | priority=10,icmp,action=normal | |
2019 | priority=100,in_port=1,tcp,action=ct(commit),2 | |
2020 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
2021 | priority=100,in_port=2,ct_state=+trk+est,tcp,action=1 | |
2022 | ]) | |
2023 | ||
2024 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2025 | ||
2026 | OVS_START_L7([at_ns0], [http]) | |
2027 | OVS_START_L7([at_ns1], [http]) | |
2028 | ||
2029 | dnl HTTP requests from ns0->ns1 should work fine. | |
2030 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2031 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2032 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2033 | ]) | |
2034 | ||
2035 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
2036 | dnl Try 3 times, in 1 second intervals. | |
2037 | NS_CHECK_EXEC([at_ns1], [wget 10.1.1.1 -t 3 -T 1 --retry-connrefused -v -o wget1.log], [4]) | |
2038 | ||
2039 | OVS_TRAFFIC_VSWITCHD_STOP | |
2040 | AT_CLEANUP | |
2041 | ||
2042 | AT_SETUP([conntrack - IPv6 HTTP]) | |
2043 | CHECK_CONNTRACK() | |
2044 | OVS_TRAFFIC_VSWITCHD_START() | |
2045 | ||
2046 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2047 | ||
2048 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
2049 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
2050 | ||
2051 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2052 | AT_DATA([flows.txt], [dnl | |
2053 | priority=1,action=drop | |
2054 | priority=10,icmp6,action=normal | |
2055 | priority=100,in_port=1,tcp6,action=ct(commit),2 | |
2056 | priority=100,in_port=2,ct_state=-trk,tcp6,action=ct(table=0) | |
2057 | priority=100,in_port=2,ct_state=+trk+est,tcp6,action=1 | |
2058 | ]) | |
2059 | ||
2060 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2061 | ||
2062 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
2063 | dnl waiting, we get occasional failures due to the following error: | |
2064 | dnl "connect: Cannot assign requested address" | |
2065 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) | |
2066 | ||
2067 | OVS_START_L7([at_ns0], [http6]) | |
2068 | OVS_START_L7([at_ns1], [http6]) | |
2069 | ||
2070 | dnl HTTP requests from ns0->ns1 should work fine. | |
2071 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2072 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
2073 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2074 | ]) | |
2075 | ||
2076 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
2077 | dnl Try 3 times, in 1 second intervals. | |
2078 | NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 --retry-connrefused -v -o wget1.log], [4]) | |
2079 | ||
2080 | OVS_TRAFFIC_VSWITCHD_STOP | |
2081 | AT_CLEANUP | |
2082 | ||
2083 | AT_SETUP([conntrack - commit, recirc]) | |
2084 | CHECK_CONNTRACK() | |
2085 | OVS_TRAFFIC_VSWITCHD_START() | |
2086 | ||
2087 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
2088 | ||
2089 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2090 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2091 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
2092 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
2093 | ||
2094 | dnl Allow any traffic from ns0->ns1, ns2->ns3. | |
2095 | AT_DATA([flows.txt], [dnl | |
2096 | priority=1,action=drop | |
2097 | priority=10,arp,action=normal | |
2098 | priority=10,icmp,action=normal | |
2099 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0) | |
2100 | priority=100,in_port=1,tcp,ct_state=+trk,action=2 | |
2101 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0) | |
2102 | priority=100,in_port=2,tcp,ct_state=+trk,action=1 | |
2103 | priority=100,in_port=3,tcp,ct_state=-trk,action=set_field:0->metadata,ct(table=0) | |
2104 | priority=100,in_port=3,tcp,ct_state=+trk,metadata=0,action=set_field:1->metadata,ct(commit,table=0) | |
2105 | priority=100,in_port=3,tcp,ct_state=+trk,metadata=1,action=4 | |
2106 | priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0) | |
2107 | priority=100,in_port=4,tcp,ct_state=+trk,action=3 | |
2108 | ]) | |
2109 | ||
2110 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2111 | ||
2112 | OVS_START_L7([at_ns1], [http]) | |
2113 | OVS_START_L7([at_ns3], [http]) | |
2114 | ||
2115 | dnl HTTP requests from p0->p1 should work fine. | |
2116 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2117 | ||
2118 | dnl HTTP requests from p2->p3 should work fine. | |
2119 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) | |
2120 | ||
2121 | OVS_TRAFFIC_VSWITCHD_STOP | |
2122 | AT_CLEANUP | |
2123 | ||
2124 | AT_SETUP([conntrack - multiple zones, local]) | |
2125 | CHECK_CONNTRACK() | |
2126 | CHECK_CONNTRACK_LOCAL_STACK() | |
2127 | OVS_TRAFFIC_VSWITCHD_START() | |
2128 | ||
2129 | ADD_NAMESPACES(at_ns0) | |
2130 | ||
2131 | AT_CHECK([ip addr add dev br0 "10.1.1.1/24"]) | |
2132 | AT_CHECK([ip link set dev br0 up]) | |
2133 | on_exit 'ip addr del dev br0 "10.1.1.1/24"' | |
2134 | ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24") | |
2135 | ||
2136 | dnl Allow traffic from local stack to ns0. Only allow neighbour discovery, | |
2137 | dnl return traffic from ns0 back to the local stack. | |
2138 | AT_DATA([flows.txt], [dnl | |
2139 | priority=1,action=drop | |
2140 | priority=10,arp,action=normal | |
2141 | priority=100,in_port=LOCAL,ip,ct_state=-trk,action=drop | |
2142 | priority=100,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=1),ct(commit,zone=2),1 | |
2143 | priority=100,in_port=LOCAL,ip,ct_state=+trk+est,action=ct(commit,zone=1),ct(commit,zone=2),1 | |
2144 | priority=100,in_port=1,ip,ct_state=-trk,action=ct(table=1,zone=1) | |
2145 | table=1,in_port=1,ip,ct_state=+trk+est,ct_zone=1,action=ct(table=2,zone=2) | |
2146 | table=2,in_port=1,ip,ct_state=+trk+est,ct_zone=2,action=LOCAL | |
2147 | ]) | |
2148 | ||
2149 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2150 | ||
2151 | AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2152 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2153 | ]) | |
2154 | ||
2155 | OVS_START_L7([at_ns0], [http]) | |
2156 | ||
2157 | dnl HTTP requests from root namespace to p0 should work fine. | |
2158 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2159 | ||
2160 | dnl (again) HTTP requests from root namespace to p0 should work fine. | |
2161 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2162 | ||
2163 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl | |
2164 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=1 | |
2165 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=2 | |
2166 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2167 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
2168 | ]) | |
2169 | ||
2170 | OVS_TRAFFIC_VSWITCHD_STOP | |
2171 | AT_CLEANUP | |
2172 | ||
2173 | AT_SETUP([conntrack - multi-stage pipeline, local]) | |
2174 | CHECK_CONNTRACK() | |
2175 | CHECK_CONNTRACK_LOCAL_STACK() | |
2176 | OVS_TRAFFIC_VSWITCHD_START() | |
2177 | ||
2178 | ADD_NAMESPACES(at_ns0) | |
2179 | ||
2180 | AT_CHECK([ip addr add dev br0 "10.1.1.1/24"]) | |
2181 | AT_CHECK([ip link set dev br0 up]) | |
2182 | on_exit 'ip addr del dev br0 "10.1.1.1/24"' | |
2183 | ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24") | |
2184 | ||
2185 | dnl Allow traffic from local stack to ns0. Only allow neighbour discovery, | |
2186 | dnl return traffic from ns0 back to the local stack. | |
2187 | AT_DATA([flows.txt], [dnl | |
2188 | dnl default | |
2189 | table=0,priority=1,action=drop | |
2190 | table=0,priority=10,arp,action=normal | |
2191 | ||
2192 | dnl Load the output port to REG0 | |
2193 | table=0,priority=100,ip,in_port=LOCAL,action=load:1->NXM_NX_REG0[[0..15]],goto_table:1 | |
2194 | table=0,priority=100,ip,in_port=1,action=load:65534->NXM_NX_REG0[[0..15]],goto_table:1 | |
2195 | ||
2196 | dnl Ingress pipeline | |
2197 | dnl - Allow all connections from LOCAL port (commit and proceed to egress) | |
2198 | dnl - All other connections go through conntracker using the input port as | |
2199 | dnl a connection tracking zone. | |
2200 | table=1,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=OXM_OF_IN_PORT[[0..15]]),goto_table:2 | |
2201 | table=1,priority=100,ip,action=ct(table=2,zone=OXM_OF_IN_PORT[[0..15]]) | |
2202 | table=1,priority=1,action=drop | |
2203 | ||
2204 | dnl Egress pipeline | |
2205 | dnl - Allow all connections from LOCAL port (commit and skip to output) | |
2206 | dnl - Allow other established connections to go through conntracker using | |
2207 | dnl output port as a connection tracking zone. | |
2208 | table=2,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=NXM_NX_REG0[[0..15]]),goto_table:4 | |
2209 | table=2,priority=100,ip,ct_state=+trk+est,action=ct(table=3,zone=NXM_NX_REG0[[0..15]]) | |
2210 | table=2,priority=1,action=drop | |
2211 | ||
2212 | dnl Only allow established traffic from egress ct lookup | |
2213 | table=3,priority=100,ip,ct_state=+trk+est,action=goto_table:4 | |
2214 | table=3,priority=1,action=drop | |
2215 | ||
2216 | dnl output table | |
2217 | table=4,priority=100,ip,action=output:NXM_NX_REG0[[]] | |
2218 | ]) | |
2219 | ||
2220 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2221 | ||
2222 | AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2223 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2224 | ]) | |
2225 | ||
2226 | OVS_START_L7([at_ns0], [http]) | |
2227 | ||
2228 | dnl HTTP requests from root namespace to p0 should work fine. | |
2229 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2230 | ||
2231 | dnl (again) HTTP requests from root namespace to p0 should work fine. | |
2232 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2233 | ||
2234 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl | |
2235 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=1 | |
2236 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=65534 | |
2237 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2238 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=65534,protoinfo=(state=<cleared>) | |
2239 | ]) | |
2240 | ||
2241 | OVS_TRAFFIC_VSWITCHD_STOP | |
2242 | AT_CLEANUP | |
2243 | ||
9d3e0e5c JR |
2244 | AT_SETUP([FTP - no conntrack]) |
2245 | AT_SKIP_IF([test $HAVE_FTP = no]) | |
2246 | OVS_TRAFFIC_VSWITCHD_START() | |
2247 | ||
2248 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2249 | ||
2250 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2251 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2252 | ||
2253 | AT_DATA([flows.txt], [dnl | |
2254 | table=0,action=normal | |
2255 | ]) | |
2256 | ||
2257 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt]) | |
2258 | ||
2259 | NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp1.pid]) | |
2260 | NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid]) | |
2261 | OVS_WAIT_UNTIL([ip netns exec at_ns1 netstat -l | grep ftp]) | |
2262 | ||
2263 | dnl FTP requests from p0->p1 should work fine. | |
2264 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2265 | ||
2266 | AT_CHECK([find -name index.html], [0], [dnl | |
2267 | ./index.html | |
2268 | ]) | |
2269 | ||
2270 | OVS_TRAFFIC_VSWITCHD_STOP | |
2271 | AT_CLEANUP | |
2272 | ||
1d768544 | 2273 | AT_SETUP([conntrack - FTP]) |
40c7b2fc | 2274 | AT_SKIP_IF([test $HAVE_FTP = no]) |
1d768544 JS |
2275 | CHECK_CONNTRACK() |
2276 | CHECK_CONNTRACK_ALG() | |
2277 | OVS_TRAFFIC_VSWITCHD_START() | |
2278 | ||
2279 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2280 | ||
2281 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2282 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2283 | ||
2284 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2285 | AT_DATA([flows1.txt], [dnl | |
2286 | table=0,priority=1,action=drop | |
2287 | table=0,priority=10,arp,action=normal | |
2288 | table=0,priority=10,icmp,action=normal | |
2289 | table=0,priority=100,in_port=1,tcp,action=ct(alg=ftp,commit),2 | |
2290 | table=0,priority=100,in_port=2,tcp,action=ct(table=1) | |
2291 | table=1,in_port=2,tcp,ct_state=+trk+est,action=1 | |
2292 | table=1,in_port=2,tcp,ct_state=+trk+rel,action=1 | |
2293 | ]) | |
2294 | ||
2295 | dnl Similar policy but without allowing all traffic from ns0->ns1. | |
2296 | AT_DATA([flows2.txt], [dnl | |
2297 | table=0,priority=1,action=drop | |
2298 | table=0,priority=10,arp,action=normal | |
2299 | table=0,priority=10,icmp,action=normal | |
2300 | ||
2301 | dnl Allow outgoing TCP connections, and treat them as FTP | |
2302 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
2303 | table=1,in_port=1,tcp,ct_state=+trk+new,action=ct(commit,alg=ftp),2 | |
2304 | table=1,in_port=1,tcp,ct_state=+trk+est,action=2 | |
2305 | ||
2306 | dnl Allow incoming FTP data connections and responses to existing connections | |
2307 | table=0,priority=100,in_port=2,tcp,action=ct(table=1) | |
2308 | table=1,in_port=2,tcp,ct_state=+trk+new+rel,action=ct(commit),1 | |
2309 | table=1,in_port=2,tcp,ct_state=+trk+est,action=1 | |
2310 | table=1,in_port=2,tcp,ct_state=+trk-new+rel,action=1 | |
2311 | ]) | |
2312 | ||
2313 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt]) | |
2314 | ||
2315 | OVS_START_L7([at_ns0], [ftp]) | |
2316 | OVS_START_L7([at_ns1], [ftp]) | |
2317 | ||
2318 | dnl FTP requests from p1->p0 should fail due to network failure. | |
2319 | dnl Try 3 times, in 1 second intervals. | |
2320 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
2321 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2322 | ]) | |
2323 | ||
2324 | dnl FTP requests from p0->p1 should work fine. | |
2325 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2326 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2327 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2328 | ]) | |
2329 | ||
2330 | dnl Try the second set of flows. | |
2331 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt]) | |
2332 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2333 | ||
2334 | dnl FTP requests from p1->p0 should fail due to network failure. | |
2335 | dnl Try 3 times, in 1 second intervals. | |
2336 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
2337 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2338 | ]) | |
2339 | ||
2340 | dnl Active FTP requests from p0->p1 should work fine. | |
2341 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0-1.log]) | |
2342 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2343 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2344 | tcp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2345 | ]) | |
2346 | ||
2347 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2348 | ||
2349 | dnl Passive FTP requests from p0->p1 should work fine. | |
2350 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0-2.log]) | |
2351 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2352 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2353 | ]) | |
2354 | ||
2355 | OVS_TRAFFIC_VSWITCHD_STOP | |
2356 | AT_CLEANUP | |
2357 | ||
2358 | AT_SETUP([conntrack - FTP over IPv6]) | |
40c7b2fc | 2359 | AT_SKIP_IF([test $HAVE_FTP = no]) |
1d768544 JS |
2360 | CHECK_CONNTRACK() |
2361 | CHECK_CONNTRACK_ALG() | |
2362 | OVS_TRAFFIC_VSWITCHD_START() | |
2363 | ||
2364 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2365 | ||
2366 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
2367 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
2368 | ||
2369 | dnl Allow any traffic from ns0->ns1. | |
2370 | dnl Only allow nd, return traffic from ns1->ns0. | |
2371 | AT_DATA([flows.txt], [dnl | |
2372 | dnl Track all IPv6 traffic and drop the rest. | |
2373 | dnl Allow ICMPv6 both ways. No commit, so pings will not be tracked. | |
2374 | table=0 priority=100 in_port=1 icmp6, action=2 | |
2375 | table=0 priority=100 in_port=2 icmp6, action=1 | |
2376 | table=0 priority=10 ip6, action=ct(table=1) | |
2377 | table=0 priority=0 action=drop | |
2378 | dnl | |
2379 | dnl Table 1 | |
2380 | dnl | |
2381 | dnl Allow new TCPv6 FTP control connections from port 1. | |
2382 | table=1 in_port=1 ct_state=+new, tcp6, tp_dst=21, action=ct(alg=ftp,commit),2 | |
2383 | dnl Allow related TCPv6 connections from port 2. | |
2384 | table=1 in_port=2 ct_state=+new+rel, tcp6, action=ct(commit),1 | |
2385 | dnl Allow established TCPv6 connections both ways. | |
2386 | table=1 in_port=1 ct_state=+est, tcp6, action=2 | |
2387 | table=1 in_port=2 ct_state=+est, tcp6, action=1 | |
2388 | dnl Drop everything else. | |
2389 | table=1 priority=0, action=drop | |
2390 | ]) | |
2391 | ||
2392 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2393 | ||
2394 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
2395 | dnl waiting, we get occasional failures due to the following error: | |
2396 | dnl "connect: Cannot assign requested address" | |
2397 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
2398 | ||
2399 | OVS_START_L7([at_ns1], [ftp]) | |
2400 | ||
2401 | dnl FTP requests from p0->p1 should work fine. | |
2402 | NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) | |
2403 | ||
2404 | dnl Discards CLOSE_WAIT and CLOSING | |
2405 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
2406 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2407 | tcp,orig=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),reply=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2408 | ]) | |
2409 | ||
2410 | OVS_TRAFFIC_VSWITCHD_STOP | |
2411 | AT_CLEANUP | |
2412 | ||
2413 | AT_SETUP([conntrack - FTP with multiple expectations]) | |
40c7b2fc | 2414 | AT_SKIP_IF([test $HAVE_FTP = no]) |
1d768544 JS |
2415 | CHECK_CONNTRACK() |
2416 | CHECK_CONNTRACK_ALG() | |
2417 | OVS_TRAFFIC_VSWITCHD_START() | |
2418 | ||
2419 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2420 | ||
2421 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2422 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2423 | ||
2424 | dnl Dual-firewall, allow all from ns1->ns2, allow established and ftp ns2->ns1. | |
2425 | AT_DATA([flows.txt], [dnl | |
2426 | table=0,priority=1,action=drop | |
2427 | table=0,priority=10,arp,action=normal | |
2428 | table=0,priority=10,icmp,action=normal | |
2429 | ||
2430 | dnl Traffic from ns1 | |
2431 | table=0,priority=100,in_port=1,tcp,action=ct(table=1,zone=1) | |
2432 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+new-rel,action=ct(commit,alg=ftp,zone=1),ct(commit,alg=ftp,zone=2),2 | |
2433 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+new+rel,action=ct(commit,zone=1),ct(commit,zone=2),2 | |
2434 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+est,action=ct(table=2,zone=2) | |
2435 | table=2,in_port=1,tcp,ct_zone=2,ct_state=+trk+est,action=2 | |
2436 | ||
2437 | dnl Traffic from ns2 | |
2438 | table=0,priority=100,in_port=2,tcp,action=ct(table=1,zone=2) | |
2439 | table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1 | |
2440 | table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+est,action=ct(table=2,zone=1) | |
2441 | table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1 | |
2442 | table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+est,action=1 | |
2443 | ]) | |
2444 | ||
2445 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2446 | ||
2447 | OVS_START_L7([at_ns0], [ftp]) | |
2448 | OVS_START_L7([at_ns1], [ftp]) | |
2449 | ||
2450 | dnl FTP requests from p1->p0 should fail due to network failure. | |
2451 | dnl Try 3 times, in 1 second intervals. | |
2452 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
2453 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2454 | ]) | |
2455 | ||
2456 | dnl Active FTP requests from p0->p1 should work fine. | |
2457 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2458 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2459 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>),helper=ftp | |
2460 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>),helper=ftp | |
2461 | tcp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2462 | tcp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
2463 | ]) | |
2464 | ||
2465 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2466 | ||
2467 | dnl Passive FTP requests from p0->p1 should work fine. | |
2468 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2469 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2470 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2471 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>),helper=ftp | |
2472 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
2473 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>),helper=ftp | |
2474 | ]) | |
2475 | ||
2476 | OVS_TRAFFIC_VSWITCHD_STOP | |
2477 | AT_CLEANUP | |
2478 | ||
40c7b2fc JS |
2479 | AT_SETUP([conntrack - TFTP]) |
2480 | AT_SKIP_IF([test $HAVE_TFTP = no]) | |
2481 | CHECK_CONNTRACK() | |
2482 | CHECK_CONNTRACK_ALG() | |
2483 | OVS_TRAFFIC_VSWITCHD_START() | |
2484 | ||
2485 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2486 | ||
2487 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2488 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2489 | ||
2490 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2491 | AT_DATA([flows1.txt], [dnl | |
2492 | table=0,priority=1,action=drop | |
2493 | table=0,priority=10,arp,action=normal | |
2494 | table=0,priority=10,icmp,action=normal | |
2495 | table=0,priority=100,in_port=1,udp,action=ct(alg=tftp,commit),2 | |
2496 | table=0,priority=100,in_port=2,udp,action=ct(table=1) | |
2497 | table=1,in_port=2,udp,ct_state=+trk+est,action=1 | |
2498 | table=1,in_port=2,udp,ct_state=+trk+rel,action=1 | |
2499 | ]) | |
2500 | ||
2501 | dnl Similar policy but without allowing all traffic from ns0->ns1. | |
2502 | AT_DATA([flows2.txt], [dnl | |
2503 | table=0,priority=1,action=drop | |
2504 | table=0,priority=10,arp,action=normal | |
2505 | table=0,priority=10,icmp,action=normal | |
2506 | ||
2507 | dnl Allow outgoing UDP connections, and treat them as TFTP | |
2508 | table=0,priority=100,in_port=1,udp,action=ct(table=1) | |
2509 | table=1,in_port=1,udp,ct_state=+trk+new-rel,action=ct(commit,alg=tftp),2 | |
2510 | table=1,in_port=1,udp,ct_state=+trk+new+rel,action=ct(commit),2 | |
2511 | table=1,in_port=1,udp,ct_state=+trk+est,action=2 | |
2512 | ||
2513 | dnl Allow incoming TFTP data connections and responses to existing connections | |
2514 | table=0,priority=100,in_port=2,udp,action=ct(table=1) | |
2515 | table=1,in_port=2,udp,ct_state=+trk+est,action=1 | |
2516 | table=1,in_port=2,udp,ct_state=+trk+new+rel,action=1 | |
2517 | ]) | |
2518 | ||
2519 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt]) | |
2520 | ||
2521 | OVS_START_L7([at_ns0], [tftp]) | |
2522 | OVS_START_L7([at_ns1], [tftp]) | |
2523 | ||
2524 | dnl TFTP requests from p1->p0 should fail due to network failure. | |
2525 | NS_CHECK_EXEC([at_ns1], [[curl $CURL_OPT tftp://10.1.1.1/flows1.txt -o foo 2>curl0.log]], [28]) | |
2526 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2527 | ]) | |
2528 | ||
2529 | dnl TFTP requests from p0->p1 should work fine. | |
2530 | NS_CHECK_EXEC([at_ns0], [[curl $CURL_OPT tftp://10.1.1.2/flows1.txt -o foo 2>curl1.log]]) | |
2531 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2532 | udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),helper=tftp | |
2533 | ]) | |
2534 | ||
2535 | dnl Try the second set of flows. | |
2536 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt]) | |
2537 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2538 | ||
2539 | dnl TFTP requests from p1->p0 should fail due to network failure. | |
2540 | NS_CHECK_EXEC([at_ns1], [[curl $CURL_OPT tftp://10.1.1.1/flows1.txt -o foo 2>curl2.log]], [28]) | |
2541 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2542 | ]) | |
2543 | ||
2544 | dnl TFTP requests from p0->p1 should work fine. | |
2545 | NS_CHECK_EXEC([at_ns0], [[curl $CURL_OPT tftp://10.1.1.2/flows1.txt -o foo 2>curl3.log]]) | |
2546 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2547 | udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),helper=tftp | |
2548 | ]) | |
2549 | ||
2550 | OVS_TRAFFIC_VSWITCHD_STOP | |
2551 | AT_CLEANUP | |
2552 | ||
ee8941ab | 2553 | AT_BANNER([conntrack - NAT]) |
9ac0aada JR |
2554 | |
2555 | AT_SETUP([conntrack - simple SNAT]) | |
2556 | CHECK_CONNTRACK() | |
4573c42e | 2557 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2558 | OVS_TRAFFIC_VSWITCHD_START() |
2559 | ||
2560 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2561 | ||
2562 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2563 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2564 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2565 | ||
2566 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2567 | AT_DATA([flows.txt], [dnl | |
2568 | in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2569 | in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat) | |
2570 | in_port=2,ct_state=+trk,ct_zone=1,ip,action=1 | |
2571 | dnl | |
2572 | dnl ARP | |
2573 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2574 | priority=10 arp action=normal | |
2575 | priority=0,action=drop | |
2576 | dnl | |
2577 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2578 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2579 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2580 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2581 | dnl TPA IP in reg2. | |
2582 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2583 | table=10 priority=100 arp xreg0=0 action=normal | |
2584 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2585 | table=10 priority=0 action=drop | |
2586 | ]) | |
2587 | ||
2588 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2589 | ||
2590 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2591 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2592 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2593 | ||
a857bb69 | 2594 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
420c73b2 | 2595 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
9ac0aada JR |
2596 | ]) |
2597 | ||
2598 | OVS_TRAFFIC_VSWITCHD_STOP | |
2599 | AT_CLEANUP | |
2600 | ||
c0324e37 JR |
2601 | AT_SETUP([conntrack - SNAT with ct_mark change on reply]) |
2602 | CHECK_CONNTRACK() | |
2603 | CHECK_CONNTRACK_NAT() | |
2604 | OVS_TRAFFIC_VSWITCHD_START() | |
2605 | ||
2606 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2607 | ||
2608 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2609 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2610 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2611 | ||
2612 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2613 | AT_DATA([flows.txt], [dnl | |
2614 | in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2615 | in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat) | |
2616 | dnl | |
2617 | dnl Setting the mark fails if the datapath can't find the existing conntrack | |
2618 | dnl entry after NAT has been reversed and the skb was lost due to an upcall. | |
2619 | dnl | |
2620 | in_port=2,ct_state=+trk,ct_zone=1,ip,action=ct(table=1,commit,zone=1,exec(set_field:1->ct_mark)),1 | |
2621 | table=1,in_port=2,ct_mark=1,ct_state=+rpl,ct_zone=1,ip,action=1 | |
2622 | dnl | |
2623 | dnl ARP | |
2624 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2625 | priority=10 arp action=normal | |
2626 | priority=0,action=drop | |
2627 | dnl | |
2628 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2629 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2630 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2631 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2632 | dnl TPA IP in reg2. | |
2633 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2634 | table=10 priority=100 arp xreg0=0 action=normal | |
2635 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2636 | table=10 priority=0 action=drop | |
2637 | ]) | |
2638 | ||
2639 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2640 | ||
2641 | dnl HTTP requests from p0->p1 should work fine. | |
2642 | NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid]) | |
2643 | NS_CHECK_EXEC([at_ns0], [ping -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2644 | 1 packets transmitted, 1 received, 0% packet loss, time 0ms | |
2645 | ]) | |
2646 | ||
2647 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl | |
2648 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.2XX,id=<cleared>,type=0,code=0),zone=1,mark=1 | |
2649 | ]) | |
2650 | ||
2651 | OVS_TRAFFIC_VSWITCHD_STOP | |
2652 | AT_CLEANUP | |
9ac0aada JR |
2653 | |
2654 | AT_SETUP([conntrack - SNAT with port range]) | |
2655 | CHECK_CONNTRACK() | |
4573c42e | 2656 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2657 | OVS_TRAFFIC_VSWITCHD_START() |
2658 | ||
2659 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2660 | ||
2661 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2662 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2663 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2664 | ||
2665 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2666 | AT_DATA([flows.txt], [dnl | |
2667 | in_port=1,tcp,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255:34567-34568,random)),2 | |
2668 | in_port=2,ct_state=-trk,tcp,tp_dst=34567,action=ct(table=0,zone=1,nat) | |
2669 | in_port=2,ct_state=-trk,tcp,tp_dst=34568,action=ct(table=0,zone=1,nat) | |
2670 | in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
2671 | dnl | |
2672 | dnl ARP | |
2673 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2674 | priority=10 arp action=normal | |
2675 | priority=0,action=drop | |
2676 | dnl | |
2677 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2678 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2679 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2680 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2681 | dnl TPA IP in reg2. | |
2682 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2683 | table=10 priority=100 arp xreg0=0 action=normal | |
2684 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2685 | table=10 priority=0 action=drop | |
2686 | ]) | |
2687 | ||
2688 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2689 | ||
2690 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2691 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2692 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2693 | ||
a857bb69 | 2694 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
420c73b2 | 2695 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
9ac0aada JR |
2696 | ]) |
2697 | ||
2698 | OVS_TRAFFIC_VSWITCHD_STOP | |
2699 | AT_CLEANUP | |
2700 | ||
2701 | ||
2702 | AT_SETUP([conntrack - more complex SNAT]) | |
2703 | CHECK_CONNTRACK() | |
4573c42e | 2704 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2705 | OVS_TRAFFIC_VSWITCHD_START() |
2706 | ||
2707 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2708 | ||
2709 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2710 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2711 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2712 | ||
2713 | AT_DATA([flows.txt], [dnl | |
2714 | dnl Track all IP traffic, NAT existing connections. | |
2715 | priority=100 ip action=ct(table=1,zone=1,nat) | |
2716 | dnl | |
2717 | dnl Allow ARP, but generate responses for NATed addresses | |
2718 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2719 | priority=10 arp action=normal | |
2720 | priority=0 action=drop | |
2721 | dnl | |
2722 | dnl Allow any traffic from ns0->ns1. SNAT ns0 to 10.1.1.240-10.1.1.255 | |
2723 | table=1 priority=100 in_port=1 ip ct_state=+trk+new-est action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2724 | table=1 priority=100 in_port=1 ip ct_state=+trk-new+est action=2 | |
2725 | dnl Only allow established traffic from ns1->ns0. | |
2726 | table=1 priority=100 in_port=2 ip ct_state=+trk-new+est action=1 | |
2727 | table=1 priority=0 action=drop | |
2728 | dnl | |
2729 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2730 | table=8 priority=100 reg2=0x0a0101f0/0xfffffff0 action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2731 | dnl Zero result means not found. | |
2732 | table=8 priority=0 action=load:0->OXM_OF_PKT_REG0[[]] | |
2733 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2734 | dnl ARP TPA IP in reg2. | |
2735 | table=10 priority=100 arp xreg0=0 action=normal | |
2736 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2737 | table=10 priority=10 arp arp_op=1 action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2738 | table=10 priority=0 action=drop | |
2739 | ]) | |
2740 | ||
2741 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2742 | ||
2743 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2744 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2745 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2746 | ||
a857bb69 | 2747 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
420c73b2 | 2748 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
9ac0aada JR |
2749 | ]) |
2750 | ||
2751 | OVS_TRAFFIC_VSWITCHD_STOP | |
2752 | AT_CLEANUP | |
2753 | ||
2754 | AT_SETUP([conntrack - simple DNAT]) | |
2755 | CHECK_CONNTRACK() | |
4573c42e | 2756 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2757 | OVS_TRAFFIC_VSWITCHD_START() |
2758 | ||
2759 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2760 | ||
2761 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2762 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2763 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88]) | |
2764 | ||
2765 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2766 | AT_DATA([flows.txt], [dnl | |
2767 | priority=100 in_port=1,ip,nw_dst=10.1.1.64,action=ct(zone=1,nat(dst=10.1.1.2),commit),2 | |
2768 | priority=10 in_port=1,ip,action=ct(commit,zone=1),2 | |
2769 | priority=100 in_port=2,ct_state=-trk,ip,action=ct(table=0,nat,zone=1) | |
2770 | priority=100 in_port=2,ct_state=+trk+est,ct_zone=1,ip,action=1 | |
2771 | dnl | |
2772 | dnl ARP | |
2773 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2774 | priority=10 arp action=normal | |
2775 | priority=0,action=drop | |
2776 | dnl | |
2777 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2778 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2779 | dnl Zero result means not found. | |
2780 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2781 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2782 | dnl TPA IP in reg2. | |
2783 | table=10 priority=100 arp xreg0=0 action=normal | |
2784 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2785 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2786 | table=10 priority=0 action=drop | |
2787 | ]) | |
2788 | ||
2789 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2790 | ||
2791 | dnl Should work with the virtual IP address through NAT | |
7ed40afe | 2792 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2793 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2794 | ||
420c73b2 JR |
2795 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2796 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2797 | ]) |
2798 | ||
2799 | dnl Should work with the assigned IP address as well | |
2800 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2801 | ||
420c73b2 JR |
2802 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
2803 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2804 | ]) |
2805 | ||
2806 | OVS_TRAFFIC_VSWITCHD_STOP | |
2807 | AT_CLEANUP | |
2808 | ||
2809 | AT_SETUP([conntrack - more complex DNAT]) | |
2810 | CHECK_CONNTRACK() | |
4573c42e | 2811 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2812 | OVS_TRAFFIC_VSWITCHD_START() |
2813 | ||
2814 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2815 | ||
2816 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2817 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2818 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88]) | |
2819 | ||
2820 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2821 | AT_DATA([flows.txt], [dnl | |
2822 | dnl Track all IP traffic | |
2823 | table=0 priority=100 ip action=ct(table=1,zone=1,nat) | |
2824 | dnl | |
2825 | dnl Allow ARP, but generate responses for NATed addresses | |
2826 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2827 | table=0 priority=10 arp action=normal | |
2828 | table=0 priority=0 action=drop | |
2829 | dnl | |
2830 | dnl Allow any IP traffic from ns0->ns1. DNAT ns0 from 10.1.1.64 to 10.1.1.2 | |
2831 | table=1 priority=100 in_port=1 ct_state=+new ip nw_dst=10.1.1.64 action=ct(zone=1,nat(dst=10.1.1.2),commit),2 | |
2832 | table=1 priority=10 in_port=1 ct_state=+new ip action=ct(commit,zone=1),2 | |
2833 | table=1 priority=100 in_port=1 ct_state=+est ct_zone=1 action=2 | |
2834 | dnl Only allow established traffic from ns1->ns0. | |
2835 | table=1 priority=100 in_port=2 ct_state=+est ct_zone=1 action=1 | |
2836 | table=1 priority=0 action=drop | |
2837 | dnl | |
2838 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2839 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2840 | dnl Zero result means not found. | |
2841 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2842 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2843 | dnl TPA IP in reg2. | |
2844 | table=10 priority=100 arp xreg0=0 action=normal | |
2845 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2846 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2847 | table=10 priority=0 action=drop | |
2848 | ]) | |
2849 | ||
2850 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2851 | ||
2852 | dnl Should work with the virtual IP address through NAT | |
7ed40afe | 2853 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2854 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2855 | ||
420c73b2 JR |
2856 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2857 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2858 | ]) |
2859 | ||
2860 | dnl Should work with the assigned IP address as well | |
2861 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2862 | ||
420c73b2 JR |
2863 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
2864 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2865 | ]) |
2866 | ||
2867 | OVS_TRAFFIC_VSWITCHD_STOP | |
2868 | AT_CLEANUP | |
2869 | ||
2870 | AT_SETUP([conntrack - ICMP related with NAT]) | |
9c1ab985 | 2871 | AT_SKIP_IF([test $HAVE_NC = no]) |
b020a416 | 2872 | AT_SKIP_IF([test $HAVE_TCPDUMP = no]) |
9ac0aada | 2873 | CHECK_CONNTRACK() |
4573c42e | 2874 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2875 | OVS_TRAFFIC_VSWITCHD_START() |
2876 | ||
2877 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2878 | ||
2879 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2880 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2881 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2882 | ||
2883 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
2884 | dnl Make sure ICMP responses are reverse-NATted. | |
2885 | AT_DATA([flows.txt], [dnl | |
2886 | in_port=1,udp,action=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:1->ct_mark)),2 | |
2887 | in_port=2,icmp,ct_state=-trk,action=ct(table=0,nat) | |
2888 | in_port=2,icmp,nw_dst=10.1.1.1,ct_state=+trk+rel,ct_mark=1,action=1 | |
2889 | dnl | |
2890 | dnl ARP | |
2891 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2892 | priority=10 arp action=normal | |
2893 | priority=0,action=drop | |
2894 | dnl | |
2895 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2896 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2897 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2898 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2899 | dnl TPA IP in reg2. | |
2900 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2901 | table=10 priority=100 arp xreg0=0 action=normal | |
2902 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2903 | table=10 priority=0 action=drop | |
2904 | ]) | |
2905 | ||
2906 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2907 | ||
b020a416 DB |
2908 | rm p0.pcap |
2909 | tcpdump -U -i ovs-p0 -w p0.pcap & | |
2910 | sleep 1 | |
2911 | ||
9ac0aada | 2912 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. |
b54971f7 | 2913 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) |
9ac0aada JR |
2914 | |
2915 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
2916 | AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
2917 | n_packets=1, n_bytes=42, priority=10,arp actions=NORMAL | |
2918 | n_packets=1, n_bytes=44, udp,in_port=1 actions=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:0x1->ct_mark)),output:2 | |
2919 | n_packets=1, n_bytes=72, ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2,nw_dst=10.1.1.1 actions=output:1 | |
2920 | n_packets=1, n_bytes=72, ct_state=-trk,icmp,in_port=2 actions=ct(table=0,nat) | |
2921 | n_packets=2, n_bytes=84, priority=100,arp,arp_op=1 actions=move:NXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2922 | table=10, n_packets=1, n_bytes=42, priority=10,arp,arp_op=1 actions=set_field:2->arp_op,move:NXM_NX_ARP_SHA[[]]->NXM_NX_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_NX_ARP_SHA[[]],move:NXM_OF_ARP_SPA[[]]->NXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->NXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],set_field:0->in_port,output:NXM_NX_REG3[[0..15]] | |
2923 | table=10, n_packets=1, n_bytes=42, priority=100,arp,reg0=0,reg1=0 actions=NORMAL | |
2924 | table=8, n_packets=1, n_bytes=42, priority=0 actions=set_field:0->xreg0 | |
2925 | table=8, n_packets=1, n_bytes=42, reg2=0xa0101f0/0xfffffff0 actions=set_field:0x808888888888->xreg0 | |
2926 | OFPST_FLOW reply (OF1.5): | |
2927 | ]) | |
2928 | ||
a857bb69 DDP |
2929 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
2930 | udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),mark=1 | |
9ac0aada JR |
2931 | ]) |
2932 | ||
b020a416 DB |
2933 | AT_CHECK([tcpdump -v "icmp" -r p0.pcap 2>/dev/null | egrep 'wrong|bad'], [1], [ignore-nolog]) |
2934 | ||
9ac0aada JR |
2935 | OVS_TRAFFIC_VSWITCHD_STOP |
2936 | AT_CLEANUP | |
2937 | ||
2cd20955 | 2938 | dnl CHECK_FTP_NAT(TITLE, IP_ADDR, FLOWS, CT_DUMP) |
019c73ac | 2939 | dnl |
74f205f6 JS |
2940 | dnl Checks the implementation of conntrack with FTP ALGs in combination with |
2941 | dnl NAT, using the provided flow table. | |
2942 | m4_define([CHECK_FTP_NAT], | |
2943 | [AT_SETUP([conntrack - FTP NAT $1]) | |
40c7b2fc | 2944 | AT_SKIP_IF([test $HAVE_FTP = no]) |
74f205f6 JS |
2945 | CHECK_CONNTRACK() |
2946 | CHECK_CONNTRACK_NAT() | |
fc9a5ee1 | 2947 | CHECK_CONNTRACK_ALG() |
019c73ac | 2948 | |
74f205f6 | 2949 | OVS_TRAFFIC_VSWITCHD_START() |
019c73ac | 2950 | |
74f205f6 | 2951 | ADD_NAMESPACES(at_ns0, at_ns1) |
019c73ac | 2952 | |
74f205f6 JS |
2953 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") |
2954 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2955 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
019c73ac | 2956 | |
74f205f6 | 2957 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. |
2cd20955 | 2958 | AT_DATA([flows.txt], [$3]) |
019c73ac | 2959 | |
74f205f6 | 2960 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
019c73ac | 2961 | |
7ed40afe | 2962 | OVS_START_L7([at_ns1], [ftp]) |
019c73ac | 2963 | |
74f205f6 JS |
2964 | dnl FTP requests from p0->p1 should work fine. |
2965 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -4 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) | |
019c73ac | 2966 | |
74f205f6 | 2967 | dnl Discards CLOSE_WAIT and CLOSING |
2cd20955 | 2968 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [$4]) |
019c73ac | 2969 | |
74f205f6 JS |
2970 | OVS_TRAFFIC_VSWITCHD_STOP |
2971 | AT_CLEANUP]) | |
019c73ac | 2972 | |
74f205f6 JS |
2973 | dnl CHECK_FTP_NAT_PRE_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX) |
2974 | dnl | |
2975 | dnl Checks the implementation of conntrack with FTP ALGs in combination with | |
2976 | dnl NAT, with flow tables that implement the NATing as part of handling of | |
2977 | dnl initial incoming packets - ie, the first flow is ct(nat,table=foo). | |
2978 | dnl | |
2979 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
2980 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
2981 | m4_define([CHECK_FTP_NAT_PRE_RECIRC], [dnl | |
2982 | CHECK_FTP_NAT([prerecirc $1], [$2], [dnl | |
9ac0aada JR |
2983 | dnl track all IP traffic, de-mangle non-NEW connections |
2984 | table=0 in_port=1, ip, action=ct(table=1,nat) | |
2985 | table=0 in_port=2, ip, action=ct(table=2,nat) | |
2986 | dnl | |
2987 | dnl ARP | |
2988 | dnl | |
2989 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2990 | table=0 priority=10 arp action=normal | |
2991 | table=0 priority=0 action=drop | |
2992 | dnl | |
2993 | dnl Table 1: port 1 -> 2 | |
2994 | dnl | |
2995 | dnl Allow new FTP connections. These need to be commited. | |
74f205f6 | 2996 | table=1 ct_state=+new, tcp, tp_dst=21, nw_src=10.1.1.1, action=ct(alg=ftp,commit,nat(src=$2)),2 |
9ac0aada | 2997 | dnl Allow established TCP connections, make sure they are NATted already. |
74f205f6 | 2998 | table=1 ct_state=+est, tcp, nw_src=$2, action=2 |
9ac0aada JR |
2999 | dnl |
3000 | dnl Table 1: droppers | |
3001 | dnl | |
3002 | table=1 priority=10, tcp, action=drop | |
3003 | table=1 priority=0,action=drop | |
3004 | dnl | |
3005 | dnl Table 2: port 2 -> 1 | |
3006 | dnl | |
3007 | dnl Allow established TCP connections, make sure they are reverse NATted | |
3008 | table=2 ct_state=+est, tcp, nw_dst=10.1.1.1, action=1 | |
3009 | dnl Allow (new) related (data) connections. These need to be commited. | |
74f205f6 | 3010 | table=2 ct_state=+new+rel, tcp, nw_dst=$2, action=ct(commit,nat),1 |
9ac0aada JR |
3011 | dnl Allow related ICMP packets, make sure they are reverse NATted |
3012 | table=2 ct_state=+rel, icmp, nw_dst=10.1.1.1, action=1 | |
3013 | dnl | |
3014 | dnl Table 2: droppers | |
3015 | dnl | |
3016 | table=2 priority=10, tcp, action=drop | |
3017 | table=2 priority=0, action=drop | |
3018 | dnl | |
3019 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3020 | dnl | |
74f205f6 | 3021 | table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
9ac0aada JR |
3022 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
3023 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3024 | dnl TPA IP in reg2. | |
3025 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3026 | table=10 priority=100 arp xreg0=0 action=normal | |
3027 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3028 | table=10 priority=0 action=drop | |
2cd20955 JR |
3029 | ], [dnl |
3030 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
3031 | tcp,orig=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3032 | ]) | |
9ac0aada JR |
3033 | ]) |
3034 | ||
74f205f6 JS |
3035 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment. |
3036 | CHECK_FTP_NAT_PRE_RECIRC([], [10.1.1.9], [0x0a010109]) | |
9ac0aada | 3037 | |
74f205f6 JS |
3038 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment. |
3039 | dnl | |
3040 | dnl The FTP PORT command includes the ASCII representation of the address, | |
3041 | dnl so when these messages need to be NATed between addresses that have | |
3042 | dnl different lengths when represented in ASCII (such as the original address | |
3043 | dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must | |
3044 | dnl resize the packet and adjust TCP sequence numbers. This test is kept | |
3045 | dnl separate from the above to easier identify issues in this code on different | |
3046 | dnl kernels. | |
3047 | CHECK_FTP_NAT_PRE_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0]) | |
3048 | ||
3049 | dnl CHECK_FTP_NAT_POST_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX) | |
3050 | dnl | |
3051 | dnl Checks the implementation of conntrack with FTP ALGs in combination with | |
3052 | dnl NAT, with flow tables that implement the NATing after the first round | |
3053 | dnl of recirculation - that is, the first flow ct(table=foo) then a subsequent | |
3054 | dnl flow will implement the NATing with ct(nat..),output:foo. | |
3055 | dnl | |
3056 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
3057 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
3058 | m4_define([CHECK_FTP_NAT_POST_RECIRC], [dnl | |
3059 | CHECK_FTP_NAT([postrecirc $1], [$2], [dnl | |
9ac0aada JR |
3060 | dnl track all IP traffic (this includes a helper call to non-NEW packets.) |
3061 | table=0 ip, action=ct(table=1) | |
3062 | dnl | |
3063 | dnl ARP | |
3064 | dnl | |
3065 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3066 | table=0 priority=10 arp action=normal | |
3067 | table=0 priority=0 action=drop | |
3068 | dnl | |
3069 | dnl Table 1 | |
3070 | dnl | |
3071 | dnl Allow new FTP connections. These need to be commited. | |
3072 | dnl This does helper for new packets. | |
74f205f6 | 3073 | table=1 in_port=1 ct_state=+new, tcp, tp_dst=21, action=ct(alg=ftp,commit,nat(src=$2)),2 |
9ac0aada JR |
3074 | dnl Allow and NAT established TCP connections |
3075 | table=1 in_port=1 ct_state=+est, tcp, action=ct(nat),2 | |
3076 | table=1 in_port=2 ct_state=+est, tcp, action=ct(nat),1 | |
3077 | dnl Allow and NAT (new) related active (data) connections. | |
3078 | dnl These need to be commited. | |
3079 | table=1 in_port=2 ct_state=+new+rel, tcp, action=ct(commit,nat),1 | |
3080 | dnl Allow related ICMP packets. | |
3081 | table=1 in_port=2 ct_state=+rel, icmp, action=ct(nat),1 | |
3082 | dnl Drop everything else. | |
3083 | table=1 priority=0, action=drop | |
3084 | dnl | |
3085 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3086 | dnl | |
74f205f6 | 3087 | table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
9ac0aada JR |
3088 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
3089 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3090 | dnl TPA IP in reg2. | |
3091 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3092 | table=10 priority=100 arp xreg0=0 action=normal | |
3093 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3094 | table=10 priority=0 action=drop | |
2cd20955 JR |
3095 | ], [dnl |
3096 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
3097 | tcp,orig=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3098 | ]) | |
9ac0aada JR |
3099 | ]) |
3100 | ||
74f205f6 JS |
3101 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment. |
3102 | CHECK_FTP_NAT_POST_RECIRC([], [10.1.1.9], [0x0a010109]) | |
9ac0aada | 3103 | |
74f205f6 JS |
3104 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment. |
3105 | dnl | |
3106 | dnl The FTP PORT command includes the ASCII representation of the address, | |
3107 | dnl so when these messages need to be NATed between addresses that have | |
3108 | dnl different lengths when represented in ASCII (such as the original address | |
3109 | dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must | |
3110 | dnl resize the packet and adjust TCP sequence numbers. This test is kept | |
3111 | dnl separate from the above to easier identify issues in this code on different | |
3112 | dnl kernels. | |
3113 | CHECK_FTP_NAT_POST_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0]) | |
9ac0aada | 3114 | |
daf4d3c1 JR |
3115 | |
3116 | dnl CHECK_FTP_NAT_ORIG_TUPLE(TITLE, IP_ADDR, IP_ADDR_AS_HEX) | |
3117 | dnl | |
3118 | dnl Checks the implementation of conntrack original direction tuple matching | |
3119 | dnl with FTP ALGs in combination with NAT, with flow tables that implement | |
3120 | dnl the NATing before the first round of recirculation - that is, the first | |
3121 | dnl flow ct(nat, table=foo) then a subsequent flow will implement the | |
3122 | dnl commiting of NATed and other connections with ct(nat..),output:foo. | |
3123 | dnl | |
3124 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
3125 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
3126 | m4_define([CHECK_FTP_NAT_ORIG_TUPLE], [dnl | |
3127 | CHECK_FTP_NAT([orig tuple $1], [$2], [dnl | |
2cd20955 JR |
3128 | dnl Store zone in reg4 and packet direction in reg3 (IN=1, OUT=2). |
3129 | dnl NAT is only applied to OUT-direction packets, so that ACL | |
3130 | dnl processing can be done with non-NATted headers. | |
3131 | dnl | |
3132 | dnl Track all IP traffic in the IN-direction (IN from Port 1). | |
3133 | table=0 in_port=1, ip, action=set_field:1->reg4,set_field:1->reg3,ct(zone=NXM_NX_REG4[[0..15]],table=1) | |
3134 | dnl Track all IP traffic in the OUT-direction (OUT to the Port 1). | |
3135 | table=0 in_port=2, ip, action=set_field:1->reg4,set_field:2->reg3,ct(zone=NXM_NX_REG4[[0..15]],nat,table=1) | |
daf4d3c1 JR |
3136 | dnl |
3137 | dnl ARP | |
3138 | dnl | |
3139 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3140 | table=0 priority=10 arp action=normal | |
3141 | table=0 priority=0 action=drop | |
3142 | dnl | |
2cd20955 JR |
3143 | dnl Pass tracked traffic through ACL, drop everything else. |
3144 | dnl Non-REPLY/RELATED packets get the ACL lookup with the packet headers | |
3145 | dnl in the actual packet direction in reg0 (IN=1, OUT=2). REPLY packets | |
3146 | dnl get the ACL lookup using the conntrack tuple and the inverted direction. | |
3147 | dnl RELATED packets get ACL lookup using the conntrack tuple in the direction | |
28033773 | 3148 | dnl of the master connection, as stored in ct_label[0]. |
2cd20955 JR |
3149 | dnl |
3150 | dnl Incoming non-related packet in the original direction (ACL IN) | |
3151 | table=1 reg3=1, ip, ct_state=-rel-rpl+trk-inv action=set_field:1->reg0,resubmit(,3),goto_table:5 | |
3152 | dnl Incoming non-related reply packet (CT ACL OUT) | |
3153 | table=1 reg3=1, ip, ct_state=-rel+rpl+trk-inv action=set_field:2->reg0,resubmit(,3,ct),goto_table:4 | |
3154 | dnl Outgoing non-related packet (ACL OUT) | |
3155 | table=1 reg3=2, ip, ct_state=-rel-rpl+trk-inv action=set_field:2->reg0,resubmit(,3),goto_table:5 | |
3156 | dnl Outgoing non-related reply packet (CT ACL IN) | |
3157 | table=1 reg3=2, ip, ct_state=-rel+rpl+trk-inv action=set_field:1->reg0,resubmit(,3,ct),goto_table:4 | |
daf4d3c1 | 3158 | dnl |
2cd20955 | 3159 | dnl Related packet (CT ACL in the direction of the master connection.) |
28033773 | 3160 | table=1 ip, ct_state=+rel+trk-inv, action=move:NXM_NX_CT_LABEL[[0]]->NXM_NX_REG0[[0]],resubmit(,3,ct),goto_table:4 |
daf4d3c1 JR |
3161 | dnl Drop everything else. |
3162 | table=1 priority=0, action=drop | |
3163 | dnl | |
2cd20955 JR |
3164 | dnl "ACL table" |
3165 | dnl | |
3166 | dnl Stateful accept (1->reg2) all incoming (reg0=1) IP connections with | |
3167 | dnl IP source address '10.1.1.1'. Store rule ID (1234) in reg1, verdict | |
3168 | dnl in reg2. | |
3169 | table=3 priority=10, reg0=1, ip, nw_src=10.1.1.1 action=set_field:1234->reg1,set_field:1->reg2 | |
3170 | dnl Stateless drop (0->reg2) everything else in both directions. (Rule ID: 1235) | |
3171 | table=3 priority=0, action=set_field:1235->reg1,set_field:0->reg2 | |
3172 | dnl | |
3173 | dnl Re-process stateful traffic that was not accepted by a stateful rule as | |
3174 | dnl normal traffic in the current direction. This should also delete the | |
3175 | dnl now stale conntrack state, so that new state can be created in it's place. | |
3176 | dnl | |
3177 | dnl Stateful accepts go to next table. | |
3178 | table=4 priority=100 reg2=1, action=goto_table:5 | |
3179 | dnl Everything else is reprocessed disregarding the CT state, using the actual | |
3180 | dnl packet direction. | |
3181 | table=4 priority=0 action=move:NXM_NX_REG3[[]]->NXM_NX_REG0[[]],resubmit(,3),goto_table:5 | |
3182 | dnl | |
3183 | dnl "ACL verdict processing table." | |
3184 | dnl | |
3185 | dnl Handle stateful (reg2=1) / stateless (reg2=2) accepts and drops (reg2=0) | |
3186 | dnl | |
3187 | dnl Drop all non-accepted packets. | |
3188 | table=5 reg2=0 priority=1000 action=drop | |
daf4d3c1 | 3189 | dnl |
2cd20955 JR |
3190 | dnl Commit new incoming FTP control connections with SNAT range. Must match on |
3191 | dnl 'tcp' when setting 'alg=ftp'. Store the directionality of non-related | |
28033773 JR |
3192 | dnl connections to ct_label[0] Store the rule ID to ct_label[96..127]. |
3193 | table=5 priority=100 reg2=1 reg3=1 ct_state=+new-rel, tcp, tp_dst=21, action=ct(zone=NXM_NX_REG4[[0..15]],alg=ftp,commit,nat(src=$2),exec(move:NXM_NX_REG3[[0]]->NXM_NX_CT_LABEL[[0]],move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 | |
2cd20955 | 3194 | dnl Commit other new incoming non-related IP connections with SNAT range. |
28033773 | 3195 | table=5 priority=10 reg2=1 reg3=1 ct_state=+new-rel, ip, action=ct(zone=NXM_NX_REG4[[0..15]],commit,nat(src=$2),exec(move:NXM_NX_REG3[[0]]->NXM_NX_CT_LABEL[[0]],move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 |
2cd20955 JR |
3196 | dnl Commit non-related outgoing new IP connections with DNAT range. |
3197 | dnl (This should not get any packets in this test.) | |
28033773 | 3198 | table=5 priority=10 reg2=1 reg3=2 ct_state=+new-rel, ip, action=ct(zone=NXM_NX_REG4[[0..15]],commit,nat(dst=$2),exec(move:NXM_NX_REG3[[0]]->NXM_NX_CT_LABEL[[0]],move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 |
2cd20955 | 3199 | dnl Commit new related connections in either direction, which need 'nat' |
28033773 | 3200 | dnl and which inherit the label (the direction of the original direction |
2cd20955 JR |
3201 | dnl master tuple) from the master connection. |
3202 | table=5 priority=10 reg2=1 ct_state=+new+rel, ip, action=ct(zone=NXM_NX_REG4[[0..15]],commit,nat,exec(move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 | |
3203 | dnl | |
3204 | dnl NAT incoming non-NEW packets. Outgoing packets were NATted in table 0. | |
3205 | dnl | |
3206 | table=5 priority=10 ct_state=-new+trk-inv reg3=1 ip, action=ct(zone=NXM_NX_REG4[[0..15]],nat),goto_table:6 | |
3207 | dnl Forward everything else, including stateless accepts. | |
3208 | table=5 priority=0 action=goto_table:6 | |
3209 | dnl | |
3210 | dnl "Forwarding table" | |
3211 | dnl | |
3212 | table=6 in_port=1 action=2 | |
3213 | table=6 in_port=2 action=1 | |
daf4d3c1 JR |
3214 | dnl |
3215 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3216 | dnl | |
2cd20955 | 3217 | table=8,reg2=$3,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
daf4d3c1 JR |
3218 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
3219 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3220 | dnl TPA IP in reg2. | |
3221 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3222 | table=10 priority=100 arp xreg0=0 action=normal | |
3223 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3224 | table=10 priority=0 action=drop | |
2cd20955 | 3225 | ], [dnl |
28033773 JR |
3226 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),zone=1,labels=0x4d2000000000000000000000001,protoinfo=(state=<cleared>),helper=ftp |
3227 | tcp,orig=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),zone=1,labels=0x4d2000000000000000000000001,protoinfo=(state=<cleared>) | |
2cd20955 | 3228 | ]) |
daf4d3c1 JR |
3229 | ]) |
3230 | ||
3231 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment with | |
3232 | dnl an ACL table based on matching on conntrack original direction tuple only. | |
3233 | CHECK_FTP_NAT_ORIG_TUPLE([], [10.1.1.9], [0x0a010109]) | |
3234 | ||
3235 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment with | |
3236 | dnl an ACL table based on matching on conntrack original direction tuple only. | |
3237 | CHECK_FTP_NAT_ORIG_TUPLE([seqadj], [10.1.1.240], [0x0a0101f0]) | |
3238 | ||
b020a416 | 3239 | AT_SETUP([conntrack - IPv6 HTTP with SNAT]) |
9ac0aada | 3240 | CHECK_CONNTRACK() |
4573c42e | 3241 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
3242 | OVS_TRAFFIC_VSWITCHD_START() |
3243 | ||
3244 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3245 | ||
3246 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3247 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
3248 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3249 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
b020a416 | 3250 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::241 lladdr 80:88:88:88:88:88 dev p1]) |
9ac0aada JR |
3251 | |
3252 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
3253 | AT_DATA([flows.txt], [dnl | |
3254 | priority=1,action=drop | |
3255 | priority=10,icmp6,action=normal | |
b020a416 | 3256 | priority=100,in_port=1,ip6,action=ct(commit,nat(src=fc00::240-fc00::241)),2 |
9ac0aada JR |
3257 | priority=100,in_port=2,ct_state=-trk,ip6,action=ct(nat,table=0) |
3258 | priority=100,in_port=2,ct_state=+trk+est,ip6,action=1 | |
3259 | priority=200,in_port=2,ct_state=+trk+new,icmp6,icmpv6_code=0,icmpv6_type=135,nd_target=fc00::240,action=ct(commit,nat(dst=fc00::1)),1 | |
b020a416 | 3260 | priority=200,in_port=2,ct_state=+trk+new,icmp6,icmpv6_code=0,icmpv6_type=135,nd_target=fc00::241,action=ct(commit,nat(dst=fc00::1)),1 |
9ac0aada JR |
3261 | ]) |
3262 | ||
3263 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3264 | ||
c10840ff JS |
3265 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
3266 | dnl waiting, we get occasional failures due to the following error: | |
9ac0aada | 3267 | dnl "connect: Cannot assign requested address" |
c10840ff | 3268 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
9ac0aada JR |
3269 | |
3270 | dnl HTTP requests from ns0->ns1 should work fine. | |
7ed40afe | 3271 | OVS_START_L7([at_ns1], [http6]) |
9ac0aada JR |
3272 | |
3273 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
3274 | ||
3275 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
3276 | dnl Try 3 times, in 1 second intervals. | |
7ed40afe | 3277 | OVS_START_L7([at_ns0], [http6]) |
9ac0aada JR |
3278 | NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4]) |
3279 | ||
3280 | OVS_TRAFFIC_VSWITCHD_STOP | |
3281 | AT_CLEANUP | |
3282 | ||
b020a416 DB |
3283 | AT_SETUP([conntrack - IPv6 HTTP with DNAT]) |
3284 | CHECK_CONNTRACK() | |
3285 | CHECK_CONNTRACK_NAT() | |
3286 | OVS_TRAFFIC_VSWITCHD_START() | |
3287 | ||
3288 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3289 | ||
3290 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3291 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3292 | NS_CHECK_EXEC([at_ns0], [ip -6 link set dev p0 address 80:88:88:88:88:77]) | |
3293 | NS_CHECK_EXEC([at_ns1], [ip -6 link set dev p1 address 80:88:88:88:88:88]) | |
3294 | NS_CHECK_EXEC([at_ns0], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p0]) | |
3295 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::1 lladdr 80:88:88:88:88:77 dev p1]) | |
3296 | ||
3297 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
3298 | AT_DATA([flows.txt], [dnl | |
3299 | priority=100 in_port=1,ip6,ipv6_dst=fc00::240,action=ct(zone=1,nat(dst=fc00::2),commit),2 | |
3300 | priority=100 in_port=2,ct_state=-trk,ip6,action=ct(table=0,nat,zone=1) | |
3301 | priority=100 in_port=2,ct_state=+trk+est,ct_zone=1,ip6,action=1 | |
3302 | ]) | |
3303 | ||
3304 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3305 | ||
3306 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
3307 | dnl waiting, we get occasional failures due to the following error: | |
3308 | dnl "connect: Cannot assign requested address" | |
3309 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::240]) | |
3310 | ||
3311 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::240 | FORMAT_PING], [0], [dnl | |
3312 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3313 | ]) | |
3314 | ||
3315 | dnl Should work with the virtual IP address through NAT | |
3316 | OVS_START_L7([at_ns1], [http6]) | |
3317 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::240]] -t 5 -T 1 --retry-connrefused -v -o wget0.log]) | |
3318 | ||
3319 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::1)], [0], [dnl | |
3320 | icmpv6,orig=(src=fc00::1,dst=fc00::240,id=<cleared>,type=128,code=0),reply=(src=fc00::2,dst=fc00::1,id=<cleared>,type=129,code=0),zone=1 | |
3321 | tcp,orig=(src=fc00::1,dst=fc00::240,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
3322 | ]) | |
3323 | ||
3324 | OVS_TRAFFIC_VSWITCHD_STOP | |
3325 | AT_CLEANUP | |
3326 | ||
3327 | AT_SETUP([conntrack - IPv6 ICMP6 Related with SNAT]) | |
3328 | AT_SKIP_IF([test $HAVE_TCPDUMP = no]) | |
3329 | CHECK_CONNTRACK() | |
3330 | CHECK_CONNTRACK_NAT() | |
3331 | OVS_TRAFFIC_VSWITCHD_START() | |
3332 | ||
3333 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3334 | ||
3335 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3336 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3337 | NS_CHECK_EXEC([at_ns0], [ip -6 link set dev p0 address 80:88:88:88:88:77]) | |
3338 | NS_CHECK_EXEC([at_ns1], [ip -6 link set dev p1 address 80:88:88:88:88:88]) | |
3339 | ||
3340 | NS_CHECK_EXEC([at_ns0], [ip -6 neigh add fc00::2 lladdr 80:88:88:88:88:88 dev p0]) | |
3341 | NS_CHECK_EXEC([at_ns0], [ip -6 neigh add fc00::3 lladdr 80:88:88:88:88:88 dev p0]) | |
3342 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:77 dev p1]) | |
3343 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::1 lladdr 80:88:88:88:88:77 dev p1]) | |
3344 | ||
3345 | NS_CHECK_EXEC([at_ns0], [ip -6 route add default via fc00::2]) | |
3346 | ||
3347 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
3348 | AT_DATA([flows.txt], [dnl | |
3349 | priority=100 in_port=1,ip6,action=ct(nat(src=fc00::240),commit),2 | |
3350 | priority=100 in_port=2,ct_state=-trk,ip6,action=ct(table=0,nat) | |
3351 | priority=100 in_port=2,ct_state=+trk+est,ip6,action=1 | |
3352 | priority=100 in_port=2,ct_state=+trk+rel,ip6,action=1 | |
3353 | ]) | |
3354 | ||
3355 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3356 | ||
3357 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
3358 | dnl waiting, we get occasional failures due to the following error: | |
3359 | dnl "connect: Cannot assign requested address" | |
3360 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) | |
3361 | ||
3362 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
3363 | ||
3364 | rm p0.pcap | |
3365 | tcpdump -U -i ovs-p0 -w p0.pcap & | |
3366 | sleep 1 | |
3367 | ||
3368 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. | |
3369 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc -6 $NC_EOF_OPT -u fc00::2 1"]) | |
3370 | ||
3371 | AT_CHECK([tcpdump -v "icmp6" -r p0.pcap 2>/dev/null | egrep 'wrong|bad'], [1], [ignore-nolog]) | |
3372 | ||
3373 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
3374 | udp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>) | |
3375 | ]) | |
3376 | ||
3377 | OVS_TRAFFIC_VSWITCHD_STOP | |
3378 | AT_CLEANUP | |
9ac0aada JR |
3379 | |
3380 | AT_SETUP([conntrack - IPv6 FTP with NAT]) | |
40c7b2fc | 3381 | AT_SKIP_IF([test $HAVE_FTP = no]) |
9ac0aada | 3382 | CHECK_CONNTRACK() |
4573c42e | 3383 | CHECK_CONNTRACK_NAT() |
fc9a5ee1 DB |
3384 | CHECK_CONNTRACK_ALG() |
3385 | ||
9ac0aada JR |
3386 | OVS_TRAFFIC_VSWITCHD_START() |
3387 | ||
3388 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3389 | ||
3390 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3391 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
3392 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3393 | dnl Would be nice if NAT could translate neighbor discovery messages, too. | |
3394 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
3395 | ||
3396 | dnl Allow any traffic from ns0->ns1. | |
3397 | dnl Only allow nd, return traffic from ns1->ns0. | |
3398 | AT_DATA([flows.txt], [dnl | |
9ac0aada JR |
3399 | dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.) |
3400 | table=0 priority=10 ip6, action=ct(nat,table=1) | |
3401 | table=0 priority=0 action=drop | |
3402 | dnl | |
3403 | dnl Table 1 | |
3404 | dnl | |
3405 | dnl Allow new TCPv6 FTP control connections. | |
3406 | table=1 in_port=1 ct_state=+new tcp6 ipv6_src=fc00::1 tp_dst=21 action=ct(alg=ftp,commit,nat(src=fc00::240)),2 | |
3407 | dnl Allow related TCPv6 connections from port 2 to the NATted address. | |
3408 | table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1 | |
3409 | dnl Allow established TCPv6 connections both ways, enforce NATting | |
3410 | table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240 action=2 | |
3411 | table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1 action=1 | |
daf4d3c1 JR |
3412 | dnl Allow other ICMPv6 both ways (without commit). |
3413 | table=1 priority=100 in_port=1 icmp6, action=2 | |
3414 | table=1 priority=100 in_port=2 icmp6, action=1 | |
9ac0aada JR |
3415 | dnl Drop everything else. |
3416 | table=1 priority=0, action=drop | |
3417 | ]) | |
3418 | ||
3419 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3420 | ||
c10840ff JS |
3421 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
3422 | dnl waiting, we get occasional failures due to the following error: | |
3423 | dnl "connect: Cannot assign requested address" | |
3424 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
3425 | ||
7ed40afe | 3426 | OVS_START_L7([at_ns1], [ftp]) |
9ac0aada JR |
3427 | |
3428 | dnl FTP requests from p0->p1 should work fine. | |
4fee8b13 | 3429 | NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) |
9ac0aada | 3430 | |
a857bb69 | 3431 | dnl Discards CLOSE_WAIT and CLOSING |
420c73b2 JR |
3432 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl |
3433 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
3434 | tcp,orig=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),reply=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
9ac0aada JR |
3435 | ]) |
3436 | ||
3437 | OVS_TRAFFIC_VSWITCHD_STOP | |
3438 | AT_CLEANUP | |
2c66ebe4 | 3439 | |
daf4d3c1 JR |
3440 | |
3441 | AT_SETUP([conntrack - IPv6 FTP with NAT - orig tuple]) | |
3442 | AT_SKIP_IF([test $HAVE_FTP = no]) | |
3443 | CHECK_CONNTRACK() | |
3444 | CHECK_CONNTRACK_NAT() | |
3445 | OVS_TRAFFIC_VSWITCHD_START() | |
3446 | ||
3447 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3448 | ||
3449 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3450 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
3451 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3452 | dnl Would be nice if NAT could translate neighbor discovery messages, too. | |
3453 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
3454 | ||
3455 | dnl Allow any traffic from ns0->ns1. | |
3456 | dnl Only allow nd, return traffic from ns1->ns0. | |
3457 | AT_DATA([flows.txt], [dnl | |
3458 | dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.) | |
3459 | table=0 priority=10 ip6, action=ct(nat,table=1) | |
3460 | table=0 priority=0 action=drop | |
3461 | dnl | |
3462 | dnl Table 1 | |
3463 | dnl | |
3464 | dnl Allow other ICMPv6 both ways (without commit). | |
3465 | table=1 priority=100 in_port=1 icmp6, action=2 | |
3466 | table=1 priority=100 in_port=2 icmp6, action=1 | |
3467 | dnl Allow new TCPv6 FTP control connections. | |
3468 | table=1 priority=10 in_port=1 ct_state=+new+trk-inv tcp6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=ct(alg=ftp,commit,nat(src=fc00::240)),2 | |
3469 | dnl Allow related TCPv6 connections from port 2 to the NATted address. | |
3470 | table=1 priority=10 in_port=2 ct_state=+new+rel+trk-inv ipv6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=ct(commit,nat),1 | |
3471 | dnl Allow established TCPv6 connections both ways, enforce NATting | |
3472 | table=1 priority=10 in_port=1 ct_state=+est+trk-inv ipv6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=2 | |
3473 | table=1 priority=10 in_port=2 ct_state=+est+trk-inv ipv6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=1 | |
3474 | dnl Drop everything else. | |
3475 | table=1 priority=0, action=drop | |
3476 | ]) | |
3477 | ||
3478 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3479 | ||
3480 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
3481 | dnl waiting, we get occasional failures due to the following error: | |
3482 | dnl "connect: Cannot assign requested address" | |
3483 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
3484 | ||
3485 | NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid]) | |
3486 | OVS_WAIT_UNTIL([ip netns exec at_ns1 netstat -l | grep ftp]) | |
3487 | ||
3488 | dnl FTP requests from p0->p1 should work fine. | |
3489 | NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) | |
3490 | ||
3491 | dnl Discards CLOSE_WAIT and CLOSING | |
3492 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
3493 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
3494 | tcp,orig=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),reply=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3495 | ]) | |
3496 | ||
3497 | OVS_TRAFFIC_VSWITCHD_STOP | |
3498 | AT_CLEANUP | |
3499 | ||
3500 | ||
2c66ebe4 JR |
3501 | AT_SETUP([conntrack - DNAT load balancing]) |
3502 | CHECK_CONNTRACK() | |
4573c42e | 3503 | CHECK_CONNTRACK_NAT() |
2c66ebe4 JR |
3504 | OVS_TRAFFIC_VSWITCHD_START() |
3505 | ||
3506 | ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4) | |
3507 | ||
3508 | ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24") | |
3509 | ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24") | |
3510 | ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24") | |
3511 | ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24") | |
3512 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11]) | |
3513 | NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22]) | |
3514 | NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33]) | |
3515 | NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44]) | |
3516 | ||
3517 | dnl Select group for load balancing. One bucket per server. Each bucket | |
3518 | dnl tracks and NATs the connection and recirculates to table 4 for egress | |
3519 | dnl routing. Packets of existing connections are always NATted based on | |
3520 | dnl connection state, only new connections are NATted according to the | |
3521 | dnl specific NAT parameters in each bucket. | |
3522 | AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-group br0 "group_id=234,type=select,bucket=weight=100,ct(nat(dst=10.1.1.2),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.3),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.4),commit,table=4)"]) | |
3523 | ||
3524 | AT_DATA([flows.txt], [dnl | |
3525 | dnl Track connections to the virtual IP address. | |
3526 | table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234 | |
3527 | dnl All other IP traffic is allowed but the connection state is no commited. | |
3528 | table=0 priority=90 ip action=ct(table=4,nat) | |
3529 | dnl | |
3530 | dnl Allow ARP, but generate responses for virtual addresses | |
3531 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3532 | table=0 priority=10 arp action=normal | |
3533 | table=0 priority=0 action=drop | |
3534 | dnl | |
3535 | dnl Routing table | |
3536 | dnl | |
3537 | table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1 | |
3538 | table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2 | |
3539 | table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3 | |
3540 | table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4 | |
3541 | table=4 priority=0 action=drop | |
3542 | dnl | |
3543 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3544 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
3545 | dnl Zero result means not found. | |
3546 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
3547 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3548 | dnl TPA IP in reg2. | |
3549 | table=10 priority=100 arp xreg0=0 action=normal | |
3550 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3551 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3552 | table=10 priority=0 action=controller | |
3553 | ]) | |
3554 | ||
3555 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3556 | ||
3557 | dnl Start web servers | |
7ed40afe JS |
3558 | OVS_START_L7([at_ns2], [http]) |
3559 | OVS_START_L7([at_ns3], [http]) | |
3560 | OVS_START_L7([at_ns4], [http]) | |
2c66ebe4 JR |
3561 | |
3562 | on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0' | |
3563 | on_exit 'ovs-appctl revalidator/purge' | |
3564 | on_exit 'ovs-appctl dpif/dump-flows br0' | |
3565 | ||
3566 | dnl Should work with the virtual IP address through NAT | |
3567 | for i in 1 2 3 4 5 6 7 8 9 10 11 12; do | |
3568 | echo Request $i | |
3569 | NS_CHECK_EXEC([at_ns1], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget$i.log]) | |
3570 | done | |
3571 | ||
3572 | dnl Each server should have at least one connection. | |
420c73b2 JR |
3573 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
3574 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3575 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.3,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3576 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2c66ebe4 JR |
3577 | ]) |
3578 | ||
3579 | ovs-appctl dpif/dump-flows br0 | |
3580 | ovs-appctl revalidator/purge | |
3581 | ovs-ofctl -O OpenFlow15 dump-flows br0 | |
3582 | ovs-ofctl -O OpenFlow15 dump-group-stats br0 | |
3583 | ||
3584 | OVS_TRAFFIC_VSWITCHD_STOP | |
3585 | AT_CLEANUP | |
3586 | ||
3587 | ||
3588 | AT_SETUP([conntrack - DNAT load balancing with NC]) | |
9c1ab985 | 3589 | AT_SKIP_IF([test $HAVE_NC = no]) |
2c66ebe4 | 3590 | CHECK_CONNTRACK() |
4573c42e | 3591 | CHECK_CONNTRACK_NAT() |
2c66ebe4 JR |
3592 | OVS_TRAFFIC_VSWITCHD_START() |
3593 | ||
3594 | ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4, at_ns5) | |
3595 | ||
3596 | ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24") | |
3597 | ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24") | |
3598 | ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24") | |
3599 | ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24") | |
3600 | ADD_VETH(p5, at_ns5, br0, "10.1.1.5/24") | |
3601 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11]) | |
3602 | NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22]) | |
3603 | NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33]) | |
3604 | NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44]) | |
3605 | NS_CHECK_EXEC([at_ns5], [ip link set dev p5 address 80:88:88:88:88:55]) | |
3606 | ||
3607 | dnl Select group for load balancing. One bucket per server. Each bucket | |
3608 | dnl tracks and NATs the connection and recirculates to table 4 for egress | |
3609 | dnl routing. Packets of existing connections are always NATted based on | |
3610 | dnl connection state, only new connections are NATted according to the | |
3611 | dnl specific NAT parameters in each bucket. | |
3612 | AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-group br0 "group_id=234,type=select,bucket=weight=100,ct(nat(dst=10.1.1.2),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.3),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.4),commit,table=4)"]) | |
3613 | ||
3614 | AT_DATA([flows.txt], [dnl | |
3615 | dnl Track connections to the virtual IP address. | |
3616 | table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234 | |
3617 | dnl All other IP traffic is allowed but the connection state is no commited. | |
3618 | table=0 priority=90 ip action=ct(table=4,nat) | |
3619 | dnl | |
3620 | dnl Allow ARP, but generate responses for virtual addresses | |
3621 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3622 | table=0 priority=10 arp action=normal | |
3623 | table=0 priority=0 action=drop | |
3624 | dnl | |
3625 | dnl Routing table | |
3626 | dnl | |
3627 | table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1 | |
3628 | table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2 | |
3629 | table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3 | |
3630 | table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4 | |
3631 | table=4,ip,nw_dst=10.1.1.5 action=mod_dl_dst:80:88:88:88:88:55,output:5 | |
3632 | table=4 priority=0 action=drop | |
3633 | dnl | |
3634 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3635 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
3636 | dnl Zero result means not found. | |
3637 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
3638 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3639 | dnl TPA IP in reg2. | |
3640 | table=10 priority=100 arp xreg0=0 action=normal | |
3641 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3642 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3643 | table=10 priority=0 action=controller | |
3644 | ]) | |
3645 | ||
3646 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3647 | ||
3648 | dnl Start web servers | |
7ed40afe JS |
3649 | OVS_START_L7([at_ns2], [http]) |
3650 | OVS_START_L7([at_ns3], [http]) | |
3651 | OVS_START_L7([at_ns4], [http]) | |
2c66ebe4 JR |
3652 | |
3653 | on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0' | |
3654 | on_exit 'ovs-appctl revalidator/purge' | |
3655 | on_exit 'ovs-appctl dpif/dump-flows br0' | |
3656 | ||
3657 | sleep 5 | |
3658 | ||
3659 | dnl Should work with the virtual IP address through NAT | |
3660 | for i in 1 2 3 4 5 6 7 8 9; do | |
3661 | echo Request $i | |
3662 | NS_CHECK_EXEC([at_ns1], [echo "TEST1" | nc -p 4100$i 10.1.1.64 80 > nc-1-$i.log]) | |
3663 | NS_CHECK_EXEC([at_ns5], [echo "TEST5" | nc -p 4100$i 10.1.1.64 80 > nc-5-$i.log]) | |
3664 | done | |
3665 | ||
3666 | conntrack -L 2>&1 | |
3667 | ||
3668 | ovs-appctl dpif/dump-flows br0 | |
3669 | ovs-appctl revalidator/purge | |
3670 | ovs-ofctl -O OpenFlow15 dump-flows br0 | |
3671 | ovs-ofctl -O OpenFlow15 dump-group-stats br0 | |
3672 | ||
3673 | OVS_TRAFFIC_VSWITCHD_STOP | |
3674 | AT_CLEANUP | |
b4fa814c EG |
3675 | |
3676 | AT_BANNER([802.1ad]) | |
3677 | ||
3678 | AT_SETUP([802.1ad - vlan_limit]) | |
3679 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3680 | OVS_CHECK_8021AD() | |
3681 | ||
3682 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3683 | ||
3684 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
3685 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
3686 | ||
3687 | ADD_SVLAN(p0, at_ns0, 4094, "10.255.2.1/24") | |
3688 | ADD_SVLAN(p1, at_ns1, 4094, "10.255.2.2/24") | |
3689 | ||
3690 | ADD_CVLAN(p0.4094, at_ns0, 100, "10.2.2.1/24") | |
3691 | ADD_CVLAN(p1.4094, at_ns1, 100, "10.2.2.2/24") | |
3692 | ||
3693 | AT_CHECK([ovs-ofctl add-flow br0 "priority=1 action=normal"]) | |
3694 | ||
3695 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3696 | ||
3697 | dnl CVLAN traffic should match the flow and drop | |
3698 | AT_CHECK([ovs-appctl revalidator/purge]) | |
3699 | AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:vlan-limit=1]) | |
3700 | AT_CHECK([ovs-ofctl add-flow br0 "priority=100 dl_type=0x8100 action=drop"]) | |
3701 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 -w 3 10.2.2.2], [1], [ignore]) | |
3702 | ||
3703 | OVS_TRAFFIC_VSWITCHD_STOP | |
3704 | AT_CLEANUP | |
0147a20e EG |
3705 | |
3706 | ||
3707 | AT_SETUP([802.1ad - push/pop outer 802.1ad]) | |
3708 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3709 | OVS_CHECK_8021AD() | |
3710 | ||
3711 | ADD_BR([br1]) | |
3712 | ADD_BR([br2]) | |
3713 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3714 | ||
3715 | AT_CHECK([ip link add ovs-p0 type veth peer name ovs-p1]) | |
3716 | AT_CHECK([ip link set dev ovs-p0 up]) | |
3717 | AT_CHECK([ip link set dev ovs-p1 up]) | |
3718 | AT_CHECK([ovs-vsctl add-port br0 ovs-p0]) | |
3719 | AT_CHECK([ovs-vsctl add-port br1 ovs-p1]) | |
3720 | on_exit 'ip link del ovs-p0' | |
3721 | ||
3722 | AT_CHECK([ip link add ovs-p2 type veth peer name ovs-p3]) | |
3723 | AT_CHECK([ip link set dev ovs-p2 up]) | |
3724 | AT_CHECK([ip link set dev ovs-p3 up]) | |
3725 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2]) | |
3726 | AT_CHECK([ovs-vsctl add-port br2 ovs-p3]) | |
3727 | on_exit 'ip link del ovs-p2' | |
3728 | ||
3729 | ADD_VETH(p4, at_ns0, br1, "10.1.1.1/24") | |
3730 | ADD_VETH(p5, at_ns1, br2, "10.1.1.2/24") | |
3731 | ADD_CVLAN(p4, at_ns0, 100, "10.2.2.1/24") | |
3732 | ADD_CVLAN(p5, at_ns1, 100, "10.2.2.2/24") | |
3733 | ||
3734 | AT_DATA([flows-br0.txt], [dnl | |
3735 | priority=1 action=drop | |
3736 | priority=100 in_port=1 action=push_vlan:0x88a8,mod_vlan_vid=4094,output:2 | |
3737 | priority=100 in_port=2 action=push_vlan:0x88a8,mod_vlan_vid=4094,output:1 | |
3738 | ]) | |
3739 | ||
3740 | AT_DATA([flows-customer-br.txt], [dnl | |
3741 | priority=1 action=normal | |
3742 | priority=100 in_port=1 vlan_tci=0x1000/0x1000 action=pop_vlan,normal | |
3743 | ]) | |
3744 | ||
3745 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) | |
3746 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-customer-br.txt]) | |
3747 | AT_CHECK([ovs-ofctl --bundle add-flows br2 flows-customer-br.txt]) | |
3748 | ||
3749 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3750 | ||
3751 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3752 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3753 | ]) | |
3754 | ||
3755 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3756 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3757 | ]) | |
3758 | ||
3759 | OVS_TRAFFIC_VSWITCHD_STOP | |
3760 | AT_CLEANUP | |
3761 | ||
3762 | ||
3763 | AT_SETUP([802.1ad - push/pop outer 802.1q]) | |
3764 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3765 | OVS_CHECK_8021AD() | |
3766 | ||
3767 | ADD_BR([br1]) | |
3768 | ADD_BR([br2]) | |
3769 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3770 | ||
3771 | AT_CHECK([ip link add ovs-p0 type veth peer name ovs-p1]) | |
3772 | AT_CHECK([ip link set dev ovs-p0 up]) | |
3773 | AT_CHECK([ip link set dev ovs-p1 up]) | |
3774 | AT_CHECK([ovs-vsctl add-port br0 ovs-p0]) | |
3775 | AT_CHECK([ovs-vsctl add-port br1 ovs-p1]) | |
3776 | on_exit 'ip link del ovs-p0' | |
3777 | ||
3778 | AT_CHECK([ip link add ovs-p2 type veth peer name ovs-p3]) | |
3779 | AT_CHECK([ip link set dev ovs-p2 up]) | |
3780 | AT_CHECK([ip link set dev ovs-p3 up]) | |
3781 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2]) | |
3782 | AT_CHECK([ovs-vsctl add-port br2 ovs-p3]) | |
3783 | on_exit 'ip link del ovs-p2' | |
3784 | ||
3785 | ADD_VETH(p4, at_ns0, br1, "10.1.1.1/24") | |
3786 | ADD_VETH(p5, at_ns1, br2, "10.1.1.2/24") | |
3787 | ADD_CVLAN(p4, at_ns0, 100, "10.2.2.1/24") | |
3788 | ADD_CVLAN(p5, at_ns1, 100, "10.2.2.2/24") | |
3789 | ||
3790 | AT_DATA([flows-br0.txt], [dnl | |
3791 | priority=1 action=drop | |
3792 | priority=100 in_port=1 action=push_vlan:0x8100,mod_vlan_vid=4094,output:2 | |
3793 | priority=100 in_port=2 action=push_vlan:0x8100,mod_vlan_vid=4094,output:1 | |
3794 | ]) | |
3795 | ||
3796 | AT_DATA([flows-customer-br.txt], [dnl | |
3797 | priority=1 action=normal | |
3798 | priority=100 in_port=1 vlan_tci=0x1000/0x1000 action=pop_vlan,normal | |
3799 | ]) | |
3800 | ||
3801 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) | |
3802 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-customer-br.txt]) | |
3803 | AT_CHECK([ovs-ofctl --bundle add-flows br2 flows-customer-br.txt]) | |
3804 | ||
3805 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3806 | ||
3807 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3808 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3809 | ]) | |
3810 | ||
3811 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3812 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3813 | ]) | |
3814 | ||
3815 | OVS_TRAFFIC_VSWITCHD_STOP | |
3816 | AT_CLEANUP | |
d4a814a8 EG |
3817 | |
3818 | ||
3819 | AT_SETUP([802.1ad - 802.1q tunnel]) | |
3820 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3821 | OVS_CHECK_8021AD() | |
3822 | ||
3823 | ADD_BR([br1]) | |
3824 | ADD_BR([br2]) | |
3825 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3826 | ||
3827 | AT_CHECK([ip link add ovs-p0 type veth peer name ovs-p1]) | |
3828 | AT_CHECK([ip link set dev ovs-p0 up]) | |
3829 | AT_CHECK([ip link set dev ovs-p1 up]) | |
3830 | AT_CHECK([ovs-vsctl add-port br0 ovs-p0]) | |
3831 | AT_CHECK([ovs-vsctl add-port br1 ovs-p1]) | |
3832 | on_exit 'ip link del ovs-p0' | |
3833 | ||
3834 | AT_CHECK([ip link add ovs-p2 type veth peer name ovs-p3]) | |
3835 | AT_CHECK([ip link set dev ovs-p2 up]) | |
3836 | AT_CHECK([ip link set dev ovs-p3 up]) | |
3837 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2]) | |
3838 | AT_CHECK([ovs-vsctl add-port br2 ovs-p3]) | |
3839 | on_exit 'ip link del ovs-p2' | |
3840 | ||
3841 | ADD_VETH(p4, at_ns0, br1, "10.1.1.1/24") | |
3842 | ADD_VETH(p5, at_ns1, br2, "10.1.1.2/24") | |
3843 | ADD_CVLAN(p4, at_ns0, 100, "10.2.2.1/24") | |
3844 | ADD_CVLAN(p5, at_ns1, 100, "10.2.2.2/24") | |
3845 | ADD_CVLAN(p4, at_ns0, 200, "10.3.2.1/24") | |
3846 | ADD_CVLAN(p5, at_ns1, 200, "10.3.2.2/24") | |
3847 | ADD_CVLAN(p4, at_ns0, 300, "10.4.2.1/24") | |
3848 | ADD_CVLAN(p5, at_ns1, 300, "10.4.2.2/24") | |
3849 | ||
3850 | AT_CHECK([ovs-ofctl add-flow br0 action=normal]) | |
3851 | AT_CHECK([ovs-ofctl add-flow br1 action=normal]) | |
3852 | AT_CHECK([ovs-ofctl add-flow br2 action=normal]) | |
3853 | AT_CHECK([ovs-vsctl set port ovs-p0 vlan_mode=dot1q-tunnel tag=4094 cvlans=100,200]) | |
3854 | AT_CHECK([ovs-vsctl set port ovs-p2 vlan_mode=dot1q-tunnel tag=4094 cvlans=100,200]) | |
3855 | ||
3856 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3857 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.3.2.2]) | |
3858 | ||
3859 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3860 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3861 | ]) | |
3862 | ||
3863 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.3.2.2 | FORMAT_PING], [0], [dnl | |
3864 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3865 | ]) | |
3866 | ||
3867 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3868 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3869 | ]) | |
3870 | ||
3871 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.3.2.2 | FORMAT_PING], [0], [dnl | |
3872 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3873 | ]) | |
3874 | ||
3875 | dnl CVLAN 300 is not permitted by dot1q-tunnel | |
3876 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 -w 3 10.4.2.2], [1], [ignore]) | |
3877 | ||
3878 | OVS_TRAFFIC_VSWITCHD_STOP(["/dropping VLAN \(0\|300\) packet received on dot1q-tunnel port/d"]) | |
3879 | AT_CLEANUP |