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