#endif /* HAVE_NETMAP */
-extern int max_pending_packets;
+extern intmax_t max_pending_packets;
#ifndef HAVE_NETMAP
ntv->flags |= NETMAP_FLAG_ZERO_COPY;
SCLogInfo("Enabling zero copy mode for %s->%s",
aconf->iface_name, aconf->out_iface_name);
+ } else {
+ uint16_t ring_size = ntv->ifsrc->rings[0].rx->num_slots;
+ if (ring_size > max_pending_packets) {
+ SCLogError(SC_ERR_NETMAP_CREATE,
+ "Packet pool size (%" PRIuMAX ") must be greater or equal than %s ring size (%" PRIu16 "). "
+ "Increase max_pending_packets option.",
+ max_pending_packets, aconf->iface_name, ring_size);
+ goto error_dst;
+ }
}
if (aconf->bpf_filter) {
uint32_t avail = nm_ring_space(rx);
uint32_t cur = rx->cur;
+ if (!(ntv->flags & NETMAP_FLAG_ZERO_COPY)) {
+ PacketPoolWaitForN(avail);
+ }
+
while (likely(avail-- > 0)) {
struct netmap_slot *slot = &rx->slot[cur];
unsigned char *slot_data = (unsigned char *)NETMAP_BUF(rx, slot->buf_idx);
}
}
- Packet *p = PacketGetFromQueueOrAlloc();
+ Packet *p = PacketPoolGetPacket();
if (unlikely(p == NULL)) {
SCReturnInt(NETMAP_FAILURE);
}