From: Victor Julien Date: Mon, 11 Nov 2019 14:26:32 +0000 (+0100) Subject: sources: fix pipeline failure handling X-Git-Tag: suricata-5.0.8~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=898dd11d8f67b5d691c44b746e7cdd6f099bb5e0;p=thirdparty%2Fsuricata.git sources: fix pipeline failure handling When TmThreadsSlotProcessPkt fails it will return the packet that was passed to it to the packetpool. Some of the packet sources were doing this manually as well. This patch fixes those sources. (cherry picked from commit 7c83cb585e634fab7f94a5b4ebddbc54365325d9) --- diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 49bb02723f..5e19fdd687 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -744,7 +744,6 @@ static int AFPRead(AFPThreadVars *ptv) } if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ptv->tv, p); SCReturnInt(AFP_SURI_FAILURE); } SCReturnInt(AFP_READ_OK); @@ -1058,7 +1057,6 @@ static int AFPReadFromRing(AFPThreadVars *ptv) if (++ptv->frame_offset >= ptv->req.v2.tp_frame_nr) { ptv->frame_offset = 0; } - TmqhOutputPacketpool(ptv->tv, p); SCReturnInt(AFP_SURI_FAILURE); } @@ -1157,7 +1155,6 @@ static inline int AFPParsePacketV3(AFPThreadVars *ptv, struct tpacket_block_desc } if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ptv->tv, p); SCReturnInt(AFP_SURI_FAILURE); } diff --git a/src/source-erf-dag.c b/src/source-erf-dag.c index 4265641949..773830d36d 100644 --- a/src/source-erf-dag.c +++ b/src/source-erf-dag.c @@ -542,7 +542,6 @@ ProcessErfDagRecord(ErfDagThreadVars *ewtn, char *prec) ewtn->bytes += wlen; if (TmThreadsSlotProcessPkt(ewtn->tv, ewtn->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ewtn->tv, p); SCReturnInt(TM_ECODE_FAILED); } diff --git a/src/source-ipfw.c b/src/source-ipfw.c index 0081898228..42afc276e4 100644 --- a/src/source-ipfw.c +++ b/src/source-ipfw.c @@ -304,7 +304,6 @@ TmEcode ReceiveIPFWLoop(ThreadVars *tv, void *data, void *slot) if (TmThreadsSlotProcessPkt(tv, ((TmSlot *) slot)->slot_next, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(tv, p); SCReturnInt(TM_ECODE_FAILED); } diff --git a/src/source-netmap.c b/src/source-netmap.c index 3cea7dc691..e9b74274e5 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -590,11 +590,7 @@ static void NetmapCallback(u_char *user, const struct nm_pkthdr *ph, const u_cha SCLogDebug("pktlen: %" PRIu32 " (pkt %p, pkt data %p)", GET_PKT_LEN(p), p, GET_PKT_DATA(p)); - if (TmThreadsSlotProcessPkt(ntv->tv, ntv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ntv->tv, p); - return; - } - return; + (void)TmThreadsSlotProcessPkt(ntv->tv, ntv->slot, p); } /** diff --git a/src/source-nflog.c b/src/source-nflog.c index 38ddd30902..218c9c6885 100644 --- a/src/source-nflog.c +++ b/src/source-nflog.c @@ -193,7 +193,6 @@ static int NFLOGCallback(struct nflog_g_handle *gh, struct nfgenmsg *msg, (void) SC_ATOMIC_ADD(ntv->livedev->pkts, 1); if (TmThreadsSlotProcessPkt(ntv->tv, ntv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ntv->tv, p); return -1; } diff --git a/src/source-nfq.c b/src/source-nfq.c index a0cab39b5e..f7875d7ef3 100644 --- a/src/source-nfq.c +++ b/src/source-nfq.c @@ -562,14 +562,8 @@ static int NFQCallBack(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg, #endif /* COUNTERS */ (void) SC_ATOMIC_ADD(ntv->livedev->pkts, 1); - if (ntv->slot) { - if (TmThreadsSlotProcessPkt(tv, ntv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ntv->tv, p); - return -1; - } - } else { - /* pass on... */ - tv->tmqh_out(tv, p); + if (TmThreadsSlotProcessPkt(tv, ntv->slot, p) != TM_ECODE_OK) { + return -1; } return 0; diff --git a/src/source-pfring.c b/src/source-pfring.c index 6653549fab..9c84c02d7d 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -417,7 +417,6 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot) PfringProcessPacket(ptv, &hdr, p); if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(ptv->tv, p); SCReturnInt(TM_ECODE_FAILED); } diff --git a/src/source-windivert.c b/src/source-windivert.c index 1c549712d8..7be8bbb074 100644 --- a/src/source-windivert.c +++ b/src/source-windivert.c @@ -500,7 +500,6 @@ static TmEcode WinDivertRecvHelper(ThreadVars *tv, WinDivertThreadVars *wd_tv) * or push it to a packet pool. So processing time can vary. */ if (TmThreadsSlotProcessPkt(tv, wd_tv->slot, p) != TM_ECODE_OK) { - TmqhOutputPacketpool(tv, p); SCReturnInt(TM_ECODE_FAILED); }