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