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