1 AT_BANNER([datapath-sanity])
3 AT_SETUP([datapath - ping between two ports])
4 OVS_TRAFFIC_VSWITCHD_START()
6 AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
8 ADD_NAMESPACES(at_ns0, at_ns1)
10 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
11 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
13 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
14 3 packets transmitted, 3 received, 0% packet loss, time 0ms
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
17 3 packets transmitted, 3 received, 0% packet loss, time 0ms
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
20 3 packets transmitted, 3 received, 0% packet loss, time 0ms
23 OVS_TRAFFIC_VSWITCHD_STOP
26 AT_SETUP([datapath - ping between two ports on vlan])
27 OVS_TRAFFIC_VSWITCHD_START()
29 AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
31 ADD_NAMESPACES(at_ns0, at_ns1)
33 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
34 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
36 ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24")
37 ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24")
39 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
40 3 packets transmitted, 3 received, 0% packet loss, time 0ms
42 NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
43 3 packets transmitted, 3 received, 0% packet loss, time 0ms
45 NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
46 3 packets transmitted, 3 received, 0% packet loss, time 0ms
49 OVS_TRAFFIC_VSWITCHD_STOP
52 AT_SETUP([datapath - ping6 between two ports])
53 OVS_TRAFFIC_VSWITCHD_START()
55 AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
57 ADD_NAMESPACES(at_ns0, at_ns1)
59 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
60 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
62 dnl Without this sleep, we get occasional failures due to the following error:
63 dnl "connect: Cannot assign requested address"
66 NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
67 3 packets transmitted, 3 received, 0% packet loss, time 0ms
69 NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
70 3 packets transmitted, 3 received, 0% packet loss, time 0ms
72 NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
73 3 packets transmitted, 3 received, 0% packet loss, time 0ms
76 OVS_TRAFFIC_VSWITCHD_STOP
79 AT_SETUP([datapath - ping6 between two ports on vlan])
80 OVS_TRAFFIC_VSWITCHD_START()
82 AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
84 ADD_NAMESPACES(at_ns0, at_ns1)
86 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
87 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
89 ADD_VLAN(p0, at_ns0, 100, "fc00:1::1/96")
90 ADD_VLAN(p1, at_ns1, 100, "fc00:1::2/96")
92 dnl Without this sleep, we get occasional failures due to the following error:
93 dnl "connect: Cannot assign requested address"
96 NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl
97 3 packets transmitted, 3 received, 0% packet loss, time 0ms
99 NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl
100 3 packets transmitted, 3 received, 0% packet loss, time 0ms
102 NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl
103 3 packets transmitted, 3 received, 0% packet loss, time 0ms
106 OVS_TRAFFIC_VSWITCHD_STOP
109 AT_SETUP([datapath - ping over vxlan tunnel])
112 OVS_TRAFFIC_VSWITCHD_START()
113 ADD_BR([br-underlay])
115 AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
116 AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"])
118 ADD_NAMESPACES(at_ns0)
120 dnl Set up underlay link from host into the namespace using veth pair.
121 ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
122 AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
123 AT_CHECK([ip link set dev br-underlay up])
125 dnl Set up tunnel endpoints on OVS outside the namespace and with a native
126 dnl linux device inside the namespace.
127 ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24])
128 ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24],
131 dnl First, check the underlay
132 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl
133 3 packets transmitted, 3 received, 0% packet loss, time 0ms
136 dnl Okay, now check the overlay with different packet sizes
137 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
138 3 packets transmitted, 3 received, 0% packet loss, time 0ms
140 NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
141 3 packets transmitted, 3 received, 0% packet loss, time 0ms
143 NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
144 3 packets transmitted, 3 received, 0% packet loss, time 0ms
147 OVS_TRAFFIC_VSWITCHD_STOP
150 AT_SETUP([conntrack - controller])
152 OVS_TRAFFIC_VSWITCHD_START()
154 ADD_NAMESPACES(at_ns0, at_ns1)
156 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
157 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
159 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
160 AT_DATA([flows.txt], [dnl
161 priority=1,action=drop
162 priority=10,arp,action=normal
163 priority=100,in_port=1,udp,action=ct(commit),controller
164 priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0)
165 priority=100,in_port=2,ct_state=+trk+est,udp,action=controller
168 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
170 AT_CAPTURE_FILE([ofctl_monitor.log])
171 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
173 dnl Send an unsolicited reply from port 2. This should be dropped.
174 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c00000000001100000a0101020a0101010002000100080000'])
176 dnl OK, now start a new connection from port 1.
177 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit\),controller '50540000000a50540000000908004500001c00000000001100000a0101010a0101020001000200080000'])
179 dnl Now try a reply from port 2.
180 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c00000000001100000a0101020a0101010002000100080000'])
182 dnl Check this output. We only see the latter two packets, not the first.
183 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
184 NXT_PACKET_IN (xid=0x0): total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
185 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
186 NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=42 ct_state=est|rpl|trk,in_port=2 (via action) data_len=42 (unbuffered)
187 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
190 OVS_TRAFFIC_VSWITCHD_STOP
193 AT_SETUP([conntrack - IPv4 HTTP])
195 OVS_TRAFFIC_VSWITCHD_START()
197 ADD_NAMESPACES(at_ns0, at_ns1)
199 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
200 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
202 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
203 AT_DATA([flows.txt], [dnl
204 priority=1,action=drop
205 priority=10,arp,action=normal
206 priority=10,icmp,action=normal
207 priority=100,in_port=1,tcp,action=ct(commit),2
208 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
209 priority=100,in_port=2,ct_state=+trk+est,tcp,action=1
212 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
214 dnl Basic connectivity check.
215 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 >/dev/null])
217 dnl HTTP requests from ns0->ns1 should work fine.
218 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
219 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
221 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
222 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=TIME_WAIT)
225 dnl HTTP requests from ns1->ns0 should fail due to network failure.
226 dnl Try 3 times, in 1 second intervals.
227 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
228 NS_CHECK_EXEC([at_ns1], [wget 10.1.1.1 -t 3 -T 1 -v -o wget1.log], [4])
230 OVS_TRAFFIC_VSWITCHD_STOP
233 AT_SETUP([conntrack - IPv6 HTTP])
235 OVS_TRAFFIC_VSWITCHD_START()
237 ADD_NAMESPACES(at_ns0, at_ns1)
239 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
240 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
242 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
243 AT_DATA([flows.txt], [dnl
244 priority=1,action=drop
245 priority=10,icmp6,action=normal
246 priority=100,in_port=1,tcp6,action=ct(commit),2
247 priority=100,in_port=2,ct_state=-trk,tcp6,action=ct(table=0)
248 priority=100,in_port=2,ct_state=+trk+est,tcp6,action=1
251 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
253 dnl Without this sleep, we get occasional failures due to the following error:
254 dnl "connect: Cannot assign requested address"
257 dnl HTTP requests from ns0->ns1 should work fine.
258 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py http6]], [http0.pid])
260 NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log])
262 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl
263 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=TIME_WAIT)
266 dnl HTTP requests from ns1->ns0 should fail due to network failure.
267 dnl Try 3 times, in 1 second intervals.
268 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py http6]], [http1.pid])
269 NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4])
271 OVS_TRAFFIC_VSWITCHD_STOP
274 AT_SETUP([conntrack - commit, recirc])
276 OVS_TRAFFIC_VSWITCHD_START()
278 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
280 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
281 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
282 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
283 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
285 dnl Allow any traffic from ns0->ns1, ns2->ns3.
286 AT_DATA([flows.txt], [dnl
287 priority=1,action=drop
288 priority=10,arp,action=normal
289 priority=10,icmp,action=normal
290 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0)
291 priority=100,in_port=1,tcp,ct_state=+trk,action=2
292 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0)
293 priority=100,in_port=2,tcp,ct_state=+trk,action=1
294 priority=100,in_port=3,tcp,ct_state=-trk,action=set_field:0->metadata,ct(table=0)
295 priority=100,in_port=3,tcp,ct_state=+trk,metadata=0,action=set_field:1->metadata,ct(commit,table=0)
296 priority=100,in_port=3,tcp,ct_state=+trk,metadata=1,action=4
297 priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0)
298 priority=100,in_port=4,tcp,ct_state=+trk,action=3
301 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
303 dnl HTTP requests from p0->p1 should work fine.
304 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
305 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
307 dnl HTTP requests from p2->p3 should work fine.
308 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
309 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log])
311 OVS_TRAFFIC_VSWITCHD_STOP
314 AT_SETUP([conntrack - preserve registers])
316 OVS_TRAFFIC_VSWITCHD_START()
318 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
320 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
321 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
322 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
323 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
325 dnl Allow any traffic from ns0->ns1, ns2->ns3.
326 AT_DATA([flows.txt], [dnl
327 priority=1,action=drop
328 priority=10,arp,action=normal
329 priority=10,icmp,action=normal
330 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0)
331 priority=100,in_port=1,tcp,ct_state=+trk,action=2
332 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0)
333 priority=100,in_port=2,tcp,ct_state=+trk,action=1
334 priority=100,in_port=3,tcp,ct_state=-trk,action=load:0->NXM_NX_REG0[[]],ct(table=0)
335 priority=100,in_port=3,tcp,ct_state=+trk,reg0=0,action=load:1->NXM_NX_REG0[[]],ct(commit,table=0)
336 priority=100,in_port=3,tcp,ct_state=+trk,reg0=1,action=4
337 priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0)
338 priority=100,in_port=4,tcp,ct_state=+trk,action=3
341 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
343 dnl HTTP requests from p0->p1 should work fine.
344 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
345 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
347 dnl HTTP requests from p2->p3 should work fine.
348 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
349 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log])
351 OVS_TRAFFIC_VSWITCHD_STOP
354 AT_SETUP([conntrack - invalid])
356 OVS_TRAFFIC_VSWITCHD_START()
358 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
360 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
361 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
362 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
363 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
365 dnl Pass traffic from ns0->ns1 without committing, but attempt to track in
366 dnl the opposite direction. This should fail.
367 dnl Pass traffic from ns3->ns4 without committing, and this time match
368 dnl invalid traffic and allow it through.
369 AT_DATA([flows.txt], [dnl
370 priority=1,action=drop
371 priority=10,arp,action=normal
372 priority=10,icmp,action=normal
373 priority=100,in_port=1,tcp,action=ct(),2
374 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
375 priority=100,in_port=2,ct_state=+trk+new,tcp,action=1
376 priority=100,in_port=3,tcp,action=ct(),4
377 priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
378 priority=100,in_port=4,ct_state=+trk+inv,tcp,action=3
379 priority=100,in_port=4,ct_state=+trk+new,tcp,action=3
382 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
384 dnl We set up our rules to allow the request without committing. The return
385 dnl traffic can't be identified, because the initial request wasn't committed.
386 dnl For the first pair of ports, this means that the connection fails.
387 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
388 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log], [4])
390 dnl For the second pair, we allow packets from invalid connections, so it works.
391 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
392 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log])
394 OVS_TRAFFIC_VSWITCHD_STOP
397 AT_SETUP([conntrack - zones])
399 OVS_TRAFFIC_VSWITCHD_START()
401 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
403 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
404 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
405 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
406 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
408 dnl Allow any traffic from ns0->ns1. Allow return traffic, matching on zone.
409 dnl For ns2->ns3, use a different zone and see that the match fails.
410 AT_DATA([flows.txt], [dnl
411 priority=1,action=drop
412 priority=10,arp,action=normal
413 priority=10,icmp,action=normal
414 priority=100,in_port=1,tcp,action=ct(commit,zone=1),2
415 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1)
416 priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1
417 priority=100,in_port=3,tcp,action=ct(commit,zone=2),4
418 priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0,zone=2)
419 priority=100,in_port=4,ct_state=+trk,ct_zone=1,tcp,action=3
422 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
424 dnl HTTP requests from p0->p1 should work fine.
425 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
426 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
428 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
429 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=TIME_WAIT)
432 dnl HTTP requests from p2->p3 should fail due to network failure.
433 dnl Try 3 times, in 1 second intervals.
434 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
435 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
437 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
438 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=ESTABLISHED)
441 OVS_TRAFFIC_VSWITCHD_STOP
444 AT_SETUP([conntrack - zones from field])
446 OVS_TRAFFIC_VSWITCHD_START()
448 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
450 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
451 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
452 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
453 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
455 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
456 AT_DATA([flows.txt], [dnl
457 priority=1,action=drop
458 priority=10,arp,action=normal
459 priority=10,icmp,action=normal
460 priority=100,in_port=1,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),2
461 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]])
462 priority=100,in_port=2,ct_state=+trk,ct_zone=0x1001,tcp,action=1
463 priority=100,in_port=3,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),4
464 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]])
465 priority=100,in_port=4,ct_state=+trk,ct_zone=0x1001,tcp,action=3
468 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
470 dnl HTTP requests from p0->p1 should work fine.
471 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
472 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
474 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
475 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=TIME_WAIT)
478 dnl HTTP requests from p2->p3 should fail due to network failure.
479 dnl Try 3 times, in 1 second intervals.
480 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
481 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
483 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
484 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=ESTABLISHED)
487 OVS_TRAFFIC_VSWITCHD_STOP
490 AT_SETUP([conntrack - multiple bridges])
492 OVS_TRAFFIC_VSWITCHD_START(
494 add-port br0 patch+ -- set int patch+ type=patch options:peer=patch- --\
495 add-port br1 patch- -- set int patch- type=patch options:peer=patch+ --])
497 ADD_NAMESPACES(at_ns0, at_ns1)
499 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
500 ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24")
502 dnl Allow any traffic from ns0->br1, allow established in reverse.
503 AT_DATA([flows-br0.txt], [dnl
504 priority=1,action=drop
505 priority=10,arp,action=normal
506 priority=10,icmp,action=normal
507 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(commit,zone=1),1
508 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=1)
509 priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=1,action=2
512 dnl Allow any traffic from br0->ns1, allow established in reverse.
513 AT_DATA([flows-br1.txt], [dnl
514 priority=1,action=drop
515 priority=10,arp,action=normal
516 priority=10,icmp,action=normal
517 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=2)
518 priority=100,in_port=1,tcp,ct_state=+trk+new,ct_zone=2,action=ct(commit,zone=2),2
519 priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=2,action=2
520 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0,zone=2)
521 priority=100,in_port=2,tcp,ct_state=+trk+est,ct_zone=2,action=ct(commit,zone=2),1
524 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt])
525 AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-br1.txt])
527 dnl HTTP requests from p0->p1 should work fine.
528 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
529 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
531 OVS_TRAFFIC_VSWITCHD_STOP
534 AT_SETUP([conntrack - multiple zones])
536 OVS_TRAFFIC_VSWITCHD_START()
538 ADD_NAMESPACES(at_ns0, at_ns1)
540 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
541 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
543 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
544 AT_DATA([flows.txt], [dnl
545 priority=1,action=drop
546 priority=10,arp,action=normal
547 priority=10,icmp,action=normal
548 priority=100,in_port=1,tcp,action=ct(commit,zone=1),ct(commit,zone=2),2
549 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=2)
550 priority=100,in_port=2,ct_state=+trk,ct_zone=2,tcp,action=1
553 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
555 dnl HTTP requests from p0->p1 should work fine.
556 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
557 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
559 dnl (again) HTTP requests from p0->p1 should work fine.
560 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
562 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
563 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=SYN_SENT)
564 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=TIME_WAIT)
567 OVS_TRAFFIC_VSWITCHD_STOP
570 AT_SETUP([conntrack - multiple zones, local])
572 OVS_TRAFFIC_VSWITCHD_START()
574 ADD_NAMESPACES(at_ns0)
576 AT_CHECK([ip addr add dev br0 "10.1.1.1/24"])
577 AT_CHECK([ip link set dev br0 up])
578 on_exit 'ip addr del dev br0 "10.1.1.1/24"'
579 ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24")
581 dnl Allow traffic from local stack to ns0. Only allow neighbour discovery,
582 dnl return traffic from ns0 back to the local stack.
583 AT_DATA([flows.txt], [dnl
584 priority=1,action=drop
585 priority=10,arp,action=normal
586 priority=100,in_port=LOCAL,ip,ct_state=-trk,action=drop
587 priority=100,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=1),ct(commit,zone=2),1
588 priority=100,in_port=LOCAL,ip,ct_state=+trk+est,action=ct(commit,zone=1),ct(commit,zone=2),1
589 priority=100,in_port=1,ip,ct_state=-trk,action=ct(table=1,zone=1)
590 table=1,priority=100,in_port=1,ip,ct_state=+trk+est,ct_zone=1,action=ct(table=2,zone=2)
591 table=2,priority=100,in_port=1,ip,ct_state=+trk+est,ct_zone=2,action=LOCAL
594 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
596 AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
597 3 packets transmitted, 3 received, 0% packet loss, time 0ms
600 dnl HTTP requests from root namespace to p0 should work fine.
601 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
602 AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
604 dnl (again) HTTP requests from root namespace to p0 should work fine.
605 AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
607 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl
608 icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>),zone=1
609 icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>),zone=2
610 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=TIME_WAIT)
611 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=TIME_WAIT)
614 OVS_TRAFFIC_VSWITCHD_STOP
617 AT_SETUP([conntrack - multiple namespaces, internal ports])
619 OVS_TRAFFIC_VSWITCHD_START(
620 [set-fail-mode br0 secure -- ])
622 ADD_NAMESPACES(at_ns0, at_ns1)
624 ADD_INT(p0, at_ns0, br0, "10.1.1.1/24")
625 ADD_INT(p1, at_ns1, br0, "10.1.1.2/24")
627 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
629 dnl If skb->nfct is leaking from inside the namespace, this test will fail.
630 AT_DATA([flows.txt], [dnl
631 priority=1,action=drop
632 priority=10,arp,action=normal
633 priority=10,icmp,action=normal
634 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,zone=1),2
635 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1)
636 priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1
639 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
641 dnl HTTP requests from p0->p1 should work fine.
642 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
643 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
645 dnl (again) HTTP requests from p0->p1 should work fine.
646 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
648 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
649 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=TIME_WAIT)
652 OVS_TRAFFIC_VSWITCHD_STOP(["dnl
653 /ioctl(SIOCGIFINDEX) on .* device failed: No such device/d
654 /removing policing failed: No such device/d"])
657 AT_SETUP([conntrack - multi-stage pipeline, local])
659 OVS_TRAFFIC_VSWITCHD_START()
661 ADD_NAMESPACES(at_ns0)
663 AT_CHECK([ip addr add dev br0 "10.1.1.1/24"])
664 AT_CHECK([ip link set dev br0 up])
665 on_exit 'ip addr del dev br0 "10.1.1.1/24"'
666 ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24")
668 dnl Allow traffic from local stack to ns0. Only allow neighbour discovery,
669 dnl return traffic from ns0 back to the local stack.
670 AT_DATA([flows.txt], [dnl
672 table=0,priority=1,action=drop
673 table=0,priority=10,arp,action=normal
675 dnl Load the output port to REG0
676 table=0,priority=100,ip,in_port=LOCAL,action=load:1->NXM_NX_REG0[[0..15]],goto_table:1
677 table=0,priority=100,ip,in_port=1,action=load:65534->NXM_NX_REG0[[0..15]],goto_table:1
680 dnl - Allow all connections from LOCAL port (commit and proceed to egress)
681 dnl - All other connections go through conntracker using the input port as
682 dnl a connection tracking zone.
683 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
684 table=1,priority=100,ip,action=ct(table=2,zone=OXM_OF_IN_PORT[[0..15]])
685 table=1,priority=1,action=drop
688 dnl - Allow all connections from LOCAL port (commit and skip to output)
689 dnl - Allow other established connections to go through conntracker using
690 dnl output port as a connection tracking zone.
691 table=2,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=NXM_NX_REG0[[0..15]]),goto_table:4
692 table=2,priority=100,ip,ct_state=+trk+est,action=ct(table=3,zone=NXM_NX_REG0[[0..15]])
693 table=2,priority=1,action=drop
695 dnl Only allow established traffic from egress ct lookup
696 table=3,priority=100,ip,ct_state=+trk+est,action=goto_table:4
697 table=3,priority=1,action=drop
700 table=4,priority=100,ip,action=output:NXM_NX_REG0[[]]
703 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
705 AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
706 3 packets transmitted, 3 received, 0% packet loss, time 0ms
709 dnl HTTP requests from root namespace to p0 should work fine.
710 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
711 AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
713 dnl (again) HTTP requests from root namespace to p0 should work fine.
714 AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
716 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl
717 icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>),zone=1
718 icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>),zone=65534
719 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=TIME_WAIT)
720 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=TIME_WAIT)
723 OVS_TRAFFIC_VSWITCHD_STOP
726 AT_SETUP([conntrack - ct_mark])
728 OVS_TRAFFIC_VSWITCHD_START()
730 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
732 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
733 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
734 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
735 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
737 dnl Allow traffic between ns0<->ns1 using the ct_mark.
738 dnl Check that different marks do not match for traffic between ns2<->ns3.
739 AT_DATA([flows.txt], [dnl
740 priority=1,action=drop
741 priority=10,arp,action=normal
742 priority=10,icmp,action=normal
743 priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:1->ct_mark)),2
744 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
745 priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1
746 priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:2->ct_mark)),4
747 priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
748 priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3
751 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
753 dnl HTTP requests from p0->p1 should work fine.
754 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
755 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
757 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep TIME], [0], [dnl
758 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=TIME_WAIT)
761 dnl HTTP requests from p2->p3 should fail due to network failure.
762 dnl Try 3 times, in 1 second intervals.
763 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
764 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
766 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
767 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=ESTABLISHED)
770 OVS_TRAFFIC_VSWITCHD_STOP
773 AT_SETUP([conntrack - ct_mark from register])
775 OVS_TRAFFIC_VSWITCHD_START()
777 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
779 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
780 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
781 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
782 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
784 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
785 AT_DATA([flows.txt], [dnl
786 priority=1,action=drop
787 priority=10,arp,action=normal
788 priority=10,icmp,action=normal
789 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
790 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
791 priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1
792 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
793 priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
794 priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3
797 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
799 dnl HTTP requests from p0->p1 should work fine.
800 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
801 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
803 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep TIME], [0], [dnl
804 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=TIME_WAIT)
807 dnl HTTP requests from p2->p3 should fail due to network failure.
808 dnl Try 3 times, in 1 second intervals.
809 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
810 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
812 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
813 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=ESTABLISHED)
816 OVS_TRAFFIC_VSWITCHD_STOP
819 AT_SETUP([conntrack - ct_label])
821 OVS_TRAFFIC_VSWITCHD_START()
823 ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
825 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
826 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
827 ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
828 ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
830 dnl Allow traffic between ns0<->ns1 using the ct_label.
831 dnl Check that different labels do not match for traffic between ns2<->ns3.
832 AT_DATA([flows.txt], [dnl
833 priority=1,action=drop
834 priority=10,arp,action=normal
835 priority=10,icmp,action=normal
836 priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:0x0a000d000005000001->ct_label)),2
837 priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
838 priority=100,in_port=2,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=1
839 priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:0x2->ct_label)),4
840 priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
841 priority=100,in_port=4,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=3
844 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
846 dnl HTTP requests from p0->p1 should work fine.
847 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
848 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
850 dnl HTTP requests from p2->p3 should fail due to network failure.
851 dnl Try 3 times, in 1 second intervals.
852 NETNS_DAEMONIZE([at_ns3], [[$PYTHON $srcdir/test-l7.py]], [http1.pid])
853 NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
855 OVS_TRAFFIC_VSWITCHD_STOP
858 AT_SETUP([conntrack - ICMP related])
860 OVS_TRAFFIC_VSWITCHD_START()
862 ADD_NAMESPACES(at_ns0, at_ns1)
864 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
865 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
867 dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back.
868 AT_DATA([flows.txt], [dnl
869 priority=1,action=drop
870 priority=10,arp,action=normal
871 priority=100,in_port=1,udp,action=ct(commit,exec(set_field:1->ct_mark)),2
872 priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0)
873 priority=100,in_port=2,icmp,ct_state=+trk+rel,ct_mark=1,action=1
876 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
878 dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response.
879 NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"])
881 AT_CHECK([ovs-appctl revalidator/purge], [0])
882 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl
883 n_packets=1, n_bytes=44, priority=100,udp,in_port=1 actions=ct(commit,exec(load:0x1->NXM_NX_CT_MARK[[]])),output:2
884 n_packets=1, n_bytes=72, priority=100,ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2 actions=output:1
885 n_packets=1, n_bytes=72, priority=100,ct_state=-trk,icmp,in_port=2 actions=ct(table=0)
886 n_packets=2, n_bytes=84, priority=10,arp actions=NORMAL
890 OVS_TRAFFIC_VSWITCHD_STOP
893 AT_SETUP([conntrack - ICMP related 2])
895 OVS_TRAFFIC_VSWITCHD_START()
897 ADD_NAMESPACES(at_ns0, at_ns1)
899 ADD_VETH(p0, at_ns0, br0, "172.16.0.1/24")
900 ADD_VETH(p1, at_ns1, br0, "172.16.0.2/24")
902 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
903 AT_DATA([flows.txt], [dnl
904 priority=1,action=drop
905 priority=10,arp,action=normal
906 priority=100,in_port=1,udp,ct_state=-trk,action=ct(commit,table=0)
907 priority=100,in_port=1,ip,ct_state=+trk,actions=controller
908 priority=100,in_port=2,ip,ct_state=-trk,action=ct(table=0)
909 priority=100,in_port=2,ip,ct_state=+trk+rel+rpl,action=controller
912 AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt])
914 AT_CAPTURE_FILE([ofctl_monitor.log])
915 AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
917 dnl 1. Send an ICMP port unreach reply for port 8738, without any previous request
918 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) 'f64c473528c9c6f54ecb72db080045c0003d2e8700004001f355ac100004ac1000030303553f0000000045000021317040004011b138ac100003ac10000411112222000d20966369616f0a'])
920 dnl 2. Send and UDP packet to port 5555
921 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit,table=0\) 'c6f94ecb72dbe64c473528c9080045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a'])
923 dnl 3. Send an ICMP port unreach reply for port 5555, related to the first packet
924 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) 'e64c473528c9c6f94ecb72db080045c0003d2e8700004001f355ac100002ac1000010303553f0000000045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a'])
926 dnl Check this output. We only see the latter two packets, not the first.
927 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
928 NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=47 ct_state=new|trk,in_port=1 (via action) data_len=47 (unbuffered)
929 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
930 NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=75 ct_state=rel|rpl|trk,in_port=2 (via action) data_len=75 (unbuffered)
931 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
934 OVS_TRAFFIC_VSWITCHD_STOP
937 AT_SETUP([conntrack - FTP])
938 AT_SKIP_IF([test $HAVE_PYFTPDLIB = no])
940 OVS_TRAFFIC_VSWITCHD_START()
942 ADD_NAMESPACES(at_ns0, at_ns1)
944 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
945 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
947 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
948 AT_DATA([flows1.txt], [dnl
949 priority=1,action=drop
950 priority=10,arp,action=normal
951 priority=10,icmp,action=normal
952 priority=100,in_port=1,tcp,action=ct(alg=ftp,commit),2
953 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0)
954 priority=100,in_port=2,tcp,ct_state=+trk+est,action=1
955 priority=100,in_port=2,tcp,ct_state=+trk+rel,action=1
958 dnl Similar policy but without allowing all traffic from ns0->ns1.
959 AT_DATA([flows2.txt], [dnl
960 priority=1,action=drop
961 priority=10,arp,action=normal
962 priority=10,icmp,action=normal
963 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0)
964 priority=100,in_port=1,tcp,ct_state=+trk+new,action=ct(commit,alg=ftp),2
965 priority=100,in_port=1,tcp,ct_state=+trk+est,action=2
966 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0)
967 priority=100,in_port=2,tcp,ct_state=+trk+new+rel,action=ct(commit),1
968 priority=100,in_port=2,tcp,ct_state=+trk+est,action=1
969 priority=100,in_port=2,tcp,ct_state=+trk-new+rel,action=1
972 AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt])
974 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp1.pid])
975 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])
977 dnl FTP requests from p1->p0 should fail due to network failure.
978 dnl Try 3 times, in 1 second intervals.
979 NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4])
980 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
983 dnl FTP requests from p0->p1 should work fine.
984 NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log])
985 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN"], [0], [dnl
986 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=TIME_WAIT),helper=ftp
989 dnl Try the second set of flows.
990 AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt])
991 AT_CHECK([ovs-appctl dpctl/flush-conntrack])
993 dnl FTP requests from p1->p0 should fail due to network failure.
994 dnl Try 3 times, in 1 second intervals.
995 NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4])
996 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
999 dnl Active FTP requests from p0->p1 should work fine.
1000 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])
1001 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN"], [0], [dnl
1002 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=TIME_WAIT),helper=ftp
1003 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=TIME_WAIT)
1006 AT_CHECK([ovs-appctl dpctl/flush-conntrack])
1008 dnl Passive FTP requests from p0->p1 should work fine.
1009 NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0-2.log])
1010 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN"], [0], [dnl
1011 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=TIME_WAIT)
1012 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=TIME_WAIT),helper=ftp
1015 OVS_TRAFFIC_VSWITCHD_STOP
1019 AT_SETUP([conntrack - IPv6 FTP])
1020 AT_SKIP_IF([test $HAVE_PYFTPDLIB = no])
1022 OVS_TRAFFIC_VSWITCHD_START()
1024 ADD_NAMESPACES(at_ns0, at_ns1)
1026 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1027 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1029 dnl Allow any traffic from ns0->ns1.
1030 dnl Only allow nd, return traffic from ns1->ns0.
1031 AT_DATA([flows.txt], [dnl
1032 dnl Track all IPv6 traffic and drop the rest.
1033 dnl Allow ICMPv6 both ways. No commit, so pings will not be tracked.
1034 table=0 priority=100 in_port=1 icmp6, action=2
1035 table=0 priority=100 in_port=2 icmp6, action=1
1036 table=0 priority=10 ip6, action=ct(table=1)
1037 table=0 priority=0 action=drop
1041 dnl Allow new TCPv6 FTP control connections from port 1.
1042 table=1 in_port=1 ct_state=+new, tcp6, tp_dst=21, action=ct(alg=ftp,commit),2
1043 dnl Allow related TCPv6 connections from port 2.
1044 table=1 in_port=2 ct_state=+new+rel, tcp6, action=ct(commit),1
1045 dnl Allow established TCPv6 connections both ways.
1046 table=1 in_port=1 ct_state=+est, tcp6, action=2
1047 table=1 in_port=2 ct_state=+est, tcp6, action=1
1048 dnl Drop everything else.
1049 table=1 priority=0, action=drop
1052 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1054 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])
1056 dnl FTP requests from p0->p1 should work fine.
1057 NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-proxy --no-remove-listing -o wget0.log -d])
1059 dnl Discards CLOSE_WAIT and CLOSING
1060 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2) | grep -v "FIN" | grep -v "CLOS"], [0], [dnl
1061 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=TIME_WAIT),helper=ftp
1062 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=TIME_WAIT)
1065 OVS_TRAFFIC_VSWITCHD_STOP
1069 AT_SETUP([conntrack - FTP with multiple expectations])
1070 AT_SKIP_IF([test $HAVE_PYFTPDLIB = no])
1072 OVS_TRAFFIC_VSWITCHD_START()
1074 ADD_NAMESPACES(at_ns0, at_ns1)
1076 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1077 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1079 dnl Dual-firewall, allow all from ns1->ns2, allow established and ftp ns2->ns1.
1080 AT_DATA([flows.txt], [dnl
1081 priority=1,action=drop
1082 priority=10,arp,action=normal
1083 priority=10,icmp,action=normal
1084 priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=1)
1085 priority=100,in_port=1,tcp,ct_zone=1,ct_state=+trk+new,action=ct(commit,alg=ftp,zone=1),ct(commit,alg=ftp,zone=2),2
1086 priority=100,in_port=1,tcp,ct_zone=1,ct_state=+trk+est,action=ct(table=0,zone=2)
1087 priority=100,in_port=1,tcp,ct_zone=2,ct_state=+trk+new,action=ct(commit,alg=ftp,zone=2)
1088 priority=100,in_port=1,tcp,ct_zone=2,ct_state=+trk+est,action=2
1089 priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0,zone=2)
1090 priority=100,in_port=2,tcp,ct_zone=2,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1
1091 priority=100,in_port=2,tcp,ct_zone=2,ct_state=+trk+est,action=ct(table=0,zone=1)
1092 priority=100,in_port=2,tcp,ct_zone=1,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1
1093 priority=100,in_port=2,tcp,ct_zone=1,ct_state=+trk+est,action=1
1096 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1098 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp1.pid])
1099 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])
1101 dnl FTP requests from p1->p0 should fail due to network failure.
1102 dnl Try 3 times, in 1 second intervals.
1103 NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4])
1104 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
1107 dnl Active FTP requests from p0->p1 should work fine.
1108 NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1109 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN"], [0], [dnl
1110 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=TIME_WAIT),helper=ftp
1111 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=TIME_WAIT),helper=ftp
1112 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=TIME_WAIT)
1113 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=TIME_WAIT)
1116 AT_CHECK([ovs-appctl dpctl/flush-conntrack])
1118 dnl Passive FTP requests from p0->p1 should work fine.
1119 NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1120 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN"], [0], [dnl
1121 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=TIME_WAIT)
1122 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=TIME_WAIT),helper=ftp
1123 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=TIME_WAIT)
1124 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=TIME_WAIT),helper=ftp
1127 OVS_TRAFFIC_VSWITCHD_STOP
1130 AT_SETUP([conntrack - IPv4 fragmentation ])
1132 OVS_TRAFFIC_VSWITCHD_START()
1134 ADD_NAMESPACES(at_ns0, at_ns1)
1136 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1137 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1139 dnl Sending ping through conntrack
1140 AT_DATA([flows.txt], [dnl
1141 priority=1,action=drop
1142 priority=10,arp,action=normal
1143 priority=100,in_port=1,icmp,action=ct(commit,zone=9),2
1144 priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9)
1145 priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1
1148 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1150 dnl Basic connectivity check.
1151 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
1152 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1155 dnl Ipv4 fragmentation connectivity check.
1156 NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
1157 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1160 dnl Ipv4 larger fragmentation connectivity check.
1161 NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
1162 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1165 OVS_TRAFFIC_VSWITCHD_STOP
1168 AT_SETUP([conntrack - IPv4 fragmentation expiry])
1170 OVS_TRAFFIC_VSWITCHD_START()
1172 ADD_NAMESPACES(at_ns0, at_ns1)
1174 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1175 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1177 AT_DATA([flows.txt], [dnl
1178 priority=1,action=drop
1179 priority=10,arp,action=normal
1181 dnl Only allow non-fragmented messages and 1st fragments of each message
1182 priority=100,in_port=1,icmp,ip_frag=no,action=ct(commit,zone=9),2
1183 priority=100,in_port=1,icmp,ip_frag=firstaction=ct(commit,zone=9),2
1184 priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9)
1185 priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1
1188 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1190 dnl Basic connectivity check.
1191 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
1192 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1195 dnl Ipv4 fragmentation connectivity check.
1196 NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 1 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
1197 7 packets transmitted, 0 received, 100% packet loss, time 0ms
1200 OVS_TRAFFIC_VSWITCHD_STOP
1203 AT_SETUP([conntrack - IPv4 fragmentation + vlan])
1205 OVS_TRAFFIC_VSWITCHD_START()
1207 ADD_NAMESPACES(at_ns0, at_ns1)
1209 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1210 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1211 ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24")
1212 ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24")
1214 dnl Sending ping through conntrack
1215 AT_DATA([flows.txt], [dnl
1216 priority=1,action=drop
1217 priority=10,arp,action=normal
1218 priority=100,in_port=1,icmp,action=ct(commit,zone=9),2
1219 priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9)
1220 priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1
1223 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1225 dnl Basic connectivity check.
1226 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
1227 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1230 dnl Ipv4 fragmentation connectivity check.
1231 NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
1232 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1235 dnl Ipv4 larger fragmentation connectivity check.
1236 NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
1237 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1240 OVS_TRAFFIC_VSWITCHD_STOP
1243 AT_SETUP([conntrack - IPv6 fragmentation])
1245 OVS_TRAFFIC_VSWITCHD_START()
1247 ADD_NAMESPACES(at_ns0, at_ns1)
1249 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1250 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1252 dnl Sending ping through conntrack
1253 AT_DATA([flows.txt], [dnl
1254 priority=1,action=drop
1255 priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2
1256 priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9)
1257 priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1
1258 priority=100,icmp6,icmp_type=135,action=normal
1259 priority=100,icmp6,icmp_type=136,action=normal
1262 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1264 dnl Without this sleep, we get occasional failures due to the following error:
1265 dnl "connect: Cannot assign requested address"
1268 dnl Basic connectivity check.
1269 NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1270 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1273 dnl Ipv6 fragmentation connectivity check.
1274 NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1275 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1278 dnl Ipv6 larger fragmentation connectivity check.
1279 NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1280 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1283 OVS_TRAFFIC_VSWITCHD_STOP
1286 AT_SETUP([conntrack - IPv6 fragmentation expiry])
1288 OVS_TRAFFIC_VSWITCHD_START()
1290 ADD_NAMESPACES(at_ns0, at_ns1)
1292 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1293 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1295 AT_DATA([flows.txt], [dnl
1296 priority=1,action=drop
1298 dnl Only allow non-fragmented messages and 1st fragments of each message
1299 priority=10,in_port=1,ipv6,ip_frag=first,action=ct(commit,zone=9),2
1300 priority=10,in_port=1,ipv6,ip_frag=no,action=ct(commit,zone=9),2
1301 priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9)
1302 priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1
1304 dnl Neighbour Discovery
1305 priority=100,icmp6,icmp_type=135,action=normal
1306 priority=100,icmp6,icmp_type=136,action=normal
1309 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1311 dnl Without this sleep, we get occasional failures due to the following error:
1312 dnl "connect: Cannot assign requested address"
1315 dnl Basic connectivity check.
1316 NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1317 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1320 dnl Send an IPv6 fragment. Some time later, it should expire.
1321 NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 1 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1322 7 packets transmitted, 0 received, 100% packet loss, time 0ms
1325 dnl At this point, the kernel will either crash or everything is OK.
1327 OVS_TRAFFIC_VSWITCHD_STOP
1330 AT_SETUP([conntrack - IPv6 fragmentation + vlan])
1332 OVS_TRAFFIC_VSWITCHD_START()
1334 ADD_NAMESPACES(at_ns0, at_ns1)
1336 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1337 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1339 ADD_VLAN(p0, at_ns0, 100, "fc00:1::3/96")
1340 ADD_VLAN(p1, at_ns1, 100, "fc00:1::4/96")
1342 dnl Sending ping through conntrack
1343 AT_DATA([flows.txt], [dnl
1344 priority=1,action=drop
1345 priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2
1346 priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9)
1347 priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1
1348 priority=100,icmp6,icmp_type=135,action=normal
1349 priority=100,icmp6,icmp_type=136,action=normal
1352 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1354 dnl Without this sleep, we get occasional failures due to the following error:
1355 dnl "connect: Cannot assign requested address"
1358 dnl Basic connectivity check.
1359 NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl
1360 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1363 dnl Ipv4 fragmentation connectivity check.
1364 NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl
1365 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1368 dnl Ipv4 larger fragmentation connectivity check.
1369 NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl
1370 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1373 OVS_TRAFFIC_VSWITCHD_STOP
1376 AT_SETUP([conntrack - Fragmentation over vxlan])
1380 OVS_TRAFFIC_VSWITCHD_START()
1381 ADD_BR([br-underlay])
1382 AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"])
1384 ADD_NAMESPACES(at_ns0)
1386 dnl Sending ping through conntrack
1387 AT_DATA([flows.txt], [dnl
1388 priority=1,action=drop
1389 priority=10,arp,action=normal
1390 priority=100,in_port=1,icmp,action=ct(commit,zone=9),LOCAL
1391 priority=100,in_port=LOCAL,icmp,action=ct(table=1,zone=9)
1392 table=1,priority=100,in_port=LOCAL,ct_state=+trk+est,icmp,action=1
1395 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1397 dnl Set up underlay link from host into the namespace using veth pair.
1398 ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
1399 AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
1400 AT_CHECK([ip link set dev br-underlay up])
1402 dnl Set up tunnel endpoints on OVS outside the namespace and with a native
1403 dnl linux device inside the namespace.
1404 ADD_OVS_TUNNEL([vxlan], [br0], [at_ns0], [172.31.1.1], [10.1.1.100/24])
1405 ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24],
1406 [id 0 dstport 4789])
1408 dnl First, check the underlay
1409 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl
1410 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1413 dnl Okay, now check the overlay with different packet sizes
1414 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
1415 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1417 NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
1418 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1420 NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
1421 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1424 OVS_TRAFFIC_VSWITCHD_STOP
1427 AT_SETUP([conntrack - IPv6 Fragmentation over vxlan])
1428 AT_SKIP_IF([! ip link help 2>&1 | grep vxlan >/dev/null])
1431 OVS_TRAFFIC_VSWITCHD_START()
1432 ADD_BR([br-underlay])
1433 AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"])
1435 ADD_NAMESPACES(at_ns0)
1437 dnl Sending ping through conntrack
1438 AT_DATA([flows.txt], [dnl
1439 priority=1,action=drop
1440 priority=100,in_port=1,ipv6,action=ct(commit,zone=9),LOCAL
1441 priority=100,in_port=LOCAL,ipv6,action=ct(table=1,zone=9)
1442 table=1,priority=100,in_port=LOCAL,ct_state=+trk+est,ipv6,action=1
1444 dnl Neighbour Discovery
1445 priority=1000,icmp6,icmp_type=135,action=normal
1446 priority=1000,icmp6,icmp_type=136,action=normal
1449 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1451 dnl Set up underlay link from host into the namespace using veth pair.
1452 ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
1453 AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
1454 AT_CHECK([ip link set dev br-underlay up])
1456 dnl Set up tunnel endpoints on OVS outside the namespace and with a native
1457 dnl linux device inside the namespace.
1458 ADD_OVS_TUNNEL([vxlan], [br0], [at_ns0], [172.31.1.1], ["fc00::2/96"])
1459 ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], ["fc00::1/96"],
1460 [id 0 dstport 4789])
1462 dnl Without this sleep, we get occasional failures due to the following error:
1463 dnl "connect: Cannot assign requested address"
1466 dnl First, check the underlay
1467 NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl
1468 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1471 dnl Okay, now check the overlay with different packet sizes
1472 NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1473 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1475 NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1476 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1478 NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
1479 3 packets transmitted, 3 received, 0% packet loss, time 0ms
1482 OVS_TRAFFIC_VSWITCHD_STOP
1485 AT_SETUP([conntrack - resubmit to ct multiple times])
1488 OVS_TRAFFIC_VSWITCHD_START(
1489 [set-fail-mode br0 secure -- ])
1491 ADD_NAMESPACES(at_ns0, at_ns1)
1493 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1494 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1496 AT_DATA([flows.txt], [dnl
1497 table=0,priority=150,arp,action=normal
1498 table=0,priority=100,ip,in_port=1,action=resubmit(,1),resubmit(,2)
1500 table=1,priority=100,ip,action=ct(table=3)
1501 table=2,priority=100,ip,action=ct(table=3)
1503 table=3,ip,action=drop
1506 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1508 NS_CHECK_EXEC([at_ns0], [ping -q -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl
1509 1 packets transmitted, 0 received, 100% packet loss, time 0ms
1512 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1513 n_packets=1, n_bytes=98, priority=100,ip,in_port=1 actions=resubmit(,1),resubmit(,2)
1514 n_packets=2, n_bytes=84, priority=150,arp actions=NORMAL
1515 table=1, n_packets=1, n_bytes=98, priority=100,ip actions=ct(table=3)
1516 table=2, n_packets=1, n_bytes=98, priority=100,ip actions=ct(table=3)
1517 table=3, n_packets=2, n_bytes=196, ip actions=drop
1521 OVS_TRAFFIC_VSWITCHD_STOP
1525 AT_SETUP([conntrack - simple SNAT])
1527 OVS_TRAFFIC_VSWITCHD_START()
1529 ADD_NAMESPACES(at_ns0, at_ns1)
1531 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1532 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1533 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1535 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1536 AT_DATA([flows.txt], [dnl
1537 in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2
1538 in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat)
1539 in_port=2,ct_state=+trk,ct_zone=1,ip,action=1
1542 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1543 priority=10 arp action=normal
1544 priority=0,action=drop
1546 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1547 table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1548 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1549 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1551 dnl Swaps the fields of the ARP message to turn a query to a response.
1552 table=10 priority=100 arp xreg0=0 action=normal
1553 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]]
1554 table=10 priority=0 action=drop
1557 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1559 dnl HTTP requests from p0->p1 should work fine.
1560 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
1561 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
1563 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
1564 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=TIME_WAIT)
1567 OVS_TRAFFIC_VSWITCHD_STOP
1571 AT_SETUP([conntrack - SNAT with port range])
1573 OVS_TRAFFIC_VSWITCHD_START()
1575 ADD_NAMESPACES(at_ns0, at_ns1)
1577 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1578 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1579 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1581 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1582 AT_DATA([flows.txt], [dnl
1583 in_port=1,tcp,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255:34567-34568,random)),2
1584 in_port=2,ct_state=-trk,tcp,tp_dst=34567,action=ct(table=0,zone=1,nat)
1585 in_port=2,ct_state=-trk,tcp,tp_dst=34568,action=ct(table=0,zone=1,nat)
1586 in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1
1589 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1590 priority=10 arp action=normal
1591 priority=0,action=drop
1593 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1594 table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1595 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1596 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1598 dnl Swaps the fields of the ARP message to turn a query to a response.
1599 table=10 priority=100 arp xreg0=0 action=normal
1600 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]]
1601 table=10 priority=0 action=drop
1604 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1606 dnl HTTP requests from p0->p1 should work fine.
1607 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
1608 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
1610 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
1611 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=TIME_WAIT)
1614 OVS_TRAFFIC_VSWITCHD_STOP
1618 AT_SETUP([conntrack - more complex SNAT])
1620 OVS_TRAFFIC_VSWITCHD_START()
1622 ADD_NAMESPACES(at_ns0, at_ns1)
1624 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1625 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1626 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1628 AT_DATA([flows.txt], [dnl
1629 dnl Track all IP traffic, NAT existing connections.
1630 priority=100 ip action=ct(table=1,zone=1,nat)
1632 dnl Allow ARP, but generate responses for NATed addresses
1633 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1634 priority=10 arp action=normal
1635 priority=0 action=drop
1637 dnl Allow any traffic from ns0->ns1. SNAT ns0 to 10.1.1.240-10.1.1.255
1638 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
1639 table=1 priority=100 in_port=1 ip ct_state=+trk-new+est action=2
1640 dnl Only allow established traffic from ns1->ns0.
1641 table=1 priority=100 in_port=2 ip ct_state=+trk-new+est action=1
1642 table=1 priority=0 action=drop
1644 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1645 table=8 priority=100 reg2=0x0a0101f0/0xfffffff0 action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1646 dnl Zero result means not found.
1647 table=8 priority=0 action=load:0->OXM_OF_PKT_REG0[[]]
1648 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1649 dnl ARP TPA IP in reg2.
1650 table=10 priority=100 arp xreg0=0 action=normal
1651 dnl Swaps the fields of the ARP message to turn a query to a response.
1652 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]]
1653 table=10 priority=0 action=drop
1656 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1658 dnl HTTP requests from p0->p1 should work fine.
1659 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
1660 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
1662 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
1663 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=TIME_WAIT)
1666 OVS_TRAFFIC_VSWITCHD_STOP
1669 AT_SETUP([conntrack - simple DNAT])
1671 OVS_TRAFFIC_VSWITCHD_START()
1673 ADD_NAMESPACES(at_ns0, at_ns1)
1675 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1676 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1677 NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88])
1679 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1680 AT_DATA([flows.txt], [dnl
1681 priority=100 in_port=1,ip,nw_dst=10.1.1.64,action=ct(zone=1,nat(dst=10.1.1.2),commit),2
1682 priority=10 in_port=1,ip,action=ct(commit,zone=1),2
1683 priority=100 in_port=2,ct_state=-trk,ip,action=ct(table=0,nat,zone=1)
1684 priority=100 in_port=2,ct_state=+trk+est,ct_zone=1,ip,action=1
1687 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1688 priority=10 arp action=normal
1689 priority=0,action=drop
1691 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1692 table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1693 dnl Zero result means not found.
1694 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1695 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1697 table=10 priority=100 arp xreg0=0 action=normal
1698 dnl Swaps the fields of the ARP message to turn a query to a response.
1699 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]]
1700 table=10 priority=0 action=drop
1703 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1705 dnl Should work with the virtual IP address through NAT
1706 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
1707 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
1709 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64) ], [0], [dnl
1710 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=TIME_WAIT)
1713 dnl Should work with the assigned IP address as well
1714 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1716 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) ], [0], [dnl
1717 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=TIME_WAIT)
1720 OVS_TRAFFIC_VSWITCHD_STOP
1723 AT_SETUP([conntrack - more complex DNAT])
1725 OVS_TRAFFIC_VSWITCHD_START()
1727 ADD_NAMESPACES(at_ns0, at_ns1)
1729 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1730 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1731 NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88])
1733 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1734 AT_DATA([flows.txt], [dnl
1735 dnl Track all IP traffic
1736 table=0 priority=100 ip action=ct(table=1,zone=1,nat)
1738 dnl Allow ARP, but generate responses for NATed addresses
1739 table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1740 table=0 priority=10 arp action=normal
1741 table=0 priority=0 action=drop
1743 dnl Allow any IP traffic from ns0->ns1. DNAT ns0 from 10.1.1.64 to 10.1.1.2
1744 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
1745 table=1 priority=10 in_port=1 ct_state=+new ip action=ct(commit,zone=1),2
1746 table=1 priority=100 in_port=1 ct_state=+est ct_zone=1 action=2
1747 dnl Only allow established traffic from ns1->ns0.
1748 table=1 priority=100 in_port=2 ct_state=+est ct_zone=1 action=1
1749 table=1 priority=0 action=drop
1751 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1752 table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1753 dnl Zero result means not found.
1754 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1755 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1757 table=10 priority=100 arp xreg0=0 action=normal
1758 dnl Swaps the fields of the ARP message to turn a query to a response.
1759 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]]
1760 table=10 priority=0 action=drop
1763 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1765 dnl Should work with the virtual IP address through NAT
1766 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid])
1767 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
1769 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64) ], [0], [dnl
1770 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=TIME_WAIT)
1773 dnl Should work with the assigned IP address as well
1774 NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1776 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) ], [0], [dnl
1777 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=TIME_WAIT)
1780 OVS_TRAFFIC_VSWITCHD_STOP
1783 AT_SETUP([conntrack - ICMP related with NAT])
1785 OVS_TRAFFIC_VSWITCHD_START()
1787 ADD_NAMESPACES(at_ns0, at_ns1)
1789 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1790 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1791 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1793 dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back.
1794 dnl Make sure ICMP responses are reverse-NATted.
1795 AT_DATA([flows.txt], [dnl
1796 in_port=1,udp,action=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:1->ct_mark)),2
1797 in_port=2,icmp,ct_state=-trk,action=ct(table=0,nat)
1798 in_port=2,icmp,nw_dst=10.1.1.1,ct_state=+trk+rel,ct_mark=1,action=1
1801 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1802 priority=10 arp action=normal
1803 priority=0,action=drop
1805 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1806 table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1807 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1808 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1810 dnl Swaps the fields of the ARP message to turn a query to a response.
1811 table=10 priority=100 arp xreg0=0 action=normal
1812 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]]
1813 table=10 priority=0 action=drop
1816 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1818 dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response.
1819 NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"])
1821 AT_CHECK([ovs-appctl revalidator/purge], [0])
1822 AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl
1823 n_packets=1, n_bytes=42, priority=10,arp actions=NORMAL
1824 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
1825 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
1826 n_packets=1, n_bytes=72, ct_state=-trk,icmp,in_port=2 actions=ct(table=0,nat)
1827 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
1828 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]]
1829 table=10, n_packets=1, n_bytes=42, priority=100,arp,reg0=0,reg1=0 actions=NORMAL
1830 table=8, n_packets=1, n_bytes=42, priority=0 actions=set_field:0->xreg0
1831 table=8, n_packets=1, n_bytes=42, reg2=0xa0101f0/0xfffffff0 actions=set_field:0x808888888888->xreg0
1832 OFPST_FLOW reply (OF1.5):
1835 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
1836 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
1839 OVS_TRAFFIC_VSWITCHD_STOP
1843 AT_SETUP([conntrack - FTP with NAT])
1844 AT_SKIP_IF([test $HAVE_PYFTPDLIB = no])
1847 OVS_TRAFFIC_VSWITCHD_START()
1849 ADD_NAMESPACES(at_ns0, at_ns1)
1851 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1852 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1853 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1855 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1857 AT_DATA([flows.txt], [dnl
1858 dnl track all IP traffic, de-mangle non-NEW connections
1859 table=0 in_port=1, ip, action=ct(table=1,nat)
1860 table=0 in_port=2, ip, action=ct(table=2,nat)
1864 table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1865 table=0 priority=10 arp action=normal
1866 table=0 priority=0 action=drop
1868 dnl Table 1: port 1 -> 2
1870 dnl Allow new FTP connections. These need to be commited.
1871 table=1 ct_state=+new, tcp, tp_dst=21, nw_src=10.1.1.1, action=ct(alg=ftp,commit,nat(src=10.1.1.240)),2
1872 dnl Allow established TCP connections, make sure they are NATted already.
1873 table=1 ct_state=+est, tcp, nw_src=10.1.1.240, action=2
1875 dnl Table 1: droppers
1877 table=1 priority=10, tcp, action=drop
1878 table=1 priority=0,action=drop
1880 dnl Table 2: port 2 -> 1
1882 dnl Allow established TCP connections, make sure they are reverse NATted
1883 table=2 ct_state=+est, tcp, nw_dst=10.1.1.1, action=1
1884 dnl Allow (new) related (data) connections. These need to be commited.
1885 table=2 ct_state=+new+rel, tcp, nw_dst=10.1.1.240, action=ct(commit,nat),1
1886 dnl Allow related ICMP packets, make sure they are reverse NATted
1887 table=2 ct_state=+rel, icmp, nw_dst=10.1.1.1, action=1
1889 dnl Table 2: droppers
1891 table=2 priority=10, tcp, action=drop
1892 table=2 priority=0, action=drop
1894 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1896 table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1897 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1898 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1900 dnl Swaps the fields of the ARP message to turn a query to a response.
1901 table=10 priority=100 arp xreg0=0 action=normal
1902 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]]
1903 table=10 priority=0 action=drop
1906 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1908 dnl NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp1.pid])
1909 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])
1911 dnl FTP requests from p0->p1 should work fine.
1912 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-proxy --no-remove-listing -o wget0.log -d])
1914 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN"], [0], [dnl
1915 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.240,sport=<cleared>,dport=<cleared>),protoinfo=(state=TIME_WAIT),helper=ftp
1916 tcp,orig=(src=10.1.1.2,dst=10.1.1.240,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=TIME_WAIT)
1919 OVS_TRAFFIC_VSWITCHD_STOP
1923 AT_SETUP([conntrack - FTP with NAT 2])
1924 AT_SKIP_IF([test $HAVE_PYFTPDLIB = no])
1926 OVS_TRAFFIC_VSWITCHD_START()
1928 ADD_NAMESPACES(at_ns0, at_ns1)
1930 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1931 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1932 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1934 dnl Allow any traffic from ns0->ns1.
1935 dnl Only allow nd, return traffic from ns1->ns0.
1936 AT_DATA([flows.txt], [dnl
1937 dnl track all IP traffic (this includes a helper call to non-NEW packets.)
1938 table=0 ip, action=ct(table=1)
1942 table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
1943 table=0 priority=10 arp action=normal
1944 table=0 priority=0 action=drop
1948 dnl Allow new FTP connections. These need to be commited.
1949 dnl This does helper for new packets.
1950 table=1 in_port=1 ct_state=+new, tcp, tp_dst=21, action=ct(alg=ftp,commit,nat(src=10.1.1.240)),2
1951 dnl Allow and NAT established TCP connections
1952 table=1 in_port=1 ct_state=+est, tcp, action=ct(nat),2
1953 table=1 in_port=2 ct_state=+est, tcp, action=ct(nat),1
1954 dnl Allow and NAT (new) related active (data) connections.
1955 dnl These need to be commited.
1956 table=1 in_port=2 ct_state=+new+rel, tcp, action=ct(commit,nat),1
1957 dnl Allow related ICMP packets.
1958 table=1 in_port=2 ct_state=+rel, icmp, action=ct(nat),1
1959 dnl Drop everything else.
1960 table=1 priority=0, action=drop
1962 dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
1964 table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
1965 table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
1966 dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
1968 dnl Swaps the fields of the ARP message to turn a query to a response.
1969 table=10 priority=100 arp xreg0=0 action=normal
1970 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]]
1971 table=10 priority=0 action=drop
1974 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1976 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])
1978 dnl FTP requests from p0->p1 should work fine.
1979 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-proxy --no-remove-listing -o wget0.log -d])
1981 dnl Discards CLOSE_WAIT and CLOSING
1982 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep -v "FIN" | grep -v "CLOS"], [0], [dnl
1983 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.240,sport=<cleared>,dport=<cleared>),protoinfo=(state=TIME_WAIT),helper=ftp
1984 tcp,orig=(src=10.1.1.2,dst=10.1.1.240,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=TIME_WAIT)
1987 OVS_TRAFFIC_VSWITCHD_STOP
1990 AT_SETUP([conntrack - IPv6 HTTP with NAT])
1992 OVS_TRAFFIC_VSWITCHD_START()
1994 ADD_NAMESPACES(at_ns0, at_ns1)
1996 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1997 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
1998 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1999 NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])
2001 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2002 AT_DATA([flows.txt], [dnl
2003 priority=1,action=drop
2004 priority=10,icmp6,action=normal
2005 priority=100,in_port=1,ip6,action=ct(commit,nat(src=fc00::240)),2
2006 priority=100,in_port=2,ct_state=-trk,ip6,action=ct(nat,table=0)
2007 priority=100,in_port=2,ct_state=+trk+est,ip6,action=1
2008 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
2011 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2013 dnl Without this sleep, we get occasional failures due to the following error:
2014 dnl "connect: Cannot assign requested address"
2017 dnl HTTP requests from ns0->ns1 should work fine.
2018 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py http6]], [http0.pid])
2020 NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2022 dnl HTTP requests from ns1->ns0 should fail due to network failure.
2023 dnl Try 3 times, in 1 second intervals.
2024 NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py http6]], [http1.pid])
2025 NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4])
2027 OVS_TRAFFIC_VSWITCHD_STOP
2031 AT_SETUP([conntrack - IPv6 FTP with NAT])
2032 AT_SKIP_IF([test $HAVE_PYFTPDLIB = no])
2034 OVS_TRAFFIC_VSWITCHD_START()
2036 ADD_NAMESPACES(at_ns0, at_ns1)
2038 ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
2039 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2040 ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
2041 dnl Would be nice if NAT could translate neighbor discovery messages, too.
2042 NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])
2044 dnl Allow any traffic from ns0->ns1.
2045 dnl Only allow nd, return traffic from ns1->ns0.
2046 AT_DATA([flows.txt], [dnl
2047 dnl Allow other ICMPv6 both ways (without commit).
2048 table=1 priority=100 in_port=1 icmp6, action=2
2049 table=1 priority=100 in_port=2 icmp6, action=1
2050 dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.)
2051 table=0 priority=10 ip6, action=ct(nat,table=1)
2052 table=0 priority=0 action=drop
2056 dnl Allow new TCPv6 FTP control connections.
2057 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
2058 dnl Allow related TCPv6 connections from port 2 to the NATted address.
2059 table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1
2060 dnl Allow established TCPv6 connections both ways, enforce NATting
2061 table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240 action=2
2062 table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1 action=1
2063 dnl Drop everything else.
2064 table=1 priority=0, action=drop
2067 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2069 NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid])
2071 dnl FTP requests from p0->p1 should work fine.
2072 NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-proxy --no-remove-listing -o wget0.log -d])
2074 dnl Discards CLOSE_WAIT and CLOSING
2075 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2) | grep -v "FIN" | grep -v "CLOS"], [0], [dnl
2076 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=TIME_WAIT),helper=ftp
2077 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=TIME_WAIT)
2080 OVS_TRAFFIC_VSWITCHD_STOP