]> git.proxmox.com Git - mirror_ovs.git/blame - tests/system-traffic.at
tests: Fix race in MPLS translate.
[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()
07659514
JS
615
616ADD_NAMESPACES(at_ns0, at_ns1)
617
618ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
619ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
620
621dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
622AT_DATA([flows.txt], [dnl
623priority=1,action=drop
624priority=10,arp,action=normal
625priority=100,in_port=1,udp,action=ct(commit),controller
626priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0)
627priority=100,in_port=2,ct_state=+trk+est,udp,action=controller
628])
629
6cfa8ec3 630AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
07659514
JS
631
632AT_CAPTURE_FILE([ofctl_monitor.log])
633AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
634
635dnl Send an unsolicited reply from port 2. This should be dropped.
4573c42e 636AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000'])
07659514
JS
637
638dnl OK, now start a new connection from port 1.
4573c42e 639AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit\),controller '50540000000a50540000000908004500001c000000000011a4cd0a0101010a0101020001000200080000'])
07659514
JS
640
641dnl Now try a reply from port 2.
4573c42e 642AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000'])
07659514
JS
643
644dnl Check this output. We only see the latter two packets, not the first.
645AT_CHECK([cat ofctl_monitor.log], [0], [dnl
f274a047 646NXT_PACKET_IN2 (xid=0x0): total_len=42 in_port=1 (via action) data_len=42 (unbuffered)
07659514 647udp,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
f274a047 648NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 ct_state=est|rpl|trk,in_port=2 (via action) data_len=42 (unbuffered)
07659514
JS
649udp,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
650])
651
652OVS_TRAFFIC_VSWITCHD_STOP
653AT_CLEANUP
654
e5cf8cce
DDP
655AT_SETUP([conntrack - IPv4 ping])
656CHECK_CONNTRACK()
657OVS_TRAFFIC_VSWITCHD_START()
658
659ADD_NAMESPACES(at_ns0, at_ns1)
660
661ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
662ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
663
664dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
665AT_DATA([flows.txt], [dnl
666priority=1,action=drop
667priority=10,arp,action=normal
668priority=100,in_port=1,icmp,action=ct(commit),2
669priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0)
670priority=100,in_port=2,icmp,ct_state=+trk+est,action=1
671])
672
673AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
674
675dnl Pings from ns0->ns1 should work fine.
676NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
6773 packets transmitted, 3 received, 0% packet loss, time 0ms
678])
679
680AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
681icmp,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)
682])
683
684AT_CHECK([ovs-appctl dpctl/flush-conntrack])
685
686dnl Pings from ns1->ns0 should fail.
687NS_CHECK_EXEC([at_ns1], [ping -q -c 3 -i 0.3 -w 2 10.1.1.1 | FORMAT_PING], [0], [dnl
6887 packets transmitted, 0 received, 100% packet loss, time 0ms
689])
690
691OVS_TRAFFIC_VSWITCHD_STOP
692AT_CLEANUP
693
694AT_SETUP([conntrack - IPv6 ping])
695CHECK_CONNTRACK()
696OVS_TRAFFIC_VSWITCHD_START()
697
698ADD_NAMESPACES(at_ns0, at_ns1)
699
700ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
701ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
702
703AT_DATA([flows.txt], [dnl
704
705dnl ICMPv6 echo request and reply go to table 1. The rest of the traffic goes
706dnl through normal action.
707table=0,priority=10,icmp6,icmp_type=128,action=goto_table:1
708table=0,priority=10,icmp6,icmp_type=129,action=goto_table:1
709table=0,priority=1,action=normal
710
711dnl Allow everything from ns0->ns1. Only allow return traffic from ns1->ns0.
712table=1,priority=100,in_port=1,icmp6,action=ct(commit),2
713table=1,priority=100,in_port=2,icmp6,ct_state=-trk,action=ct(table=0)
714table=1,priority=100,in_port=2,icmp6,ct_state=+trk+est,action=1
715table=1,priority=1,action=drop
716])
717
718AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
719
720OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
721
027f7e84
DDP
722dnl The above ping creates state in the connection tracker. We're not
723dnl interested in that state.
724AT_CHECK([ovs-appctl dpctl/flush-conntrack])
725
e5cf8cce
DDP
726dnl Pings from ns1->ns0 should fail.
727NS_CHECK_EXEC([at_ns1], [ping6 -q -c 3 -i 0.3 -w 2 fc00::1 | FORMAT_PING], [0], [dnl
7287 packets transmitted, 0 received, 100% packet loss, time 0ms
729])
730
731dnl Pings from ns0->ns1 should work fine.
732NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
7333 packets transmitted, 3 received, 0% packet loss, time 0ms
734])
735
736AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl
737icmpv6,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)
738])
739
740OVS_TRAFFIC_VSWITCHD_STOP
741AT_CLEANUP
742
07659514
JS
743AT_SETUP([conntrack - preserve registers])
744CHECK_CONNTRACK()
cf7659b6 745OVS_TRAFFIC_VSWITCHD_START()
07659514
JS
746
747ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
748
749ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
750ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
751ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
752ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
753
754dnl Allow any traffic from ns0->ns1, ns2->ns3.
755AT_DATA([flows.txt], [dnl
756priority=1,action=drop
757priority=10,arp,action=normal
758priority=10,icmp,action=normal
759priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0)
760priority=100,in_port=1,tcp,ct_state=+trk,action=2
761priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0)
762priority=100,in_port=2,tcp,ct_state=+trk,action=1
763priority=100,in_port=3,tcp,ct_state=-trk,action=load:0->NXM_NX_REG0[[]],ct(table=0)
764priority=100,in_port=3,tcp,ct_state=+trk,reg0=0,action=load:1->NXM_NX_REG0[[]],ct(commit,table=0)
765priority=100,in_port=3,tcp,ct_state=+trk,reg0=1,action=4
766priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0)
767priority=100,in_port=4,tcp,ct_state=+trk,action=3
768])
769
6cfa8ec3 770AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
07659514 771
7ed40afe
JS
772OVS_START_L7([at_ns1], [http])
773OVS_START_L7([at_ns3], [http])
774
07659514 775dnl HTTP requests from p0->p1 should work fine.
07659514
JS
776NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
777
778dnl HTTP requests from p2->p3 should work fine.
07659514
JS
779NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log])
780
781OVS_TRAFFIC_VSWITCHD_STOP
782AT_CLEANUP
783
784AT_SETUP([conntrack - invalid])
785CHECK_CONNTRACK()
cf7659b6 786OVS_TRAFFIC_VSWITCHD_START()
07659514
JS
787
788ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
789
790ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
791ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
792ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
793ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
794
795dnl Pass traffic from ns0->ns1 without committing, but attempt to track in
796dnl the opposite direction. This should fail.
797dnl Pass traffic from ns3->ns4 without committing, and this time match
798dnl invalid traffic and allow it through.
799AT_DATA([flows.txt], [dnl
800priority=1,action=drop
801priority=10,arp,action=normal
802priority=10,icmp,action=normal
803priority=100,in_port=1,tcp,action=ct(),2
804priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
805priority=100,in_port=2,ct_state=+trk+new,tcp,action=1
806priority=100,in_port=3,tcp,action=ct(),4
807priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
808priority=100,in_port=4,ct_state=+trk+inv,tcp,action=3
809priority=100,in_port=4,ct_state=+trk+new,tcp,action=3
810])
811
6cfa8ec3 812AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
07659514
JS
813
814dnl We set up our rules to allow the request without committing. The return
815dnl traffic can't be identified, because the initial request wasn't committed.
816dnl For the first pair of ports, this means that the connection fails.
7ed40afe
JS
817OVS_START_L7([at_ns1], [http])
818OVS_START_L7([at_ns3], [http])
07659514
JS
819NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log], [4])
820
821dnl For the second pair, we allow packets from invalid connections, so it works.
07659514
JS
822NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log])
823
824OVS_TRAFFIC_VSWITCHD_STOP
825AT_CLEANUP
826
827AT_SETUP([conntrack - zones])
828CHECK_CONNTRACK()
cf7659b6 829OVS_TRAFFIC_VSWITCHD_START()
07659514
JS
830
831ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
832
833ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
834ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
835ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
836ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
837
838dnl Allow any traffic from ns0->ns1. Allow return traffic, matching on zone.
839dnl For ns2->ns3, use a different zone and see that the match fails.
840AT_DATA([flows.txt], [dnl
841priority=1,action=drop
842priority=10,arp,action=normal
843priority=10,icmp,action=normal
844priority=100,in_port=1,tcp,action=ct(commit,zone=1),2
845priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1)
846priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1
847priority=100,in_port=3,tcp,action=ct(commit,zone=2),4
848priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0,zone=2)
849priority=100,in_port=4,ct_state=+trk,ct_zone=1,tcp,action=3
850])
851
6cfa8ec3 852AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
07659514 853
7ed40afe
JS
854OVS_START_L7([at_ns1], [http])
855OVS_START_L7([at_ns3], [http])
856
07659514 857dnl HTTP requests from p0->p1 should work fine.
07659514
JS
858NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
859
ec3aa16c 860AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
420c73b2 861tcp,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
862])
863
864dnl HTTP requests from p2->p3 should fail due to network failure.
865dnl Try 3 times, in 1 second intervals.
07659514
JS
866NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
867
ec3aa16c 868AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
420c73b2 869tcp,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
870])
871
872OVS_TRAFFIC_VSWITCHD_STOP
873AT_CLEANUP
874
875AT_SETUP([conntrack - zones from field])
876CHECK_CONNTRACK()
cf7659b6 877OVS_TRAFFIC_VSWITCHD_START()
07659514
JS
878
879ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
880
881ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
882ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
883ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
884ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
885
886dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
887AT_DATA([flows.txt], [dnl
888priority=1,action=drop
889priority=10,arp,action=normal
890priority=10,icmp,action=normal
891priority=100,in_port=1,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),2
892priority=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]])
893priority=100,in_port=2,ct_state=+trk,ct_zone=0x1001,tcp,action=1
894priority=100,in_port=3,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),4
895priority=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]])
896priority=100,in_port=4,ct_state=+trk,ct_zone=0x1001,tcp,action=3
897])
898
6cfa8ec3 899AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
07659514 900
7ed40afe
JS
901OVS_START_L7([at_ns1], [http])
902OVS_START_L7([at_ns3], [http])
903
07659514 904dnl HTTP requests from p0->p1 should work fine.
07659514
JS
905NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
906
ec3aa16c 907AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
420c73b2 908tcp,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
909])
910
911dnl HTTP requests from p2->p3 should fail due to network failure.
912dnl Try 3 times, in 1 second intervals.
07659514
JS
913NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
914
ec3aa16c 915AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
420c73b2 916tcp,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
917])
918
919OVS_TRAFFIC_VSWITCHD_STOP
920AT_CLEANUP
921
922AT_SETUP([conntrack - multiple bridges])
923CHECK_CONNTRACK()
924OVS_TRAFFIC_VSWITCHD_START(
cf7659b6 925 [_ADD_BR([br1]) --\
07659514
JS
926 add-port br0 patch+ -- set int patch+ type=patch options:peer=patch- --\
927 add-port br1 patch- -- set int patch- type=patch options:peer=patch+ --])
928
929ADD_NAMESPACES(at_ns0, at_ns1)
930
931ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
932ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24")
933
934dnl Allow any traffic from ns0->br1, allow established in reverse.
935AT_DATA([flows-br0.txt], [dnl
936priority=1,action=drop
937priority=10,arp,action=normal
938priority=10,icmp,action=normal
939priority=100,in_port=2,tcp,ct_state=-trk,action=ct(commit,zone=1),1
940priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=1)
941priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=1,action=2
942])
943
944dnl Allow any traffic from br0->ns1, allow established in reverse.
945AT_DATA([flows-br1.txt], [dnl
946priority=1,action=drop
947priority=10,arp,action=normal
948priority=10,icmp,action=normal
949priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=2)
950priority=100,in_port=1,tcp,ct_state=+trk+new,ct_zone=2,action=ct(commit,zone=2),2
951priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=2,action=2
952priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0,zone=2)
953priority=100,in_port=2,tcp,ct_state=+trk+est,ct_zone=2,action=ct(commit,zone=2),1
954])
955
6cfa8ec3
JR
956AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt])
957AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-br1.txt])
07659514
JS
958
959dnl HTTP requests from p0->p1 should work fine.
7ed40afe 960OVS_START_L7([at_ns1], [http])
07659514
JS
961NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
962
963OVS_TRAFFIC_VSWITCHD_STOP
964AT_CLEANUP
965
966AT_SETUP([conntrack - multiple zones])
967CHECK_CONNTRACK()
cf7659b6 968OVS_TRAFFIC_VSWITCHD_START()
07659514
JS
969
970ADD_NAMESPACES(at_ns0, at_ns1)
971
972ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
973ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
974
975dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
976AT_DATA([flows.txt], [dnl
977priority=1,action=drop
978priority=10,arp,action=normal
979priority=10,icmp,action=normal
980priority=100,in_port=1,tcp,action=ct(commit,zone=1),ct(commit,zone=2),2
981priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=2)
982priority=100,in_port=2,ct_state=+trk,ct_zone=2,tcp,action=1
983])
984
6cfa8ec3 985AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
07659514 986
7ed40afe
JS
987OVS_START_L7([at_ns1], [http])
988
07659514 989dnl HTTP requests from p0->p1 should work fine.
07659514
JS
990NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
991
992dnl (again) HTTP requests from p0->p1 should work fine.
993NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
994
ec3aa16c 995AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
420c73b2
JR
996tcp,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>)
997tcp,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
998])
999
1000OVS_TRAFFIC_VSWITCHD_STOP
1001AT_CLEANUP
1002
0e27c629
JS
1003AT_SETUP([conntrack - multiple namespaces, internal ports])
1004CHECK_CONNTRACK()
4573c42e 1005CHECK_CONNTRACK_LOCAL_STACK()
0e27c629
JS
1006OVS_TRAFFIC_VSWITCHD_START(
1007 [set-fail-mode br0 secure -- ])
1008
1009ADD_NAMESPACES(at_ns0, at_ns1)
1010
1011ADD_INT(p0, at_ns0, br0, "10.1.1.1/24")
1012ADD_INT(p1, at_ns1, br0, "10.1.1.2/24")
1013
1014dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1015dnl
1016dnl If skb->nfct is leaking from inside the namespace, this test will fail.
1017AT_DATA([flows.txt], [dnl
1018priority=1,action=drop
1019priority=10,arp,action=normal
1020priority=10,icmp,action=normal
1021priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,zone=1),2
1022priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1)
1023priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1
1024])
1025
1026AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1027
7ed40afe
JS
1028OVS_START_L7([at_ns1], [http])
1029
0e27c629 1030dnl HTTP requests from p0->p1 should work fine.
0e27c629
JS
1031NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1032
1033dnl (again) HTTP requests from p0->p1 should work fine.
1034NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1035
ec3aa16c 1036AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
420c73b2 1037tcp,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
1038])
1039
1040OVS_TRAFFIC_VSWITCHD_STOP(["dnl
1041/ioctl(SIOCGIFINDEX) on .* device failed: No such device/d
1042/removing policing failed: No such device/d"])
1043AT_CLEANUP
1044
8e53fe8c
JS
1045AT_SETUP([conntrack - ct_mark])
1046CHECK_CONNTRACK()
cf7659b6 1047OVS_TRAFFIC_VSWITCHD_START()
8e53fe8c
JS
1048
1049ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1050
1051ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1052ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1053ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
1054ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
1055
1056dnl Allow traffic between ns0<->ns1 using the ct_mark.
1057dnl Check that different marks do not match for traffic between ns2<->ns3.
1058AT_DATA([flows.txt], [dnl
1059priority=1,action=drop
1060priority=10,arp,action=normal
1061priority=10,icmp,action=normal
1062priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:1->ct_mark)),2
1063priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
1064priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1
1065priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:2->ct_mark)),4
1066priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
1067priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3
1068])
1069
6cfa8ec3 1070AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
8e53fe8c 1071
7ed40afe
JS
1072OVS_START_L7([at_ns1], [http])
1073OVS_START_L7([at_ns3], [http])
1074
8e53fe8c 1075dnl HTTP requests from p0->p1 should work fine.
8e53fe8c 1076NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
420c73b2
JR
1077AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
1078tcp,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
1079])
1080
1081dnl HTTP requests from p2->p3 should fail due to network failure.
1082dnl Try 3 times, in 1 second intervals.
8e53fe8c 1083NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
ec3aa16c 1084AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
420c73b2 1085tcp,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
1086])
1087
1088OVS_TRAFFIC_VSWITCHD_STOP
1089AT_CLEANUP
1090
4d182934
JS
1091AT_SETUP([conntrack - ct_mark bit-fiddling])
1092CHECK_CONNTRACK()
1093OVS_TRAFFIC_VSWITCHD_START()
1094
1095ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1096
1097ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1098ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1099
1100dnl Allow traffic between ns0<->ns1 using the ct_mark. Return traffic should
1101dnl cause an additional bit to be set in the connection (and be allowed).
1102AT_DATA([flows.txt], [dnl
1103table=0,priority=1,action=drop
1104table=0,priority=10,arp,action=normal
1105table=0,priority=10,icmp,action=normal
1106table=0,priority=100,in_port=1,tcp,action=ct(table=1)
1107table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=1,commit,exec(set_field:0x2/0x6->ct_mark))
723af132
JS
1108table=1,in_port=1,ct_state=+new,tcp,action=ct(commit,exec(set_field:0x5/0x5->ct_mark)),2
1109table=1,in_port=1,ct_state=-new,tcp,action=2
1110table=1,in_port=2,ct_state=+trk,ct_mark=3,tcp,action=1
4d182934
JS
1111])
1112
1113AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1114
7ed40afe
JS
1115OVS_START_L7([at_ns1], [http])
1116
4d182934 1117dnl HTTP requests from p0->p1 should work fine.
4d182934
JS
1118NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1119
420c73b2
JR
1120AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
1121tcp,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
1122])
1123
1124OVS_TRAFFIC_VSWITCHD_STOP
1125AT_CLEANUP
1126
8e53fe8c
JS
1127AT_SETUP([conntrack - ct_mark from register])
1128CHECK_CONNTRACK()
cf7659b6 1129OVS_TRAFFIC_VSWITCHD_START()
8e53fe8c
JS
1130
1131ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1132
1133ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1134ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1135ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
1136ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
1137
1138dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1139AT_DATA([flows.txt], [dnl
1140priority=1,action=drop
1141priority=10,arp,action=normal
1142priority=10,icmp,action=normal
1143priority=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
1144priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
1145priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1
1146priority=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
1147priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
1148priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3
1149])
1150
6cfa8ec3 1151AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
8e53fe8c 1152
7ed40afe
JS
1153OVS_START_L7([at_ns1], [http])
1154OVS_START_L7([at_ns3], [http])
1155
8e53fe8c 1156dnl HTTP requests from p0->p1 should work fine.
8e53fe8c 1157NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
420c73b2
JR
1158AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
1159tcp,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
1160])
1161
1162dnl HTTP requests from p2->p3 should fail due to network failure.
1163dnl Try 3 times, in 1 second intervals.
8e53fe8c 1164NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
ec3aa16c 1165AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl
420c73b2 1166tcp,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
1167])
1168
1169OVS_TRAFFIC_VSWITCHD_STOP
1170AT_CLEANUP
1171
9daf2348
JS
1172AT_SETUP([conntrack - ct_label])
1173CHECK_CONNTRACK()
cf7659b6 1174OVS_TRAFFIC_VSWITCHD_START()
9daf2348
JS
1175
1176ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1177
1178ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1179ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1180ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
1181ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
1182
1183dnl Allow traffic between ns0<->ns1 using the ct_label.
1184dnl Check that different labels do not match for traffic between ns2<->ns3.
1185AT_DATA([flows.txt], [dnl
1186priority=1,action=drop
1187priority=10,arp,action=normal
1188priority=10,icmp,action=normal
1189priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:0x0a000d000005000001->ct_label)),2
1190priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
1191priority=100,in_port=2,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=1
1192priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:0x2->ct_label)),4
1193priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0)
1194priority=100,in_port=4,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=3
1195])
1196
6cfa8ec3 1197AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
9daf2348 1198
7ed40afe
JS
1199OVS_START_L7([at_ns1], [http])
1200OVS_START_L7([at_ns3], [http])
1201
9daf2348 1202dnl HTTP requests from p0->p1 should work fine.
9daf2348
JS
1203NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1204
1205dnl HTTP requests from p2->p3 should fail due to network failure.
1206dnl Try 3 times, in 1 second intervals.
9daf2348
JS
1207NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4])
1208
1209OVS_TRAFFIC_VSWITCHD_STOP
1210AT_CLEANUP
1211
4d182934
JS
1212AT_SETUP([conntrack - ct_label bit-fiddling])
1213CHECK_CONNTRACK()
1214OVS_TRAFFIC_VSWITCHD_START()
1215
1216ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1217
1218ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1219ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1220
1221dnl Allow traffic between ns0<->ns1 using the ct_labels. Return traffic should
1222dnl cause an additional bit to be set in the connection labels (and be allowed)
1223AT_DATA([flows.txt], [dnl
1224table=0,priority=1,action=drop
1225table=0,priority=10,arp,action=normal
1226table=0,priority=10,icmp,action=normal
1227table=0,priority=100,in_port=1,tcp,action=ct(table=1)
1228table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=1,commit,exec(set_field:0x200000000/0x200000004->ct_label))
723af132
JS
1229table=1,in_port=1,tcp,ct_state=+new,action=ct(commit,exec(set_field:0x5/0x5->ct_label)),2
1230table=1,in_port=1,tcp,ct_state=-new,action=2
1231table=1,in_port=2,ct_state=+trk,ct_label=0x200000001,tcp,action=1
4d182934
JS
1232])
1233
1234AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1235
7ed40afe
JS
1236OVS_START_L7([at_ns1], [http])
1237
4d182934 1238dnl HTTP requests from p0->p1 should work fine.
4d182934
JS
1239NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1240
420c73b2
JR
1241AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
1242tcp,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
1243])
1244
1245OVS_TRAFFIC_VSWITCHD_STOP
1246AT_CLEANUP
1247
f2d105b5
JS
1248AT_SETUP([conntrack - ct metadata, multiple zones])
1249CHECK_CONNTRACK()
1250OVS_TRAFFIC_VSWITCHD_START()
1251
1252ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1253
1254ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1255ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1256
1257dnl Allow traffic between ns0<->ns1 using the ct_mark and ct_labels in zone=1,
1258dnl but do *not* set any of these for the ct() in zone=2. Traffic should pass,
1259dnl and we should see that the conntrack entries only apply the ct_mark and
1260dnl ct_labels to the connection in zone=1.
1261AT_DATA([flows.txt], [dnl
1262table=0,priority=1,action=drop
1263table=0,priority=10,arp,action=normal
1264table=0,priority=10,icmp,action=normal
1265table=0,priority=100,in_port=1,tcp,action=ct(zone=1,table=1)
1266table=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
1267table=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
1268table=1,in_port=1,tcp,ct_state=-new,action=ct(zone=2),2
1269table=1,in_port=2,tcp,action=ct(zone=2),1
f2d105b5
JS
1270])
1271
1272AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1273
7ed40afe
JS
1274OVS_START_L7([at_ns1], [http])
1275
f2d105b5 1276dnl HTTP requests from p0->p1 should work fine.
f2d105b5
JS
1277NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1278
420c73b2
JR
1279AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
1280tcp,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>)
1281tcp,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
1282])
1283
1284OVS_TRAFFIC_VSWITCHD_STOP
1285AT_CLEANUP
1286
8e53fe8c 1287AT_SETUP([conntrack - ICMP related])
9c1ab985 1288AT_SKIP_IF([test $HAVE_NC = no])
8e53fe8c 1289CHECK_CONNTRACK()
cf7659b6 1290OVS_TRAFFIC_VSWITCHD_START()
8e53fe8c
JS
1291
1292ADD_NAMESPACES(at_ns0, at_ns1)
1293
1294ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1295ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1296
1297dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back.
1298AT_DATA([flows.txt], [dnl
1299priority=1,action=drop
1300priority=10,arp,action=normal
1301priority=100,in_port=1,udp,action=ct(commit,exec(set_field:1->ct_mark)),2
1302priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0)
1303priority=100,in_port=2,icmp,ct_state=+trk+rel,ct_mark=1,action=1
1304])
1305
6cfa8ec3 1306AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
8e53fe8c 1307
bde2e7b5 1308dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response.
b54971f7 1309NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"])
8e53fe8c
JS
1310
1311AT_CHECK([ovs-appctl revalidator/purge], [0])
1312AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl
1313 n_packets=1, n_bytes=44, priority=100,udp,in_port=1 actions=ct(commit,exec(load:0x1->NXM_NX_CT_MARK[[]])),output:2
1314 n_packets=1, n_bytes=72, priority=100,ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2 actions=output:1
1315 n_packets=1, n_bytes=72, priority=100,ct_state=-trk,icmp,in_port=2 actions=ct(table=0)
bde2e7b5 1316 n_packets=2, n_bytes=84, priority=10,arp actions=NORMAL
8e53fe8c
JS
1317NXST_FLOW reply:
1318])
1319
1320OVS_TRAFFIC_VSWITCHD_STOP
1321AT_CLEANUP
1322
07659514
JS
1323AT_SETUP([conntrack - ICMP related 2])
1324CHECK_CONNTRACK()
cf7659b6 1325OVS_TRAFFIC_VSWITCHD_START()
07659514
JS
1326
1327ADD_NAMESPACES(at_ns0, at_ns1)
1328
1329ADD_VETH(p0, at_ns0, br0, "172.16.0.1/24")
1330ADD_VETH(p1, at_ns1, br0, "172.16.0.2/24")
1331
1332dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1333AT_DATA([flows.txt], [dnl
5c2e106b
DDP
1334table=0,ip,action=ct(commit,table=1)
1335table=1,ip,action=controller
07659514
JS
1336])
1337
6cfa8ec3 1338AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt])
07659514
JS
1339
1340AT_CAPTURE_FILE([ofctl_monitor.log])
1341AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log])
1342
1343dnl 1. Send an ICMP port unreach reply for port 8738, without any previous request
5c2e106b 1344AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) 'f64c473528c9c6f54ecb72db080045c0003d2e8700004001f351ac100004ac1000030303da490000000045000021317040004011b138ac100003ac10000411112222000d20966369616f0a'])
07659514
JS
1345
1346dnl 2. Send and UDP packet to port 5555
5c2e106b 1347AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 resubmit\(,0\) 'c6f94ecb72dbe64c473528c9080045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a'])
07659514
JS
1348
1349dnl 3. Send an ICMP port unreach reply for port 5555, related to the first packet
5c2e106b 1350AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) 'e64c473528c9c6f94ecb72db080045c0003d2e8700004001f355ac100002ac1000010303553f0000000045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a'])
07659514
JS
1351
1352dnl Check this output. We only see the latter two packets, not the first.
1353AT_CHECK([cat ofctl_monitor.log], [0], [dnl
5c2e106b
DDP
1354NXT_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)
1355icmp,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
1356NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=47 ct_state=new|trk,in_port=1 (via action) data_len=47 (unbuffered)
07659514 1357udp,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
5c2e106b 1358NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=75 ct_state=rel|rpl|trk,in_port=2 (via action) data_len=75 (unbuffered)
07659514
JS
1359icmp,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
1360])
1361
5c2e106b
DDP
1362AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.1)], [0], [dnl
1363udp,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>)
1364])
1365
1366AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.3)], [0], [dnl
1367])
1368
07659514
JS
1369OVS_TRAFFIC_VSWITCHD_STOP
1370AT_CLEANUP
d787ad39 1371
1d768544 1372AT_SETUP([conntrack - IPv4 fragmentation ])
d787ad39 1373CHECK_CONNTRACK()
1d768544 1374CHECK_CONNTRACK_FRAG()
cf7659b6 1375OVS_TRAFFIC_VSWITCHD_START()
27130224
AZ
1376
1377ADD_NAMESPACES(at_ns0, at_ns1)
1378
1379ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1380ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1381
1382dnl Sending ping through conntrack
1383AT_DATA([flows.txt], [dnl
1384priority=1,action=drop
1385priority=10,arp,action=normal
1386priority=100,in_port=1,icmp,action=ct(commit,zone=9),2
1387priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9)
1388priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1
1389])
1390
6cfa8ec3 1391AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
27130224 1392
27130224
AZ
1393dnl Ipv4 fragmentation connectivity check.
1394NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
13953 packets transmitted, 3 received, 0% packet loss, time 0ms
1396])
1397
1398dnl Ipv4 larger fragmentation connectivity check.
1399NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
14003 packets transmitted, 3 received, 0% packet loss, time 0ms
1401])
1402
1403OVS_TRAFFIC_VSWITCHD_STOP
1404AT_CLEANUP
1405
0cf28088
JS
1406AT_SETUP([conntrack - IPv4 fragmentation expiry])
1407CHECK_CONNTRACK()
4573c42e 1408CHECK_CONNTRACK_FRAG()
0cf28088
JS
1409OVS_TRAFFIC_VSWITCHD_START()
1410
1411ADD_NAMESPACES(at_ns0, at_ns1)
1412
1413ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1414ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1415
1416AT_DATA([flows.txt], [dnl
1417priority=1,action=drop
1418priority=10,arp,action=normal
1419
1420dnl Only allow non-fragmented messages and 1st fragments of each message
1421priority=100,in_port=1,icmp,ip_frag=no,action=ct(commit,zone=9),2
1422priority=100,in_port=1,icmp,ip_frag=firstaction=ct(commit,zone=9),2
1423priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9)
1424priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1
1425])
1426
1427AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1428
0cf28088
JS
1429dnl Ipv4 fragmentation connectivity check.
1430NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 1 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
14317 packets transmitted, 0 received, 100% packet loss, time 0ms
1432])
1433
1434OVS_TRAFFIC_VSWITCHD_STOP
1435AT_CLEANUP
1436
27130224
AZ
1437AT_SETUP([conntrack - IPv4 fragmentation + vlan])
1438CHECK_CONNTRACK()
4573c42e 1439CHECK_CONNTRACK_FRAG()
cf7659b6 1440OVS_TRAFFIC_VSWITCHD_START()
27130224
AZ
1441
1442ADD_NAMESPACES(at_ns0, at_ns1)
1443
1444ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1445ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1446ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24")
1447ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24")
1448
1449dnl Sending ping through conntrack
1450AT_DATA([flows.txt], [dnl
1451priority=1,action=drop
1452priority=10,arp,action=normal
1453priority=100,in_port=1,icmp,action=ct(commit,zone=9),2
1454priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9)
1455priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1
1456])
1457
6cfa8ec3 1458AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
27130224 1459
27130224
AZ
1460dnl Ipv4 fragmentation connectivity check.
1461NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
14623 packets transmitted, 3 received, 0% packet loss, time 0ms
1463])
1464
1465dnl Ipv4 larger fragmentation connectivity check.
1466NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl
14673 packets transmitted, 3 received, 0% packet loss, time 0ms
1468])
1469
1470OVS_TRAFFIC_VSWITCHD_STOP
1471AT_CLEANUP
1472
1473AT_SETUP([conntrack - IPv6 fragmentation])
1474CHECK_CONNTRACK()
4573c42e 1475CHECK_CONNTRACK_FRAG()
cf7659b6 1476OVS_TRAFFIC_VSWITCHD_START()
27130224
AZ
1477
1478ADD_NAMESPACES(at_ns0, at_ns1)
1479
1480ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1481ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1482
1483dnl Sending ping through conntrack
1484AT_DATA([flows.txt], [dnl
1485priority=1,action=drop
1486priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2
1487priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9)
1488priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1
1489priority=100,icmp6,icmp_type=135,action=normal
1490priority=100,icmp6,icmp_type=136,action=normal
1491])
1492
6cfa8ec3 1493AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
27130224 1494
c10840ff
JS
1495dnl Linux seems to take a little time to get its IPv6 stack in order. Without
1496dnl waiting, we get occasional failures due to the following error:
27130224 1497dnl "connect: Cannot assign requested address"
c10840ff 1498OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
27130224 1499
221a2668 1500dnl Ipv6 fragmentation connectivity check.
27130224
AZ
1501NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
15023 packets transmitted, 3 received, 0% packet loss, time 0ms
1503])
1504
221a2668 1505dnl Ipv6 larger fragmentation connectivity check.
27130224
AZ
1506NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
15073 packets transmitted, 3 received, 0% packet loss, time 0ms
1508])
1509
1510OVS_TRAFFIC_VSWITCHD_STOP
1511AT_CLEANUP
1512
0cf28088
JS
1513AT_SETUP([conntrack - IPv6 fragmentation expiry])
1514CHECK_CONNTRACK()
4573c42e 1515CHECK_CONNTRACK_FRAG()
0cf28088
JS
1516OVS_TRAFFIC_VSWITCHD_START()
1517
1518ADD_NAMESPACES(at_ns0, at_ns1)
1519
1520ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1521ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1522
1523AT_DATA([flows.txt], [dnl
1524priority=1,action=drop
1525
1526dnl Only allow non-fragmented messages and 1st fragments of each message
1527priority=10,in_port=1,ipv6,ip_frag=first,action=ct(commit,zone=9),2
1528priority=10,in_port=1,ipv6,ip_frag=no,action=ct(commit,zone=9),2
1529priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9)
1530priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1
1531
1532dnl Neighbour Discovery
1533priority=100,icmp6,icmp_type=135,action=normal
1534priority=100,icmp6,icmp_type=136,action=normal
1535])
1536
1537AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1538
c10840ff
JS
1539dnl Linux seems to take a little time to get its IPv6 stack in order. Without
1540dnl waiting, we get occasional failures due to the following error:
0cf28088 1541dnl "connect: Cannot assign requested address"
c10840ff 1542OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
0cf28088 1543
0cf28088
JS
1544dnl Send an IPv6 fragment. Some time later, it should expire.
1545NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 1 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
15467 packets transmitted, 0 received, 100% packet loss, time 0ms
1547])
1548
1549dnl At this point, the kernel will either crash or everything is OK.
1550
1551OVS_TRAFFIC_VSWITCHD_STOP
1552AT_CLEANUP
1553
27130224
AZ
1554AT_SETUP([conntrack - IPv6 fragmentation + vlan])
1555CHECK_CONNTRACK()
4573c42e 1556CHECK_CONNTRACK_FRAG()
cf7659b6 1557OVS_TRAFFIC_VSWITCHD_START()
27130224
AZ
1558
1559ADD_NAMESPACES(at_ns0, at_ns1)
1560
1561ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1562ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1563
1564ADD_VLAN(p0, at_ns0, 100, "fc00:1::3/96")
1565ADD_VLAN(p1, at_ns1, 100, "fc00:1::4/96")
1566
1567dnl Sending ping through conntrack
1568AT_DATA([flows.txt], [dnl
1569priority=1,action=drop
1570priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2
1571priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9)
1572priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1
1573priority=100,icmp6,icmp_type=135,action=normal
1574priority=100,icmp6,icmp_type=136,action=normal
1575])
1576
6cfa8ec3 1577AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
27130224 1578
c10840ff
JS
1579dnl Linux seems to take a little time to get its IPv6 stack in order. Without
1580dnl waiting, we get occasional failures due to the following error:
27130224 1581dnl "connect: Cannot assign requested address"
c10840ff 1582OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
27130224 1583
27130224
AZ
1584dnl Ipv4 fragmentation connectivity check.
1585NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl
15863 packets transmitted, 3 received, 0% packet loss, time 0ms
1587])
1588
1589dnl Ipv4 larger fragmentation connectivity check.
1590NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl
15913 packets transmitted, 3 received, 0% packet loss, time 0ms
1592])
1593
1594OVS_TRAFFIC_VSWITCHD_STOP
1595AT_CLEANUP
1596
1597AT_SETUP([conntrack - Fragmentation over vxlan])
dfb21e96 1598OVS_CHECK_VXLAN()
27130224 1599CHECK_CONNTRACK()
4573c42e 1600CHECK_CONNTRACK_FRAG()
27130224 1601
cf7659b6
JR
1602OVS_TRAFFIC_VSWITCHD_START()
1603ADD_BR([br-underlay])
1604AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"])
1605
27130224
AZ
1606ADD_NAMESPACES(at_ns0)
1607
1608dnl Sending ping through conntrack
1609AT_DATA([flows.txt], [dnl
1610priority=1,action=drop
1611priority=10,arp,action=normal
1612priority=100,in_port=1,icmp,action=ct(commit,zone=9),LOCAL
3a9eb803 1613priority=100,in_port=LOCAL,icmp,action=ct(table=1,zone=9)
723af132 1614table=1,in_port=LOCAL,ct_state=+trk+est,icmp,action=1
27130224
AZ
1615])
1616
6cfa8ec3 1617AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
27130224
AZ
1618
1619dnl Set up underlay link from host into the namespace using veth pair.
1620ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
1621AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
1622AT_CHECK([ip link set dev br-underlay up])
1623
1624dnl Set up tunnel endpoints on OVS outside the namespace and with a native
1625dnl linux device inside the namespace.
6e3a764c 1626ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24])
27130224
AZ
1627ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24],
1628 [id 0 dstport 4789])
1629
1630dnl First, check the underlay
1631NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl
16323 packets transmitted, 3 received, 0% packet loss, time 0ms
1633])
1634
1635dnl Okay, now check the overlay with different packet sizes
1636NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
16373 packets transmitted, 3 received, 0% packet loss, time 0ms
1638])
1639NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
16403 packets transmitted, 3 received, 0% packet loss, time 0ms
1641])
1642NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl
16433 packets transmitted, 3 received, 0% packet loss, time 0ms
1644])
1645
1646OVS_TRAFFIC_VSWITCHD_STOP
1647AT_CLEANUP
c4e34c61 1648
84f646df 1649AT_SETUP([conntrack - IPv6 Fragmentation over vxlan])
a9f70f3d 1650OVS_CHECK_VXLAN()
84f646df 1651CHECK_CONNTRACK()
4573c42e 1652CHECK_CONNTRACK_FRAG()
84f646df
JS
1653
1654OVS_TRAFFIC_VSWITCHD_START()
1655ADD_BR([br-underlay])
1656AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"])
1657
1658ADD_NAMESPACES(at_ns0)
1659
1660dnl Sending ping through conntrack
1661AT_DATA([flows.txt], [dnl
1662priority=1,action=drop
1663priority=100,in_port=1,ipv6,action=ct(commit,zone=9),LOCAL
1664priority=100,in_port=LOCAL,ipv6,action=ct(table=1,zone=9)
723af132 1665table=1,in_port=LOCAL,ct_state=+trk+est,ipv6,action=1
84f646df
JS
1666
1667dnl Neighbour Discovery
1668priority=1000,icmp6,icmp_type=135,action=normal
1669priority=1000,icmp6,icmp_type=136,action=normal
1670])
1671
1672AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1673
1674dnl Set up underlay link from host into the namespace using veth pair.
1675ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24")
1676AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"])
1677AT_CHECK([ip link set dev br-underlay up])
1678
1679dnl Set up tunnel endpoints on OVS outside the namespace and with a native
1680dnl linux device inside the namespace.
6e3a764c 1681ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], ["fc00::2/96"])
84f646df
JS
1682ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], ["fc00::1/96"],
1683 [id 0 dstport 4789])
1684
c10840ff
JS
1685dnl Linux seems to take a little time to get its IPv6 stack in order. Without
1686dnl waiting, we get occasional failures due to the following error:
84f646df 1687dnl "connect: Cannot assign requested address"
c10840ff 1688OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
84f646df
JS
1689
1690dnl First, check the underlay
1691NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl
16923 packets transmitted, 3 received, 0% packet loss, time 0ms
1693])
1694
1695dnl Okay, now check the overlay with different packet sizes
1696NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
16973 packets transmitted, 3 received, 0% packet loss, time 0ms
1698])
1699NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
17003 packets transmitted, 3 received, 0% packet loss, time 0ms
1701])
1702NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl
17033 packets transmitted, 3 received, 0% packet loss, time 0ms
1704])
1705
1706OVS_TRAFFIC_VSWITCHD_STOP
1707AT_CLEANUP
9ac0aada 1708
c4e34c61
RB
1709AT_SETUP([conntrack - resubmit to ct multiple times])
1710CHECK_CONNTRACK()
1711
1712OVS_TRAFFIC_VSWITCHD_START(
1713 [set-fail-mode br0 secure -- ])
1714
1715ADD_NAMESPACES(at_ns0, at_ns1)
1716
1717ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1718ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1719
1720AT_DATA([flows.txt], [dnl
1721table=0,priority=150,arp,action=normal
1722table=0,priority=100,ip,in_port=1,action=resubmit(,1),resubmit(,2)
1723
723af132
JS
1724table=1,ip,action=ct(table=3)
1725table=2,ip,action=ct(table=3)
c4e34c61
RB
1726
1727table=3,ip,action=drop
1728])
1729
1730AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1731
1732NS_CHECK_EXEC([at_ns0], [ping -q -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl
17331 packets transmitted, 0 received, 100% packet loss, time 0ms
1734])
1735
1736AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1737 n_packets=1, n_bytes=98, priority=100,ip,in_port=1 actions=resubmit(,1),resubmit(,2)
1738 n_packets=2, n_bytes=84, priority=150,arp actions=NORMAL
723af132
JS
1739 table=1, n_packets=1, n_bytes=98, ip actions=ct(table=3)
1740 table=2, n_packets=1, n_bytes=98, ip actions=ct(table=3)
c4e34c61
RB
1741 table=3, n_packets=2, n_bytes=196, ip actions=drop
1742NXST_FLOW reply:
1743])
1744
1745OVS_TRAFFIC_VSWITCHD_STOP
1746AT_CLEANUP
9ac0aada 1747
1d768544
JS
1748AT_BANNER([conntrack - L7])
1749
1750AT_SETUP([conntrack - IPv4 HTTP])
1751CHECK_CONNTRACK()
1752OVS_TRAFFIC_VSWITCHD_START()
1753
1754ADD_NAMESPACES(at_ns0, at_ns1)
1755
1756ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1757ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1758
1759dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1760AT_DATA([flows.txt], [dnl
1761priority=1,action=drop
1762priority=10,arp,action=normal
1763priority=10,icmp,action=normal
1764priority=100,in_port=1,tcp,action=ct(commit),2
1765priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0)
1766priority=100,in_port=2,ct_state=+trk+est,tcp,action=1
1767])
1768
1769AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1770
1771OVS_START_L7([at_ns0], [http])
1772OVS_START_L7([at_ns1], [http])
1773
1774dnl HTTP requests from ns0->ns1 should work fine.
1775NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1776AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
1777tcp,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>)
1778])
1779
1780dnl HTTP requests from ns1->ns0 should fail due to network failure.
1781dnl Try 3 times, in 1 second intervals.
1782NS_CHECK_EXEC([at_ns1], [wget 10.1.1.1 -t 3 -T 1 --retry-connrefused -v -o wget1.log], [4])
1783
1784OVS_TRAFFIC_VSWITCHD_STOP
1785AT_CLEANUP
1786
1787AT_SETUP([conntrack - IPv6 HTTP])
1788CHECK_CONNTRACK()
1789OVS_TRAFFIC_VSWITCHD_START()
1790
1791ADD_NAMESPACES(at_ns0, at_ns1)
1792
1793ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
1794ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
1795
1796dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
1797AT_DATA([flows.txt], [dnl
1798priority=1,action=drop
1799priority=10,icmp6,action=normal
1800priority=100,in_port=1,tcp6,action=ct(commit),2
1801priority=100,in_port=2,ct_state=-trk,tcp6,action=ct(table=0)
1802priority=100,in_port=2,ct_state=+trk+est,tcp6,action=1
1803])
1804
1805AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1806
1807dnl Linux seems to take a little time to get its IPv6 stack in order. Without
1808dnl waiting, we get occasional failures due to the following error:
1809dnl "connect: Cannot assign requested address"
1810OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
1811
1812OVS_START_L7([at_ns0], [http6])
1813OVS_START_L7([at_ns1], [http6])
1814
1815dnl HTTP requests from ns0->ns1 should work fine.
1816NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1817AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl
1818tcp,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>)
1819])
1820
1821dnl HTTP requests from ns1->ns0 should fail due to network failure.
1822dnl Try 3 times, in 1 second intervals.
1823NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 --retry-connrefused -v -o wget1.log], [4])
1824
1825OVS_TRAFFIC_VSWITCHD_STOP
1826AT_CLEANUP
1827
1828AT_SETUP([conntrack - commit, recirc])
1829CHECK_CONNTRACK()
1830OVS_TRAFFIC_VSWITCHD_START()
1831
1832ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3)
1833
1834ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1835ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1836ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24")
1837ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24")
1838
1839dnl Allow any traffic from ns0->ns1, ns2->ns3.
1840AT_DATA([flows.txt], [dnl
1841priority=1,action=drop
1842priority=10,arp,action=normal
1843priority=10,icmp,action=normal
1844priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0)
1845priority=100,in_port=1,tcp,ct_state=+trk,action=2
1846priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0)
1847priority=100,in_port=2,tcp,ct_state=+trk,action=1
1848priority=100,in_port=3,tcp,ct_state=-trk,action=set_field:0->metadata,ct(table=0)
1849priority=100,in_port=3,tcp,ct_state=+trk,metadata=0,action=set_field:1->metadata,ct(commit,table=0)
1850priority=100,in_port=3,tcp,ct_state=+trk,metadata=1,action=4
1851priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0)
1852priority=100,in_port=4,tcp,ct_state=+trk,action=3
1853])
1854
1855AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1856
1857OVS_START_L7([at_ns1], [http])
1858OVS_START_L7([at_ns3], [http])
1859
1860dnl HTTP requests from p0->p1 should work fine.
1861NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1862
1863dnl HTTP requests from p2->p3 should work fine.
1864NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log])
1865
1866OVS_TRAFFIC_VSWITCHD_STOP
1867AT_CLEANUP
1868
1869AT_SETUP([conntrack - multiple zones, local])
1870CHECK_CONNTRACK()
1871CHECK_CONNTRACK_LOCAL_STACK()
1872OVS_TRAFFIC_VSWITCHD_START()
1873
1874ADD_NAMESPACES(at_ns0)
1875
1876AT_CHECK([ip addr add dev br0 "10.1.1.1/24"])
1877AT_CHECK([ip link set dev br0 up])
1878on_exit 'ip addr del dev br0 "10.1.1.1/24"'
1879ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24")
1880
1881dnl Allow traffic from local stack to ns0. Only allow neighbour discovery,
1882dnl return traffic from ns0 back to the local stack.
1883AT_DATA([flows.txt], [dnl
1884priority=1,action=drop
1885priority=10,arp,action=normal
1886priority=100,in_port=LOCAL,ip,ct_state=-trk,action=drop
1887priority=100,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=1),ct(commit,zone=2),1
1888priority=100,in_port=LOCAL,ip,ct_state=+trk+est,action=ct(commit,zone=1),ct(commit,zone=2),1
1889priority=100,in_port=1,ip,ct_state=-trk,action=ct(table=1,zone=1)
1890table=1,in_port=1,ip,ct_state=+trk+est,ct_zone=1,action=ct(table=2,zone=2)
1891table=2,in_port=1,ip,ct_state=+trk+est,ct_zone=2,action=LOCAL
1892])
1893
1894AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1895
1896AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
18973 packets transmitted, 3 received, 0% packet loss, time 0ms
1898])
1899
1900OVS_START_L7([at_ns0], [http])
1901
1902dnl HTTP requests from root namespace to p0 should work fine.
1903AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1904
1905dnl (again) HTTP requests from root namespace to p0 should work fine.
1906AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1907
1908AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl
1909icmp,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
1910icmp,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
1911tcp,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>)
1912tcp,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>)
1913])
1914
1915OVS_TRAFFIC_VSWITCHD_STOP
1916AT_CLEANUP
1917
1918AT_SETUP([conntrack - multi-stage pipeline, local])
1919CHECK_CONNTRACK()
1920CHECK_CONNTRACK_LOCAL_STACK()
1921OVS_TRAFFIC_VSWITCHD_START()
1922
1923ADD_NAMESPACES(at_ns0)
1924
1925AT_CHECK([ip addr add dev br0 "10.1.1.1/24"])
1926AT_CHECK([ip link set dev br0 up])
1927on_exit 'ip addr del dev br0 "10.1.1.1/24"'
1928ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24")
1929
1930dnl Allow traffic from local stack to ns0. Only allow neighbour discovery,
1931dnl return traffic from ns0 back to the local stack.
1932AT_DATA([flows.txt], [dnl
1933dnl default
1934table=0,priority=1,action=drop
1935table=0,priority=10,arp,action=normal
1936
1937dnl Load the output port to REG0
1938table=0,priority=100,ip,in_port=LOCAL,action=load:1->NXM_NX_REG0[[0..15]],goto_table:1
1939table=0,priority=100,ip,in_port=1,action=load:65534->NXM_NX_REG0[[0..15]],goto_table:1
1940
1941dnl Ingress pipeline
1942dnl - Allow all connections from LOCAL port (commit and proceed to egress)
1943dnl - All other connections go through conntracker using the input port as
1944dnl a connection tracking zone.
1945table=1,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=OXM_OF_IN_PORT[[0..15]]),goto_table:2
1946table=1,priority=100,ip,action=ct(table=2,zone=OXM_OF_IN_PORT[[0..15]])
1947table=1,priority=1,action=drop
1948
1949dnl Egress pipeline
1950dnl - Allow all connections from LOCAL port (commit and skip to output)
1951dnl - Allow other established connections to go through conntracker using
1952dnl output port as a connection tracking zone.
1953table=2,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=NXM_NX_REG0[[0..15]]),goto_table:4
1954table=2,priority=100,ip,ct_state=+trk+est,action=ct(table=3,zone=NXM_NX_REG0[[0..15]])
1955table=2,priority=1,action=drop
1956
1957dnl Only allow established traffic from egress ct lookup
1958table=3,priority=100,ip,ct_state=+trk+est,action=goto_table:4
1959table=3,priority=1,action=drop
1960
1961dnl output table
1962table=4,priority=100,ip,action=output:NXM_NX_REG0[[]]
1963])
1964
1965AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
1966
1967AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
19683 packets transmitted, 3 received, 0% packet loss, time 0ms
1969])
1970
1971OVS_START_L7([at_ns0], [http])
1972
1973dnl HTTP requests from root namespace to p0 should work fine.
1974AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1975
1976dnl (again) HTTP requests from root namespace to p0 should work fine.
1977AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
1978
1979AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl
1980icmp,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
1981icmp,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
1982tcp,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>)
1983tcp,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>)
1984])
1985
1986OVS_TRAFFIC_VSWITCHD_STOP
1987AT_CLEANUP
1988
1989AT_SETUP([conntrack - FTP])
40c7b2fc 1990AT_SKIP_IF([test $HAVE_FTP = no])
1d768544
JS
1991CHECK_CONNTRACK()
1992CHECK_CONNTRACK_ALG()
1993OVS_TRAFFIC_VSWITCHD_START()
1994
1995ADD_NAMESPACES(at_ns0, at_ns1)
1996
1997ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
1998ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
1999
2000dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2001AT_DATA([flows1.txt], [dnl
2002table=0,priority=1,action=drop
2003table=0,priority=10,arp,action=normal
2004table=0,priority=10,icmp,action=normal
2005table=0,priority=100,in_port=1,tcp,action=ct(alg=ftp,commit),2
2006table=0,priority=100,in_port=2,tcp,action=ct(table=1)
2007table=1,in_port=2,tcp,ct_state=+trk+est,action=1
2008table=1,in_port=2,tcp,ct_state=+trk+rel,action=1
2009])
2010
2011dnl Similar policy but without allowing all traffic from ns0->ns1.
2012AT_DATA([flows2.txt], [dnl
2013table=0,priority=1,action=drop
2014table=0,priority=10,arp,action=normal
2015table=0,priority=10,icmp,action=normal
2016
2017dnl Allow outgoing TCP connections, and treat them as FTP
2018table=0,priority=100,in_port=1,tcp,action=ct(table=1)
2019table=1,in_port=1,tcp,ct_state=+trk+new,action=ct(commit,alg=ftp),2
2020table=1,in_port=1,tcp,ct_state=+trk+est,action=2
2021
2022dnl Allow incoming FTP data connections and responses to existing connections
2023table=0,priority=100,in_port=2,tcp,action=ct(table=1)
2024table=1,in_port=2,tcp,ct_state=+trk+new+rel,action=ct(commit),1
2025table=1,in_port=2,tcp,ct_state=+trk+est,action=1
2026table=1,in_port=2,tcp,ct_state=+trk-new+rel,action=1
2027])
2028
2029AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt])
2030
2031OVS_START_L7([at_ns0], [ftp])
2032OVS_START_L7([at_ns1], [ftp])
2033
2034dnl FTP requests from p1->p0 should fail due to network failure.
2035dnl Try 3 times, in 1 second intervals.
2036NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4])
2037AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
2038])
2039
2040dnl FTP requests from p0->p1 should work fine.
2041NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2042AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2043tcp,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
2044])
2045
2046dnl Try the second set of flows.
2047AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt])
2048AT_CHECK([ovs-appctl dpctl/flush-conntrack])
2049
2050dnl FTP requests from p1->p0 should fail due to network failure.
2051dnl Try 3 times, in 1 second intervals.
2052NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4])
2053AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
2054])
2055
2056dnl Active FTP requests from p0->p1 should work fine.
2057NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0-1.log])
2058AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2059tcp,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
2060tcp,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>)
2061])
2062
2063AT_CHECK([ovs-appctl dpctl/flush-conntrack])
2064
2065dnl Passive FTP requests from p0->p1 should work fine.
2066NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0-2.log])
2067AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2068tcp,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
2069])
2070
2071OVS_TRAFFIC_VSWITCHD_STOP
2072AT_CLEANUP
2073
2074AT_SETUP([conntrack - FTP over IPv6])
40c7b2fc 2075AT_SKIP_IF([test $HAVE_FTP = no])
1d768544
JS
2076CHECK_CONNTRACK()
2077CHECK_CONNTRACK_ALG()
2078OVS_TRAFFIC_VSWITCHD_START()
2079
2080ADD_NAMESPACES(at_ns0, at_ns1)
2081
2082ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
2083ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
2084
2085dnl Allow any traffic from ns0->ns1.
2086dnl Only allow nd, return traffic from ns1->ns0.
2087AT_DATA([flows.txt], [dnl
2088dnl Track all IPv6 traffic and drop the rest.
2089dnl Allow ICMPv6 both ways. No commit, so pings will not be tracked.
2090table=0 priority=100 in_port=1 icmp6, action=2
2091table=0 priority=100 in_port=2 icmp6, action=1
2092table=0 priority=10 ip6, action=ct(table=1)
2093table=0 priority=0 action=drop
2094dnl
2095dnl Table 1
2096dnl
2097dnl Allow new TCPv6 FTP control connections from port 1.
2098table=1 in_port=1 ct_state=+new, tcp6, tp_dst=21, action=ct(alg=ftp,commit),2
2099dnl Allow related TCPv6 connections from port 2.
2100table=1 in_port=2 ct_state=+new+rel, tcp6, action=ct(commit),1
2101dnl Allow established TCPv6 connections both ways.
2102table=1 in_port=1 ct_state=+est, tcp6, action=2
2103table=1 in_port=2 ct_state=+est, tcp6, action=1
2104dnl Drop everything else.
2105table=1 priority=0, action=drop
2106])
2107
2108AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2109
2110dnl Linux seems to take a little time to get its IPv6 stack in order. Without
2111dnl waiting, we get occasional failures due to the following error:
2112dnl "connect: Cannot assign requested address"
2113OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null])
2114
2115OVS_START_L7([at_ns1], [ftp])
2116
2117dnl FTP requests from p0->p1 should work fine.
2118NS_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])
2119
2120dnl Discards CLOSE_WAIT and CLOSING
2121AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl
2122tcp,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
2123tcp,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>)
2124])
2125
2126OVS_TRAFFIC_VSWITCHD_STOP
2127AT_CLEANUP
2128
2129AT_SETUP([conntrack - FTP with multiple expectations])
40c7b2fc 2130AT_SKIP_IF([test $HAVE_FTP = no])
1d768544
JS
2131CHECK_CONNTRACK()
2132CHECK_CONNTRACK_ALG()
2133OVS_TRAFFIC_VSWITCHD_START()
2134
2135ADD_NAMESPACES(at_ns0, at_ns1)
2136
2137ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2138ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2139
2140dnl Dual-firewall, allow all from ns1->ns2, allow established and ftp ns2->ns1.
2141AT_DATA([flows.txt], [dnl
2142table=0,priority=1,action=drop
2143table=0,priority=10,arp,action=normal
2144table=0,priority=10,icmp,action=normal
2145
2146dnl Traffic from ns1
2147table=0,priority=100,in_port=1,tcp,action=ct(table=1,zone=1)
2148table=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
2149table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+new+rel,action=ct(commit,zone=1),ct(commit,zone=2),2
2150table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+est,action=ct(table=2,zone=2)
2151table=2,in_port=1,tcp,ct_zone=2,ct_state=+trk+est,action=2
2152
2153dnl Traffic from ns2
2154table=0,priority=100,in_port=2,tcp,action=ct(table=1,zone=2)
2155table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1
2156table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+est,action=ct(table=2,zone=1)
2157table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1
2158table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+est,action=1
2159])
2160
2161AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2162
2163OVS_START_L7([at_ns0], [ftp])
2164OVS_START_L7([at_ns1], [ftp])
2165
2166dnl FTP requests from p1->p0 should fail due to network failure.
2167dnl Try 3 times, in 1 second intervals.
2168NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4])
2169AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
2170])
2171
2172dnl Active FTP requests from p0->p1 should work fine.
2173NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2174AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2175tcp,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
2176tcp,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
2177tcp,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>)
2178tcp,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>)
2179])
2180
2181AT_CHECK([ovs-appctl dpctl/flush-conntrack])
2182
2183dnl Passive FTP requests from p0->p1 should work fine.
2184NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2185AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2186tcp,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>)
2187tcp,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
2188tcp,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>)
2189tcp,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
2190])
2191
2192OVS_TRAFFIC_VSWITCHD_STOP
2193AT_CLEANUP
2194
40c7b2fc
JS
2195AT_SETUP([conntrack - TFTP])
2196AT_SKIP_IF([test $HAVE_TFTP = no])
2197CHECK_CONNTRACK()
2198CHECK_CONNTRACK_ALG()
2199OVS_TRAFFIC_VSWITCHD_START()
2200
2201ADD_NAMESPACES(at_ns0, at_ns1)
2202
2203ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2204ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2205
2206dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2207AT_DATA([flows1.txt], [dnl
2208table=0,priority=1,action=drop
2209table=0,priority=10,arp,action=normal
2210table=0,priority=10,icmp,action=normal
2211table=0,priority=100,in_port=1,udp,action=ct(alg=tftp,commit),2
2212table=0,priority=100,in_port=2,udp,action=ct(table=1)
2213table=1,in_port=2,udp,ct_state=+trk+est,action=1
2214table=1,in_port=2,udp,ct_state=+trk+rel,action=1
2215])
2216
2217dnl Similar policy but without allowing all traffic from ns0->ns1.
2218AT_DATA([flows2.txt], [dnl
2219table=0,priority=1,action=drop
2220table=0,priority=10,arp,action=normal
2221table=0,priority=10,icmp,action=normal
2222
2223dnl Allow outgoing UDP connections, and treat them as TFTP
2224table=0,priority=100,in_port=1,udp,action=ct(table=1)
2225table=1,in_port=1,udp,ct_state=+trk+new-rel,action=ct(commit,alg=tftp),2
2226table=1,in_port=1,udp,ct_state=+trk+new+rel,action=ct(commit),2
2227table=1,in_port=1,udp,ct_state=+trk+est,action=2
2228
2229dnl Allow incoming TFTP data connections and responses to existing connections
2230table=0,priority=100,in_port=2,udp,action=ct(table=1)
2231table=1,in_port=2,udp,ct_state=+trk+est,action=1
2232table=1,in_port=2,udp,ct_state=+trk+new+rel,action=1
2233])
2234
2235AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt])
2236
2237OVS_START_L7([at_ns0], [tftp])
2238OVS_START_L7([at_ns1], [tftp])
2239
2240dnl TFTP requests from p1->p0 should fail due to network failure.
2241NS_CHECK_EXEC([at_ns1], [[curl $CURL_OPT tftp://10.1.1.1/flows1.txt -o foo 2>curl0.log]], [28])
2242AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
2243])
2244
2245dnl TFTP requests from p0->p1 should work fine.
2246NS_CHECK_EXEC([at_ns0], [[curl $CURL_OPT tftp://10.1.1.2/flows1.txt -o foo 2>curl1.log]])
2247AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2248udp,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
2249])
2250
2251dnl Try the second set of flows.
2252AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt])
2253AT_CHECK([ovs-appctl dpctl/flush-conntrack])
2254
2255dnl TFTP requests from p1->p0 should fail due to network failure.
2256NS_CHECK_EXEC([at_ns1], [[curl $CURL_OPT tftp://10.1.1.1/flows1.txt -o foo 2>curl2.log]], [28])
2257AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl
2258])
2259
2260dnl TFTP requests from p0->p1 should work fine.
2261NS_CHECK_EXEC([at_ns0], [[curl $CURL_OPT tftp://10.1.1.2/flows1.txt -o foo 2>curl3.log]])
2262AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2263udp,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
2264])
2265
2266OVS_TRAFFIC_VSWITCHD_STOP
2267AT_CLEANUP
2268
ee8941ab 2269AT_BANNER([conntrack - NAT])
9ac0aada
JR
2270
2271AT_SETUP([conntrack - simple SNAT])
2272CHECK_CONNTRACK()
4573c42e 2273CHECK_CONNTRACK_NAT()
9ac0aada
JR
2274OVS_TRAFFIC_VSWITCHD_START()
2275
2276ADD_NAMESPACES(at_ns0, at_ns1)
2277
2278ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2279NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2280ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2281
2282dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2283AT_DATA([flows.txt], [dnl
2284in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2
2285in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat)
2286in_port=2,ct_state=+trk,ct_zone=1,ip,action=1
2287dnl
2288dnl ARP
2289priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2290priority=10 arp action=normal
2291priority=0,action=drop
2292dnl
2293dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2294table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2295table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2296dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2297dnl TPA IP in reg2.
2298dnl Swaps the fields of the ARP message to turn a query to a response.
2299table=10 priority=100 arp xreg0=0 action=normal
2300table=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]]
2301table=10 priority=0 action=drop
2302])
2303
2304AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2305
2306dnl HTTP requests from p0->p1 should work fine.
7ed40afe 2307OVS_START_L7([at_ns1], [http])
9ac0aada
JR
2308NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
2309
a857bb69 2310AT_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 2311tcp,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
2312])
2313
2314OVS_TRAFFIC_VSWITCHD_STOP
2315AT_CLEANUP
2316
2317
2318AT_SETUP([conntrack - SNAT with port range])
2319CHECK_CONNTRACK()
4573c42e 2320CHECK_CONNTRACK_NAT()
9ac0aada
JR
2321OVS_TRAFFIC_VSWITCHD_START()
2322
2323ADD_NAMESPACES(at_ns0, at_ns1)
2324
2325ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2326NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2327ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2328
2329dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2330AT_DATA([flows.txt], [dnl
2331in_port=1,tcp,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255:34567-34568,random)),2
2332in_port=2,ct_state=-trk,tcp,tp_dst=34567,action=ct(table=0,zone=1,nat)
2333in_port=2,ct_state=-trk,tcp,tp_dst=34568,action=ct(table=0,zone=1,nat)
2334in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1
2335dnl
2336dnl ARP
2337priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2338priority=10 arp action=normal
2339priority=0,action=drop
2340dnl
2341dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2342table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2343table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2344dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2345dnl TPA IP in reg2.
2346dnl Swaps the fields of the ARP message to turn a query to a response.
2347table=10 priority=100 arp xreg0=0 action=normal
2348table=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]]
2349table=10 priority=0 action=drop
2350])
2351
2352AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2353
2354dnl HTTP requests from p0->p1 should work fine.
7ed40afe 2355OVS_START_L7([at_ns1], [http])
9ac0aada
JR
2356NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
2357
a857bb69 2358AT_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 2359tcp,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
2360])
2361
2362OVS_TRAFFIC_VSWITCHD_STOP
2363AT_CLEANUP
2364
2365
2366AT_SETUP([conntrack - more complex SNAT])
2367CHECK_CONNTRACK()
4573c42e 2368CHECK_CONNTRACK_NAT()
9ac0aada
JR
2369OVS_TRAFFIC_VSWITCHD_START()
2370
2371ADD_NAMESPACES(at_ns0, at_ns1)
2372
2373ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2374NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2375ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2376
2377AT_DATA([flows.txt], [dnl
2378dnl Track all IP traffic, NAT existing connections.
2379priority=100 ip action=ct(table=1,zone=1,nat)
2380dnl
2381dnl Allow ARP, but generate responses for NATed addresses
2382priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2383priority=10 arp action=normal
2384priority=0 action=drop
2385dnl
2386dnl Allow any traffic from ns0->ns1. SNAT ns0 to 10.1.1.240-10.1.1.255
2387table=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
2388table=1 priority=100 in_port=1 ip ct_state=+trk-new+est action=2
2389dnl Only allow established traffic from ns1->ns0.
2390table=1 priority=100 in_port=2 ip ct_state=+trk-new+est action=1
2391table=1 priority=0 action=drop
2392dnl
2393dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2394table=8 priority=100 reg2=0x0a0101f0/0xfffffff0 action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2395dnl Zero result means not found.
2396table=8 priority=0 action=load:0->OXM_OF_PKT_REG0[[]]
2397dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2398dnl ARP TPA IP in reg2.
2399table=10 priority=100 arp xreg0=0 action=normal
2400dnl Swaps the fields of the ARP message to turn a query to a response.
2401table=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]]
2402table=10 priority=0 action=drop
2403])
2404
2405AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2406
2407dnl HTTP requests from p0->p1 should work fine.
7ed40afe 2408OVS_START_L7([at_ns1], [http])
9ac0aada
JR
2409NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
2410
a857bb69 2411AT_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 2412tcp,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
2413])
2414
2415OVS_TRAFFIC_VSWITCHD_STOP
2416AT_CLEANUP
2417
2418AT_SETUP([conntrack - simple DNAT])
2419CHECK_CONNTRACK()
4573c42e 2420CHECK_CONNTRACK_NAT()
9ac0aada
JR
2421OVS_TRAFFIC_VSWITCHD_START()
2422
2423ADD_NAMESPACES(at_ns0, at_ns1)
2424
2425ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2426ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2427NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88])
2428
2429dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2430AT_DATA([flows.txt], [dnl
2431priority=100 in_port=1,ip,nw_dst=10.1.1.64,action=ct(zone=1,nat(dst=10.1.1.2),commit),2
2432priority=10 in_port=1,ip,action=ct(commit,zone=1),2
2433priority=100 in_port=2,ct_state=-trk,ip,action=ct(table=0,nat,zone=1)
2434priority=100 in_port=2,ct_state=+trk+est,ct_zone=1,ip,action=1
2435dnl
2436dnl ARP
2437priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2438priority=10 arp action=normal
2439priority=0,action=drop
2440dnl
2441dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2442table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2443dnl Zero result means not found.
2444table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2445dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2446dnl TPA IP in reg2.
2447table=10 priority=100 arp xreg0=0 action=normal
2448dnl Swaps the fields of the ARP message to turn a query to a response.
2449table=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]]
2450table=10 priority=0 action=drop
2451])
2452
2453AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2454
2455dnl Should work with the virtual IP address through NAT
7ed40afe 2456OVS_START_L7([at_ns1], [http])
9ac0aada
JR
2457NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
2458
420c73b2
JR
2459AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl
2460tcp,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
2461])
2462
2463dnl Should work with the assigned IP address as well
2464NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2465
420c73b2
JR
2466AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2467tcp,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
2468])
2469
2470OVS_TRAFFIC_VSWITCHD_STOP
2471AT_CLEANUP
2472
2473AT_SETUP([conntrack - more complex DNAT])
2474CHECK_CONNTRACK()
4573c42e 2475CHECK_CONNTRACK_NAT()
9ac0aada
JR
2476OVS_TRAFFIC_VSWITCHD_START()
2477
2478ADD_NAMESPACES(at_ns0, at_ns1)
2479
2480ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2481ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2482NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88])
2483
2484dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2485AT_DATA([flows.txt], [dnl
2486dnl Track all IP traffic
2487table=0 priority=100 ip action=ct(table=1,zone=1,nat)
2488dnl
2489dnl Allow ARP, but generate responses for NATed addresses
2490table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2491table=0 priority=10 arp action=normal
2492table=0 priority=0 action=drop
2493dnl
2494dnl Allow any IP traffic from ns0->ns1. DNAT ns0 from 10.1.1.64 to 10.1.1.2
2495table=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
2496table=1 priority=10 in_port=1 ct_state=+new ip action=ct(commit,zone=1),2
2497table=1 priority=100 in_port=1 ct_state=+est ct_zone=1 action=2
2498dnl Only allow established traffic from ns1->ns0.
2499table=1 priority=100 in_port=2 ct_state=+est ct_zone=1 action=1
2500table=1 priority=0 action=drop
2501dnl
2502dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2503table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2504dnl Zero result means not found.
2505table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2506dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2507dnl TPA IP in reg2.
2508table=10 priority=100 arp xreg0=0 action=normal
2509dnl Swaps the fields of the ARP message to turn a query to a response.
2510table=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]]
2511table=10 priority=0 action=drop
2512])
2513
2514AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2515
2516dnl Should work with the virtual IP address through NAT
7ed40afe 2517OVS_START_L7([at_ns1], [http])
9ac0aada
JR
2518NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log])
2519
420c73b2
JR
2520AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl
2521tcp,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
2522])
2523
2524dnl Should work with the assigned IP address as well
2525NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2526
420c73b2
JR
2527AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2528tcp,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
2529])
2530
2531OVS_TRAFFIC_VSWITCHD_STOP
2532AT_CLEANUP
2533
2534AT_SETUP([conntrack - ICMP related with NAT])
9c1ab985 2535AT_SKIP_IF([test $HAVE_NC = no])
9ac0aada 2536CHECK_CONNTRACK()
4573c42e 2537CHECK_CONNTRACK_NAT()
9ac0aada
JR
2538OVS_TRAFFIC_VSWITCHD_START()
2539
2540ADD_NAMESPACES(at_ns0, at_ns1)
2541
2542ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2543NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2544ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
2545
2546dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back.
2547dnl Make sure ICMP responses are reverse-NATted.
2548AT_DATA([flows.txt], [dnl
2549in_port=1,udp,action=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:1->ct_mark)),2
2550in_port=2,icmp,ct_state=-trk,action=ct(table=0,nat)
2551in_port=2,icmp,nw_dst=10.1.1.1,ct_state=+trk+rel,ct_mark=1,action=1
2552dnl
2553dnl ARP
2554priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2555priority=10 arp action=normal
2556priority=0,action=drop
2557dnl
2558dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2559table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2560table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2561dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2562dnl TPA IP in reg2.
2563dnl Swaps the fields of the ARP message to turn a query to a response.
2564table=10 priority=100 arp xreg0=0 action=normal
2565table=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]]
2566table=10 priority=0 action=drop
2567])
2568
2569AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2570
2571dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response.
b54971f7 2572NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"])
9ac0aada
JR
2573
2574AT_CHECK([ovs-appctl revalidator/purge], [0])
2575AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl
2576 n_packets=1, n_bytes=42, priority=10,arp actions=NORMAL
2577 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
2578 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
2579 n_packets=1, n_bytes=72, ct_state=-trk,icmp,in_port=2 actions=ct(table=0,nat)
2580 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
2581 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]]
2582 table=10, n_packets=1, n_bytes=42, priority=100,arp,reg0=0,reg1=0 actions=NORMAL
2583 table=8, n_packets=1, n_bytes=42, priority=0 actions=set_field:0->xreg0
2584 table=8, n_packets=1, n_bytes=42, reg2=0xa0101f0/0xfffffff0 actions=set_field:0x808888888888->xreg0
2585OFPST_FLOW reply (OF1.5):
2586])
2587
a857bb69
DDP
2588AT_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
2589udp,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
2590])
2591
2592OVS_TRAFFIC_VSWITCHD_STOP
2593AT_CLEANUP
2594
74f205f6 2595dnl CHECK_FTP_NAT(TITLE, IP_ADDR, FLOWS)
019c73ac 2596dnl
74f205f6
JS
2597dnl Checks the implementation of conntrack with FTP ALGs in combination with
2598dnl NAT, using the provided flow table.
2599m4_define([CHECK_FTP_NAT],
2600 [AT_SETUP([conntrack - FTP NAT $1])
40c7b2fc 2601 AT_SKIP_IF([test $HAVE_FTP = no])
74f205f6
JS
2602 CHECK_CONNTRACK()
2603 CHECK_CONNTRACK_NAT()
019c73ac 2604
74f205f6 2605 OVS_TRAFFIC_VSWITCHD_START()
019c73ac 2606
74f205f6 2607 ADD_NAMESPACES(at_ns0, at_ns1)
019c73ac 2608
74f205f6
JS
2609 ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24")
2610 NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2611 ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24")
019c73ac 2612
74f205f6
JS
2613 dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2614 AT_DATA([flows.txt], [$3
019c73ac
JS
2615])
2616
74f205f6 2617 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
019c73ac 2618
7ed40afe 2619 OVS_START_L7([at_ns1], [ftp])
019c73ac 2620
74f205f6
JS
2621 dnl FTP requests from p0->p1 should work fine.
2622 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 2623
74f205f6
JS
2624 dnl Discards CLOSE_WAIT and CLOSING
2625 AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl
2626tcp,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
2627tcp,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>)
2628])
019c73ac 2629
74f205f6
JS
2630 OVS_TRAFFIC_VSWITCHD_STOP
2631 AT_CLEANUP])
019c73ac 2632
74f205f6
JS
2633dnl CHECK_FTP_NAT_PRE_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX)
2634dnl
2635dnl Checks the implementation of conntrack with FTP ALGs in combination with
2636dnl NAT, with flow tables that implement the NATing as part of handling of
2637dnl initial incoming packets - ie, the first flow is ct(nat,table=foo).
2638dnl
2639dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format,
2640dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx.
2641m4_define([CHECK_FTP_NAT_PRE_RECIRC], [dnl
2642 CHECK_FTP_NAT([prerecirc $1], [$2], [dnl
9ac0aada
JR
2643dnl track all IP traffic, de-mangle non-NEW connections
2644table=0 in_port=1, ip, action=ct(table=1,nat)
2645table=0 in_port=2, ip, action=ct(table=2,nat)
2646dnl
2647dnl ARP
2648dnl
2649table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2650table=0 priority=10 arp action=normal
2651table=0 priority=0 action=drop
2652dnl
2653dnl Table 1: port 1 -> 2
2654dnl
2655dnl Allow new FTP connections. These need to be commited.
74f205f6 2656table=1 ct_state=+new, tcp, tp_dst=21, nw_src=10.1.1.1, action=ct(alg=ftp,commit,nat(src=$2)),2
9ac0aada 2657dnl Allow established TCP connections, make sure they are NATted already.
74f205f6 2658table=1 ct_state=+est, tcp, nw_src=$2, action=2
9ac0aada
JR
2659dnl
2660dnl Table 1: droppers
2661dnl
2662table=1 priority=10, tcp, action=drop
2663table=1 priority=0,action=drop
2664dnl
2665dnl Table 2: port 2 -> 1
2666dnl
2667dnl Allow established TCP connections, make sure they are reverse NATted
2668table=2 ct_state=+est, tcp, nw_dst=10.1.1.1, action=1
2669dnl Allow (new) related (data) connections. These need to be commited.
74f205f6 2670table=2 ct_state=+new+rel, tcp, nw_dst=$2, action=ct(commit,nat),1
9ac0aada
JR
2671dnl Allow related ICMP packets, make sure they are reverse NATted
2672table=2 ct_state=+rel, icmp, nw_dst=10.1.1.1, action=1
2673dnl
2674dnl Table 2: droppers
2675dnl
2676table=2 priority=10, tcp, action=drop
2677table=2 priority=0, action=drop
2678dnl
2679dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2680dnl
74f205f6 2681table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
9ac0aada
JR
2682table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2683dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2684dnl TPA IP in reg2.
2685dnl Swaps the fields of the ARP message to turn a query to a response.
2686table=10 priority=100 arp xreg0=0 action=normal
2687table=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]]
2688table=10 priority=0 action=drop
74f205f6 2689 ])
9ac0aada
JR
2690])
2691
74f205f6
JS
2692dnl Check that ct(nat,table=foo) works without TCP sequence adjustment.
2693CHECK_FTP_NAT_PRE_RECIRC([], [10.1.1.9], [0x0a010109])
9ac0aada 2694
74f205f6
JS
2695dnl Check that ct(nat,table=foo) works with TCP sequence adjustment.
2696dnl
2697dnl The FTP PORT command includes the ASCII representation of the address,
2698dnl so when these messages need to be NATed between addresses that have
2699dnl different lengths when represented in ASCII (such as the original address
2700dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must
2701dnl resize the packet and adjust TCP sequence numbers. This test is kept
2702dnl separate from the above to easier identify issues in this code on different
2703dnl kernels.
2704CHECK_FTP_NAT_PRE_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0])
2705
2706dnl CHECK_FTP_NAT_POST_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX)
2707dnl
2708dnl Checks the implementation of conntrack with FTP ALGs in combination with
2709dnl NAT, with flow tables that implement the NATing after the first round
2710dnl of recirculation - that is, the first flow ct(table=foo) then a subsequent
2711dnl flow will implement the NATing with ct(nat..),output:foo.
2712dnl
2713dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format,
2714dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx.
2715m4_define([CHECK_FTP_NAT_POST_RECIRC], [dnl
2716 CHECK_FTP_NAT([postrecirc $1], [$2], [dnl
9ac0aada
JR
2717dnl track all IP traffic (this includes a helper call to non-NEW packets.)
2718table=0 ip, action=ct(table=1)
2719dnl
2720dnl ARP
2721dnl
2722table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2723table=0 priority=10 arp action=normal
2724table=0 priority=0 action=drop
2725dnl
2726dnl Table 1
2727dnl
2728dnl Allow new FTP connections. These need to be commited.
2729dnl This does helper for new packets.
74f205f6 2730table=1 in_port=1 ct_state=+new, tcp, tp_dst=21, action=ct(alg=ftp,commit,nat(src=$2)),2
9ac0aada
JR
2731dnl Allow and NAT established TCP connections
2732table=1 in_port=1 ct_state=+est, tcp, action=ct(nat),2
2733table=1 in_port=2 ct_state=+est, tcp, action=ct(nat),1
2734dnl Allow and NAT (new) related active (data) connections.
2735dnl These need to be commited.
2736table=1 in_port=2 ct_state=+new+rel, tcp, action=ct(commit,nat),1
2737dnl Allow related ICMP packets.
2738table=1 in_port=2 ct_state=+rel, icmp, action=ct(nat),1
2739dnl Drop everything else.
2740table=1 priority=0, action=drop
2741dnl
2742dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2743dnl
74f205f6 2744table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
9ac0aada
JR
2745table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2746dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2747dnl TPA IP in reg2.
2748dnl Swaps the fields of the ARP message to turn a query to a response.
2749table=10 priority=100 arp xreg0=0 action=normal
2750table=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]]
2751table=10 priority=0 action=drop
74f205f6 2752 ])
9ac0aada
JR
2753])
2754
74f205f6
JS
2755dnl Check that ct(nat,table=foo) works without TCP sequence adjustment.
2756CHECK_FTP_NAT_POST_RECIRC([], [10.1.1.9], [0x0a010109])
9ac0aada 2757
74f205f6
JS
2758dnl Check that ct(nat,table=foo) works with TCP sequence adjustment.
2759dnl
2760dnl The FTP PORT command includes the ASCII representation of the address,
2761dnl so when these messages need to be NATed between addresses that have
2762dnl different lengths when represented in ASCII (such as the original address
2763dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must
2764dnl resize the packet and adjust TCP sequence numbers. This test is kept
2765dnl separate from the above to easier identify issues in this code on different
2766dnl kernels.
2767CHECK_FTP_NAT_POST_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0])
9ac0aada
JR
2768
2769AT_SETUP([conntrack - IPv6 HTTP with NAT])
2770CHECK_CONNTRACK()
4573c42e 2771CHECK_CONNTRACK_NAT()
9ac0aada
JR
2772OVS_TRAFFIC_VSWITCHD_START()
2773
2774ADD_NAMESPACES(at_ns0, at_ns1)
2775
2776ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
2777NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2778ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
2779NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])
2780
2781dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0.
2782AT_DATA([flows.txt], [dnl
2783priority=1,action=drop
2784priority=10,icmp6,action=normal
2785priority=100,in_port=1,ip6,action=ct(commit,nat(src=fc00::240)),2
2786priority=100,in_port=2,ct_state=-trk,ip6,action=ct(nat,table=0)
2787priority=100,in_port=2,ct_state=+trk+est,ip6,action=1
2788priority=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
2789])
2790
2791AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2792
c10840ff
JS
2793dnl Linux seems to take a little time to get its IPv6 stack in order. Without
2794dnl waiting, we get occasional failures due to the following error:
9ac0aada 2795dnl "connect: Cannot assign requested address"
c10840ff 2796OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2])
9ac0aada
JR
2797
2798dnl HTTP requests from ns0->ns1 should work fine.
7ed40afe 2799OVS_START_L7([at_ns1], [http6])
9ac0aada
JR
2800
2801NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log])
2802
2803dnl HTTP requests from ns1->ns0 should fail due to network failure.
2804dnl Try 3 times, in 1 second intervals.
7ed40afe 2805OVS_START_L7([at_ns0], [http6])
9ac0aada
JR
2806NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4])
2807
2808OVS_TRAFFIC_VSWITCHD_STOP
2809AT_CLEANUP
2810
2811
2812AT_SETUP([conntrack - IPv6 FTP with NAT])
40c7b2fc 2813AT_SKIP_IF([test $HAVE_FTP = no])
9ac0aada 2814CHECK_CONNTRACK()
4573c42e 2815CHECK_CONNTRACK_NAT()
9ac0aada
JR
2816OVS_TRAFFIC_VSWITCHD_START()
2817
2818ADD_NAMESPACES(at_ns0, at_ns1)
2819
2820ADD_VETH(p0, at_ns0, br0, "fc00::1/96")
2821NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88])
2822ADD_VETH(p1, at_ns1, br0, "fc00::2/96")
2823dnl Would be nice if NAT could translate neighbor discovery messages, too.
2824NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1])
2825
2826dnl Allow any traffic from ns0->ns1.
2827dnl Only allow nd, return traffic from ns1->ns0.
2828AT_DATA([flows.txt], [dnl
2829dnl Allow other ICMPv6 both ways (without commit).
2830table=1 priority=100 in_port=1 icmp6, action=2
2831table=1 priority=100 in_port=2 icmp6, action=1
2832dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.)
2833table=0 priority=10 ip6, action=ct(nat,table=1)
2834table=0 priority=0 action=drop
2835dnl
2836dnl Table 1
2837dnl
2838dnl Allow new TCPv6 FTP control connections.
2839table=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
2840dnl Allow related TCPv6 connections from port 2 to the NATted address.
2841table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1
2842dnl Allow established TCPv6 connections both ways, enforce NATting
2843table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240 action=2
2844table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1 action=1
2845dnl Drop everything else.
2846table=1 priority=0, action=drop
2847])
2848
2849AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2850
c10840ff
JS
2851dnl Linux seems to take a little time to get its IPv6 stack in order. Without
2852dnl waiting, we get occasional failures due to the following error:
2853dnl "connect: Cannot assign requested address"
2854OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null])
2855
7ed40afe 2856OVS_START_L7([at_ns1], [ftp])
9ac0aada
JR
2857
2858dnl FTP requests from p0->p1 should work fine.
4fee8b13 2859NS_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 2860
a857bb69 2861dnl Discards CLOSE_WAIT and CLOSING
420c73b2
JR
2862AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl
2863tcp,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
2864tcp,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
2865])
2866
2867OVS_TRAFFIC_VSWITCHD_STOP
2868AT_CLEANUP
2c66ebe4
JR
2869
2870AT_SETUP([conntrack - DNAT load balancing])
2871CHECK_CONNTRACK()
4573c42e 2872CHECK_CONNTRACK_NAT()
2c66ebe4
JR
2873OVS_TRAFFIC_VSWITCHD_START()
2874
2875ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4)
2876
2877ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24")
2878ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24")
2879ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24")
2880ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24")
2881NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11])
2882NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22])
2883NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33])
2884NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44])
2885
2886dnl Select group for load balancing. One bucket per server. Each bucket
2887dnl tracks and NATs the connection and recirculates to table 4 for egress
2888dnl routing. Packets of existing connections are always NATted based on
2889dnl connection state, only new connections are NATted according to the
2890dnl specific NAT parameters in each bucket.
2891AT_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)"])
2892
2893AT_DATA([flows.txt], [dnl
2894dnl Track connections to the virtual IP address.
2895table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234
2896dnl All other IP traffic is allowed but the connection state is no commited.
2897table=0 priority=90 ip action=ct(table=4,nat)
2898dnl
2899dnl Allow ARP, but generate responses for virtual addresses
2900table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2901table=0 priority=10 arp action=normal
2902table=0 priority=0 action=drop
2903dnl
2904dnl Routing table
2905dnl
2906table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1
2907table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2
2908table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3
2909table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4
2910table=4 priority=0 action=drop
2911dnl
2912dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
2913table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
2914dnl Zero result means not found.
2915table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
2916dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
2917dnl TPA IP in reg2.
2918table=10 priority=100 arp xreg0=0 action=normal
2919dnl Swaps the fields of the ARP message to turn a query to a response.
2920table=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]]
2921table=10 priority=0 action=controller
2922])
2923
2924AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
2925
2926dnl Start web servers
7ed40afe
JS
2927OVS_START_L7([at_ns2], [http])
2928OVS_START_L7([at_ns3], [http])
2929OVS_START_L7([at_ns4], [http])
2c66ebe4
JR
2930
2931on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0'
2932on_exit 'ovs-appctl revalidator/purge'
2933on_exit 'ovs-appctl dpif/dump-flows br0'
2934
2935dnl Should work with the virtual IP address through NAT
2936for i in 1 2 3 4 5 6 7 8 9 10 11 12; do
2937 echo Request $i
2938 NS_CHECK_EXEC([at_ns1], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget$i.log])
2939done
2940
2941dnl Each server should have at least one connection.
420c73b2
JR
2942AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl
2943tcp,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>)
2944tcp,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>)
2945tcp,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
2946])
2947
2948ovs-appctl dpif/dump-flows br0
2949ovs-appctl revalidator/purge
2950ovs-ofctl -O OpenFlow15 dump-flows br0
2951ovs-ofctl -O OpenFlow15 dump-group-stats br0
2952
2953OVS_TRAFFIC_VSWITCHD_STOP
2954AT_CLEANUP
2955
2956
2957AT_SETUP([conntrack - DNAT load balancing with NC])
9c1ab985 2958AT_SKIP_IF([test $HAVE_NC = no])
2c66ebe4 2959CHECK_CONNTRACK()
4573c42e 2960CHECK_CONNTRACK_NAT()
2c66ebe4
JR
2961OVS_TRAFFIC_VSWITCHD_START()
2962
2963ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4, at_ns5)
2964
2965ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24")
2966ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24")
2967ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24")
2968ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24")
2969ADD_VETH(p5, at_ns5, br0, "10.1.1.5/24")
2970NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11])
2971NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22])
2972NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33])
2973NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44])
2974NS_CHECK_EXEC([at_ns5], [ip link set dev p5 address 80:88:88:88:88:55])
2975
2976dnl Select group for load balancing. One bucket per server. Each bucket
2977dnl tracks and NATs the connection and recirculates to table 4 for egress
2978dnl routing. Packets of existing connections are always NATted based on
2979dnl connection state, only new connections are NATted according to the
2980dnl specific NAT parameters in each bucket.
2981AT_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)"])
2982
2983AT_DATA([flows.txt], [dnl
2984dnl Track connections to the virtual IP address.
2985table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234
2986dnl All other IP traffic is allowed but the connection state is no commited.
2987table=0 priority=90 ip action=ct(table=4,nat)
2988dnl
2989dnl Allow ARP, but generate responses for virtual addresses
2990table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10
2991table=0 priority=10 arp action=normal
2992table=0 priority=0 action=drop
2993dnl
2994dnl Routing table
2995dnl
2996table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1
2997table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2
2998table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3
2999table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4
3000table=4,ip,nw_dst=10.1.1.5 action=mod_dl_dst:80:88:88:88:88:55,output:5
3001table=4 priority=0 action=drop
3002dnl
3003dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0
3004table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]]
3005dnl Zero result means not found.
3006table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]]
3007dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action.
3008dnl TPA IP in reg2.
3009table=10 priority=100 arp xreg0=0 action=normal
3010dnl Swaps the fields of the ARP message to turn a query to a response.
3011table=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]]
3012table=10 priority=0 action=controller
3013])
3014
3015AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
3016
3017dnl Start web servers
7ed40afe
JS
3018OVS_START_L7([at_ns2], [http])
3019OVS_START_L7([at_ns3], [http])
3020OVS_START_L7([at_ns4], [http])
2c66ebe4
JR
3021
3022on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0'
3023on_exit 'ovs-appctl revalidator/purge'
3024on_exit 'ovs-appctl dpif/dump-flows br0'
3025
3026sleep 5
3027
3028dnl Should work with the virtual IP address through NAT
3029for i in 1 2 3 4 5 6 7 8 9; do
3030 echo Request $i
3031 NS_CHECK_EXEC([at_ns1], [echo "TEST1" | nc -p 4100$i 10.1.1.64 80 > nc-1-$i.log])
3032 NS_CHECK_EXEC([at_ns5], [echo "TEST5" | nc -p 4100$i 10.1.1.64 80 > nc-5-$i.log])
3033done
3034
3035conntrack -L 2>&1
3036
3037ovs-appctl dpif/dump-flows br0
3038ovs-appctl revalidator/purge
3039ovs-ofctl -O OpenFlow15 dump-flows br0
3040ovs-ofctl -O OpenFlow15 dump-group-stats br0
3041
3042OVS_TRAFFIC_VSWITCHD_STOP
3043AT_CLEANUP