meta-flow: Correctly set destination MAC in mf_set_flow_value().
[sliver-openvswitch.git] / tests / ofproto-dpif.at
1 AT_BANNER([ofproto-dpif])
2
3 AT_SETUP([ofproto-dpif - resubmit])
4 OVS_VSWITCHD_START
5 AT_DATA([flows.txt], [dnl
6 table=0 in_port=1 priority=1000 icmp actions=output(10),resubmit(2),output(19),resubmit(3),output(21)
7 table=0 in_port=2 priority=1500 icmp actions=output(11),resubmit(,1),output(16),resubmit(2,1),output(18)
8 table=0 in_port=3 priority=2000 icmp actions=output(20)
9 table=1 in_port=1 priority=1000 icmp actions=output(12),resubmit(4,1),output(13),resubmit(3),output(15)
10 table=1 in_port=2 priority=1500 icmp actions=output(17),resubmit(,2)
11 table=1 in_port=3 priority=1500 icmp actions=output(14),resubmit(,2)
12 ])
13 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
14 AT_CHECK([ovs-appctl ofproto/trace br0 '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])
15 AT_CHECK([tail -1 stdout], [0],
16   [Datapath actions: 10,11,12,13,14,15,16,17,18,19,20,21
17 ])
18 OVS_VSWITCHD_STOP
19 AT_CLEANUP
20
21 AT_SETUP([ofproto-dpif - registers])
22 OVS_VSWITCHD_START
23 AT_DATA([flows.txt], [dnl
24 in_port=90                 actions=resubmit:2,resubmit:3,resubmit:4,resubmit:91
25 in_port=91                 actions=resubmit:5,resubmit:6,resubmit:7,resubmit:92
26 in_port=92                 actions=resubmit:8,resubmit:9,resubmit:10,resubmit:11
27 in_port=2                  actions=load:0x000db000->NXM_NX_REG0[[]]
28 in_port=3                  actions=load:0xdea->NXM_NX_REG0[[20..31]]
29 in_port=4                  actions=load:0xeef->NXM_NX_REG0[[0..11]]
30 in_port=5                  actions=move:NXM_NX_REG0[[]]->NXM_NX_REG1[[]]
31 in_port=6                  actions=load:0x22222222->NXM_NX_REG2[[]]
32 in_port=7                  actions=move:NXM_NX_REG1[[20..31]]->NXM_NX_REG2[[0..11]]
33 in_port=8                  actions=move:NXM_NX_REG1[[0..11]]->NXM_NX_REG2[[20..31]]
34 in_port=9,reg0=0xdeadbeef  actions=output:20
35 in_port=10,reg1=0xdeadbeef actions=output:21
36 in_port=11,reg2=0xeef22dea actions=output:22
37 ])
38 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
39 AT_CHECK([ovs-appctl ofproto/trace br0 '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])
40 AT_CHECK([tail -1 stdout], [0],
41   [Datapath actions: 20,21,22
42 ])
43 OVS_VSWITCHD_STOP
44 AT_CLEANUP
45
46 AT_SETUP([ofproto-dpif - output])
47 OVS_VSWITCHD_START
48 AT_DATA([flows.txt], [dnl
49 in_port=1 actions=resubmit:2,resubmit:3,resubmit:4,resubmit:5,resubmit:6,resubmit:7
50 in_port=2 actions=output:9
51 in_port=3 actions=load:55->NXM_NX_REG0[[]],output:NXM_NX_REG0[[]],load:66->NXM_NX_REG1[[]]
52 in_port=4 actions=output:10,output:NXM_NX_REG0[[]],output:NXM_NX_REG1[[]],output:11
53 in_port=5 actions=load:77->NXM_NX_REG0[[0..15]],load:88->NXM_NX_REG0[[16..31]]
54 in_port=6 actions=output:NXM_NX_REG0[[0..15]],output:NXM_NX_REG0[[16..31]]
55 in_port=7 actions=load:0x110000ff->NXM_NX_REG0[[]],output:NXM_NX_REG0[[]]
56 ])
57 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
58 AT_CHECK([ovs-appctl ofproto/trace br0 '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])
59 AT_CHECK([tail -1 stdout], [0],
60   [Datapath actions: 9,55,10,55,66,11,77,88
61 ])
62 OVS_VSWITCHD_STOP
63 AT_CLEANUP
64
65 AT_SETUP([ofproto-dpif - output, OFPP_NONE ingress port])
66 OVS_VSWITCHD_START(
67        [add-port br0 p1 -- set Interface p1 type=dummy --\
68         add-port br0 p2 -- set Interface p2 type=dummy])
69
70 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
71
72 # "in_port" defaults to OFPP_NONE if it's not specified.
73 flow="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)"
74 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
75 actual=`tail -1 stdout | sed 's/Datapath actions: //'`
76
77 expected="0,1,2"
78 AT_CHECK([ovs-dpctl normalize-actions "$flow" "$expected"], [0], [stdout])
79 mv stdout expout
80 AT_CHECK([ovs-dpctl normalize-actions "$flow" "$actual"], [0], [expout])
81
82 OVS_VSWITCHD_STOP
83 AT_CLEANUP
84
85 AT_SETUP([ofproto-dpif - DSCP])
86 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy])
87 AT_DATA([flows.txt], [dnl
88 actions=output:65534,enqueue:1:1,enqueue:1:2,enqueue:1:2,enqueue:1:1,output:1,mod_nw_tos:0,output:1,output:65534
89 ])
90 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
91 AT_CHECK([ovs-vsctl -- \
92         set Port p1 qos=@newqos --\
93         --id=@newqos create QoS type=linux-htb queues=1=@q1,2=@q2 --\
94         --id=@q1 create Queue dscp=1 --\
95         --id=@q2 create Queue dscp=2], [0], [ignore])
96 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(9),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xff,ttl=128,frag=no),icmp(type=8,code=0)'], [0], [stdout])
97 AT_CHECK([tail -1 stdout], [0],
98   [Datapath actions: dnl
99 0,dnl
100 set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x7,ttl=128,frag=no)),set(priority(1)),1,dnl
101 set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xb,ttl=128,frag=no)),set(priority(2)),1,dnl
102 1,dnl
103 set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x7,ttl=128,frag=no)),set(priority(1)),1,dnl
104 set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xff,ttl=128,frag=no)),set(priority(0)),1,dnl
105 set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x3,ttl=128,frag=no)),1,dnl
106 0
107 ])
108 OVS_VSWITCHD_STOP
109 AT_CLEANUP
110
111 AT_SETUP([ofproto-dpif - output/flood flags])
112 OVS_VSWITCHD_START([dnl
113         add-port br0 p1 -- set Interface p1 type=dummy --\
114         add-port br0 p2 -- set Interface p2 type=dummy --\
115         add-port br0 p3 -- set Interface p3 type=dummy --\
116         add-port br0 p4 -- set Interface p4 type=dummy --\
117         add-port br0 p5 -- set Interface p5 type=dummy --\
118         add-port br0 p6 -- set Interface p6 type=dummy --\
119         add-port br0 p7 -- set Interface p7 type=dummy ])
120
121 AT_DATA([flows.txt], [dnl
122 in_port=local actions=local,flood
123 in_port=1 actions=flood
124 in_port=2 actions=all
125 in_port=3 actions=output:65534,output:1,output:2,output:3,output:4,output:5,output:6,output:7
126 in_port=4 actions=enqueue:65534:1,enqueue:1:1,enqueue:2:1,enqueue:3:2,enqueue:4:1,enqueue:5:1,enqueue:6:1,enqueue:7:1
127 ])
128 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
129 AT_CHECK([ovs-ofctl mod-port br0 5 noforward])
130 AT_CHECK([ovs-ofctl mod-port br0 6 noflood])
131
132 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(0),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x0900)'], [0], [stdout])
133 AT_CHECK([tail -1 stdout \
134 | sed -e 's/Datapath actions: //' | tr ',' '\n' | sort], [0], [dnl
135 1
136 2
137 3
138 4
139 7
140 ])
141
142 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(1),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x0900)'], [0], [stdout])
143 AT_CHECK([tail -1 stdout \
144 | sed -e 's/Datapath actions: //' | tr ',' '\n' | sort], [0], [dnl
145 0
146 2
147 3
148 4
149 7
150 ])
151
152 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(2),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x0900)'], [0], [stdout])
153 AT_CHECK([tail -1 stdout \
154 | sed -e 's/Datapath actions: //' | tr ',' '\n' | sort], [0], [dnl
155 0
156 1
157 3
158 4
159 6
160 7
161 ])
162
163 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(3),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x0900)'], [0], [stdout])
164 AT_CHECK([tail -1 stdout], [0],
165   [Datapath actions: 0,1,2,4,6,7
166 ])
167
168 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(4),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x0900)'], [0], [stdout])
169 AT_CHECK([tail -1 stdout], [0],
170   [Datapath actions: set(priority(1)),0,1,2,set(priority(2)),3,set(priority(1)),6,7
171 ])
172 OVS_VSWITCHD_STOP
173 AT_CLEANUP
174
175 AT_SETUP([ofproto-dpif - set_tunnel])
176 OVS_VSWITCHD_START
177 AT_DATA([flows.txt], [dnl
178 in_port=90 actions=resubmit:1,resubmit:2,resubmit:3,resubmit:4,resubmit:5
179 in_port=1 actions=set_tunnel:1,output:1
180 in_port=2 actions=set_tunnel:1,output:2
181 in_port=3 actions=set_tunnel:2,set_tunnel:3,output:3
182 in_port=4 actions=set_tunnel:4,set_tunnel:3,output:4
183 in_port=5 actions=set_tunnel:5
184 ])
185 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
186 AT_CHECK([ovs-appctl ofproto/trace br0 'tun_id(0x1),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])
187 AT_CHECK([tail -1 stdout], [0],
188   [Datapath actions: set(tun_id(0x1)),1,2,set(tun_id(0x3)),3,4
189 ])
190 OVS_VSWITCHD_STOP
191 AT_CLEANUP
192
193 AT_SETUP([ofproto-dpif - controller])
194 OVS_VSWITCHD_START([dnl
195    add-port br0 p1 -- set Interface p1 type=dummy
196 ])
197
198 AT_CAPTURE_FILE([ofctl_monitor.log])
199 AT_DATA([flows.txt], [dnl
200 cookie=0x0 dl_src=10:11:11:11:11:11 actions=controller
201 cookie=0x1 dl_src=20:22:22:22:22:22 actions=controller,resubmit(80,1)
202 cookie=0x2 dl_src=30:33:33:33:33:33 actions=mod_vlan_vid:15,controller
203
204 cookie=0x3 table=1 in_port=80 actions=load:1->NXM_NX_REG0[[]],mod_vlan_vid:80,controller,resubmit(81,2)
205 cookie=0x4 table=2 in_port=81 actions=load:2->NXM_NX_REG1[[]],mod_dl_src:80:81:81:81:81:81,controller,resubmit(82,3)
206 cookie=0x5 table=3 in_port=82 actions=load:3->NXM_NX_REG2[[]],mod_dl_dst:82:82:82:82:82:82,controller,resubmit(83,4)
207 cookie=0x6 table=4 in_port=83 actions=load:4->NXM_NX_REG3[[]],mod_nw_src:83.83.83.83,controller,resubmit(84,5)
208 cookie=0x7 table=5 in_port=84 actions=load:5->NXM_NX_REG4[[]],load:6->NXM_NX_TUN_ID[[]],mod_nw_dst:84.84.84.84,controller,resubmit(85,6)
209 cookie=0x8 table=6 in_port=85 actions=mod_tp_src:85,controller,resubmit(86,7)
210 cookie=0x9 table=7 in_port=86 actions=mod_tp_dst:86,controller,controller
211 ])
212 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
213
214 dnl Flow miss.
215 AT_CHECK([ovs-ofctl monitor -P openflow10 br0 65534 --detach --pidfile 2> ofctl_monitor.log])
216
217 for i in 1 2 3 ; do
218     ovs-appctl netdev-dummy/receive p1 '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)'
219 done
220
221 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
222 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
223 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=1 data_len=60 (unbuffered)
224 priority:0,tunnel:0,in_port:0000,tci(0) mac(50:54:00:00:00:05->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->9) tcp_csum:0
225 dnl
226 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=1 data_len=60 (unbuffered)
227 priority:0,tunnel:0,in_port:0000,tci(0) mac(50:54:00:00:00:05->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->9) tcp_csum:0
228 dnl
229 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=1 data_len=60 (unbuffered)
230 priority:0,tunnel:0,in_port:0000,tci(0) mac(50:54:00:00:00:05->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->9) tcp_csum:0
231 ])
232
233 dnl Singleton controller action.
234 AT_CHECK([ovs-ofctl monitor -P openflow10 br0 65534 --detach --pidfile 2> ofctl_monitor.log])
235
236 for i in 1 2 3 ; do
237     ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=10:11:11:11:11:11,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=10)'
238 done
239
240 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
241 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
242 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=1 (via action) data_len=60 (unbuffered)
243 priority:0,tunnel:0,in_port:0000,tci(0) mac(10:11:11:11:11:11->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->10) tcp_csum:0
244 dnl
245 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=1 (via action) data_len=60 (unbuffered)
246 priority:0,tunnel:0,in_port:0000,tci(0) mac(10:11:11:11:11:11->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->10) tcp_csum:0
247 dnl
248 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=1 (via action) data_len=60 (unbuffered)
249 priority:0,tunnel:0,in_port:0000,tci(0) mac(10:11:11:11:11:11->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->10) tcp_csum:0
250 ])
251
252 dnl Modified controller action.
253 AT_CHECK([ovs-ofctl monitor -P openflow10 br0 65534 --detach --pidfile 2> ofctl_monitor.log])
254
255 for i in 1 2 3 ; do
256     ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=30:33:33:33:33:33,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=10)'
257 done
258
259 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
260 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
261 OFPT_PACKET_IN (xid=0x0): total_len=64 in_port=1 (via action) data_len=64 (unbuffered)
262 priority:0,tunnel:0,in_port:0000,tci(vlan:15,pcp:0) mac(30:33:33:33:33:33->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->10) tcp_csum:0
263 dnl
264 OFPT_PACKET_IN (xid=0x0): total_len=64 in_port=1 (via action) data_len=64 (unbuffered)
265 priority:0,tunnel:0,in_port:0000,tci(vlan:15,pcp:0) mac(30:33:33:33:33:33->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->10) tcp_csum:0
266 dnl
267 OFPT_PACKET_IN (xid=0x0): total_len=64 in_port=1 (via action) data_len=64 (unbuffered)
268 priority:0,tunnel:0,in_port:0000,tci(vlan:15,pcp:0) mac(30:33:33:33:33:33->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->10) tcp_csum:0
269 ])
270
271 dnl Checksum TCP.
272 AT_CHECK([ovs-ofctl monitor br0 65534 -P nxm --detach --pidfile 2> ofctl_monitor.log])
273
274 for i in 1 ; do
275     ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=20:22:22:22:22:22,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=11)'
276 done
277
278 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
279 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
280 NXT_PACKET_IN (xid=0x0): cookie=0x1 total_len=60 in_port=1 tun_id=0x0 reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 (via action) data_len=60 (unbuffered)
281 priority:0,tunnel:0,in_port:0000,tci(0) mac(20:22:22:22:22:22->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) tcp_csum:0
282 dnl
283 NXT_PACKET_IN (xid=0x0): table_id=1 cookie=0x3 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 (via action) data_len=64 (unbuffered)
284 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(20:22:22:22:22:22->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) tcp_csum:0
285 dnl
286 NXT_PACKET_IN (xid=0x0): table_id=2 cookie=0x4 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x2 reg2=0x0 reg3=0x0 reg4=0x0 (via action) data_len=64 (unbuffered)
287 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->50:54:00:00:00:07) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) tcp_csum:0
288 dnl
289 NXT_PACKET_IN (xid=0x0): table_id=3 cookie=0x5 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x0 reg4=0x0 (via action) data_len=64 (unbuffered)
290 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:6 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) tcp_csum:0
291 dnl
292 NXT_PACKET_IN (xid=0x0): table_id=4 cookie=0x6 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x0 (via action) data_len=64 (unbuffered)
293 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:6 tos:0 ttl:0 ip(83.83.83.83->192.168.0.2) port(8->11) tcp_csum:1a03
294 dnl
295 NXT_PACKET_IN (xid=0x0): table_id=5 cookie=0x7 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
296 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:6 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(8->11) tcp_csum:3205
297 dnl
298 NXT_PACKET_IN (xid=0x0): table_id=6 cookie=0x8 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
299 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:6 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(85->11) tcp_csum:31b8
300 dnl
301 NXT_PACKET_IN (xid=0x0): table_id=7 cookie=0x9 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
302 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:6 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(85->86) tcp_csum:316d
303 dnl
304 NXT_PACKET_IN (xid=0x0): table_id=7 cookie=0x9 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
305 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:6 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(85->86) tcp_csum:316d
306 ])
307
308 dnl Checksum UDP.
309 AT_CHECK([ovs-ofctl monitor br0 65534 --detach --pidfile 2> ofctl_monitor.log])
310
311 for i in 1 ; do
312     ovs-appctl netdev-dummy/receive p1 '50 54 00 00 00 07 20 22 22 22 22 22 08 00 45 00 00 1C 00 00 00 00 00 11 00 00 C0 A8 00 01 C0 A8 00 02 00 08 00 0B 00 00 12 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
313 done
314
315 OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])
316 AT_CHECK([cat ofctl_monitor.log], [0], [dnl
317 NXT_PACKET_IN (xid=0x0): cookie=0x1 total_len=60 in_port=1 tun_id=0x0 reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 (via action) data_len=60 (unbuffered)
318 priority:0,tunnel:0,in_port:0000,tci(0) mac(20:22:22:22:22:22->50:54:00:00:00:07) type:0800 proto:17 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) udp_csum:1234
319 dnl
320 NXT_PACKET_IN (xid=0x0): table_id=1 cookie=0x3 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 (via action) data_len=64 (unbuffered)
321 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(20:22:22:22:22:22->50:54:00:00:00:07) type:0800 proto:17 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) udp_csum:1234
322 dnl
323 NXT_PACKET_IN (xid=0x0): table_id=2 cookie=0x4 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x2 reg2=0x0 reg3=0x0 reg4=0x0 (via action) data_len=64 (unbuffered)
324 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->50:54:00:00:00:07) type:0800 proto:17 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) udp_csum:1234
325 dnl
326 NXT_PACKET_IN (xid=0x0): table_id=3 cookie=0x5 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x0 reg4=0x0 (via action) data_len=64 (unbuffered)
327 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:17 tos:0 ttl:0 ip(192.168.0.1->192.168.0.2) port(8->11) udp_csum:1234
328 dnl
329 NXT_PACKET_IN (xid=0x0): table_id=4 cookie=0x6 total_len=64 in_port=1 tun_id=0x0 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x0 (via action) data_len=64 (unbuffered)
330 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:17 tos:0 ttl:0 ip(83.83.83.83->192.168.0.2) port(8->11) udp_csum:2c37
331 dnl
332 NXT_PACKET_IN (xid=0x0): table_id=5 cookie=0x7 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
333 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:17 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(8->11) udp_csum:4439
334 dnl
335 NXT_PACKET_IN (xid=0x0): table_id=6 cookie=0x8 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
336 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:17 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(85->11) udp_csum:43ec
337 dnl
338 NXT_PACKET_IN (xid=0x0): table_id=7 cookie=0x9 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
339 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:17 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(85->86) udp_csum:43a1
340 dnl
341 NXT_PACKET_IN (xid=0x0): table_id=7 cookie=0x9 total_len=64 in_port=1 tun_id=0x6 reg0=0x1 reg1=0x2 reg2=0x3 reg3=0x4 reg4=0x5 (via action) data_len=64 (unbuffered)
342 priority:0,tunnel:0,in_port:0000,tci(vlan:80,pcp:0) mac(80:81:81:81:81:81->82:82:82:82:82:82) type:0800 proto:17 tos:0 ttl:0 ip(83.83.83.83->84.84.84.84) port(85->86) udp_csum:43a1
343 ])
344
345 AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_DURATION | sort], [0], [dnl
346  cookie=0x0, duration=?s, table=0, n_packets=3, n_bytes=180, dl_src=10:11:11:11:11:11 actions=CONTROLLER:65535
347  cookie=0x1, duration=?s, table=0, n_packets=2, n_bytes=120, dl_src=20:22:22:22:22:22 actions=CONTROLLER:65535,resubmit(80,1)
348  cookie=0x2, duration=?s, table=0, n_packets=3, n_bytes=180, dl_src=30:33:33:33:33:33 actions=mod_vlan_vid:15,CONTROLLER:65535
349  cookie=0x3, duration=?s, table=1, n_packets=2, n_bytes=120, in_port=80 actions=load:0x1->NXM_NX_REG0[[]],mod_vlan_vid:80,CONTROLLER:65535,resubmit(81,2)
350  cookie=0x4, duration=?s, table=2, n_packets=2, n_bytes=120, in_port=81 actions=load:0x2->NXM_NX_REG1[[]],mod_dl_src:80:81:81:81:81:81,CONTROLLER:65535,resubmit(82,3)
351  cookie=0x5, duration=?s, table=3, n_packets=2, n_bytes=120, in_port=82 actions=load:0x3->NXM_NX_REG2[[]],mod_dl_dst:82:82:82:82:82:82,CONTROLLER:65535,resubmit(83,4)
352  cookie=0x6, duration=?s, table=4, n_packets=2, n_bytes=120, in_port=83 actions=load:0x4->NXM_NX_REG3[[]],mod_nw_src:83.83.83.83,CONTROLLER:65535,resubmit(84,5)
353  cookie=0x7, duration=?s, table=5, n_packets=2, n_bytes=120, in_port=84 actions=load:0x5->NXM_NX_REG4[[]],load:0x6->NXM_NX_TUN_ID[[]],mod_nw_dst:84.84.84.84,CONTROLLER:65535,resubmit(85,6)
354  cookie=0x8, duration=?s, table=6, n_packets=2, n_bytes=120, in_port=85 actions=mod_tp_src:85,CONTROLLER:65535,resubmit(86,7)
355  cookie=0x9, duration=?s, table=7, n_packets=2, n_bytes=120, in_port=86 actions=mod_tp_dst:86,CONTROLLER:65535,CONTROLLER:65535
356 NXST_FLOW reply (xid=0x4):
357 ])
358
359 OVS_VSWITCHD_STOP
360 AT_CLEANUP
361
362 AT_SETUP([ofproto-dpif - VLAN handling])
363 OVS_VSWITCHD_START(
364   [set Bridge br0 fail-mode=standalone -- \
365    add-port br0 p1                                  trunks=10,12 -- \
366    add-port br0 p2                           tag=10              -- \
367    add-port br0 p3                           tag=12              \
368                    other-config:priority-tags=true               -- \
369    add-port br0 p4                           tag=12              -- \
370    add-port br0 p5 vlan_mode=native-tagged   tag=10              -- \
371    add-port br0 p6 vlan_mode=native-tagged   tag=10 trunks=10,12 -- \
372    add-port br0 p7 vlan_mode=native-untagged tag=12              -- \
373    add-port br0 p8 vlan_mode=native-untagged tag=12 trunks=10,12 \
374                    other-config:priority-tags=true               -- \
375    set Interface p1 type=dummy -- \
376    set Interface p2 type=dummy -- \
377    set Interface p3 type=dummy -- \
378    set Interface p4 type=dummy -- \
379    set Interface p5 type=dummy -- \
380    set Interface p6 type=dummy -- \
381    set Interface p7 type=dummy -- \
382    set Interface p8 type=dummy --])
383
384 dnl Each of these specifies an in_port by number, a VLAN VID (or "none"),
385 dnl a VLAN PCP (used if the VID isn't "none") and the expected set of datapath
386 dnl actions.
387 for tuple in \
388         "0 none 0 drop" \
389         "0 0    0 drop" \
390         "0 0    1 drop" \
391         "0 10   0 1,5,6,7,8,pop_vlan,2" \
392         "0 10   1 1,5,6,7,8,pop_vlan,2" \
393         "0 11   0 5,7" \
394         "0 11   1 5,7" \
395         "0 12   0 1,5,6,pop_vlan,3,4,7,8" \
396         "0 12   1 1,5,6,pop_vlan,4,7,push_vlan(vid=0,pcp=1),3,8" \
397         "1  none 0 drop" \
398         "1  0    0 drop" \
399         "1  0    1 drop" \
400         "1  10   0 0,5,6,7,8,pop_vlan,2" \
401         "1  10   1 0,5,6,7,8,pop_vlan,2" \
402         "1  11   0 drop" \
403         "1  11   1 drop" \
404         "1  12   0 0,5,6,pop_vlan,3,4,7,8" \
405         "1  12   1 0,5,6,pop_vlan,4,7,push_vlan(vid=0,pcp=1),3,8" \
406         "2  none 0 push_vlan(vid=10,pcp=0),0,1,5,6,7,8" \
407         "2  0    0 pop_vlan,push_vlan(vid=10,pcp=0),0,1,5,6,7,8" \
408         "2  0    1 pop_vlan,push_vlan(vid=10,pcp=1),0,1,5,6,7,8" \
409         "2  10   0 drop" \
410         "2  10   1 drop" \
411         "2  11   0 drop" \
412         "2  11   1 drop" \
413         "2  12   0 drop" \
414         "2  12   1 drop" \
415         "3  none 0 4,7,8,push_vlan(vid=12,pcp=0),0,1,5,6" \
416         "3  0    0 pop_vlan,4,7,8,push_vlan(vid=12,pcp=0),0,1,5,6" \
417         "3  0    1 8,pop_vlan,4,7,push_vlan(vid=12,pcp=1),0,1,5,6" \
418         "3  10   0 drop" \
419         "3  10   1 drop" \
420         "3  11   0 drop" \
421         "3  11   1 drop" \
422         "3  12   0 drop" \
423         "3  12   1 drop" \
424         "4  none 0 3,7,8,push_vlan(vid=12,pcp=0),0,1,5,6" \
425         "4  0    0 pop_vlan,3,7,8,push_vlan(vid=12,pcp=0),0,1,5,6" \
426         "4  0    1 3,8,pop_vlan,7,push_vlan(vid=12,pcp=1),0,1,5,6" \
427         "4  10   0 drop" \
428         "4  10   1 drop" \
429         "4  11   0 drop" \
430         "4  11   1 drop" \
431         "4  12   0 drop" \
432         "4  12   1 drop" \
433         "5  none 0 2,push_vlan(vid=10,pcp=0),0,1,6,7,8" \
434         "5  0    0 pop_vlan,2,push_vlan(vid=10,pcp=0),0,1,6,7,8" \
435         "5  0    1 pop_vlan,2,push_vlan(vid=10,pcp=1),0,1,6,7,8" \
436         "5  10   0 0,1,6,7,8,pop_vlan,2" \
437         "5  10   1 0,1,6,7,8,pop_vlan,2" \
438         "5  11   0 0,7" \
439         "5  11   1 0,7" \
440         "5  12   0 0,1,6,pop_vlan,3,4,7,8" \
441         "5  12   1 0,1,6,pop_vlan,4,7,push_vlan(vid=0,pcp=1),3,8" \
442         "6  none 0 2,push_vlan(vid=10,pcp=0),0,1,5,7,8" \
443         "6  0    0 pop_vlan,2,push_vlan(vid=10,pcp=0),0,1,5,7,8" \
444         "6  0    1 pop_vlan,2,push_vlan(vid=10,pcp=1),0,1,5,7,8" \
445         "6  10   0 0,1,5,7,8,pop_vlan,2" \
446         "6  10   1 0,1,5,7,8,pop_vlan,2" \
447         "6  11   0 drop" \
448         "6  11   1 drop" \
449         "6  12   0 0,1,5,pop_vlan,3,4,7,8" \
450         "6  12   1 0,1,5,pop_vlan,4,7,push_vlan(vid=0,pcp=1),3,8" \
451         "7  none 0 3,4,8,push_vlan(vid=12,pcp=0),0,1,5,6" \
452         "7  0    0 pop_vlan,3,4,8,push_vlan(vid=12,pcp=0),0,1,5,6" \
453         "7  0    1 3,8,pop_vlan,4,push_vlan(vid=12,pcp=1),0,1,5,6" \
454         "7  10   0 0,1,5,6,8,pop_vlan,2" \
455         "7  10   1 0,1,5,6,8,pop_vlan,2" \
456         "7  11   0 0,5" \
457         "7  11   1 0,5" \
458         "7  12   0 0,1,5,6,pop_vlan,3,4,8" \
459         "7  12   1 0,1,5,6,pop_vlan,4,push_vlan(vid=0,pcp=1),3,8" \
460         "8  none 0 3,4,7,push_vlan(vid=12,pcp=0),0,1,5,6" \
461         "8  0    0 pop_vlan,3,4,7,push_vlan(vid=12,pcp=0),0,1,5,6" \
462         "8  0    1 3,pop_vlan,4,7,push_vlan(vid=12,pcp=1),0,1,5,6" \
463         "8  10   0 0,1,5,6,7,pop_vlan,2" \
464         "8  10   1 0,1,5,6,7,pop_vlan,2" \
465         "8  11   0 drop" \
466         "8  11   1 drop" \
467         "8  12   0 0,1,5,6,pop_vlan,3,4,7" \
468         "8  12   1 0,1,5,6,pop_vlan,4,7,push_vlan(vid=0,pcp=1),3"
469 do
470   set $tuple
471   in_port=$1
472   vlan=$2
473   pcp=$3
474   expected=$4
475
476   if test $vlan = none; then
477     flow="in_port($in_port),eth(src=50:54:00:00:00:01,dst=ff:ff:ff:ff:ff:ff),eth_type(0xabcd)"
478   else
479     flow="in_port($in_port),eth(src=50:54:00:00:00:01,dst=ff:ff:ff:ff:ff:ff),eth_type(0x8100),vlan(vid=$vlan,pcp=$pcp),encap(eth_type(0xabcd))"
480   fi
481
482   echo "----------------------------------------------------------------------"
483   echo "in_port=$in_port vlan=$vlan pcp=$pcp"
484
485   AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
486   actual=`tail -1 stdout | sed 's/Datapath actions: //'`
487
488   AT_CHECK([ovs-dpctl normalize-actions "$flow" "$expected"], [0], [stdout])
489   mv stdout expout
490   AT_CHECK([ovs-dpctl normalize-actions "$flow" "$actual"], [0], [expout])
491 done
492
493 OVS_VSWITCHD_STOP
494 AT_CLEANUP
495
496 AT_SETUP([ofproto-dpif - fragment handling])
497 OVS_VSWITCHD_START
498 AT_DATA([flows.txt], [dnl
499 priority=75 tcp ip_frag=no    tp_dst=80 actions=output:1
500 priority=75 tcp ip_frag=first tp_dst=80 actions=output:2
501 priority=75 tcp ip_frag=later tp_dst=80 actions=output:3
502 priority=50 tcp ip_frag=no              actions=output:4
503 priority=50 tcp ip_frag=first           actions=output:5
504 priority=50 tcp ip_frag=later           actions=output:6
505 ])
506 AT_CHECK([ovs-ofctl replace-flows br0 flows.txt])
507
508 base_flow="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=6,tos=0,ttl=128"
509 no_flow="$base_flow,frag=no),tcp(src=12345,dst=80)"
510 first_flow="$base_flow,frag=first),tcp(src=12345,dst=80)"
511 later_flow="$base_flow,frag=later)"
512
513     # mode    no  first  later
514 for tuple in \
515     'normal    1     5      6' \
516     'drop      1  drop   drop' \
517     'nx-match  1     2      6'
518 do
519   set $tuple
520   mode=$1
521   no=$2
522   first=$3
523   later=$4
524
525   AT_CHECK([ovs-ofctl set-frags br0 $mode])
526   for type in no first later; do
527     eval flow=\$${type}_flow exp_output=\$$type
528     AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
529     AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $exp_output
530 ])
531   done
532 done
533 OVS_VSWITCHD_STOP
534 AT_CLEANUP
535
536 AT_SETUP([ofproto-dpif - exit])
537 OVS_VSWITCHD_START
538 AT_DATA([flows.txt], [dnl
539 in_port=1 actions=output:10,exit,output:11
540 in_port=2 actions=output:12,resubmit:1,output:12
541 in_port=3 actions=output:13,resubmit:2,output:14
542 ])
543 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
544 AT_CHECK([ovs-appctl ofproto/trace br0 '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])
545 AT_CHECK([tail -1 stdout], [0],
546   [Datapath actions: 10
547 ])
548 AT_CHECK([ovs-appctl ofproto/trace br0 '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])
549 AT_CHECK([tail -1 stdout], [0],
550   [Datapath actions: 12,10
551 ])
552 AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(3),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])
553 AT_CHECK([tail -1 stdout], [0],
554   [Datapath actions: 13,12,10
555 ])
556 OVS_VSWITCHD_STOP
557 AT_CLEANUP
558
559
560 AT_SETUP([ofproto-dpif - mirroring, select_all])
561 OVS_VSWITCHD_START(
562        [add-port br0 p1 -- set Interface p1 type=dummy --\
563         add-port br0 p2 -- set Interface p2 type=dummy --\
564         add-port br0 p3 -- set Interface p3 type=dummy --\
565         set Bridge br0 mirrors=@m --\
566         --id=@p3 get Port p3 --\
567         --id=@m create Mirror name=mymirror \
568         select_all=true output_port=@p3], [<0>
569 ])
570
571 AT_DATA([flows.txt], [dnl
572 in_port=1 actions=output:2
573 in_port=2 actions=output:1
574 ])
575 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
576
577 flow="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)"
578 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
579 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
580   [Datapath actions: 2,3
581 ])
582
583 flow="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)"
584 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
585 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
586   [Datapath actions: 1,3
587 ])
588
589 OVS_VSWITCHD_STOP
590 AT_CLEANUP
591
592
593 AT_SETUP([ofproto-dpif - mirroring, select_src])
594 OVS_VSWITCHD_START(
595        [add-port br0 p1 -- set Interface p1 type=dummy --\
596         add-port br0 p2 -- set Interface p2 type=dummy --\
597         add-port br0 p3 -- set Interface p3 type=dummy --\
598         set Bridge br0 mirrors=@m --\
599         --id=@p1 get Port p1 -- --id=@p3 get Port p3 --\
600         --id=@m create Mirror name=mymirror \
601         select_src_port=@p1 output_port=@p3], [<0>
602 ])
603
604 AT_DATA([flows.txt], [dnl
605 in_port=1 actions=output:2
606 in_port=2 actions=output:1
607 ])
608 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
609
610 flow="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)"
611 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
612 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
613   [Datapath actions: 2,3
614 ])
615
616 flow="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)"
617 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
618 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
619   [Datapath actions: 1
620 ])
621 OVS_VSWITCHD_STOP
622 AT_CLEANUP
623
624 AT_SETUP([ofproto-dpif - mirroring, OFPP_NONE ingress port])
625 OVS_VSWITCHD_START(
626        [add-port br0 p1 -- set Interface p1 type=dummy --\
627         add-port br0 p2 -- set Interface p2 type=dummy --\
628         set Bridge br0 mirrors=@m --\
629         --id=@p2 get Port p2 --\
630         --id=@m create Mirror name=mymirror \
631         select_all=true output_port=@p2], [<0>
632 ])
633
634 AT_CHECK([ovs-ofctl add-flow br0 action=output:1])
635
636 # "in_port" defaults to OFPP_NONE if it's not specified.
637 flow="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)"
638 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
639 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
640   [Datapath actions: 1,2
641 ])
642
643 OVS_VSWITCHD_STOP
644 AT_CLEANUP
645
646
647 AT_SETUP([ofproto-dpif - mirroring, select_dst])
648 OVS_VSWITCHD_START(
649        [add-port br0 p1 -- set Interface p1 type=dummy --\
650         add-port br0 p2 -- set Interface p2 type=dummy --\
651         add-port br0 p3 -- set Interface p3 type=dummy --\
652         set Bridge br0 mirrors=@m --\
653         --id=@p2 get Port p2 -- --id=@p3 get Port p3 --\
654         --id=@m create Mirror name=mymirror \
655         select_dst_port=@p2 output_port=@p3], [<0>
656 ])
657
658 AT_DATA([flows.txt], [dnl
659 in_port=1 actions=output:2
660 in_port=2 actions=output:1
661 ])
662 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
663
664 flow="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)"
665 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
666 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
667   [Datapath actions: 2,3
668 ])
669
670 flow="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)"
671 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
672 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
673   [Datapath actions: 1
674 ])
675
676 OVS_VSWITCHD_STOP
677 AT_CLEANUP
678
679
680 AT_SETUP([ofproto-dpif - mirroring, select_vlan])
681 OVS_VSWITCHD_START(
682        [add-port br0 p1 -- set Interface p1 type=dummy --\
683         add-port br0 p2 -- set Interface p2 type=dummy --\
684         add-port br0 p3 -- set Interface p3 type=dummy --\
685         set Bridge br0 mirrors=@m --\
686         --id=@p2 get Port p2 -- --id=@p3 get Port p3 --\
687         --id=@m create Mirror name=mymirror \
688         select_all=true select_vlan=11 output_port=@p3], [<0>
689 ])
690
691 AT_DATA([flows.txt], [dnl
692 in_port=1, actions=output:2
693 ])
694 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
695
696 flow="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)"
697 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
698 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
699   [Datapath actions: 2
700 ])
701
702 flow="in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x8100),vlan(vid=10,pcp=0),encap(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))"
703 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
704 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
705   [Datapath actions: 2
706 ])
707
708 flow="in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x8100),vlan(vid=11,pcp=0),encap(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))"
709 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
710 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
711   [Datapath actions: 2,3
712 ])
713
714 OVS_VSWITCHD_STOP
715 AT_CLEANUP
716
717
718 AT_SETUP([ofproto-dpif - mirroring, output_port])
719 OVS_VSWITCHD_START(
720        [add-port br0 p1 -- set Interface p1 type=dummy --\
721         add-port br0 p2 -- set Interface p2 type=dummy --\
722         add-port br0 p3 -- set Interface p3 type=dummy --\
723         set Bridge br0 mirrors=@m --\
724         --id=@p3 get Port p3 --\
725         --id=@m create Mirror name=mymirror \
726         select_all=true output_port=@p3], [<0>
727 ])
728
729 AT_DATA([flows.txt], [dnl
730 in_port=1 actions=mod_vlan_vid:17,output:2
731 in_port=2 actions=output:1
732 ])
733 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
734
735 flow="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)"
736 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
737 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
738   [Datapath actions: push_vlan(vid=17,pcp=0),2,pop_vlan,3
739 ])
740
741 flow="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)"
742 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
743 AT_CHECK_UNQUOTED([tail -1 stdout], [0],
744   [Datapath actions: 1,3
745 ])
746
747 OVS_VSWITCHD_STOP
748 AT_CLEANUP
749
750 AT_SETUP([ofproto-dpif - mirroring, output_vlan])
751 OVS_VSWITCHD_START(
752        [add-port br0 p1 -- set Interface p1 type=dummy --\
753         add-port br0 p2 -- set Interface p2 type=dummy --\
754         set Bridge br0 mirrors=@m --\
755         --id=@m create Mirror name=mymirror \
756         select_all=true output_vlan=12], [<0>
757 ])
758
759 AT_DATA([flows.txt], [dnl
760 in_port=1 actions=output:2
761 in_port=2 actions=mod_vlan_vid:17,output:1
762 ])
763 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
764
765 flow="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)"
766 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
767 actual=`tail -1 stdout | sed 's/Datapath actions: //'`
768
769 expected="2,push_vlan(vid=12,pcp=0),0,1,2"
770 AT_CHECK([ovs-dpctl normalize-actions "$flow" "$expected"], [0], [stdout])
771 mv stdout expout
772 AT_CHECK([ovs-dpctl normalize-actions "$flow" "$actual"], [0], [expout])
773
774 flow="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)"
775 AT_CHECK([ovs-appctl ofproto/trace br0 "$flow"], [0], [stdout])
776 actual=`tail -1 stdout | sed 's/Datapath actions: //'`
777
778 expected="push_vlan(vid=17,pcp=0),1,pop_vlan,push_vlan(vid=12,pcp=0),0,1,2"
779 AT_CHECK([ovs-dpctl normalize-actions "$flow" "$expected"], [0], [stdout])
780 mv stdout expout
781 AT_CHECK([ovs-dpctl normalize-actions "$flow" "$actual"], [0], [expout])
782
783 OVS_VSWITCHD_STOP
784 AT_CLEANUP
785
786 m4_define([OFPROTO_TRACE],
787   [flow="$2"
788    AT_CHECK([ovs-appctl ofproto/trace $1 "$flow" $3], [0], [stdout])
789    actual=`tail -1 stdout | sed 's/Datapath actions: //'`
790    expected="$4"
791    AT_CHECK([ovs-dpctl normalize-actions "$flow" "$expected" $5],
792      [0], [stdout])
793    mv stdout expout
794    AT_CHECK([ovs-dpctl normalize-actions "$flow" "$actual" $5],
795      [0], [expout])])
796
797 AT_SETUP([ofproto-dpif - MAC learning])
798 OVS_VSWITCHD_START(
799   [set bridge br0 fail-mode=standalone -- \
800    add-port br0 p1 -- set Interface p1 type=dummy -- \
801    add-port br0 p2 -- set Interface p2 type=dummy -- \
802    add-port br0 p3 -- set Interface p3 type=dummy])
803
804 arp='eth_type(0x0806),arp(sip=192.168.0.1,tip=192.168.0.2,op=1,sha=50:54:00:00:00:05,tha=00:00:00:00:00:00)'
805
806 # Trace an ARP packet arriving on p3, to create a MAC learning entry.
807 OFPROTO_TRACE(
808   [br0],
809   [in_port(3),eth(src=50:54:00:00:00:05,dst=ff:ff:ff:ff:ff:ff),$arp],
810   [-generate],
811   [0,1,2])
812
813 # Check for the MAC learning entry.
814 AT_CHECK_UNQUOTED([ovs-appctl fdb/show br0 | sed 's/[[0-9]]$/?/'], [0], [dnl
815  port  VLAN  MAC                Age
816     3     0  50:54:00:00:00:05    ?
817 ])
818
819 # Trace a packet arrival destined for the learned MAC.
820 # (This will also learn a MAC.)
821 OFPROTO_TRACE(
822   [br0],
823   [in_port(1),eth(src=50:54:00:00:00:06,dst=50:54:00:00:00:05),$arp],
824   [-generate],
825   [3])
826
827 # Check for both MAC learning entries.
828 AT_CHECK_UNQUOTED([ovs-appctl fdb/show br0 | sed 's/[[0-9]]$/?/'], [0], [dnl
829  port  VLAN  MAC                Age
830     3     0  50:54:00:00:00:05    ?
831     1     0  50:54:00:00:00:06    ?
832 ])
833
834 # Trace a packet arrival that updates the first learned MAC entry.
835 OFPROTO_TRACE(
836   [br0],
837   [in_port(2),eth(src=50:54:00:00:00:05,dst=ff:ff:ff:ff:ff:ff),$arp],
838   [-generate],
839   [0,1,3])
840
841 # Check that the MAC learning entry was updated.
842 AT_CHECK_UNQUOTED([ovs-appctl fdb/show br0 | sed 's/[[0-9]]$/?/'], [0], [dnl
843  port  VLAN  MAC                Age
844     1     0  50:54:00:00:00:06    ?
845     2     0  50:54:00:00:00:05    ?
846 ])
847
848 # Add another bridge.
849 AT_CHECK(
850   [ovs-vsctl \
851      -- add-br br1 \
852      -- set bridge br1 datapath-type=dummy \
853      -- add-port br1 p4 -- set interface p4 type=dummy \
854      -- add-port br1 p5 -- set interface p5 type=dummy])
855
856 # Trace some packet arrivals in br1 to create MAC learning entries there too.
857 OFPROTO_TRACE(
858   [br1],
859   [in_port(4),eth(src=50:54:00:00:00:06,dst=ff:ff:ff:ff:ff:ff),$arp],
860   [-generate],
861   [0,5])
862 OFPROTO_TRACE(
863   [br1],
864   [in_port(5),eth(src=50:54:00:00:00:07,dst=ff:ff:ff:ff:ff:ff),$arp],
865   [-generate],
866   [0,4])
867
868 # Check that the MAC learning entries were added.
869 AT_CHECK_UNQUOTED([ovs-appctl fdb/show br1 | sed 's/[[0-9]]$/?/'], [0], [dnl
870  port  VLAN  MAC                Age
871     4     0  50:54:00:00:00:06    ?
872     5     0  50:54:00:00:00:07    ?
873 ])
874
875 # Delete port p1 and see that its MAC learning entry disappeared, and
876 # that the MAC learning entry for the same MAC was also deleted from br1.
877 AT_CHECK([ovs-vsctl del-port p1])
878 AT_CHECK_UNQUOTED([ovs-appctl fdb/show br0 | sed 's/[[0-9]]$/?/'], [0], [dnl
879  port  VLAN  MAC                Age
880     2     0  50:54:00:00:00:05    ?
881 ])
882 AT_CHECK_UNQUOTED([ovs-appctl fdb/show br1 | sed 's/[[0-9]]$/?/'], [0], [dnl
883  port  VLAN  MAC                Age
884     5     0  50:54:00:00:00:07    ?
885 ])
886
887 OVS_VSWITCHD_STOP
888 AT_CLEANUP
889
890 dnl Test that basic NetFlow reports flow statistics correctly:
891 dnl - The initial packet of a flow are correctly accounted.
892 dnl - Later packets within a flow are correctly accounted.
893 dnl - Flow actions changing (in this case, due to MAC learning)
894 dnl   cause a record to be sent.
895 AT_SETUP([ofproto-dpif - NetFlow flow expiration])
896
897 AT_SKIP_IF([test "x$RANDOM" = x])
898 NETFLOW_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
899
900 OVS_VSWITCHD_START(
901   [set Bridge br0 fail-mode=standalone -- \
902    add-port br0 p1 -- set Interface p1 type=dummy -- \
903    add-port br0 p2 -- set Interface p2 type=dummy -- \
904    set Bridge br0 netflow=@nf -- \
905    --id=@nf create NetFlow targets=\"127.0.0.1:$NETFLOW_PORT\" \
906      engine_id=1 engine_type=2 active_timeout=30 \
907      add-id-to-interface=false], [<0>
908 ])
909
910 AT_CHECK([test-netflow --detach --pidfile $NETFLOW_PORT:127.0.0.1 > netflow.log])AT_CAPTURE_FILE([netflow.log])
911
912 for delay in 1000 30000; do
913     ovs-appctl netdev-dummy/receive p1 '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=64,frag=no),icmp(type=8,code=0)'
914     ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)'
915
916     ovs-appctl time/warp $delay
917 done
918
919 OVS_VSWITCHD_STOP
920 ovs-appctl -t test-netflow exit
921
922 AT_CHECK([[sed -e 's/, uptime [0-9]*//
923 s/, now [0-9.]*//
924 s/time \([0-9]*\)\.\.\.\1\b/time <moment>/
925 s/time [0-9]*\.\.\.[0-9]*/time <range>/
926 ' netflow.log]], [0],
927   [header: v5, seq 0, engine 2,1
928 rec: 192.168.0.1 > 192.168.0.2, if 1 > 65535, 1 pkts, 60 bytes, ICMP 8:0, time <moment>
929
930 header: v5, seq 1, engine 2,1
931 rec: 192.168.0.2 > 192.168.0.1, if 2 > 1, 2 pkts, 120 bytes, ICMP 0:0, time <range>
932 rec: 192.168.0.1 > 192.168.0.2, if 1 > 2, 1 pkts, 60 bytes, ICMP 8:0, time <moment>
933 ])
934 AT_CLEANUP
935
936 dnl Test that basic NetFlow reports active expirations correctly.
937 AT_SETUP([ofproto-dpif - NetFlow active expiration])
938
939 AT_SKIP_IF([test "x$RANDOM" = x])
940 NETFLOW_PORT=`expr 32767 + \( $RANDOM % 32767 \)`
941
942 OVS_VSWITCHD_START(
943   [set Bridge br0 fail-mode=standalone -- \
944    add-port br0 p1 -- set Interface p1 type=dummy -- \
945    add-port br0 p2 -- set Interface p2 type=dummy -- \
946    set Bridge br0 netflow=@nf -- \
947    --id=@nf create NetFlow targets=\"127.0.0.1:$NETFLOW_PORT\" \
948      engine_id=1 engine_type=2 active_timeout=10 \
949      add-id-to-interface=false], [<0>
950 ])
951
952 AT_CHECK([test-netflow --detach --pidfile $NETFLOW_PORT:127.0.0.1 > netflow.log])AT_CAPTURE_FILE([netflow.log])
953
954 AT_CHECK([ovs-appctl time/stop])
955 n=1
956 while test $n -le 60; do
957     n=`expr $n + 1`
958
959     ovs-appctl netdev-dummy/receive p1 '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=0,ttl=64,frag=no),tcp(src=1234,dst=80)'
960     ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=6,tos=0,ttl=64,frag=no),tcp(src=80,dst=1234)'
961
962     ovs-appctl time/warp 1000
963 done
964
965 ovs-appctl time/warp 10000
966
967 OVS_VSWITCHD_STOP
968 ovs-appctl -t test-netflow exit
969
970 # Count the number of reported packets:
971 # - From source to destination before MAC learning kicks in (just one).
972 # - From source to destination after that.
973 # - From destination to source.
974 n_learn=0
975 n_in=0
976 n_out=0
977 n_other=0
978 n_recs=0
979 none=0
980 while read line; do
981     pkts=`echo "$line" | sed 's/.*, \([[0-9]]*\) pkts,.*/\1/'`
982     case $pkts in
983          [[0-9]]*) ;;
984          *) continue ;;
985     esac
986
987     case $line in
988         "rec: 192.168.0.1 > 192.168.0.2, if 1 > 65535, "*" pkts, "*" bytes, TCP 1234 > 80, time "*)
989             counter=n_learn
990             ;;
991         "rec: 192.168.0.1 > 192.168.0.2, if 1 > 2, "*" pkts, "*" bytes, TCP 1234 > 80, time "*)
992             counter=n_in
993             ;;
994         "rec: 192.168.0.2 > 192.168.0.1, if 2 > 1, "*" pkts, "*" bytes, TCP 80 > 1234, time "*)
995             counter=n_out
996             ;;
997         *)
998             counter=n_other
999             ;;
1000     esac
1001     eval $counter=\`expr \$$counter + \$pkts\`
1002     n_recs=`expr $n_recs + 1`
1003 done < netflow.log
1004
1005 # There should be exactly 1 MAC learning packet,
1006 # exactly 59 other packets in that direction,
1007 # and exactly 60 packets in the other direction.
1008 AT_CHECK([echo $n_learn $n_in $n_out $n_other], [0], [1 59 60 0
1009 ])
1010
1011 # There should be 1 expiration for MAC learning,
1012 # at least 5 active and a final expiration in one direction,
1013 # and at least 5 active and a final expiration in the other direction.
1014 echo $n_recs
1015 AT_CHECK([test $n_recs -ge 13])
1016
1017 AT_CLEANUP