Skip to content

Commit

Permalink
pcap: improve pcap_breakloop support
Browse files Browse the repository at this point in the history
When pcap_breakloop has been issued on a handle, the current pcap_dispatch
call may return -2 (PCAP_ERROR_BREAK), but it can also return the number
of processed packets if lower than the desired number. So add this condition
as a check.
  • Loading branch information
victorjulien committed Apr 11, 2023
1 parent 8a968fa commit 9fe08f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/source-pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ static TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot)

int r = pcap_dispatch(ptv->pcap_handle, packet_q_len,
(pcap_handler)PcapCallbackLoop, (u_char *)ptv);
if (unlikely(r == 0 || r == PCAP_ERROR_BREAK)) {
if (unlikely(r == 0 || r == PCAP_ERROR_BREAK || r < packet_q_len)) {
if (r == PCAP_ERROR_BREAK && ptv->cb_result == TM_ECODE_FAILED) {
SCReturnInt(TM_ECODE_FAILED);
}
Expand Down

0 comments on commit 9fe08f2

Please sign in to comment.