]> git.proxmox.com Git - mirror_ovs.git/blob - tests/tunnel.at
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / tests / tunnel.at
1 AT_BANNER([tunnel])
2
3 AT_SETUP([tunnel - input])
4 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
5 options:remote_ip=1.1.1.1 ofport_request=1\
6 -- add-port br0 p2 -- set Interface p2 type=gre \
7 options:local_ip=2.2.2.2 options:remote_ip=1.1.1.1 \
8 ofport_request=2 \
9 -- add-port br0 p3 -- set Interface p3 type=gre \
10 options:remote_ip=2.2.2.2 ofport_request=3])
11 AT_DATA([flows.txt], [dnl
12 actions=IN_PORT
13 ])
14 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
15
16 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
17
18 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
19 br0 65534/100: (dummy-internal)
20 p1 1/1: (gre: remote_ip=1.1.1.1)
21 p2 2/1: (gre: local_ip=2.2.2.2, remote_ip=1.1.1.1)
22 p3 3/1: (gre: remote_ip=2.2.2.2)
23 ])
24
25 dnl remote_ip
26 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=1.2.3.4,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
27 AT_CHECK([tail -1 stdout], [0],
28 [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,flags(df))),1
29 ])
30
31 dnl local_ip, remote_ip
32 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
33 AT_CHECK([tail -1 stdout], [0],
34 [Datapath actions: set(tunnel(src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df))),1
35 ])
36
37 dnl reconfigure, local_ip, remote_ip
38 AT_CHECK([ovs-vsctl set Interface p2 type=gre options:local_ip=2.2.2.3 \
39 options:df_default=false options:ttl=1 options:csum=true \
40 -- set Interface p3 type=vxlan])
41 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
42 br0 65534/100: (dummy-internal)
43 p1 1/1: (gre: remote_ip=1.1.1.1)
44 p2 2/1: (gre: csum=true, df_default=false, local_ip=2.2.2.3, remote_ip=1.1.1.1, ttl=1)
45 p3 3/4789: (vxlan: remote_ip=2.2.2.2)
46 ])
47 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
48 AT_CHECK([tail -1 stdout], [0],
49 [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,flags(df))),1
50 ])
51 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.3,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
52 AT_CHECK([tail -1 stdout], [0],
53 [Datapath actions: set(tunnel(src=2.2.2.3,dst=1.1.1.1,ttl=1,flags(csum))),1
54 ])
55
56 dnl nonexistent tunnel
57 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=5.5.5.5,dst=6.6.6.6,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [2], [ignore], [dnl
58 no OpenFlow tunnel port for this packet
59 ovs-appctl: ovs-vswitchd: server returned an error
60 ])
61
62 OVS_VSWITCHD_STOP(["/receive tunnel port not found/d"])
63 AT_CLEANUP
64
65 AT_SETUP([tunnel - ECN decapsulation])
66 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
67 options:remote_ip=1.1.1.1 ofport_request=1 \
68 -- add-port br0 p2 -- set Interface p2 type=dummy \
69 ofport_request=2])
70 AT_DATA([flows.txt], [dnl
71 actions=2
72 ])
73
74 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
75
76 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
77 br0 65534/100: (dummy-internal)
78 p1 1/1: (gre: remote_ip=1.1.1.1)
79 p2 2/2: (dummy)
80 ])
81
82 dnl Tunnel CE and encapsulated packet CE
83 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,tos=0x3,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=3,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
84 AT_CHECK([tail -2 stdout], [0],
85 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=3,tun_flags=-df-csum-key,in_port=1,nw_ecn=3,nw_frag=no
86 Datapath actions: 2
87 ])
88
89 dnl Tunnel CE and encapsulated packet ECT(1)
90 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,tos=0x3,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=1,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
91 AT_CHECK([tail -2 stdout], [0],
92 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=3,tun_flags=-df-csum-key,in_port=1,nw_ecn=1,nw_frag=no
93 Datapath actions: set(ipv4(tos=0x3/0x3)),2
94 ])
95
96 dnl Tunnel CE and encapsulated packet ECT(2)
97 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,tos=0x3,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=2,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
98 AT_CHECK([tail -2 stdout], [0],
99 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=3,tun_flags=-df-csum-key,in_port=1,nw_ecn=2,nw_frag=no
100 Datapath actions: set(ipv4(tos=0x3/0x3)),2
101 ])
102
103 dnl Tunnel CE and encapsulated packet Non-ECT
104 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,tos=0x3,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
105 AT_CHECK([tail -3 stdout], [0],
106 [Final flow: unchanged
107 Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=3,tun_flags=-df-csum-key,in_port=1,nw_ecn=0,nw_frag=no
108 Datapath actions: drop
109 ])
110 OVS_VSWITCHD_STOP(["/dropping tunnel packet marked ECN CE but is not ECN capable/d"])
111 AT_CLEANUP
112
113 AT_SETUP([tunnel - input with matching tunnel mask])
114 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
115 options:remote_ip=1.1.1.1 \
116 ofport_request=1 \
117 -- add-port br0 p2 -- set Interface p2 type=dummy \
118 ofport_request=2])
119
120 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
121 br0 65534/100: (dummy-internal)
122 p1 1/1: (gre: remote_ip=1.1.1.1)
123 p2 2/2: (dummy)
124 ])
125
126 AT_CHECK([ovs-appctl dpctl/add-flow "tunnel(dst=1.1.1.1,src=3.3.3.200/255.255.255.0,tp_dst=123,tp_src=1,ttl=64),recirc_id(0),in_port(1),eth(),eth_type(0x0800),ipv4()" "2"])
127
128 AT_CHECK([ovs-appctl dpctl/dump-flows | tail -1], [0], [dnl
129 tunnel(src=3.3.3.200/255.255.255.0,dst=1.1.1.1,ttl=64,tp_src=1,tp_dst=123),recirc_id(0),in_port(1),eth_type(0x0800), packets:0, bytes:0, used:never, actions:2
130 ])
131
132 OVS_VSWITCHD_STOP
133 AT_CLEANUP
134
135 AT_SETUP([tunnel - too long nested attributes])
136 OVS_VSWITCHD_START([add-port br0 p1 \
137 -- set Interface p1 type=gre options:remote_ip=1.1.1.1 ofport_request=1 \
138 -- add-port br0 p2 -- set Interface p2 type=dummy ofport_request=2])
139
140 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
141 br0 65534/100: (dummy-internal)
142 p1 1/1: (gre: remote_ip=1.1.1.1)
143 p2 2/2: (dummy)
144 ])
145
146 dst_single="dst=1.1.1.1"
147 dst_rep=${dst_single}
148 dnl Size of one OVS_TUNNEL_KEY_ATTR_IPV4_DST is 4 bytes + NLA_HDRLEN (4 bytes).
149 dnl One nested message has room for UINT16_MAX - NLA_HDRLEN (4) bytes, i.e.
150 dnl (UINT16_MAX - NLA_HDRLEN) / (4 + NLA_HDRLEN) = 8191.375 of dst addresses.
151 for i in `seq 1 8192` ; do
152 dst_rep="${dst_rep},${dst_single}"
153 done
154
155 AT_CHECK([ovs-appctl dpctl/add-flow "tunnel(${dst_rep})" "2" 2>&1 | dnl
156 sed "s/${dst_single},//g"], [], [dnl
157 ovs-vswitchd: parsing flow key (syntax error at tunnel(dst=1.1.1.1)) (Argument list too long)
158 ovs-appctl: ovs-vswitchd: server returned an error
159 ])
160
161 OVS_VSWITCHD_STOP
162 AT_CLEANUP
163
164 AT_SETUP([tunnel - output])
165 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
166 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
167 options:key=5 ofport_request=1\
168 -- add-port br0 p2 -- set Interface p2 type=dummy \
169 ofport_request=2])
170 AT_DATA([flows.txt], [dnl
171 actions=output:1
172 ])
173
174 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
175 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
176
177 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
178 br0 65534/100: (dummy-internal)
179 p1 1/1: (gre: key=5, local_ip=2.2.2.2, remote_ip=1.1.1.1)
180 p2 2/2: (dummy)
181 ])
182
183 dnl Basic
184 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=4,ttl=128,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
185 AT_CHECK([tail -1 stdout], [0],
186 [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df|key))),1
187 ])
188
189 dnl ECN
190 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=1,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
191 AT_CHECK([tail -1 stdout], [0],
192 [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,tos=0x1,ttl=64,flags(df|key))),1
193 ])
194 OVS_VSWITCHD_STOP
195 AT_CLEANUP
196
197 AT_SETUP([tunnel - unencrypted tunnel and not setting skb_mark])
198 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
199 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
200 options:key=5 ofport_request=1\
201 -- add-port br0 p2 -- set Interface p2 type=dummy \
202 ofport_request=2 ofport_request=2])
203 AT_DATA([flows.txt], [dnl
204 actions=output:1
205 ])
206 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
207 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
208 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=4,ttl=128,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
209 AT_CHECK([tail -1 stdout], [0],
210 [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df|key))),1
211 ])
212 OVS_VSWITCHD_STOP
213 AT_CLEANUP
214
215 AT_SETUP([tunnel - unencrypted tunnel and setting skb_mark to 1])
216 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
217 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
218 options:key=5 ofport_request=1\
219 -- add-port br0 p2 -- set Interface p2 type=dummy \
220 ofport_request=2 ofport_request=2])
221 AT_DATA([flows.txt], [dnl
222 actions=load:0x1->NXM_NX_PKT_MARK[[]],output:1
223 ])
224 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
225 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
226 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=4,ttl=128,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
227 AT_CHECK([tail -1 stdout], [0],
228 [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df|key))),set(skb_mark(0x1)),1
229 ])
230 OVS_VSWITCHD_STOP
231 AT_CLEANUP
232
233 AT_SETUP([tunnel - unencrypted tunnel and setting skb_mark to 2])
234 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
235 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
236 options:key=5 ofport_request=1\
237 -- add-port br0 p2 -- set Interface p2 type=dummy \
238 ofport_request=2 ofport_request=2])
239 AT_DATA([flows.txt], [dnl
240 actions=load:0x2->NXM_NX_PKT_MARK[[]],output:1
241 ])
242 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
243 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
244 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=4,ttl=128,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
245 AT_CHECK([tail -1 stdout], [0],
246 [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df|key))),set(skb_mark(0x2)),1
247 ])
248
249 AT_CHECK([ovs-appctl netdev-dummy/receive p2 'aa55aa550001f8bc124434b6080045000054ba20000040018486010103580101037001004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637'])
250
251 ovs-appctl time/warp 5000
252
253 AT_CHECK([
254 ovs-appctl coverage/read-counter datapath_drop_invalid_port
255 ], [0], [dnl
256 1
257 ])
258
259 OVS_VSWITCHD_STOP
260 AT_CLEANUP
261
262 AT_SETUP([tunnel - ToS and TTL inheritance])
263 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
264 options:remote_ip=1.1.1.1 options:tos=inherit \
265 options:ttl=inherit ofport_request=1 \
266 -- add-port br0 p2 -- set Interface p2 type=dummy \
267 ofport_request=2 ofport_request=2])
268 AT_DATA([flows.txt], [dnl
269 actions=output:1
270 ])
271
272 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
273 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
274
275 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
276 br0 65534/100: (dummy-internal)
277 p1 1/1: (gre: remote_ip=1.1.1.1, tos=inherit, ttl=inherit)
278 p2 2/2: (dummy)
279 ])
280
281 dnl Basic
282 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=4,ttl=128,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
283 AT_CHECK([tail -1 stdout], [0],
284 [Datapath actions: set(tunnel(dst=1.1.1.1,tos=0x4,ttl=128,flags(df))),1
285 ])
286
287 dnl ECN
288 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=5,ttl=128,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
289 AT_CHECK([tail -1 stdout], [0],
290 [Datapath actions: set(tunnel(dst=1.1.1.1,tos=0x5,ttl=128,flags(df))),1
291 ])
292
293 dnl non-IP
294 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0806),arp(sip=1.2.3.4,tip=5.6.7.8,op=1,sha=00:0f:10:11:12:13,tha=00:14:15:16:17:18)'], [0], [stdout])
295 AT_CHECK([tail -1 stdout], [0],
296 [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,flags(df))),1
297 ])
298 OVS_VSWITCHD_STOP
299 AT_CLEANUP
300
301 AT_SETUP([tunnel - set_tunnel])
302 OVS_VSWITCHD_START([dnl
303 add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
304 options:remote_ip=1.1.1.1 ofport_request=1 \
305 -- add-port br0 p2 -- set Interface p2 type=gre options:key=flow \
306 options:remote_ip=2.2.2.2 ofport_request=2 \
307 -- add-port br0 p3 -- set Interface p3 type=gre options:key=flow \
308 options:remote_ip=3.3.3.3 ofport_request=3 \
309 -- add-port br0 p4 -- set Interface p4 type=gre options:key=flow \
310 options:remote_ip=4.4.4.4 ofport_request=4])
311 AT_DATA([flows.txt], [dnl
312 actions=set_tunnel:1,output:1,set_tunnel:2,output:2,set_tunnel:3,output:3,set_tunnel:5,output:4
313 ])
314
315 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
316 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
317
318 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
319 br0 65534/100: (dummy-internal)
320 p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
321 p2 2/1: (gre: key=flow, remote_ip=2.2.2.2)
322 p3 3/1: (gre: key=flow, remote_ip=3.3.3.3)
323 p4 4/1: (gre: key=flow, remote_ip=4.4.4.4)
324 ])
325
326 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(100),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
327 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
328 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
329 set(tunnel(tun_id=0x2,dst=2.2.2.2,ttl=64,flags(df|key))),1,dnl
330 set(tunnel(tun_id=0x3,dst=3.3.3.3,ttl=64,flags(df|key))),1,dnl
331 set(tunnel(tun_id=0x5,dst=4.4.4.4,ttl=64,flags(df|key))),1
332 ])
333 OVS_VSWITCHD_STOP
334 AT_CLEANUP
335
336 AT_SETUP([tunnel - key])
337 OVS_VSWITCHD_START([dnl
338 add-port br0 p1 -- set Interface p1 type=gre options:key=1 \
339 options:remote_ip=1.1.1.1 ofport_request=1 \
340 -- add-port br0 p2 -- set Interface p2 type=gre options:in_key=2 \
341 options:out_key=3 options:remote_ip=1.1.1.1 ofport_request=2 \
342 -- add-port br0 p3 -- set Interface p3 type=gre options:out_key=5 \
343 options:remote_ip=1.1.1.1 ofport_request=3])
344 AT_DATA([flows.txt], [dnl
345 actions=IN_PORT,output:1,output:2,output:3
346 ])
347
348 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
349 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
350
351 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
352 br0 65534/100: (dummy-internal)
353 p1 1/1: (gre: key=1, remote_ip=1.1.1.1)
354 p2 2/1: (gre: in_key=2, out_key=3, remote_ip=1.1.1.1)
355 p3 3/1: (gre: out_key=5, remote_ip=1.1.1.1)
356 ])
357
358 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=1.1.1.1,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
359 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
360 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
361 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
362 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1
363 ])
364
365 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x2,src=1.1.1.1,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
366 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
367 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
368 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
369 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1
370 ])
371
372 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(src=1.1.1.1,dst=2.2.2.2,ttl=64,flags()),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
373 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
374 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
375 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
376 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1
377 ])
378
379 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0xf,src=1.1.1.1,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [2], [ignore], [dnl
380 no OpenFlow tunnel port for this packet
381 ovs-appctl: ovs-vswitchd: server returned an error
382 ])
383 OVS_VSWITCHD_STOP(["/receive tunnel port not found/d"])
384 AT_CLEANUP
385
386 AT_SETUP([tunnel - key match])
387 OVS_VSWITCHD_START([dnl
388 add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
389 options:remote_ip=1.1.1.1 ofport_request=1 \
390 -- add-port br0 p2 -- set Interface p2 type=gre options:key=3 \
391 options:remote_ip=3.3.3.3 ofport_request=2 \
392 -- add-port br0 p3 -- set Interface p3 type=dummy ofport_request=3 \
393 -- add-port br0 p4 -- set Interface p4 type=dummy ofport_request=4 \
394 -- add-port br0 p5 -- set Interface p5 type=dummy ofport_request=5])
395 AT_DATA([flows.txt], [dnl
396 tun_id=2,actions=output:3
397 tun_id=3,actions=output:4,set_tunnel:2,resubmit:99,set_tunnel:4,output:2,resubmit:99
398 tun_id=4,actions=output:5
399 ])
400
401 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
402 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
403
404 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
405 br0 65534/100: (dummy-internal)
406 p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
407 p2 2/1: (gre: key=3, remote_ip=3.3.3.3)
408 p3 3/3: (dummy)
409 p4 4/4: (dummy)
410 p5 5/5: (dummy)
411 ])
412
413 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x2,src=1.1.1.1,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
414 AT_CHECK([tail -1 stdout], [0], [dnl
415 Datapath actions: 3
416 ])
417
418 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x3,src=1.1.1.1,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
419 AT_CHECK([tail -1 stdout], [0], [dnl
420 Datapath actions: 4,3,set(tunnel(tun_id=0x3,dst=3.3.3.3,ttl=64,flags(df|key))),1,5
421 ])
422
423 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x3,src=3.3.3.3,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
424 AT_CHECK([tail -1 stdout], [0], [dnl
425 Datapath actions: 4,3,5
426 ])
427
428 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,src=1.1.1.1,dst=2.2.2.2,ttl=64,flags(key)),in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout])
429 AT_CHECK([tail -1 stdout], [0], [dnl
430 Datapath actions: drop
431 ])
432
433 OVS_VSWITCHD_STOP
434 AT_CLEANUP
435
436 AT_SETUP([tunnel - Geneve])
437 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
438 options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=5000])
439
440 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
441 br0 65534/100: (dummy-internal)
442 p1 1/5000: (geneve: dst_port=5000, remote_ip=1.1.1.1)
443 ])
444
445 OVS_VSWITCHD_STOP
446 AT_CLEANUP
447
448 AT_SETUP([tunnel - VXLAN])
449 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
450 options:remote_ip=1.1.1.1 ofport_request=1])
451
452 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
453 br0 65534/100: (dummy-internal)
454 p1 1/4789: (vxlan: remote_ip=1.1.1.1)
455 ])
456
457 OVS_VSWITCHD_STOP
458 AT_CLEANUP
459
460 AT_SETUP([tunnel - table version])
461 dnl check if changes in the egress bridge flow table affects
462 dnl discovering the link layer address of tunnel endpoints.
463 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00])
464 AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy], [0])
465 AT_CHECK([ovs-vsctl add-port int-br v1 -- set Interface v1 type=vxlan \
466 options:remote_ip=172.31.1.2 options:key=123 \
467 ofport_request=2 \
468 -- add-port int-br v2 -- set Interface v2 type=internal \
469 ofport_request=3 \
470 ], [0])
471
472 AT_CHECK([ovs-appctl dpif/show], [0], [dnl
473 dummy@ovs-dummy: hit:0 missed:0
474 br0:
475 br0 65534/100: (dummy-internal)
476 p0 1/1: (dummy)
477 int-br:
478 int-br 65534/2: (dummy-internal)
479 v1 2/4789: (vxlan: key=123, remote_ip=172.31.1.2)
480 v2 3/3: (dummy-internal)
481 ])
482
483 dnl First setup dummy interface IP address, then add the route
484 dnl so that tnl-port table can get valid IP address for the device.
485 AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 172.31.1.1/24], [0], [OK
486 ])
487 AT_CHECK([ovs-appctl ovs/route/add 172.31.1.0/24 br0], [0], [OK
488 ])
489
490 dnl change the flow table to bump the internal table version
491 AT_CHECK([ovs-ofctl add-flow int-br action=normal])
492 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
493 AT_CHECK([ovs-ofctl del-flows br0])
494 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
495 AT_CHECK([ovs-ofctl del-flows br0])
496 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
497 AT_CHECK([ovs-ofctl del-flows br0])
498 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
499 AT_CHECK([ovs-ofctl del-flows br0])
500 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
501 AT_CHECK([ovs-ofctl del-flows br0])
502 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
503 AT_CHECK([ovs-ofctl del-flows br0])
504 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
505 AT_CHECK([ovs-ofctl del-flows br0])
506 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
507
508 dnl Check Neighbour discovery.
509 AT_CHECK([ovs-vsctl -- set Interface p0 options:pcap=p0.pcap])
510
511 AT_CHECK([ovs-appctl netdev-dummy/receive int-br 'in_port(2),eth(src=aa:55:aa:55:00:00,dst=f8:bc:12:ff:ff:ff),eth_type(0x0800),ipv4(src=1.1.3.92,dst=1.1.3.88,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'])
512 AT_CHECK([ovs-pcap p0.pcap > p0.pcap.txt 2>&1])
513
514 dnl When the wrong version is used, the flow is not visible and the
515 dnl packet is dropped.
516 AT_CHECK([cat p0.pcap.txt | grep ffffffffffffaa55aa55000008060001080006040001aa55aa550000ac1f0101000000000000ac1f0102 | uniq], [0], [dnl
517 ffffffffffffaa55aa55000008060001080006040001aa55aa550000ac1f0101000000000000ac1f0102
518 ])
519 OVS_VSWITCHD_STOP
520 AT_CLEANUP
521
522 AT_SETUP([tunnel - LISP])
523 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=lisp \
524 options:remote_ip=1.1.1.1 ofport_request=1])
525
526 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
527 br0 65534/100: (dummy-internal)
528 p1 1/4341: (lisp: remote_ip=1.1.1.1)
529 ])
530
531 OVS_VSWITCHD_STOP
532 AT_CLEANUP
533
534 AT_SETUP([tunnel - ERSPAN])
535 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=erspan \
536 options:remote_ip=1.1.1.1 options:key=1 options:erspan_ver=1 \
537 options:erspan_idx=0x0 ofport_request=1 \
538 -- add-port br0 p2 -- set Interface p2 type=erspan \
539 options:remote_ip=1.1.1.1 ofport_request=2 \
540 options:key=flow options:erspan_ver=1 options:erspan_idx=flow \
541 -- add-port br0 p3 -- set Interface p3 type=erspan \
542 options:remote_ip=1.1.1.1 ofport_request=3 \
543 options:key=10 options:erspan_ver=2 options:erspan_dir=flow \
544 options:erspan_hwid=flow \
545 -- add-port br0 p4 -- set Interface p4 type=erspan \
546 options:remote_ip=1.2.3.4 ofport_request=4 \
547 options:key=flow options:erspan_ver=flow\
548 ])
549
550 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
551 br0 65534/100: (dummy-internal)
552 p1 1/1: (erspan: erspan_idx=0x0, erspan_ver=1, key=1, remote_ip=1.1.1.1)
553 p2 2/1: (erspan: erspan_idx=flow, erspan_ver=1, key=flow, remote_ip=1.1.1.1)
554 p3 3/1: (erspan: erspan_dir=flow, erspan_hwid=flow, erspan_ver=2, key=10, remote_ip=1.1.1.1)
555 p4 4/1: (erspan: erspan_dir=flow, erspan_hwid=flow, erspan_idx=flow, erspan_ver=flow, key=flow, remote_ip=1.2.3.4)
556 ])
557
558 dnl Check ERSPAN v1 flow-based tunnel push
559 AT_CHECK([ovs-ofctl add-flow br0 "in_port=1, actions=set_tunnel:11,set_field:0x1->tun_erspan_idx,2"])
560
561 dnl Check ERSPAN v2 flow-based tunnel push
562 AT_CHECK([ovs-ofctl add-flow br0 "in_port=2, actions=set_field:1->tun_erspan_dir,set_field:0x0->tun_erspan_hwid,3"])
563
564 AT_CHECK([ovs-ofctl add-flow br0 "in_port=3, actions=set_field:2->tun_erspan_ver,set_field:1->tun_erspan_dir,set_field:0x0->tun_erspan_hwid,4"])
565
566 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip],
567 [0], [dnl
568 NXST_FLOW reply:
569 in_port=1 actions=set_tunnel:0xb,set_field:0x1->tun_erspan_idx,output:2
570 in_port=2 actions=set_field:1->tun_erspan_dir,set_field:0->tun_erspan_hwid,output:3
571 in_port=3 actions=set_field:2->tun_erspan_ver,set_field:1->tun_erspan_dir,set_field:0->tun_erspan_hwid,output:4
572 ])
573
574 OVS_VSWITCHD_STOP
575 AT_CLEANUP
576
577 AT_SETUP([tunnel - different VXLAN UDP port])
578 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
579 options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=4341])
580
581 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
582 br0 65534/100: (dummy-internal)
583 p1 1/4341: (vxlan: dst_port=4341, remote_ip=1.1.1.1)
584 ])
585
586 dnl change UDP port
587
588 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=5000])
589
590 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
591 br0 65534/100: (dummy-internal)
592 p1 1/5000: (vxlan: dst_port=5000, remote_ip=1.1.1.1)
593 ])
594
595 dnl change UDP port to default
596
597 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=4789])
598
599 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
600 br0 65534/100: (dummy-internal)
601 p1 1/4789: (vxlan: remote_ip=1.1.1.1)
602 ])
603 OVS_VSWITCHD_STOP
604 AT_CLEANUP
605
606 AT_SETUP([ofproto-dpif - set_field - tun_src/tun_dst/tun_id])
607 OVS_VSWITCHD_START([dnl
608 add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
609 options:remote_ip=1.1.1.1 ofport_request=1 \
610 -- add-port br0 p2 -- set Interface p2 type=gre options:key=flow \
611 options:remote_ip=flow ofport_request=2 \
612 -- add-port br0 p3 -- set Interface p3 type=gre options:key=flow \
613 options:remote_ip=flow options:local_ip=flow ofport_request=3 \
614 -- add-port br0 p4 -- set Interface p4 type=gre options:key=3 \
615 options:remote_ip=flow ofport_request=4 \
616 -- add-port br0 p5 -- set Interface p5 type=gre options:key=flow \
617 options:remote_ip=5.5.5.5 ofport_request=5])
618
619 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
620 add_of_ports br0 90
621 AT_DATA([flows.txt], [dnl
622 in_port=90 actions=resubmit:1,resubmit:2,resubmit:3,resubmit:4,resubmit:5
623 in_port=1 actions=set_field:42->tun_id,output:1
624 in_port=2 actions=set_field:3.3.3.3->tun_dst,output:2
625 in_port=3 actions=set_field:1.1.1.1->tun_src,set_field:4.4.4.4->tun_dst,output:3
626 in_port=4 actions=set_field:2.2.2.2->tun_dst,output:4
627 in_port=5 actions=set_field:5->tun_id
628 ])
629 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
630 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(90),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
631 AT_CHECK([tail -1 stdout], [0],
632 [Datapath actions: set(tunnel(tun_id=0x2a,dst=1.1.1.1,ttl=64,flags(df|key))),1,set(tunnel(tun_id=0x2a,dst=3.3.3.3,ttl=64,flags(df|key))),1,set(tunnel(tun_id=0x2a,src=1.1.1.1,dst=4.4.4.4,ttl=64,flags(df|key))),1,set(tunnel(tun_id=0x3,dst=2.2.2.2,ttl=64,flags(df|key))),1
633 ])
634 OVS_VSWITCHD_STOP
635 AT_CLEANUP
636
637 AT_SETUP([tunnel - ERSPAN v1/v2 metadata])
638 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy \
639 ofport_request=1 \
640 -- add-port br0 p2 -- set Interface p2 type=dummy \
641 ofport_request=2])
642
643 # Add these ports separately to ensure that they get the datapath port
644 # number expected below.
645 ovs-vsctl -- add-port br0 p3 \
646 -- set Interface p3 type=erspan \
647 ofport_request=3 \
648 options:remote_ip=1.1.1.1 \
649 options:key=1 options:erspan_ver=1 \
650 options:erspan_idx=7 \
651 -- add-port br0 p4 \
652 -- set Interface p4 type=erspan \
653 ofport_request=4 \
654 options:remote_ip=1.1.1.2 \
655 options:key=2 options:erspan_ver=2 \
656 options:erspan_dir=1 \
657 options:erspan_hwid=7
658 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
659
660 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
661 br0 65534/100: (dummy-internal)
662 p1 1/1: (dummy)
663 p2 2/2: (dummy)
664 p3 3/3: (erspan: erspan_idx=0x7, erspan_ver=1, key=1, remote_ip=1.1.1.1)
665 p4 4/3: (erspan: erspan_dir=1, erspan_hwid=0x7, erspan_ver=2, key=2, remote_ip=1.1.1.2)
666 ])
667
668 AT_DATA([flows.txt], [dnl
669 in_port=1,actions=3
670 in_port=2,actions=4
671 in_port=3,tun_erspan_ver=1,tun_erspan_idx=0x7,actions=1
672 in_port=4,tun_erspan_ver=2,tun_erspan_dir=1,tun_erspan_hwid=0xf/0x1,actions=2
673 ])
674 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
675
676 dnl test encap: in_port=1,actions=3 (erspan v1 port)
677 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
678 AT_CHECK([tail -1 stdout], [0],
679 [Datapath actions: set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,erspan(ver=1,idx=0x7),flags(df|key))),3
680 ])
681
682 dnl test encap: in_port=2,actions=4 (erspan v2 port)
683 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
684 AT_CHECK([tail -1 stdout], [0],
685 [Datapath actions: set(tunnel(tun_id=0x2,dst=1.1.1.2,ttl=64,erspan(ver=2,dir=1,hwid=0x7),flags(df|key))),3
686 ])
687
688 dnl receive packet from ERSPAN port with v1 metadata
689 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x1,src=1.1.1.1,dst=2.2.2.2,ttl=64,erspan(ver=1,idx=0x7),flags(df|key)),in_port(3),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
690 AT_CHECK([tail -2 stdout], [0],
691 [Megaflow: recirc_id=0,eth,ip,tun_id=0x1,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=0,tun_erspan_ver=1,tun_erspan_idx=0x7,tun_flags=+df-csum+key,in_port=3,nw_frag=no
692 Datapath actions: 1
693 ])
694
695 dnl receive packet from ERSPAN port with wrong v1 metadata
696 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x1,src=1.1.1.1,dst=2.2.2.2,ttl=64,erspan(ver=1,idx=0xabcd),flags(df|key)),in_port(3),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
697 AT_CHECK([tail -2 stdout], [0],
698 [Megaflow: recirc_id=0,eth,ip,tun_id=0x1,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=0,tun_erspan_ver=1,tun_erspan_idx=0xabcd,tun_flags=+df-csum+key,in_port=3,nw_frag=no
699 Datapath actions: drop
700 ])
701
702 dnl receive packet from ERSPAN port with v2 metadata
703 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x2,src=1.1.1.2,dst=2.2.2.2,ttl=64,erspan(ver=2,dir=1,hwid=0x7),flags(df|key)),in_port(3),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
704 AT_CHECK([tail -2 stdout], [0],
705 [Megaflow: recirc_id=0,eth,ip,tun_id=0x2,tun_src=1.1.1.2,tun_dst=2.2.2.2,tun_tos=0,tun_erspan_ver=2,tun_erspan_dir=1,tun_erspan_hwid=0x1,tun_flags=+df-csum+key,in_port=4,nw_frag=no
706 Datapath actions: 2
707 ])
708
709 dnl receive packet from ERSPAN port with wrong v2 metadata
710 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x2,src=1.1.1.2,dst=2.2.2.2,ttl=64,erspan(ver=2,dir=0,hwid=0x17),flags(df|key)),in_port(3),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
711 AT_CHECK([tail -2 stdout], [0],
712 [Megaflow: recirc_id=0,eth,ip,tun_id=0x2,tun_src=1.1.1.2,tun_dst=2.2.2.2,tun_tos=0,tun_erspan_ver=2,tun_erspan_dir=0,tun_erspan_hwid=0x1,tun_flags=+df-csum+key,in_port=4,nw_frag=no
713 Datapath actions: drop
714 ])
715
716 dnl test wildcard mask: recevie all v2 regardless of its metadata
717 AT_CHECK([ovs-ofctl del-flows br0 in_port=4,tun_erspan_ver=2,tun_erspan_dir=1,tun_erspan_hwid=0xf/0x1])
718 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,tun_erspan_ver=2,tun_erspan_dir=0/0,tun_erspan_hwid=0x0/0x0,actions=2])
719
720 AT_CHECK([ovs-ofctl --sort=in_port dump-flows br0 | ofctl_strip],
721 [0], [dnl
722 in_port=1 actions=output:3
723 in_port=2 actions=output:4
724 tun_erspan_ver=1,tun_erspan_idx=0x7,in_port=3 actions=output:1
725 tun_erspan_ver=2,in_port=4 actions=output:2
726 ])
727
728 dnl this time it won't drop
729 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x2,src=1.1.1.2,dst=2.2.2.2,ttl=64,erspan(ver=2,dir=0,hwid=0x17),flags(df|key)),in_port(3),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
730 AT_CHECK([tail -2 stdout], [0],
731 [Megaflow: recirc_id=0,eth,ip,tun_id=0x2,tun_src=1.1.1.2,tun_dst=2.2.2.2,tun_tos=0,tun_erspan_ver=2,tun_flags=+df-csum+key,in_port=4,nw_frag=no
732 Datapath actions: 2
733 ])
734
735 dnl flow-based erspan_idx options
736 AT_CHECK([ovs-vsctl add-port br0 p5 -- set Interface p5 type=erspan \
737 options:remote_ip=1.1.1.2 ofport_request=5 \
738 options:key=flow options:erspan_ver=1 options:erspan_idx=flow])
739
740 AT_CHECK([ovs-ofctl del-flows br0])
741 AT_CHECK([ovs-ofctl add-flow br0 "in_port=1, actions=set_tunnel:11,set_field:0x7->tun_erspan_idx,5"])
742
743 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip],
744 [0], [dnl
745 NXST_FLOW reply:
746 in_port=1 actions=set_tunnel:0xb,set_field:0x7->tun_erspan_idx,output:5
747 ])
748
749 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
750 AT_CHECK([tail -1 stdout], [0],
751 [Datapath actions: set(tunnel(tun_id=0xb,dst=1.1.1.2,ttl=64,erspan(ver=1,idx=0x7),flags(df|key))),3
752 ])
753
754 OVS_VSWITCHD_STOP
755 AT_CLEANUP
756
757 AT_SETUP([tunnel - Geneve metadata])
758 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
759 options:remote_ip=1.1.1.1 ofport_request=1 \
760 -- add-port br0 p2 -- set Interface p2 type=dummy \
761 ofport_request=2 ofport_request=2])
762 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
763
764 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0,{class=0xffff,type=1,len=8}->tun_metadata1"])
765
766 AT_DATA([flows.txt], [dnl
767 in_port=2,actions=set_field:0xa->tun_metadata0,set_field:0x1234567890abcdef->tun_metadata1,1
768 tun_metadata0=0xb/0xf,actions=2
769 ])
770 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
771
772 dnl Option generation
773 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
774 AT_CHECK([tail -1 stdout], [0],
775 [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0,len=4,0xa}{class=0xffff,type=0x1,len=8,0x1234567890abcdef}),flags(df))),6081
776 ])
777
778 dnl Option match
779 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0xb}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
780 AT_CHECK([tail -2 stdout], [0],
781 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata0=0xb/0xf,in_port=1,nw_frag=no
782 Datapath actions: 2
783 ])
784
785 dnl Skip unknown option
786 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0xb}{class=0xffff,type=2,len=4,0xc}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
787 AT_CHECK([tail -2 stdout], [0],
788 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata0=0xb/0xf,in_port=1,nw_frag=no
789 Datapath actions: 2
790 ])
791
792 dnl Check mapping table constraints
793 AT_CHECK([ovs-ofctl del-flows br0])
794 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=2,len=124}->tun_metadata2,{class=0xffff,type=3,len=124}->tun_metadata3"], [1], [ignore],
795 [OFPT_ERROR (xid=0x4): NXTTMFC_TABLE_FULL
796 NXT_TLV_TABLE_MOD (xid=0x4):
797 ADD mapping table:
798 class type length match field
799 ------ ---- ------ --------------
800 0xffff 0x2 124 tun_metadata2
801 0xffff 0x3 124 tun_metadata3
802 ])
803
804 AT_CHECK([ovs-ofctl add-flow br0 "tun_metadata0,tun_metadata0,actions=drop"], [1], [ignore],
805 [ovs-ofctl: field tun_metadata0 set multiple times
806 ])
807
808 AT_CHECK([ovs-ofctl add-flow br0 "tun_metadata0=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef,tun_metadata1=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef,tun_metadata2=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef,tun_metadata3=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef,tun_metadata4=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef,actions=drop"], [1], [ignore],
809 [ovs-ofctl: field tun_metadata4 exceeds maximum size for tunnel metadata (used 320, max 256)
810 ])
811
812 dnl Allocation and match with fragmented address space
813 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=2,len=124}->tun_metadata2"])
814 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata3"])
815 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=4,len=112}->tun_metadata4"])
816 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata3"])
817 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=8}->tun_metadata3"])
818
819 AT_CHECK([ovs-ofctl add-flow br0 tun_metadata3=0x1234567890abcdef,actions=2])
820 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=3,len=8,0x1234567890abcdef}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
821 AT_CHECK([tail -2 stdout], [0],
822 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata3=0x1234567890abcdef,in_port=1,nw_frag=no
823 Datapath actions: 2
824 ])
825
826 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip],
827 [0], [dnl
828 NXST_FLOW reply:
829 tun_metadata3=0x1234567890abcdef actions=output:2
830 ])
831
832 dnl A TLV mapping should not be removed if any active flow uses the mapping.
833 AT_CHECK([ovs-ofctl del-tlv-map br0], [1], [], [dnl
834 OFPT_ERROR (xid=0x4): NXTTMFC_INVALID_TLV_DEL
835 NXT_TLV_TABLE_MOD (xid=0x4):
836 CLEAR
837 ])
838
839 AT_CHECK([ovs-ofctl del-flows br0], [0])
840 AT_CHECK([ovs-ofctl del-tlv-map br0], [0])
841
842 dnl Flow modification
843 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=1,len=4}->tun_metadata0"])
844 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=2,len=4}->tun_metadata1"])
845 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata2"])
846
847 AT_CHECK([ovs-ofctl add-flow br0 "in_port=1 actions=multipath(eth_src,50,modulo_n,1,0,tun_metadata0[[0..31]])"])
848 AT_CHECK([ovs-ofctl add-flow br0 "in_port=2 actions=push:tun_metadata1[[0..31]],clone(move:tun_metadata2[[0..31]]->reg0[[0..31]])"])
849
850 AT_CHECK([ovs-ofctl add-flow br0 "in_port=1 actions=output:4"])
851 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata0"])
852
853 AT_CHECK([ovs-ofctl add-flow br0 "in_port=2 actions=push:tun_metadata2[[0..31]]"])
854 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=2,len=4}->tun_metadata1"])
855 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata2"], [1], [], [dnl
856 OFPT_ERROR (xid=0x4): NXTTMFC_INVALID_TLV_DEL
857 NXT_TLV_TABLE_MOD (xid=0x4):
858 DEL mapping table:
859 class type length match field
860 ------ ---- ------ --------------
861 0xffff 0x3 4 tun_metadata2
862 ])
863
864 AT_CHECK([ovs-ofctl del-flows br0], [0])
865 AT_CHECK([ovs-ofctl del-tlv-map br0], [0])
866
867 dnl Learn action
868 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=1,len=4}->tun_metadata1"])
869 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=2,len=4}->tun_metadata2"])
870 AT_CHECK([ovs-ofctl add-flow br0 "in_port=2, eth_src=00:00:00:00:00:01 actions=learn(tun_metadata1[[0..31]]=reg1, output:NXM_OF_IN_PORT[[]])"])
871 AT_CHECK([ovs-ofctl add-flow br0 "in_port=2, eth_src=00:00:00:00:00:02 actions=learn(reg1[[0..31]]=0xFF, load:reg1[[0..31]]->tun_metadata2[[0..31]])"])
872 flow1="in_port(2),eth(src=00:00:00:00:00:01,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0800)"
873 flow2="in_port(2),eth(src=00:00:00:00:00:02,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0800)"
874 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy "$flow1" -generate], [0], [stdout])
875 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy "$flow2" -generate], [0], [stdout])
876
877 dnl Delete flows with learn action
878 AT_CHECK([ovs-ofctl del-flows br0 "in_port=2"])
879
880 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=1,len=4}->tun_metadata1"], [1], [], [dnl
881 OFPT_ERROR (xid=0x4): NXTTMFC_INVALID_TLV_DEL
882 NXT_TLV_TABLE_MOD (xid=0x4):
883 DEL mapping table:
884 class type length match field
885 ------ ---- ------ --------------
886 0xffff 0x1 4 tun_metadata1
887 ])
888 AT_CHECK([ovs-ofctl del-flows br0 "tun_metadata1"])
889 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=1,len=4}->tun_metadata1"])
890
891 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=2,len=4}->tun_metadata2"], [1], [], [dnl
892 OFPT_ERROR (xid=0x4): NXTTMFC_INVALID_TLV_DEL
893 NXT_TLV_TABLE_MOD (xid=0x4):
894 DEL mapping table:
895 class type length match field
896 ------ ---- ------ --------------
897 0xffff 0x2 4 tun_metadata2
898 ])
899 AT_CHECK([ovs-ofctl del-flows br0 "reg1=0xFF"])
900 AT_CHECK([ovs-ofctl del-tlv-map br0], [0])
901
902 OVS_VSWITCHD_STOP
903 AT_CLEANUP
904
905 AT_SETUP([tunnel - Geneve option present])
906 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
907 options:remote_ip=1.1.1.1 ofport_request=1 \
908 -- add-port br0 p2 -- set Interface p2 type=dummy \
909 ofport_request=2 ofport_request=2])
910 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
911
912 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0,{class=0xffff,type=1,len=0}->tun_metadata1,{class=0xffff,type=2,len=4}->tun_metadata2"])
913
914 AT_DATA([flows.txt], [dnl
915 priority=1,tun_metadata0,actions=2
916 priority=2,tun_metadata1=0,actions=IN_PORT
917 priority=3,tun_metadata2=0,actions=drop
918 ])
919 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
920
921 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort],
922 [0], [dnl
923 priority=1,tun_metadata0 actions=output:2
924 priority=2,tun_metadata1 actions=IN_PORT
925 priority=3,tun_metadata2=0 actions=drop
926 NXST_FLOW reply:
927 ])
928
929 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x12345678}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
930 AT_CHECK([tail -2 stdout], [0],
931 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata0,tun_metadata1=NP,tun_metadata2=NP,in_port=1,nw_frag=no
932 Datapath actions: 2
933 ])
934
935 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=1,len=0}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
936 AT_CHECK([tail -2 stdout], [0],
937 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata1,tun_metadata2=NP,in_port=1,nw_ecn=0,nw_frag=no
938 Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0x1,len=0}),flags(df))),6081
939 ])
940
941 OVS_VSWITCHD_STOP
942 AT_CLEANUP
943
944 AT_SETUP([tunnel - Delete Geneve option])
945 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
946 options:remote_ip=1.1.1.1 ofport_request=1 \
947 -- add-port br0 p2 -- set Interface p2 type=dummy \
948 ofport_request=2 ofport_request=2])
949 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
950
951 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0,{class=0xffff,type=1,len=4}->tun_metadata1,{class=0xffff,type=2,len=4}->tun_metadata3"])
952
953 AT_DATA([flows.txt], [dnl
954 table=0,tun_metadata0=0x11112222,actions=set_field:0x55556666->tun_metadata1,resubmit(,1)
955 table=0,tun_metadata0=0x33334444,actions=delete_field:tun_metadata0,set_field:0x77778888->tun_metadata1,resubmit(,1)
956 table=0,tun_metadata0=0x88889999,actions=delete_field:tun_metadata3,resubmit(,1)
957 table=1,actions=IN_PORT
958 ])
959 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
960
961 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x11112222}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
962 AT_CHECK([tail -2 stdout], [0],
963 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata0=0x11112222,tun_metadata1=NP,in_port=1,nw_ecn=0,nw_frag=no
964 Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0,len=4,0x11112222}{class=0xffff,type=0x1,len=4,0x55556666}),flags(df))),6081
965 ])
966
967 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x33334444}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
968 AT_CHECK([tail -2 stdout], [0],
969 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata0=0x33334444,tun_metadata1=NP,in_port=1,nw_ecn=0,nw_frag=no
970 Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0x1,len=4,0x77778888}),flags(df))),6081
971 ])
972
973 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x88889999}),flags(df|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
974 AT_CHECK([tail -2 stdout], [0],
975 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=+df-csum+key,tun_metadata0=0x88889999,in_port=1,nw_ecn=0,nw_frag=no
976 Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0,len=4,0x88889999}),flags(df))),6081
977 ])
978 OVS_VSWITCHD_STOP
979 AT_CLEANUP
980
981 AT_SETUP([tunnel - concomitant IPv6 and IPv4 tunnels])
982 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
983 options:remote_ip=1.1.1.1 ofport_request=1 \
984 -- add-port br0 p2 -- set Interface p2 type=vxlan \
985 options:remote_ip=2001:cafe::1 ofport_request=2])
986 AT_DATA([flows.txt], [dnl
987 in_port=1,actions=2
988 in_port=2,actions=1
989 ])
990 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
991
992 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
993
994 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0,src=1.1.1.1,dst=1.1.1.2,ttl=64),in_port(4789)'], [0], [stdout])
995 AT_CHECK([tail -1 stdout], [0],
996 [Datapath actions: set(tunnel(ipv6_dst=2001:cafe::1,ttl=64,tp_dst=4789,flags(df))),4789
997 ])
998
999 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,ipv6_src=2001:cafe::1,ipv6_dst=2001:cafe::2,ttl=64),in_port(4789)'], [0], [stdout])
1000 AT_CHECK([tail -1 stdout], [0],
1001 [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,tp_dst=4789,flags(df))),4789
1002 ])
1003
1004 OVS_VSWITCHD_STOP
1005 AT_CLEANUP
1006
1007 AT_SETUP([tunnel - concomitant incompatible tunnels on the same port])
1008 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
1009 options:remote_ip=flow ofport_request=1])
1010
1011 AT_CHECK([ovs-vsctl add-port br0 p2 -- set Interface p2 type=vxlan \
1012 options:remote_ip=flow options:exts=gbp options:key=1 ofport_request=2], [0],
1013 [], [ignore])
1014
1015 AT_CHECK([grep 'p2: could not set configuration (File exists)' ovs-vswitchd.log | sed "s/^.*\(p2:.*\)$/\1/"], [0],
1016 [p2: could not set configuration (File exists)
1017 ])
1018
1019 OVS_VSWITCHD_STOP(["/p2: VXLAN-GBP, and non-VXLAN-GBP tunnels can't be configured on the same dst_port/d
1020 /p2: could not set configuration (File exists)/d"])
1021 AT_CLEANUP
1022
1023 AT_SETUP([tunnel - concomitant incompatible tunnels on different ports])
1024 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
1025 options:remote_ip=flow ofport_request=1])
1026
1027 AT_CHECK([ovs-vsctl add-port br0 p2 -- set Interface p2 type=vxlan options:dst_port=9000 \
1028 options:remote_ip=flow options:exts=gbp ofport_request=2])
1029
1030 AT_CHECK([grep p2 ovs-vswitchd.log | sed "s/^.*\(bridge br0:.*\)$/\1/"], [0],
1031 [bridge br0: added interface p2 on port 2
1032 ])
1033
1034 OVS_VSWITCHD_STOP
1035 AT_CLEANUP
1036
1037 AT_SETUP([tunnel - Mix Geneve/GRE options])
1038 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
1039 options:remote_ip=1.1.1.1 options:csum=true ofport_request=1 \
1040 -- add-port br0 p2 -- set Interface p2 type=dummy \
1041 ofport_request=2 ofport_request=2 \
1042 -- add-port br0 p3 -- set Interface p3 type=gre \
1043 options:remote_ip=2.2.2.2 options:csum=false options:key=123 ofport_request=3])
1044 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
1045
1046 AT_DATA([flows.txt], [dnl
1047 priority=1,in_port=1,actions=3
1048 ])
1049 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1050
1051 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort],
1052 [0], [dnl
1053 priority=1,in_port=1 actions=output:3
1054 NXST_FLOW reply:
1055 ])
1056
1057 dnl the input packet from geneve tunnel has flags(-df+csum+key) flags, making
1058 dnl sure that the output gre tunnel has (+df-csum+key).
1059 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x12345678}),flags(csum|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
1060 AT_CHECK([tail -2 stdout], [0],
1061 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=-df+csum+key,in_port=1,nw_ecn=0,nw_frag=no
1062 Datapath actions: set(tunnel(tun_id=0x7b,dst=2.2.2.2,ttl=64,flags(df|key))),1
1063 ])
1064
1065 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0"])
1066 AT_CHECK([ovs-ofctl del-flows br0])
1067
1068 AT_DATA([flows2.txt], [dnl
1069 priority=1,in_port=1,tun_metadata0=0x123, actions=3
1070 ])
1071 AT_CHECK([ovs-ofctl add-flows br0 flows2.txt])
1072
1073 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x0,src=1.1.1.1,dst=1.1.1.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x123}),flags(csum|key)),in_port(6081),skb_mark(0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(frag=no)'], [0], [stdout])
1074 AT_CHECK([tail -2 stdout], [0],
1075 [Megaflow: recirc_id=0,eth,ip,tun_id=0,tun_src=1.1.1.1,tun_dst=1.1.1.2,tun_tos=0,tun_flags=-df+csum+key,tun_metadata0=0x123,in_port=1,nw_ecn=0,nw_frag=no
1076 Datapath actions: set(tunnel(tun_id=0x7b,dst=2.2.2.2,ttl=64,flags(df|key))),1
1077 ])
1078
1079 dnl without the fix, the actions have geneve options:
1080 dnl set(tunnel(tun_id=0x7b,dst=2.2.2.2,ttl=64,geneve({class=0xffff,type=0,len=4,0x123}),flags(df|key))),1
1081 dnl which is not correct
1082
1083 OVS_VSWITCHD_STOP
1084 AT_CLEANUP
1085
1086 AT_SETUP([tunnel - neighbor entry add and deletion])
1087 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
1088 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
1089 options:key=5 ofport_request=1 \
1090 -- add-port br0 p2 -- set Interface p2 type=gre \
1091 options:local_ip=3.3.3.3 options:remote_ip=4.4.4.4 \
1092 ofport_request=2])
1093 AT_CHECK([ovs-vsctl add-br br1 -- set bridge br1 datapath_type=dummy], [0])
1094
1095 dnl Populate tunnel neighbor cache table
1096 AT_CHECK([
1097 ovs-appctl tnl/arp/set p1 10.0.0.1 00:00:10:00:00:01
1098 ovs-appctl tnl/arp/set p1 10.0.0.2 00:00:10:00:00:02
1099 ovs-appctl tnl/arp/set p2 10.0.1.1 00:00:10:00:01:01
1100 ovs-appctl tnl/arp/set br0 10.0.2.1 00:00:10:00:02:01
1101 ovs-appctl tnl/arp/set br0 10.0.2.2 00:00:10:00:02:02
1102 ovs-appctl tnl/arp/set br1 20.0.0.1 00:00:20:00:00:01
1103 ], [0], [stdout])
1104
1105 AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl
1106 10.0.0.1 00:00:10:00:00:01 p1
1107 10.0.0.2 00:00:10:00:00:02 p1
1108 10.0.1.1 00:00:10:00:01:01 p2
1109 10.0.2.1 00:00:10:00:02:01 br0
1110 10.0.2.2 00:00:10:00:02:02 br0
1111 20.0.0.1 00:00:20:00:00:01 br1
1112 ])
1113
1114 dnl neighbor table after deleting port p1
1115 AT_CHECK([ovs-vsctl del-port br0 p1],[0], [stdout])
1116 AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | grep -w p1 | sort], [0], [dnl
1117 ])
1118
1119 dnl neighbor table after deleting bridge br0
1120 AT_CHECK([ovs-vsctl del-br br0],[0], [stdout])
1121 AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl
1122 20.0.0.1 00:00:20:00:00:01 br1
1123 ])
1124
1125 dnl neighbor table after deleting bridge br1
1126 AT_CHECK([ovs-vsctl del-br br1],[0], [stdout])
1127 AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl
1128 ])
1129
1130 OVS_VSWITCHD_STOP
1131 AT_CLEANUP
1132
1133 AT_SETUP([tunnel - GTP-U basic])
1134 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gtpu \
1135 options:remote_ip=1.1.1.1 \
1136 options:key=123 ofport_request=1])
1137
1138 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
1139 br0 65534/100: (dummy-internal)
1140 p1 1/2152: (gtpu: key=123, remote_ip=1.1.1.1)
1141 ])
1142
1143 AT_CHECK([ovs-appctl tnl/ports/show |sort], [0], [dnl
1144 Listening ports:
1145 gtpu_sys_2152 (2152) ref_cnt=1
1146 ])
1147
1148 OVS_VSWITCHD_STOP
1149 AT_CLEANUP
1150
1151 AT_SETUP([tunnel - GTP-U push and pop])
1152 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy \
1153 ofport_request=1 \
1154 -- add-port br0 p2 -- set Interface p2 type=dummy \
1155 ofport_request=2])
1156
1157 # Add these ports separately to ensure that they get the datapath port
1158 # number expected below.
1159 ovs-vsctl -- add-port br0 p3 \
1160 -- set Interface p3 type=gtpu \
1161 ofport_request=3 \
1162 options:remote_ip=1.1.1.1 \
1163 options:key=3 \
1164 options:packet_type=legacy_l3
1165 ovs-vsctl -- add-port br0 p4 \
1166 -- set Interface p4 type=gtpu \
1167 ofport_request=4 \
1168 options:remote_ip=1.1.1.2 \
1169 options:key=4 \
1170 options:packet_type=legacy_l3
1171 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
1172
1173 dnl AT_CHECK([ovs-appctl dpif/show | tail -n +4], [0], [dnl
1174 AT_CHECK([ovs-appctl dpif/show | tail -n +4], [0], [dnl
1175 p1 1/1: (dummy)
1176 p2 2/2: (dummy)
1177 p3 3/2152: (gtpu: key=3, remote_ip=1.1.1.1)
1178 p4 4/2152: (gtpu: key=4, remote_ip=1.1.1.2)
1179 ])
1180
1181 AT_DATA([flows.txt], [dnl
1182 in_port=1,actions=3
1183 in_port=2,actions=4
1184 in_port=3,tun_gtpu_flags=0x30,tun_gtpu_msgtype=255,actions=1
1185 ])
1186 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1187
1188 AT_CHECK([ovs-appctl tnl/ports/show |sort], [0], [dnl
1189 Listening ports:
1190 gtpu_sys_2152 (2152) ref_cnt=2
1191 ])
1192
1193 dnl Encap: in_port=1,actions=3
1194 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
1195 AT_CHECK([tail -1 stdout], [0],
1196 [Datapath actions: set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,tp_dst=2152,flags(df|key))),pop_eth,2152
1197 ])
1198
1199 dnl receive packet from GTP-U port, match it, and output to layer3 GRE
1200 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'recirc_id(0),tunnel(tun_id=0x3,src=1.1.1.1,dst=2.2.2.2,ttl=64,gtpu(flags=0x30,msgtype=255),flags(df|key)),in_port(2152),packet_type(ns=1,id=0),skb_mark(0),ipv4(frag=no)'], [0], [stdout])
1201 AT_CHECK([tail -2 stdout], [0],
1202 [Megaflow: recirc_id=0,packet_type=(1,0),tun_id=0x3,tun_src=1.1.1.1,tun_dst=2.2.2.2,tun_tos=0,gtpu_flags=0x30,gtpu_msgtype=255,tun_flags=+df-csum+key,in_port=3,dl_type=0x0000
1203 Datapath actions: push_eth(src=00:00:00:00:00:00,dst=00:00:00:00:00:00),1
1204 ])
1205
1206 OVS_VSWITCHD_STOP
1207 AT_CLEANUP