dpif_packet: Rename to dp_packet
[cascardo/ovs.git] / lib / odp-execute.c
1 /*
2  * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
3  * Copyright (c) 2013 Simon Horman
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <config.h>
19 #include "odp-execute.h"
20 #include <arpa/inet.h>
21 #include <netinet/in.h>
22 #include <netinet/icmp6.h>
23 #include <netinet/ip6.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "dp-packet.h"
28 #include "dpif.h"
29 #include "netlink.h"
30 #include "ofpbuf.h"
31 #include "odp-netlink.h"
32 #include "odp-util.h"
33 #include "packets.h"
34 #include "flow.h"
35 #include "unaligned.h"
36 #include "util.h"
37
38 /* Masked copy of an ethernet address. 'src' is already properly masked. */
39 static void
40 ether_addr_copy_masked(uint8_t *dst, const uint8_t *src,
41                        const uint8_t *mask)
42 {
43     int i;
44
45     for (i = 0; i < ETH_ADDR_LEN; i++) {
46         dst[i] = src[i] | (dst[i] & ~mask[i]);
47     }
48 }
49
50 static void
51 odp_eth_set_addrs(struct ofpbuf *packet, const struct ovs_key_ethernet *key,
52                   const struct ovs_key_ethernet *mask)
53 {
54     struct eth_header *eh = ofpbuf_l2(packet);
55
56     if (eh) {
57         if (!mask) {
58             memcpy(eh->eth_src, key->eth_src, sizeof eh->eth_src);
59             memcpy(eh->eth_dst, key->eth_dst, sizeof eh->eth_dst);
60         } else {
61             ether_addr_copy_masked(eh->eth_src, key->eth_src, mask->eth_src);
62             ether_addr_copy_masked(eh->eth_dst, key->eth_dst, mask->eth_dst);
63         }
64     }
65 }
66
67 static void
68 odp_set_ipv4(struct ofpbuf *packet, const struct ovs_key_ipv4 *key,
69              const struct ovs_key_ipv4 *mask)
70 {
71     struct ip_header *nh = ofpbuf_l3(packet);
72
73     packet_set_ipv4(
74         packet,
75         key->ipv4_src | (get_16aligned_be32(&nh->ip_src) & ~mask->ipv4_src),
76         key->ipv4_dst | (get_16aligned_be32(&nh->ip_dst) & ~mask->ipv4_dst),
77         key->ipv4_tos | (nh->ip_tos & ~mask->ipv4_tos),
78         key->ipv4_ttl | (nh->ip_ttl & ~mask->ipv4_ttl));
79 }
80
81 static const ovs_be32 *
82 mask_ipv6_addr(const ovs_16aligned_be32 *old, const ovs_be32 *addr,
83                const ovs_be32 *mask, ovs_be32 *masked)
84 {
85     for (int i = 0; i < 4; i++) {
86         masked[i] = addr[i] | (get_16aligned_be32(&old[i]) & ~mask[i]);
87     }
88
89     return masked;
90 }
91
92 static void
93 odp_set_ipv6(struct ofpbuf *packet, const struct ovs_key_ipv6 *key,
94              const struct ovs_key_ipv6 *mask)
95 {
96     struct ovs_16aligned_ip6_hdr *nh = ofpbuf_l3(packet);
97     ovs_be32 sbuf[4], dbuf[4];
98     uint8_t old_tc = ntohl(get_16aligned_be32(&nh->ip6_flow)) >> 20;
99     ovs_be32 old_fl = get_16aligned_be32(&nh->ip6_flow) & htonl(0xfffff);
100
101     packet_set_ipv6(
102         packet,
103         key->ipv6_proto,
104         mask_ipv6_addr(nh->ip6_src.be32, key->ipv6_src, mask->ipv6_src, sbuf),
105         mask_ipv6_addr(nh->ip6_dst.be32, key->ipv6_dst, mask->ipv6_dst, dbuf),
106         key->ipv6_tclass | (old_tc & ~mask->ipv6_tclass),
107         key->ipv6_label | (old_fl & ~mask->ipv6_label),
108         key->ipv6_hlimit | (nh->ip6_hlim & ~mask->ipv6_hlimit));
109 }
110
111 static void
112 odp_set_tcp(struct ofpbuf *packet, const struct ovs_key_tcp *key,
113              const struct ovs_key_tcp *mask)
114 {
115     struct tcp_header *th = ofpbuf_l4(packet);
116
117     if (OVS_LIKELY(th && ofpbuf_get_tcp_payload(packet))) {
118         packet_set_tcp_port(packet,
119                             key->tcp_src | (th->tcp_src & ~mask->tcp_src),
120                             key->tcp_dst | (th->tcp_dst & ~mask->tcp_dst));
121     }
122 }
123
124 static void
125 odp_set_udp(struct ofpbuf *packet, const struct ovs_key_udp *key,
126              const struct ovs_key_udp *mask)
127 {
128     struct udp_header *uh = ofpbuf_l4(packet);
129
130     if (OVS_LIKELY(uh && ofpbuf_get_udp_payload(packet))) {
131         packet_set_udp_port(packet,
132                             key->udp_src | (uh->udp_src & ~mask->udp_src),
133                             key->udp_dst | (uh->udp_dst & ~mask->udp_dst));
134     }
135 }
136
137 static void
138 odp_set_sctp(struct ofpbuf *packet, const struct ovs_key_sctp *key,
139              const struct ovs_key_sctp *mask)
140 {
141     struct sctp_header *sh = ofpbuf_l4(packet);
142
143     if (OVS_LIKELY(sh && ofpbuf_get_sctp_payload(packet))) {
144         packet_set_sctp_port(packet,
145                              key->sctp_src | (sh->sctp_src & ~mask->sctp_src),
146                              key->sctp_dst | (sh->sctp_dst & ~mask->sctp_dst));
147     }
148 }
149
150 static void
151 odp_set_tunnel_action(const struct nlattr *a, struct flow_tnl *tun_key)
152 {
153     enum odp_key_fitness fitness;
154
155     fitness = odp_tun_key_from_attr(a, tun_key);
156     ovs_assert(fitness != ODP_FIT_ERROR);
157 }
158
159 static void
160 set_arp(struct ofpbuf *packet, const struct ovs_key_arp *key,
161         const struct ovs_key_arp *mask)
162 {
163     struct arp_eth_header *arp = ofpbuf_l3(packet);
164
165     if (!mask) {
166         arp->ar_op = key->arp_op;
167         memcpy(arp->ar_sha, key->arp_sha, ETH_ADDR_LEN);
168         put_16aligned_be32(&arp->ar_spa, key->arp_sip);
169         memcpy(arp->ar_tha, key->arp_tha, ETH_ADDR_LEN);
170         put_16aligned_be32(&arp->ar_tpa, key->arp_tip);
171     } else {
172         ovs_be32 ar_spa = get_16aligned_be32(&arp->ar_spa);
173         ovs_be32 ar_tpa = get_16aligned_be32(&arp->ar_tpa);
174
175         arp->ar_op = key->arp_op | (arp->ar_op & ~mask->arp_op);
176         ether_addr_copy_masked(arp->ar_sha, key->arp_sha, mask->arp_sha);
177         put_16aligned_be32(&arp->ar_spa,
178                            key->arp_sip | (ar_spa & ~mask->arp_sip));
179         ether_addr_copy_masked(arp->ar_tha, key->arp_tha, mask->arp_tha);
180         put_16aligned_be32(&arp->ar_tpa,
181                            key->arp_tip | (ar_tpa & ~mask->arp_tip));
182     }
183 }
184
185 static void
186 odp_set_nd(struct ofpbuf *packet, const struct ovs_key_nd *key,
187            const struct ovs_key_nd *mask)
188 {
189     const struct ovs_nd_msg *ns = ofpbuf_l4(packet);
190     const struct ovs_nd_opt *nd_opt = ofpbuf_get_nd_payload(packet);
191
192     if (OVS_LIKELY(ns && nd_opt)) {
193         int bytes_remain = ofpbuf_l4_size(packet) - sizeof(*ns);
194         ovs_be32 tgt_buf[4];
195         uint8_t sll_buf[ETH_ADDR_LEN] = {0};
196         uint8_t tll_buf[ETH_ADDR_LEN] = {0};
197
198         while (bytes_remain >= ND_OPT_LEN && nd_opt->nd_opt_len != 0) {
199             if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LINKADDR
200                 && nd_opt->nd_opt_len == 1) {
201                 memcpy(sll_buf, nd_opt->nd_opt_data, ETH_ADDR_LEN);
202                 ether_addr_copy_masked(sll_buf, key->nd_sll, mask->nd_sll);
203
204                 /* A packet can only contain one SLL or TLL option */
205                 break;
206             } else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LINKADDR
207                        && nd_opt->nd_opt_len == 1) {
208                 memcpy(tll_buf, nd_opt->nd_opt_data, ETH_ADDR_LEN);
209                 ether_addr_copy_masked(tll_buf, key->nd_tll, mask->nd_tll);
210
211                 /* A packet can only contain one SLL or TLL option */
212                 break;
213             }
214
215             nd_opt += nd_opt->nd_opt_len;
216             bytes_remain -= nd_opt->nd_opt_len * ND_OPT_LEN;
217         }
218
219         packet_set_nd(packet,
220                       mask_ipv6_addr(ns->target.be32,
221                                      key->nd_target, mask->nd_target, tgt_buf),
222                       sll_buf,
223                       tll_buf);
224     }
225 }
226
227 static void
228 odp_execute_set_action(struct dp_packet *packet, const struct nlattr *a)
229 {
230     enum ovs_key_attr type = nl_attr_type(a);
231     const struct ovs_key_ipv4 *ipv4_key;
232     const struct ovs_key_ipv6 *ipv6_key;
233     struct pkt_metadata *md = &packet->md;
234
235     switch (type) {
236     case OVS_KEY_ATTR_PRIORITY:
237         md->skb_priority = nl_attr_get_u32(a);
238         break;
239
240     case OVS_KEY_ATTR_TUNNEL:
241         odp_set_tunnel_action(a, &md->tunnel);
242         break;
243
244     case OVS_KEY_ATTR_SKB_MARK:
245         md->pkt_mark = nl_attr_get_u32(a);
246         break;
247
248     case OVS_KEY_ATTR_ETHERNET:
249         odp_eth_set_addrs(&packet->ofpbuf, nl_attr_get(a), NULL);
250         break;
251
252     case OVS_KEY_ATTR_IPV4:
253         ipv4_key = nl_attr_get_unspec(a, sizeof(struct ovs_key_ipv4));
254         packet_set_ipv4(&packet->ofpbuf, ipv4_key->ipv4_src,
255                         ipv4_key->ipv4_dst, ipv4_key->ipv4_tos,
256                         ipv4_key->ipv4_ttl);
257         break;
258
259     case OVS_KEY_ATTR_IPV6:
260         ipv6_key = nl_attr_get_unspec(a, sizeof(struct ovs_key_ipv6));
261         packet_set_ipv6(&packet->ofpbuf, ipv6_key->ipv6_proto,
262                         ipv6_key->ipv6_src, ipv6_key->ipv6_dst,
263                         ipv6_key->ipv6_tclass, ipv6_key->ipv6_label,
264                         ipv6_key->ipv6_hlimit);
265         break;
266
267     case OVS_KEY_ATTR_TCP:
268         if (OVS_LIKELY(ofpbuf_get_tcp_payload(&packet->ofpbuf))) {
269             const struct ovs_key_tcp *tcp_key
270                 = nl_attr_get_unspec(a, sizeof(struct ovs_key_tcp));
271
272             packet_set_tcp_port(&packet->ofpbuf, tcp_key->tcp_src,
273                                 tcp_key->tcp_dst);
274         }
275         break;
276
277     case OVS_KEY_ATTR_UDP:
278         if (OVS_LIKELY(ofpbuf_get_udp_payload(&packet->ofpbuf))) {
279             const struct ovs_key_udp *udp_key
280                 = nl_attr_get_unspec(a, sizeof(struct ovs_key_udp));
281
282             packet_set_udp_port(&packet->ofpbuf, udp_key->udp_src,
283                                 udp_key->udp_dst);
284         }
285         break;
286
287     case OVS_KEY_ATTR_SCTP:
288         if (OVS_LIKELY(ofpbuf_get_sctp_payload(&packet->ofpbuf))) {
289             const struct ovs_key_sctp *sctp_key
290                 = nl_attr_get_unspec(a, sizeof(struct ovs_key_sctp));
291
292             packet_set_sctp_port(&packet->ofpbuf, sctp_key->sctp_src,
293                                  sctp_key->sctp_dst);
294         }
295         break;
296
297     case OVS_KEY_ATTR_MPLS:
298         set_mpls_lse(&packet->ofpbuf, nl_attr_get_be32(a));
299         break;
300
301     case OVS_KEY_ATTR_ARP:
302         set_arp(&packet->ofpbuf, nl_attr_get(a), NULL);
303         break;
304
305     case OVS_KEY_ATTR_ND:
306         if (OVS_LIKELY(ofpbuf_get_nd_payload(&packet->ofpbuf))) {
307             const struct ovs_key_nd *nd_key
308                    = nl_attr_get_unspec(a, sizeof(struct ovs_key_nd));
309             packet_set_nd(&packet->ofpbuf, nd_key->nd_target,
310                           nd_key->nd_sll, nd_key->nd_tll);
311         }
312         break;
313
314     case OVS_KEY_ATTR_DP_HASH:
315         md->dp_hash = nl_attr_get_u32(a);
316         dp_packet_set_dp_hash(packet, md->dp_hash);
317         break;
318
319     case OVS_KEY_ATTR_RECIRC_ID:
320         md->recirc_id = nl_attr_get_u32(a);
321         break;
322
323     case OVS_KEY_ATTR_UNSPEC:
324     case OVS_KEY_ATTR_ENCAP:
325     case OVS_KEY_ATTR_ETHERTYPE:
326     case OVS_KEY_ATTR_IN_PORT:
327     case OVS_KEY_ATTR_VLAN:
328     case OVS_KEY_ATTR_ICMP:
329     case OVS_KEY_ATTR_ICMPV6:
330     case OVS_KEY_ATTR_TCP_FLAGS:
331     case __OVS_KEY_ATTR_MAX:
332     default:
333         OVS_NOT_REACHED();
334     }
335 }
336
337 #define get_mask(a, type) ((const type *)(const void *)(a + 1) + 1)
338
339 static void
340 odp_execute_masked_set_action(struct dp_packet *packet,
341                               const struct nlattr *a)
342 {
343     struct pkt_metadata *md = &packet->md;
344     enum ovs_key_attr type = nl_attr_type(a);
345     struct mpls_hdr *mh;
346
347     switch (type) {
348     case OVS_KEY_ATTR_PRIORITY:
349         md->skb_priority = nl_attr_get_u32(a)
350             | (md->skb_priority & ~*get_mask(a, uint32_t));
351         break;
352
353     case OVS_KEY_ATTR_SKB_MARK:
354         md->pkt_mark = nl_attr_get_u32(a)
355             | (md->pkt_mark & ~*get_mask(a, uint32_t));
356         break;
357
358     case OVS_KEY_ATTR_ETHERNET:
359         odp_eth_set_addrs(&packet->ofpbuf, nl_attr_get(a),
360                           get_mask(a, struct ovs_key_ethernet));
361         break;
362
363     case OVS_KEY_ATTR_IPV4:
364         odp_set_ipv4(&packet->ofpbuf, nl_attr_get(a),
365                      get_mask(a, struct ovs_key_ipv4));
366         break;
367
368     case OVS_KEY_ATTR_IPV6:
369         odp_set_ipv6(&packet->ofpbuf, nl_attr_get(a),
370                      get_mask(a, struct ovs_key_ipv6));
371         break;
372
373     case OVS_KEY_ATTR_TCP:
374         odp_set_tcp(&packet->ofpbuf, nl_attr_get(a),
375                     get_mask(a, struct ovs_key_tcp));
376         break;
377
378     case OVS_KEY_ATTR_UDP:
379         odp_set_udp(&packet->ofpbuf, nl_attr_get(a),
380                     get_mask(a, struct ovs_key_udp));
381         break;
382
383     case OVS_KEY_ATTR_SCTP:
384         odp_set_sctp(&packet->ofpbuf, nl_attr_get(a),
385                      get_mask(a, struct ovs_key_sctp));
386         break;
387
388     case OVS_KEY_ATTR_MPLS:
389         mh = ofpbuf_l2_5(&packet->ofpbuf);
390         if (mh) {
391             put_16aligned_be32(&mh->mpls_lse, nl_attr_get_be32(a)
392                                | (get_16aligned_be32(&mh->mpls_lse)
393                                   & ~*get_mask(a, ovs_be32)));
394         }
395         break;
396
397     case OVS_KEY_ATTR_ARP:
398         set_arp(&packet->ofpbuf, nl_attr_get(a),
399                 get_mask(a, struct ovs_key_arp));
400         break;
401
402     case OVS_KEY_ATTR_ND:
403         odp_set_nd(&packet->ofpbuf, nl_attr_get(a),
404                    get_mask(a, struct ovs_key_nd));
405         break;
406
407     case OVS_KEY_ATTR_DP_HASH:
408         md->dp_hash = nl_attr_get_u32(a)
409             | (dp_packet_get_dp_hash(packet) & ~*get_mask(a, uint32_t));
410         dp_packet_set_dp_hash(packet, md->dp_hash);
411         break;
412
413     case OVS_KEY_ATTR_RECIRC_ID:
414         md->recirc_id = nl_attr_get_u32(a)
415             | (md->recirc_id & ~*get_mask(a, uint32_t));
416         break;
417
418     case OVS_KEY_ATTR_TUNNEL:    /* Masked data not supported for tunnel. */
419     case OVS_KEY_ATTR_UNSPEC:
420     case OVS_KEY_ATTR_ENCAP:
421     case OVS_KEY_ATTR_ETHERTYPE:
422     case OVS_KEY_ATTR_IN_PORT:
423     case OVS_KEY_ATTR_VLAN:
424     case OVS_KEY_ATTR_ICMP:
425     case OVS_KEY_ATTR_ICMPV6:
426     case OVS_KEY_ATTR_TCP_FLAGS:
427     case __OVS_KEY_ATTR_MAX:
428     default:
429         OVS_NOT_REACHED();
430     }
431 }
432
433 static void
434 odp_execute_sample(void *dp, struct dp_packet *packet, bool steal,
435                    const struct nlattr *action,
436                    odp_execute_cb dp_execute_action)
437 {
438     const struct nlattr *subactions = NULL;
439     const struct nlattr *a;
440     size_t left;
441
442     NL_NESTED_FOR_EACH_UNSAFE (a, left, action) {
443         int type = nl_attr_type(a);
444
445         switch ((enum ovs_sample_attr) type) {
446         case OVS_SAMPLE_ATTR_PROBABILITY:
447             if (random_uint32() >= nl_attr_get_u32(a)) {
448                 if (steal) {
449                     dp_packet_delete(packet);
450                 }
451                 return;
452             }
453             break;
454
455         case OVS_SAMPLE_ATTR_ACTIONS:
456             subactions = a;
457             break;
458
459         case OVS_SAMPLE_ATTR_UNSPEC:
460         case __OVS_SAMPLE_ATTR_MAX:
461         default:
462             OVS_NOT_REACHED();
463         }
464     }
465
466     odp_execute_actions(dp, &packet, 1, steal, nl_attr_get(subactions),
467                         nl_attr_get_size(subactions), dp_execute_action);
468 }
469
470 void
471 odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
472                     const struct nlattr *actions, size_t actions_len,
473                     odp_execute_cb dp_execute_action)
474 {
475     const struct nlattr *a;
476     unsigned int left;
477     int i;
478
479     NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
480         int type = nl_attr_type(a);
481         bool last_action = (left <= NLA_ALIGN(a->nla_len));
482
483         switch ((enum ovs_action_attr) type) {
484             /* These only make sense in the context of a datapath. */
485         case OVS_ACTION_ATTR_OUTPUT:
486         case OVS_ACTION_ATTR_TUNNEL_PUSH:
487         case OVS_ACTION_ATTR_TUNNEL_POP:
488         case OVS_ACTION_ATTR_USERSPACE:
489         case OVS_ACTION_ATTR_RECIRC:
490             if (dp_execute_action) {
491                 /* Allow 'dp_execute_action' to steal the packet data if we do
492                  * not need it any more. */
493                 bool may_steal = steal && last_action;
494
495                 dp_execute_action(dp, packets, cnt, a, may_steal);
496
497                 if (last_action) {
498                     /* We do not need to free the packets. dp_execute_actions()
499                      * has stolen them */
500                     return;
501                 }
502             }
503             break;
504
505         case OVS_ACTION_ATTR_HASH: {
506             const struct ovs_action_hash *hash_act = nl_attr_get(a);
507
508             /* Calculate a hash value directly.  This might not match the
509              * value computed by the datapath, but it is much less expensive,
510              * and the current use case (bonding) does not require a strict
511              * match to work properly. */
512             if (hash_act->hash_alg == OVS_HASH_ALG_L4) {
513                 struct flow flow;
514                 uint32_t hash;
515
516                 for (i = 0; i < cnt; i++) {
517                     flow_extract(&packets[i]->ofpbuf, &packets[i]->md, &flow);
518                     hash = flow_hash_5tuple(&flow, hash_act->hash_basis);
519
520                     /* We also store the hash value with each packet */
521                     dp_packet_set_dp_hash(packets[i], hash ? hash : 1);
522                 }
523             } else {
524                 /* Assert on unknown hash algorithm.  */
525                 OVS_NOT_REACHED();
526             }
527             break;
528         }
529
530         case OVS_ACTION_ATTR_PUSH_VLAN: {
531             const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
532
533             for (i = 0; i < cnt; i++) {
534                 struct ofpbuf *buf = &packets[i]->ofpbuf;
535
536                 eth_push_vlan(buf, htons(ETH_TYPE_VLAN), vlan->vlan_tci);
537             }
538             break;
539         }
540
541         case OVS_ACTION_ATTR_POP_VLAN:
542             for (i = 0; i < cnt; i++) {
543                 struct ofpbuf *buf = &packets[i]->ofpbuf;
544
545                 eth_pop_vlan(buf);
546             }
547             break;
548
549         case OVS_ACTION_ATTR_PUSH_MPLS: {
550             const struct ovs_action_push_mpls *mpls = nl_attr_get(a);
551
552             for (i = 0; i < cnt; i++) {
553                 struct ofpbuf *buf = &packets[i]->ofpbuf;
554
555                 push_mpls(buf, mpls->mpls_ethertype, mpls->mpls_lse);
556             }
557             break;
558          }
559
560         case OVS_ACTION_ATTR_POP_MPLS:
561             for (i = 0; i < cnt; i++) {
562                 struct ofpbuf *buf = &packets[i]->ofpbuf;
563
564                 pop_mpls(buf, nl_attr_get_be16(a));
565             }
566             break;
567
568         case OVS_ACTION_ATTR_SET:
569             for (i = 0; i < cnt; i++) {
570                 odp_execute_set_action(packets[i], nl_attr_get(a));
571             }
572             break;
573
574         case OVS_ACTION_ATTR_SET_MASKED:
575             for (i = 0; i < cnt; i++) {
576                 odp_execute_masked_set_action(packets[i], nl_attr_get(a));
577             }
578             break;
579
580         case OVS_ACTION_ATTR_SAMPLE:
581             for (i = 0; i < cnt; i++) {
582                 odp_execute_sample(dp, packets[i], steal && last_action, a,
583                                    dp_execute_action);
584             }
585
586             if (last_action) {
587                 /* We do not need to free the packets. odp_execute_sample() has
588                  * stolen them*/
589                 return;
590             }
591             break;
592
593         case OVS_ACTION_ATTR_UNSPEC:
594         case __OVS_ACTION_ATTR_MAX:
595             OVS_NOT_REACHED();
596         }
597     }
598
599     if (steal) {
600         for (i = 0; i < cnt; i++) {
601             dp_packet_delete(packets[i]);
602         }
603     }
604 }