1 AT_BANNER([dpif-netdev])
3 m4_divert_push([PREPARE_TESTS])
5 # Strips out uninteresting parts of flow output, as well as parts
6 # that vary from one run to another (e.g., timing and bond actions).
9 s/duration:[0-9]*\.[0-9]*/duration:0.0/
10 s/used:[0-9]*\.[0-9]*/used:0.0/
17 s/used:[0-9]*\.[0-9]*/used:0.0/
18 s/actions:.*/actions: <del>/
19 s/packets:[0-9]*/packets:0/
20 s/bytes:[0-9]*/bytes:0/
24 strip_xout_keep_actions () {
27 s/used:[0-9]*\.[0-9]*/used:0.0/
28 s/packets:[0-9]*/packets:0/
29 s/bytes:[0-9]*/bytes:0/
33 filter_flow_install () {
34 grep 'flow_add' | sed 's/.*flow_add: //' | sort | uniq
37 filter_hw_flow_install () {
38 grep 'netdev_dummy.*flow put\[create\]' | sed 's/.*|DBG|//' | sort | uniq
41 filter_hw_flow_del () {
42 grep 'netdev_dummy.*flow del' | sed 's/.*|DBG|//' | sort | uniq
45 filter_hw_packet_netdev_dummy () {
46 grep 'netdev_dummy.*: packet:.*with mark' | sed 's/.*|DBG|//' | sort | uniq
50 grep 'flow_dump ' | sed '
52 s/used:[0-9]*\.[0-9]*/used:0.0/
57 sed 's/metadata=0x[0-9a-f]*/metadata=0x0/'
60 m4_divert_pop([PREPARE_TESTS])
62 AT_SETUP([dpif-netdev - netdev-dummy/receive])
63 # Create br0 with interfaces p0
64 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1 -- ])
65 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
67 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
69 ovs-appctl time/warp 5000
70 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:01,dst=50:54:00:00:02:00),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)'])
71 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
72 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:01,dst=50:54:00:00:02:00),eth_type(0x0800),ipv4(src=10.0.0.1,dst=10.0.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)
75 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:06:00),eth_type(0x0800),ipv4(src=10.0.0.5,dst=10.0.0.6,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)' --len 1024])
76 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
77 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:05,dst=50:54:00:00:06:00),eth_type(0x0800),ipv4(src=10.0.0.5,dst=10.0.0.6,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9),tcp_flags(ack)
83 m4_define([DPIF_NETDEV_DUMMY_IFACE],
84 [AT_SETUP([dpif-netdev - $1 interface])
85 # Create br0 with interfaces p1 and p7
86 # and br1 with interfaces p2 and p8
87 # with p1 and p2 connected via unix domain socket
89 [add-port br0 p1 -- set interface p1 type=$1 options:pstream=punix:$OVS_RUNDIR/p0.sock ofport_request=1 -- \
90 add-port br0 p7 -- set interface p7 ofport_request=7 type=$1 -- \
92 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
93 set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
95 add-port br1 p2 -- set interface p2 type=$1 options:stream=unix:$OVS_RUNDIR/p0.sock ofport_request=2 -- \
96 add-port br1 p8 -- set interface p8 ofport_request=8 type=$1 --], [], [],
97 [m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
98 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
100 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
101 AT_CHECK([ovs-ofctl add-flow br1 action=normal])
103 ovs-appctl time/warp 5000
104 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
105 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
106 ovs-appctl time/warp 100
107 sleep 1 # wait for forwarders process packets
109 AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
110 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(frag=no), actions: <del>
111 recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
112 recirc_id(0),in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
113 recirc_id(0),in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(frag=no), actions: <del>
119 DPIF_NETDEV_DUMMY_IFACE([dummy])
120 DPIF_NETDEV_DUMMY_IFACE([dummy-pmd])
122 m4_define([DPIF_NETDEV_MISS_FLOW_INSTALL],
123 [AT_SETUP([dpif-netdev - miss upcall key matches flow_install - $1])
126 -- set interface p1 type=$1 options:pstream=punix:$OVS_RUNDIR/p0.sock \
127 -- set bridge br0 datapath-type=dummy \
128 other-config:datapath-id=1234 fail-mode=secure], [], [],
129 [m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
130 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
132 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
133 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
134 ovs-appctl ofproto/trace 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'
137 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
138 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
140 AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
141 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
144 # Now, the same again without megaflows.
145 AT_CHECK([ovs-appctl upcall/disable-megaflows], [0], [megaflows disabled
147 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
150 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
151 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
153 AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
154 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(frag=no), actions: <del>
155 skb_priority(0),skb_mark(0),ct_state(-new-est-rel-rpl-inv-trk-snat-dnat),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0), actions: <del>
161 DPIF_NETDEV_MISS_FLOW_INSTALL([dummy])
162 DPIF_NETDEV_MISS_FLOW_INSTALL([dummy-pmd])
164 m4_define([DPIF_NETDEV_FLOW_PUT_MODIFY],
165 [AT_SETUP([dpif-netdev - datapath flow modification - $1])
167 [add-port br0 p1 -- set interface p1 type=$1 ofport_request=1 options:pstream=punix:$OVS_RUNDIR/p1.sock -- \
168 add-port br0 p2 -- set interface p2 type=$1 ofport_request=2 options:pstream=punix:$OVS_RUNDIR/p2.sock -- \
169 set bridge br0 datapath-type=dummy \
170 other-config:datapath-id=1234 fail-mode=secure], [], [],
171 [m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
172 AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg])
174 # Add a flow that directs some packets received on p1 to p2 and the
176 AT_CHECK([ovs-ofctl del-flows br0])
177 AT_CHECK([ovs-ofctl add-flow br0 priority=1,ip,in_port=1,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,actions=output:2])
178 AT_CHECK([ovs-ofctl add-flow br0 priority=0,in_port=1,actions=IN_PORT])
180 # Inject a packet of the form that should go to p2.
181 packet="in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no))"
182 AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
184 OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
185 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
186 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no))
188 ovs-appctl revalidator/wait
189 # Dump the datapath flow to see that it goes to p2 ("actions:2").
190 AT_CHECK([ovs-appctl dpif/dump-flows br0], [0], [dnl
191 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5),encap(eth_type(0x0800),ipv4(frag=no)), packets:0, bytes:0, used:never, actions:2
194 # Delete the flows, then add new flows that would not match the same
196 AT_CHECK([ovs-ofctl del-flows br0])
197 AT_CHECK([ovs-ofctl add-flow br0 priority=1,in_port=1,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,dl_type=0x0801,actions=output:2])
198 AT_CHECK([ovs-ofctl add-flow br0 priority=0,in_port=1,actions=IN_PORT])
200 # Wait for flow revalidation
201 ovs-appctl revalidator/wait
203 # Inject the same packet again.
204 AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64])
206 ovs-appctl revalidator/wait
207 # Dump the datapath flow to see that it goes to p1 ("actions:IN_PORT").
208 AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
209 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=1000,pcp=5),encap(eth_type(0x0800),ipv4(frag=no)), packets:1, bytes:64, used:0.0s, actions:1
214 DPIF_NETDEV_FLOW_PUT_MODIFY([dummy])
215 DPIF_NETDEV_FLOW_PUT_MODIFY([dummy-pmd])
218 m4_define([DPIF_NETDEV_MISS_FLOW_DUMP],
219 [AT_SETUP([dpif-netdev - miss upcall key matches flow_dump - $1])
222 -- set interface p1 type=$1 options:pstream=punix:$OVS_RUNDIR/p0.sock \
223 -- set bridge br0 datapath-type=dummy \
224 other-config:datapath-id=1234 fail-mode=secure], [], [],
225 [m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
226 AT_CHECK([ovs-appctl upcall/disable-ufid], [0], [Datapath dumping tersely using UFID disabled
228 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
230 AT_CHECK([ovs-ofctl add-flow br0 action=normal])
231 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
234 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
235 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
237 AT_CHECK([filter_flow_dump < ovs-vswitchd.log | strip_xout], [0], [dnl
238 skb_priority(0/0),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),recirc_id(0),dp_hash(0/0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:0, bytes:0, used:never, actions: <del>
241 # Now, the same again without megaflows.
242 AT_CHECK([ovs-appctl upcall/disable-megaflows], [0], [megaflows disabled
244 AT_CHECK([ovs-appctl upcall/disable-ufid], [0], [Datapath dumping tersely using UFID disabled
246 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)'])
249 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
250 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)
252 AT_CHECK([filter_flow_dump < ovs-vswitchd.log | strip_xout], [0], [dnl
253 skb_priority(0),skb_mark(0),ct_state(0/0xff),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0), packets:0, bytes:0, used:never, actions: <del>
254 skb_priority(0/0),skb_mark(0/0),ct_state(0/0),ct_zone(0/0),ct_mark(0/0),ct_label(0/0),recirc_id(0),dp_hash(0/0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2/0.0.0.0,dst=10.0.0.1/0.0.0.0,proto=1/0,tos=0/0,ttl=64/0,frag=no),icmp(type=8/0,code=0/0), packets:0, bytes:0, used:never, actions: <del>
260 DPIF_NETDEV_MISS_FLOW_DUMP([dummy])
261 DPIF_NETDEV_MISS_FLOW_DUMP([dummy-pmd])
263 AT_SETUP([dpif-netdev - meters])
264 # Create br0 with interfaces p1 and p7
265 # and br1 with interfaces p2 and p8
266 # with p1 and p2 connected via unix domain socket
268 [add-port br0 p1 -- set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock ofport_request=1 -- \
269 add-port br0 p7 -- set interface p7 ofport_request=7 type=dummy -- \
271 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
272 set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
273 fail-mode=secure -- \
274 add-port br1 p2 -- set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock ofport_request=2 -- \
275 add-port br1 p8 -- set interface p8 ofport_request=8 type=dummy --])
276 AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg])
278 AT_CHECK([ovs-ofctl -O OpenFlow13 add-meter br0 'meter=1 pktps burst stats bands=type=drop rate=1 burst_size=1'])
279 AT_CHECK([ovs-ofctl -O OpenFlow13 add-meter br0 'meter=2 kbps burst stats bands=type=drop rate=1 burst_size=2'])
280 AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 'in_port=1 action=meter:1,7'])
281 AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 'in_port=7 action=meter:2,1'])
282 AT_CHECK([ovs-ofctl add-flow br1 'in_port=2 action=8'])
283 AT_CHECK([ovs-ofctl add-flow br1 'in_port=8 action=2'])
286 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-meters br0], [0], [dnl
287 OFPST_METER_CONFIG reply (OF1.3) (xid=0x2):
288 meter=1 pktps burst stats bands=
289 type=drop rate=1 burst_size=1
291 meter=2 kbps burst stats bands=
292 type=drop rate=1 burst_size=2
295 ovs-appctl time/warp 5000
296 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
297 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
298 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
299 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
300 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
301 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
302 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
303 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
304 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
305 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
306 sleep 1 # wait for forwarders process packets
308 # Meter 1 is measuring packets, allowing one packet per second with
309 # bursts of one packet, so 4 out of 5 packets should hit the drop
311 # Meter 2 is measuring kbps, with burst size 2 (== 2000 bits). 4 packets
312 # (240 bytes == 1920 bits) pass, but the last packet should hit the drop band.
313 AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl
314 OFPST_METER reply (OF1.3) (xid=0x2):
315 meter:1 flow_count:1 packet_in_count:5 byte_in_count:300 duration:0.0s bands:
316 0: packet_count:4 byte_count:240
318 meter:2 flow_count:1 packet_in_count:5 byte_in_count:300 duration:0.0s bands:
319 0: packet_count:1 byte_count:60
322 # Advance time by 1/2 second
323 ovs-appctl time/warp 500
325 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
326 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
327 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
328 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
329 AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
330 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
331 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
332 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
333 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
334 AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60])
335 sleep 1 # wait for forwarders process packets
337 # Meter 1 is measuring packets, allowing one packet per second with
338 # bursts of one packet, so all 5 of the new packets should hit the drop
340 # Meter 2 is measuring kbps, with burst size 2 (== 2000 bits). After 500ms
341 # there should be space for 80 + 500 bits, so one new 60 byte (480 bit) packet
342 # should pass, remaining 4 should hit the drop band.
343 AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl
344 OFPST_METER reply (OF1.3) (xid=0x2):
345 meter:1 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands:
346 0: packet_count:9 byte_count:540
348 meter:2 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands:
349 0: packet_count:5 byte_count:300
352 AT_CHECK([cat ovs-vswitchd.log | filter_flow_install | strip_xout_keep_actions], [0], [dnl
353 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:meter(0),7
354 recirc_id(0),in_port(2),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:8
355 recirc_id(0),in_port(7),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:meter(1),1
356 recirc_id(0),in_port(8),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions:2
362 m4_define([DPIF_NETDEV_FLOW_HW_OFFLOAD],
363 [AT_SETUP([dpif-netdev - partial hw offload - $1])
365 [add-port br0 p1 -- \
366 set interface p1 type=$1 ofport_request=1 options:pstream=punix:$OVS_RUNDIR/p1.sock options:ifindex=1 -- \
367 set bridge br0 datapath-type=dummy \
368 other-config:datapath-id=1234 fail-mode=secure], [], [],
369 [m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
370 AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg netdev_dummy:file:dbg])
372 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
373 OVS_WAIT_UNTIL([grep "netdev: Flow API Enabled" ovs-vswitchd.log])
375 AT_CHECK([ovs-ofctl del-flows br0])
376 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=IN_PORT])
378 packet="packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no)"
379 AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
381 OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
382 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
383 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=0,tos=0,ttl=64,frag=no)
385 # Check that flow successfully offloaded.
386 OVS_WAIT_UNTIL([grep "succeed to add netdev flow" ovs-vswitchd.log])
387 AT_CHECK([filter_hw_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
388 p1: flow put[[create]]: flow match: recirc_id=0,eth,ip,in_port=1,vlan_tci=0x0000,nw_frag=no, mark: 0
390 # Check that datapath flow installed successfully.
391 AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
392 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), actions: <del>
394 # Inject the same packet again.
395 AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
397 # Check for succesfull packet matching with installed offloaded flow.
398 AT_CHECK([filter_hw_packet_netdev_dummy < ovs-vswitchd.log | strip_xout], [0], [dnl
399 p1: packet: ip,vlan_tci=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_proto=0,nw_tos=0,nw_ecn=0,nw_ttl=64 matches with flow: recirc_id=0,eth,ip,vlan_tci=0x0000,nw_frag=no with mark: 0
402 ovs-appctl revalidator/wait
403 # Dump the datapath flow to see that actions was executed for a packet.
404 AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
405 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), packets:1, bytes:64, used:0.0s, actions:1
408 # Wait for datapath flow expiration.
410 ovs-appctl time/warp 15000
411 ovs-appctl revalidator/wait
413 # Check that flow successfully deleted from HW.
414 OVS_WAIT_UNTIL([grep "succeed to delete netdev flow" ovs-vswitchd.log])
415 AT_CHECK([filter_hw_flow_del < ovs-vswitchd.log | strip_xout], [0], [dnl
416 p1: flow del: mark: 0
421 DPIF_NETDEV_FLOW_HW_OFFLOAD([dummy])
422 DPIF_NETDEV_FLOW_HW_OFFLOAD([dummy-pmd])
425 m4_define([DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS],
426 [AT_SETUP([dpif-netdev - partial hw offload with packet modifications - $1])
428 [add-port br0 p1 -- \
429 set interface p1 type=$1 ofport_request=1 options:pcap=p1.pcap options:ifindex=1 -- \
430 set bridge br0 datapath-type=dummy \
431 other-config:datapath-id=1234 fail-mode=secure], [], [],
432 [m4_if([$1], [dummy-pmd], [--dummy-numa="0,0,0,0,1,1,1,1"], [])])
433 AT_CHECK([ovs-appctl vlog/set dpif:file:dbg dpif_netdev:file:dbg netdev_dummy:file:dbg])
435 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:hw-offload=true])
436 OVS_WAIT_UNTIL([grep "netdev: Flow API Enabled" ovs-vswitchd.log])
438 AT_CHECK([ovs-ofctl del-flows br0])
440 # Setting flow to modify ipv4 src address and udp dst port to be sure that
441 # offloaded packets has correctly initialized l3/l4 offsets.
442 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,udp,actions=mod_nw_src:192.168.0.7,mod_tp_dst:3773,output:IN_PORT])
444 packet="packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=17,ttl=64,frag=no),udp(src=81,dst=82))"
445 AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
447 OVS_WAIT_UNTIL([grep "miss upcall" ovs-vswitchd.log])
448 AT_CHECK([grep -A 1 'miss upcall' ovs-vswitchd.log | tail -n 1], [0], [dnl
449 skb_priority(0),skb_mark(0),ct_state(0),ct_zone(0),ct_mark(0),ct_label(0),recirc_id(0),dp_hash(0),in_port(1),dnl
450 packet_type(ns=0,id=0),eth(src=00:06:07:08:09:0a,dst=00:01:02:03:04:05),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0800),ipv4(src=127.0.0.1,dst=127.0.0.1,proto=17,tos=0,ttl=64,frag=no),udp(src=81,dst=82))
452 # Check that flow successfully offloaded.
453 OVS_WAIT_UNTIL([grep "succeed to add netdev flow" ovs-vswitchd.log])
454 AT_CHECK([filter_hw_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
455 p1: flow put[[create]]: flow match: recirc_id=0,eth,udp,in_port=1,dl_vlan=99,dl_vlan_pcp=7,nw_src=127.0.0.1,nw_frag=no,tp_dst=82, mark: 0
457 # Check that datapath flow installed successfully.
458 AT_CHECK([filter_flow_install < ovs-vswitchd.log | strip_xout], [0], [dnl
459 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0800),ipv4(src=127.0.0.1,proto=17,frag=no),udp(dst=82)), actions: <del>
461 # Inject the same packet again.
462 AT_CHECK([ovs-appctl netdev-dummy/receive p1 $packet --len 64], [0])
464 # Check for succesfull packet matching with installed offloaded flow.
465 AT_CHECK([filter_hw_packet_netdev_dummy < ovs-vswitchd.log | strip_xout], [0], [dnl
466 p1: packet: udp,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=81,tp_dst=82 dnl
467 matches with flow: recirc_id=0,eth,udp,dl_vlan=99,dl_vlan_pcp=7,nw_src=127.0.0.1,nw_frag=no,tp_dst=82 with mark: 0
470 ovs-appctl revalidator/wait
471 # Dump the datapath flow to see that actions was executed for a packet.
472 AT_CHECK([ovs-appctl dpif/dump-flows br0 | strip_timers], [0], [dnl
473 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x8100),vlan(vid=99,pcp=7),encap(eth_type(0x0800),ipv4(src=127.0.0.1,proto=17,frag=no),udp(dst=82)), dnl
474 packets:1, bytes:64, used:0.0s, actions:set(ipv4(src=192.168.0.7)),set(udp(dst=3773)),1
477 # Wait for datapath flow expiration.
479 ovs-appctl time/warp 15000
480 ovs-appctl revalidator/wait
482 # Check that flow successfully deleted from HW.
483 OVS_WAIT_UNTIL([grep "succeed to delete netdev flow" ovs-vswitchd.log])
484 AT_CHECK([filter_hw_flow_del < ovs-vswitchd.log | strip_xout], [0], [dnl
485 p1: flow del: mark: 0
488 # Check that ip address and udp port were correctly modified in output packets.
489 AT_CHECK([ovs-ofctl parse-pcap p1.pcap], [0], [dnl
490 udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=81,tp_dst=82
491 udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=192.168.0.7,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=81,tp_dst=3773
492 udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=127.0.0.1,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=81,tp_dst=82
493 udp,in_port=ANY,dl_vlan=99,dl_vlan_pcp=7,vlan_tci1=0x0000,dl_src=00:06:07:08:09:0a,dl_dst=00:01:02:03:04:05,nw_src=192.168.0.7,nw_dst=127.0.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=81,tp_dst=3773
499 DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS([dummy])
500 DPIF_NETDEV_FLOW_HW_OFFLOAD_OFFSETS([dummy-pmd])