Project

General

Profile

Bug #5744 » source-netmap.c.diff

Reverts a unnecessary change from Suricata 6.0.8 - Jeff Lucovsky, 12/07/2022 01:43 PM

View differences:

src/source-netmap.c
PacketFreeOrRelease(p);
}
#if USE_NEW_NETMAP_API
static void NetmapProcessPacket(NetmapThreadVars *ntv, const struct nm_pkthdr *ph)
#else
static void NetmapCallback(u_char *user, const struct nm_pkthdr *ph, const u_char *d)
#endif
{
#if USE_NEW_NETMAP_API
const u_char *d = ph->buf;
#else
NetmapThreadVars *ntv = (NetmapThreadVars *)user;
#endif
if (ntv->bpf_prog.bf_len) {
struct pcap_pkthdr pkthdr = { {0, 0}, ph->len, ph->len };
if (pcap_offline_filter(&ntv->bpf_prog, &pkthdr, ph->buf) == 0) {
if (pcap_offline_filter(&ntv->bpf_prog, &pkthdr, d) == 0) {
return;
}
}
......
ntv->bytes += ph->len;
if (ntv->flags & NETMAP_FLAG_ZERO_COPY) {
if (PacketSetData(p, (uint8_t *)ph->buf, ph->len) == -1) {
if (PacketSetData(p, (uint8_t *)d, ph->len) == -1) {
TmqhOutputPacketpool(ntv->tv, p);
return;
}
} else {
if (PacketCopyData(p, (uint8_t *)ph->buf, ph->len) == -1) {
if (PacketCopyData(p, (uint8_t *)d, ph->len) == -1) {
TmqhOutputPacketpool(ntv->tv, p);
return;
}
......
*/
#if USE_NEW_NETMAP_API
static TmEcode NetmapReadPackets(struct nmport_d *d, int cnt, NetmapThreadVars *ntv)
#else
static TmEcode NetmapReadPackets(struct nm_desc *d, int cnt, NetmapThreadVars *ntv)
#endif
{
struct nm_pkthdr hdr;
int last_ring = d->last_rx_ring - d->first_rx_ring + 1;
......
}
return got;
}
#endif
/**
* \brief Main netmap reading loop function
......
}
if (likely(fds.revents & POLLIN)) {
#if USE_NEW_NETMAP_API
/* have data on RX ring, so copy to Packet for processing */
NetmapReadPackets(ntv->ifsrc->nmd, -1, ntv);
#else
nm_dispatch(ntv->ifsrc->nmd, -1, NetmapCallback, (void *)ntv);
#endif
}
NetmapDumpCounters(ntv);
(1-1/7)