MCPcopy Create free account
hub / github.com/NetSys/bess / Free

Method Free

core/packet.h:332–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330#include "packet_avx.h"
331#else
332inline void Packet::Free(Packet **pkts, size_t cnt) {
333 DCHECK_LE(cnt, PacketBatch::kMaxBurst);
334
335 // rte_mempool_put_bulk() crashes when called with cnt == 0
336 if (unlikely(cnt <= 0)) {
337 return;
338 }
339
340 struct rte_mempool *pool = pkts[0]->pool_;
341
342 for (size_t i = 0; i < cnt; i++) {
343 const Packet *pkt = pkts[i];
344
345 if (unlikely(pkt->pool_ != pool || !pkt->is_simple() ||
346 pkt->refcnt() != 1)) {
347 goto slow_path;
348 }
349 }
350
351 /* NOTE: it seems that zeroing the refcnt of mbufs is not necessary.
352 * (allocators will reset them) */
353 rte_mempool_put_bulk(pool, reinterpret_cast<void **>(pkts), cnt);
354 return;
355
356slow_path:
357 // slow path: packets are not homogeneous or simple enough
358 for (size_t i = 0; i < cnt; i++) {
359 Free(pkts[i]);
360 }
361}
362#endif
363
364} // namespace bess

Callers 1

TESTFunction · 0.45

Calls 1

is_simpleMethod · 0.80

Tested by 1

TESTFunction · 0.36