pcap: improve pcap_breakloop support

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.

(cherry picked from commit 9fe08f2374)
(cherry picked from commit 2ddd26446e)
pull/8721/head
Victor Julien 3 years ago
parent 6d8b50b748
commit 80abc3121d

@ -321,7 +321,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 > 0 && r < packet_q_len))) {
if (r == PCAP_ERROR_BREAK && ptv->cb_result == TM_ECODE_FAILED) {
SCReturnInt(TM_ECODE_FAILED);
}

Loading…
Cancel
Save