source/pcap: fix infinite loop if interface goes down

When in live-pcap mode, if the sniffed interface went down and up again,
Suri would enter an infinite and keep running, while not registering new
events. This fixes that behavior by allowing Suri to retry to open the
pcap in case of a retry on an already activated capture
('PCAP_ERROR_ACTIVATED').

This change is based on Zhiyuan Liao's work.

Bug #3846

(cherry picked from commit 2544be4672)
pull/7672/head
Juliana Fajardini 4 years ago
parent 41967bf119
commit c56871c9e6

@ -207,7 +207,7 @@ static int PcapTryReopen(PcapThreadVars *ptv)
ptv->pcap_state = PCAP_STATE_DOWN;
int pcap_activate_r = pcap_activate(ptv->pcap_handle);
if (pcap_activate_r != 0) {
if (pcap_activate_r != 0 && pcap_activate_r != PCAP_ERROR_ACTIVATED) {
return pcap_activate_r;
}

Loading…
Cancel
Save