ofpbuf: Fix trivial spelling typo.
[cascardo/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)
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)
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 Invalid datapath flow
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)
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: pkt_mark=0,recirc_id=0,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: pkt_mark=0,recirc_id=0,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: pkt_mark=0,recirc_id=0,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 -2 stdout], [0],
106   [Megaflow: pkt_mark=0,recirc_id=0,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
107 Datapath actions: drop
108 ])
109 OVS_VSWITCHD_STOP(["/dropping tunnel packet marked ECN CE but is not ECN capable/d"])
110 AT_CLEANUP
111
112 AT_SETUP([tunnel - output])
113 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
114                     options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
115                     options:key=5 ofport_request=1\
116                     -- add-port br0 p2 -- set Interface p2 type=dummy \
117                     ofport_request=2 ofport_request=2])
118 AT_DATA([flows.txt], [dnl
119 actions=output:1
120 ])
121
122 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
123 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
124
125 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
126                 br0 65534/100: (dummy)
127                 p1 1/1: (gre: key=5, local_ip=2.2.2.2, remote_ip=1.1.1.1)
128                 p2 2/2: (dummy)
129 ])
130
131 dnl Basic
132 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])
133 AT_CHECK([tail -1 stdout], [0],
134   [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df|key))),1
135 ])
136
137 dnl ECN
138 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])
139 AT_CHECK([tail -1 stdout], [0],
140   [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
141 ])
142 OVS_VSWITCHD_STOP
143 AT_CLEANUP
144
145 AT_SETUP([tunnel - ToS and TTL inheritance])
146 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
147                     options:remote_ip=1.1.1.1 options:tos=inherit \
148                     options:ttl=inherit ofport_request=1 \
149                     -- add-port br0 p2 -- set Interface p2 type=dummy \
150                     ofport_request=2 ofport_request=2])
151 AT_DATA([flows.txt], [dnl
152 actions=output:1
153 ])
154
155 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
156 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
157
158 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
159                 br0 65534/100: (dummy)
160                 p1 1/1: (gre: remote_ip=1.1.1.1, tos=inherit, ttl=inherit)
161                 p2 2/2: (dummy)
162 ])
163
164 dnl Basic
165 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])
166 AT_CHECK([tail -1 stdout], [0],
167   [Datapath actions: set(tunnel(dst=1.1.1.1,tos=0x4,ttl=128,flags(df))),1
168 ])
169
170 dnl ECN
171 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])
172 AT_CHECK([tail -1 stdout], [0],
173   [Datapath actions: set(tunnel(dst=1.1.1.1,tos=0x5,ttl=128,flags(df))),1
174 ])
175
176 dnl non-IP
177 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])
178 AT_CHECK([tail -1 stdout], [0],
179   [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,flags(df))),1
180 ])
181 OVS_VSWITCHD_STOP
182 AT_CLEANUP
183
184 AT_SETUP([tunnel - set_tunnel])
185 OVS_VSWITCHD_START([dnl
186     add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
187         options:remote_ip=1.1.1.1 ofport_request=1 \
188     -- add-port br0 p2 -- set Interface p2 type=gre options:key=flow \
189         options:remote_ip=2.2.2.2 ofport_request=2 \
190     -- add-port br0 p3 -- set Interface p3 type=gre options:key=flow \
191         options:remote_ip=3.3.3.3 ofport_request=3 \
192     -- add-port br0 p4 -- set Interface p4 type=gre options:key=flow \
193         options:remote_ip=4.4.4.4 ofport_request=4])
194 AT_DATA([flows.txt], [dnl
195 actions=set_tunnel:1,output:1,set_tunnel:2,output:2,set_tunnel:3,output:3,set_tunnel:5,output:4
196 ])
197
198 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
199 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
200
201 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
202                 br0 65534/100: (dummy)
203                 p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
204                 p2 2/1: (gre: key=flow, remote_ip=2.2.2.2)
205                 p3 3/1: (gre: key=flow, remote_ip=3.3.3.3)
206                 p4 4/1: (gre: key=flow, remote_ip=4.4.4.4)
207 ])
208
209 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])
210 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
211 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
212 set(tunnel(tun_id=0x2,dst=2.2.2.2,ttl=64,flags(df|key))),1,dnl
213 set(tunnel(tun_id=0x3,dst=3.3.3.3,ttl=64,flags(df|key))),1,dnl
214 set(tunnel(tun_id=0x5,dst=4.4.4.4,ttl=64,flags(df|key))),1
215 ])
216 OVS_VSWITCHD_STOP
217 AT_CLEANUP
218
219 AT_SETUP([tunnel - key])
220 OVS_VSWITCHD_START([dnl
221     add-port br0 p1 -- set Interface p1 type=gre options:key=1 \
222         options:remote_ip=1.1.1.1 ofport_request=1 \
223     -- add-port br0 p2 -- set Interface p2 type=gre options:in_key=2 \
224         options:out_key=3 options:remote_ip=1.1.1.1 ofport_request=2 \
225     -- add-port br0 p3 -- set Interface p3 type=gre options:out_key=5 \
226         options:remote_ip=1.1.1.1 ofport_request=3])
227 AT_DATA([flows.txt], [dnl
228 actions=IN_PORT,output:1,output:2,output:3
229 ])
230
231 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
232 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
233
234 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
235                 br0 65534/100: (dummy)
236                 p1 1/1: (gre: key=1, remote_ip=1.1.1.1)
237                 p2 2/1: (gre: in_key=2, out_key=3, remote_ip=1.1.1.1)
238                 p3 3/1: (gre: out_key=5, remote_ip=1.1.1.1)
239 ])
240
241 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])
242 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
243 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
244 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
245 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1
246 ])
247
248 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])
249 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
250 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
251 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
252 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1
253 ])
254
255 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])
256 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
257 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
258 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
259 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1
260 ])
261
262 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
263 Invalid datapath flow
264 ovs-appctl: ovs-vswitchd: server returned an error
265 ])
266 OVS_VSWITCHD_STOP(["/receive tunnel port not found/d"])
267 AT_CLEANUP
268
269 AT_SETUP([tunnel - key match])
270 OVS_VSWITCHD_START([dnl
271     add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
272         options:remote_ip=1.1.1.1 ofport_request=1 \
273     -- add-port br0 p2 -- set Interface p2 type=gre options:key=3 \
274         options:remote_ip=3.3.3.3 ofport_request=2 \
275     -- add-port br0 p3 -- set Interface p3 type=dummy ofport_request=3 \
276     -- add-port br0 p4 -- set Interface p4 type=dummy ofport_request=4 \
277     -- add-port br0 p5 -- set Interface p5 type=dummy ofport_request=5])
278 AT_DATA([flows.txt], [dnl
279 tun_id=2,actions=output:3
280 tun_id=3,actions=output:4,set_tunnel:2,resubmit:99,set_tunnel:4,output:2,resubmit:99
281 tun_id=4,actions=output:5
282 ])
283
284 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
285 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
286
287 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
288                 br0 65534/100: (dummy)
289                 p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
290                 p2 2/1: (gre: key=3, remote_ip=3.3.3.3)
291                 p3 3/3: (dummy)
292                 p4 4/4: (dummy)
293                 p5 5/5: (dummy)
294 ])
295
296 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])
297 AT_CHECK([tail -1 stdout], [0], [dnl
298 Datapath actions: 3
299 ])
300
301 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])
302 AT_CHECK([tail -1 stdout], [0], [dnl
303 Datapath actions: 4,3,set(tunnel(tun_id=0x3,dst=3.3.3.3,ttl=64,flags(df|key))),1,5
304 ])
305
306 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])
307 AT_CHECK([tail -1 stdout], [0], [dnl
308 Datapath actions: 4,3,5
309 ])
310
311 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])
312 AT_CHECK([tail -1 stdout], [0], [dnl
313 Datapath actions: drop
314 ])
315
316 OVS_VSWITCHD_STOP
317 AT_CLEANUP
318
319 AT_SETUP([tunnel - Geneve])
320 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
321                     options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=5000])
322
323 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
324                 br0 65534/100: (dummy)
325                 p1 1/5000: (geneve: dst_port=5000, remote_ip=1.1.1.1)
326 ])
327
328 OVS_VSWITCHD_STOP
329 AT_CLEANUP
330
331 AT_SETUP([tunnel - VXLAN])
332 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
333                     options:remote_ip=1.1.1.1 ofport_request=1])
334
335 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
336                 br0 65534/100: (dummy)
337                 p1 1/4789: (vxlan: remote_ip=1.1.1.1)
338 ])
339
340 OVS_VSWITCHD_STOP
341 AT_CLEANUP
342
343 AT_SETUP([tunnel - LISP])
344 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=lisp \
345                     options:remote_ip=1.1.1.1 ofport_request=1])
346
347 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
348                 br0 65534/100: (dummy)
349                 p1 1/4341: (lisp: remote_ip=1.1.1.1)
350 ])
351
352 OVS_VSWITCHD_STOP
353 AT_CLEANUP
354
355 AT_SETUP([tunnel - different VXLAN UDP port])
356 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
357                     options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=4341])
358
359 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
360                 br0 65534/100: (dummy)
361                 p1 1/4341: (vxlan: dst_port=4341, remote_ip=1.1.1.1)
362 ])
363
364 dnl change UDP port
365
366 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=5000])
367
368 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
369                 br0 65534/100: (dummy)
370                 p1 1/5000: (vxlan: dst_port=5000, remote_ip=1.1.1.1)
371 ])
372
373 dnl change UDP port to default
374
375 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=4789])
376
377 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
378                 br0 65534/100: (dummy)
379                 p1 1/4789: (vxlan: remote_ip=1.1.1.1)
380 ])
381 OVS_VSWITCHD_STOP
382 AT_CLEANUP
383
384 AT_SETUP([ofproto-dpif - set_field - tun_src/tun_dst/tun_id])
385 OVS_VSWITCHD_START([dnl
386     add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
387         options:remote_ip=1.1.1.1 ofport_request=1 \
388     -- add-port br0 p2 -- set Interface p2 type=gre options:key=flow \
389         options:remote_ip=flow ofport_request=2 \
390     -- add-port br0 p3 -- set Interface p3 type=gre options:key=flow \
391         options:remote_ip=flow options:local_ip=flow ofport_request=3 \
392     -- add-port br0 p4 -- set Interface p4 type=gre options:key=3 \
393         options:remote_ip=flow ofport_request=4 \
394     -- add-port br0 p5 -- set Interface p5 type=gre options:key=flow \
395         options:remote_ip=5.5.5.5 ofport_request=5])
396
397 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
398 add_of_ports br0 90
399 AT_DATA([flows.txt], [dnl
400 in_port=90 actions=resubmit:1,resubmit:2,resubmit:3,resubmit:4,resubmit:5
401 in_port=1 actions=set_field:42->tun_id,output:1
402 in_port=2 actions=set_field:3.3.3.3->tun_dst,output:2
403 in_port=3 actions=set_field:1.1.1.1->tun_src,set_field:4.4.4.4->tun_dst,output:3
404 in_port=4 actions=set_field:2.2.2.2->tun_dst,output:4
405 in_port=5 actions=set_field:5->tun_id
406 ])
407 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
408 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])
409 AT_CHECK([tail -1 stdout], [0],
410   [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
411 ])
412 OVS_VSWITCHD_STOP
413 AT_CLEANUP
414
415 AT_SETUP([tunnel - Geneve metadata])
416 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
417                     options:remote_ip=1.1.1.1 ofport_request=1 \
418                     -- add-port br0 p2 -- set Interface p2 type=dummy \
419                     ofport_request=2 ofport_request=2])
420 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
421
422 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0,{class=0xffff,type=1,len=8}->tun_metadata1"])
423
424 AT_DATA([flows.txt], [dnl
425 in_port=2,actions=set_field:0xa->tun_metadata0,set_field:0x1234567890abcdef->tun_metadata1,1
426 tun_metadata0=0xb/0xf,actions=2
427 ])
428 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
429
430 dnl Option generation
431 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])
432 AT_CHECK([tail -1 stdout], [0],
433   [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,geneve({class=0xffff,type=0,len=4,0xa}{class=0xffff,type=0x1,len=8,0x1234567890abcdef}),flags(df))),6081
434 ])
435
436 dnl Option match
437 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_type(0x0800),ipv4(frag=no)'], [0], [stdout])
438 AT_CHECK([tail -2 stdout], [0],
439   [Megaflow: pkt_mark=0,recirc_id=0,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
440 Datapath actions: 2
441 ])
442
443 dnl Skip unknown option
444 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_type(0x0800),ipv4(frag=no)'], [0], [stdout])
445 AT_CHECK([tail -2 stdout], [0],
446   [Megaflow: pkt_mark=0,recirc_id=0,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
447 Datapath actions: 2
448 ])
449
450 dnl Check mapping table constraints
451 AT_CHECK([ovs-ofctl del-flows br0])
452 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],
453 [OFPT_ERROR (xid=0x4): NXTTMFC_TABLE_FULL
454 NXT_TLV_TABLE_MOD (xid=0x4):
455  ADD mapping table:
456  class  type    length  match field
457  -----  ----    ------  -----------
458  0xffff 0x2     124     tun_metadata2
459  0xffff 0x3     124     tun_metadata3
460 ])
461
462 AT_CHECK([ovs-ofctl add-flow br0 "tun_metadata0,tun_metadata0,actions=drop"], [1], [ignore],
463 [ovs-ofctl: field tun_metadata0 set multiple times
464 ])
465
466 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],
467 [ovs-ofctl: field tun_metadata4 exceeds maximum size for tunnel metadata (used 320, max 256)
468 ])
469
470 dnl Allocation and match with fragmented address space
471 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=2,len=124}->tun_metadata2"])
472 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata3"])
473 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=4,len=112}->tun_metadata4"])
474 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata3"])
475 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=8}->tun_metadata3"])
476
477 AT_CHECK([ovs-ofctl add-flow br0 tun_metadata3=0x1234567890abcdef,actions=2])
478 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_type(0x0800),ipv4(frag=no)'], [0], [stdout])
479 AT_CHECK([tail -2 stdout], [0],
480   [Megaflow: pkt_mark=0,recirc_id=0,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
481 Datapath actions: 2
482 ])
483
484 AT_CHECK([ovs-ofctl del-tlv-map br0])
485
486 OVS_VSWITCHD_STOP
487 AT_CLEANUP
488
489 AT_SETUP([tunnel - Geneve option present])
490 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
491                     options:remote_ip=1.1.1.1 ofport_request=1 \
492                     -- add-port br0 p2 -- set Interface p2 type=dummy \
493                     ofport_request=2 ofport_request=2])
494 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
495
496 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"])
497
498 AT_DATA([flows.txt], [dnl
499 priority=1,tun_metadata0,actions=2
500 priority=2,tun_metadata1=0,actions=IN_PORT
501 priority=3,tun_metadata2=0,actions=drop
502 ])
503 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
504
505 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort],
506 [0], [dnl
507  priority=1,tun_metadata0 actions=output:2
508  priority=2,tun_metadata1 actions=IN_PORT
509  priority=3,tun_metadata2=0 actions=drop
510 NXST_FLOW reply:
511 ])
512
513 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_type(0x0800),ipv4(frag=no)'], [0], [stdout])
514 AT_CHECK([tail -2 stdout], [0],
515   [Megaflow: pkt_mark=0,recirc_id=0,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
516 Datapath actions: 2
517 ])
518
519 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_type(0x0800),ipv4(frag=no)'], [0], [stdout])
520 AT_CHECK([tail -2 stdout], [0],
521   [Megaflow: pkt_mark=0,recirc_id=0,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
522 Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,geneve({class=0xffff,type=0x1,len=0}),flags(df|key))),6081
523 ])
524
525 OVS_VSWITCHD_STOP
526 AT_CLEANUP