]> git.proxmox.com Git - mirror_ovs.git/blob - tests/tunnel.at
1ba209dd4ce779622f19109375a7784e684ba2ae
[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 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-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,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,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,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: 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])
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-internal)
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 - unencrypted tunnel and not setting skb_mark])
146 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
147 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
148 options:key=5 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 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
155 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
156 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])
157 AT_CHECK([tail -1 stdout], [0],
158 [Datapath actions: set(tunnel(tun_id=0x5,src=2.2.2.2,dst=1.1.1.1,ttl=64,flags(df|key))),1
159 ])
160 OVS_VSWITCHD_STOP
161 AT_CLEANUP
162
163 AT_SETUP([tunnel - unencrypted tunnel and setting skb_mark to 1])
164 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
165 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
166 options:key=5 ofport_request=1\
167 -- add-port br0 p2 -- set Interface p2 type=dummy \
168 ofport_request=2 ofport_request=2])
169 AT_DATA([flows.txt], [dnl
170 actions=load:0x1->NXM_NX_PKT_MARK[[]],output:1
171 ])
172 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
173 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
174 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])
175 AT_CHECK([tail -1 stdout], [0],
176 [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
177 ])
178 OVS_VSWITCHD_STOP
179 AT_CLEANUP
180
181 AT_SETUP([tunnel - unencrypted tunnel and setting skb_mark to 2])
182 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
183 options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \
184 options:key=5 ofport_request=1\
185 -- add-port br0 p2 -- set Interface p2 type=dummy \
186 ofport_request=2 ofport_request=2])
187 AT_DATA([flows.txt], [dnl
188 actions=load:0x2->NXM_NX_PKT_MARK[[]],output:1
189 ])
190 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
191 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
192 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])
193 AT_CHECK([tail -1 stdout], [0],
194 [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
195 ])
196 OVS_VSWITCHD_STOP
197 AT_CLEANUP
198
199 AT_SETUP([tunnel - ToS and TTL inheritance])
200 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
201 options:remote_ip=1.1.1.1 options:tos=inherit \
202 options:ttl=inherit ofport_request=1 \
203 -- add-port br0 p2 -- set Interface p2 type=dummy \
204 ofport_request=2 ofport_request=2])
205 AT_DATA([flows.txt], [dnl
206 actions=output:1
207 ])
208
209 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
210 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
211
212 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
213 br0 65534/100: (dummy-internal)
214 p1 1/1: (gre: remote_ip=1.1.1.1, tos=inherit, ttl=inherit)
215 p2 2/2: (dummy)
216 ])
217
218 dnl Basic
219 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])
220 AT_CHECK([tail -1 stdout], [0],
221 [Datapath actions: set(tunnel(dst=1.1.1.1,tos=0x4,ttl=128,flags(df))),1
222 ])
223
224 dnl ECN
225 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])
226 AT_CHECK([tail -1 stdout], [0],
227 [Datapath actions: set(tunnel(dst=1.1.1.1,tos=0x5,ttl=128,flags(df))),1
228 ])
229
230 dnl non-IP
231 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])
232 AT_CHECK([tail -1 stdout], [0],
233 [Datapath actions: set(tunnel(dst=1.1.1.1,ttl=64,flags(df))),1
234 ])
235 OVS_VSWITCHD_STOP
236 AT_CLEANUP
237
238 AT_SETUP([tunnel - set_tunnel])
239 OVS_VSWITCHD_START([dnl
240 add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
241 options:remote_ip=1.1.1.1 ofport_request=1 \
242 -- add-port br0 p2 -- set Interface p2 type=gre options:key=flow \
243 options:remote_ip=2.2.2.2 ofport_request=2 \
244 -- add-port br0 p3 -- set Interface p3 type=gre options:key=flow \
245 options:remote_ip=3.3.3.3 ofport_request=3 \
246 -- add-port br0 p4 -- set Interface p4 type=gre options:key=flow \
247 options:remote_ip=4.4.4.4 ofport_request=4])
248 AT_DATA([flows.txt], [dnl
249 actions=set_tunnel:1,output:1,set_tunnel:2,output:2,set_tunnel:3,output:3,set_tunnel:5,output:4
250 ])
251
252 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
253 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
254
255 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
256 br0 65534/100: (dummy-internal)
257 p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
258 p2 2/1: (gre: key=flow, remote_ip=2.2.2.2)
259 p3 3/1: (gre: key=flow, remote_ip=3.3.3.3)
260 p4 4/1: (gre: key=flow, remote_ip=4.4.4.4)
261 ])
262
263 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])
264 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
265 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
266 set(tunnel(tun_id=0x2,dst=2.2.2.2,ttl=64,flags(df|key))),1,dnl
267 set(tunnel(tun_id=0x3,dst=3.3.3.3,ttl=64,flags(df|key))),1,dnl
268 set(tunnel(tun_id=0x5,dst=4.4.4.4,ttl=64,flags(df|key))),1
269 ])
270 OVS_VSWITCHD_STOP
271 AT_CLEANUP
272
273 AT_SETUP([tunnel - key])
274 OVS_VSWITCHD_START([dnl
275 add-port br0 p1 -- set Interface p1 type=gre options:key=1 \
276 options:remote_ip=1.1.1.1 ofport_request=1 \
277 -- add-port br0 p2 -- set Interface p2 type=gre options:in_key=2 \
278 options:out_key=3 options:remote_ip=1.1.1.1 ofport_request=2 \
279 -- add-port br0 p3 -- set Interface p3 type=gre options:out_key=5 \
280 options:remote_ip=1.1.1.1 ofport_request=3])
281 AT_DATA([flows.txt], [dnl
282 actions=IN_PORT,output:1,output:2,output:3
283 ])
284
285 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
286 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
287
288 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
289 br0 65534/100: (dummy-internal)
290 p1 1/1: (gre: key=1, remote_ip=1.1.1.1)
291 p2 2/1: (gre: in_key=2, out_key=3, remote_ip=1.1.1.1)
292 p3 3/1: (gre: out_key=5, remote_ip=1.1.1.1)
293 ])
294
295 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])
296 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
297 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
298 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
299 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1
300 ])
301
302 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])
303 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
304 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
305 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
306 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1
307 ])
308
309 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])
310 AT_CHECK([tail -1 stdout], [0], [Datapath actions: dnl
311 set(tunnel(tun_id=0x5,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
312 set(tunnel(tun_id=0x1,dst=1.1.1.1,ttl=64,flags(df|key))),1,dnl
313 set(tunnel(tun_id=0x3,dst=1.1.1.1,ttl=64,flags(df|key))),1
314 ])
315
316 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
317 Invalid datapath flow
318 ovs-appctl: ovs-vswitchd: server returned an error
319 ])
320 OVS_VSWITCHD_STOP(["/receive tunnel port not found/d"])
321 AT_CLEANUP
322
323 AT_SETUP([tunnel - key match])
324 OVS_VSWITCHD_START([dnl
325 add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
326 options:remote_ip=1.1.1.1 ofport_request=1 \
327 -- add-port br0 p2 -- set Interface p2 type=gre options:key=3 \
328 options:remote_ip=3.3.3.3 ofport_request=2 \
329 -- add-port br0 p3 -- set Interface p3 type=dummy ofport_request=3 \
330 -- add-port br0 p4 -- set Interface p4 type=dummy ofport_request=4 \
331 -- add-port br0 p5 -- set Interface p5 type=dummy ofport_request=5])
332 AT_DATA([flows.txt], [dnl
333 tun_id=2,actions=output:3
334 tun_id=3,actions=output:4,set_tunnel:2,resubmit:99,set_tunnel:4,output:2,resubmit:99
335 tun_id=4,actions=output:5
336 ])
337
338 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
339 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
340
341 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
342 br0 65534/100: (dummy-internal)
343 p1 1/1: (gre: key=flow, remote_ip=1.1.1.1)
344 p2 2/1: (gre: key=3, remote_ip=3.3.3.3)
345 p3 3/3: (dummy)
346 p4 4/4: (dummy)
347 p5 5/5: (dummy)
348 ])
349
350 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])
351 AT_CHECK([tail -1 stdout], [0], [dnl
352 Datapath actions: 3
353 ])
354
355 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])
356 AT_CHECK([tail -1 stdout], [0], [dnl
357 Datapath actions: 4,3,set(tunnel(tun_id=0x3,dst=3.3.3.3,ttl=64,flags(df|key))),1,5
358 ])
359
360 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])
361 AT_CHECK([tail -1 stdout], [0], [dnl
362 Datapath actions: 4,3,5
363 ])
364
365 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])
366 AT_CHECK([tail -1 stdout], [0], [dnl
367 Datapath actions: drop
368 ])
369
370 OVS_VSWITCHD_STOP
371 AT_CLEANUP
372
373 AT_SETUP([tunnel - Geneve])
374 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
375 options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=5000])
376
377 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
378 br0 65534/100: (dummy-internal)
379 p1 1/5000: (geneve: dst_port=5000, remote_ip=1.1.1.1)
380 ])
381
382 OVS_VSWITCHD_STOP
383 AT_CLEANUP
384
385 AT_SETUP([tunnel - VXLAN])
386 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
387 options:remote_ip=1.1.1.1 ofport_request=1])
388
389 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
390 br0 65534/100: (dummy-internal)
391 p1 1/4789: (vxlan: remote_ip=1.1.1.1)
392 ])
393
394 OVS_VSWITCHD_STOP
395 AT_CLEANUP
396
397 AT_SETUP([tunnel - LISP])
398 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=lisp \
399 options:remote_ip=1.1.1.1 ofport_request=1])
400
401 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
402 br0 65534/100: (dummy-internal)
403 p1 1/4341: (lisp: remote_ip=1.1.1.1)
404 ])
405
406 OVS_VSWITCHD_STOP
407 AT_CLEANUP
408
409 AT_SETUP([tunnel - different VXLAN UDP port])
410 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
411 options:remote_ip=1.1.1.1 ofport_request=1 options:dst_port=4341])
412
413 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
414 br0 65534/100: (dummy-internal)
415 p1 1/4341: (vxlan: dst_port=4341, remote_ip=1.1.1.1)
416 ])
417
418 dnl change UDP port
419
420 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=5000])
421
422 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
423 br0 65534/100: (dummy-internal)
424 p1 1/5000: (vxlan: dst_port=5000, remote_ip=1.1.1.1)
425 ])
426
427 dnl change UDP port to default
428
429 AT_CHECK([ovs-vsctl -- set Interface p1 options:dst_port=4789])
430
431 AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
432 br0 65534/100: (dummy-internal)
433 p1 1/4789: (vxlan: remote_ip=1.1.1.1)
434 ])
435 OVS_VSWITCHD_STOP
436 AT_CLEANUP
437
438 AT_SETUP([ofproto-dpif - set_field - tun_src/tun_dst/tun_id])
439 OVS_VSWITCHD_START([dnl
440 add-port br0 p1 -- set Interface p1 type=gre options:key=flow \
441 options:remote_ip=1.1.1.1 ofport_request=1 \
442 -- add-port br0 p2 -- set Interface p2 type=gre options:key=flow \
443 options:remote_ip=flow ofport_request=2 \
444 -- add-port br0 p3 -- set Interface p3 type=gre options:key=flow \
445 options:remote_ip=flow options:local_ip=flow ofport_request=3 \
446 -- add-port br0 p4 -- set Interface p4 type=gre options:key=3 \
447 options:remote_ip=flow ofport_request=4 \
448 -- add-port br0 p5 -- set Interface p5 type=gre options:key=flow \
449 options:remote_ip=5.5.5.5 ofport_request=5])
450
451 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
452 add_of_ports br0 90
453 AT_DATA([flows.txt], [dnl
454 in_port=90 actions=resubmit:1,resubmit:2,resubmit:3,resubmit:4,resubmit:5
455 in_port=1 actions=set_field:42->tun_id,output:1
456 in_port=2 actions=set_field:3.3.3.3->tun_dst,output:2
457 in_port=3 actions=set_field:1.1.1.1->tun_src,set_field:4.4.4.4->tun_dst,output:3
458 in_port=4 actions=set_field:2.2.2.2->tun_dst,output:4
459 in_port=5 actions=set_field:5->tun_id
460 ])
461 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
462 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])
463 AT_CHECK([tail -1 stdout], [0],
464 [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
465 ])
466 OVS_VSWITCHD_STOP
467 AT_CLEANUP
468
469 AT_SETUP([tunnel - Geneve metadata])
470 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
471 options:remote_ip=1.1.1.1 ofport_request=1 \
472 -- add-port br0 p2 -- set Interface p2 type=dummy \
473 ofport_request=2 ofport_request=2])
474 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
475
476 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=0,len=4}->tun_metadata0,{class=0xffff,type=1,len=8}->tun_metadata1"])
477
478 AT_DATA([flows.txt], [dnl
479 in_port=2,actions=set_field:0xa->tun_metadata0,set_field:0x1234567890abcdef->tun_metadata1,1
480 tun_metadata0=0xb/0xf,actions=2
481 ])
482 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
483
484 dnl Option generation
485 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])
486 AT_CHECK([tail -1 stdout], [0],
487 [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
488 ])
489
490 dnl Option match
491 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])
492 AT_CHECK([tail -2 stdout], [0],
493 [Megaflow: 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
494 Datapath actions: 2
495 ])
496
497 dnl Skip unknown option
498 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])
499 AT_CHECK([tail -2 stdout], [0],
500 [Megaflow: 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
501 Datapath actions: 2
502 ])
503
504 dnl Check mapping table constraints
505 AT_CHECK([ovs-ofctl del-flows br0])
506 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],
507 [OFPT_ERROR (xid=0x4): NXTTMFC_TABLE_FULL
508 NXT_TLV_TABLE_MOD (xid=0x4):
509 ADD mapping table:
510 class type length match field
511 ----- ---- ------ -----------
512 0xffff 0x2 124 tun_metadata2
513 0xffff 0x3 124 tun_metadata3
514 ])
515
516 AT_CHECK([ovs-ofctl add-flow br0 "tun_metadata0,tun_metadata0,actions=drop"], [1], [ignore],
517 [ovs-ofctl: field tun_metadata0 set multiple times
518 ])
519
520 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],
521 [ovs-ofctl: field tun_metadata4 exceeds maximum size for tunnel metadata (used 320, max 256)
522 ])
523
524 dnl Allocation and match with fragmented address space
525 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=2,len=124}->tun_metadata2"])
526 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata3"])
527 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=4,len=112}->tun_metadata4"])
528 AT_CHECK([ovs-ofctl del-tlv-map br0 "{class=0xffff,type=3,len=4}->tun_metadata3"])
529 AT_CHECK([ovs-ofctl add-tlv-map br0 "{class=0xffff,type=3,len=8}->tun_metadata3"])
530
531 AT_CHECK([ovs-ofctl add-flow br0 tun_metadata3=0x1234567890abcdef,actions=2])
532 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])
533 AT_CHECK([tail -2 stdout], [0],
534 [Megaflow: 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
535 Datapath actions: 2
536 ])
537
538 AT_CHECK([ovs-ofctl del-tlv-map br0])
539
540 OVS_VSWITCHD_STOP
541 AT_CLEANUP
542
543 AT_SETUP([tunnel - Geneve option present])
544 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=geneve \
545 options:remote_ip=1.1.1.1 ofport_request=1 \
546 -- add-port br0 p2 -- set Interface p2 type=dummy \
547 ofport_request=2 ofport_request=2])
548 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
549
550 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"])
551
552 AT_DATA([flows.txt], [dnl
553 priority=1,tun_metadata0,actions=2
554 priority=2,tun_metadata1=0,actions=IN_PORT
555 priority=3,tun_metadata2=0,actions=drop
556 ])
557 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
558
559 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort],
560 [0], [dnl
561 priority=1,tun_metadata0 actions=output:2
562 priority=2,tun_metadata1 actions=IN_PORT
563 priority=3,tun_metadata2=0 actions=drop
564 NXST_FLOW reply:
565 ])
566
567 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])
568 AT_CHECK([tail -2 stdout], [0],
569 [Megaflow: 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
570 Datapath actions: 2
571 ])
572
573 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])
574 AT_CHECK([tail -2 stdout], [0],
575 [Megaflow: 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
576 Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,tp_dst=6081,geneve({class=0xffff,type=0x1,len=0}),flags(df|key))),6081
577 ])
578
579 OVS_VSWITCHD_STOP
580 AT_CLEANUP
581
582 AT_SETUP([tunnel - concomitant IPv6 and IPv4 tunnels])
583 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=vxlan \
584 options:remote_ip=1.1.1.1 ofport_request=1 \
585 -- add-port br0 p2 -- set Interface p2 type=vxlan \
586 options:remote_ip=2001:cafe::1 ofport_request=2])
587 AT_DATA([flows.txt], [dnl
588 in_port=1,actions=2
589 in_port=2,actions=1
590 ])
591 OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP
592
593 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
594
595 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])
596 AT_CHECK([tail -1 stdout], [0],
597 [Datapath actions: set(tunnel(tun_id=0x0,ipv6_dst=2001:cafe::1,ttl=64,tp_dst=4789,flags(df|key))),4789
598 ])
599
600 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])
601 AT_CHECK([tail -1 stdout], [0],
602 [Datapath actions: set(tunnel(tun_id=0x0,dst=1.1.1.1,ttl=64,tp_dst=4789,flags(df|key))),4789
603 ])
604
605
606 OVS_VSWITCHD_STOP
607 AT_CLEANUP