]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
source/pcap: fix infinite loop if interface goes down 7672/head
authorJuliana Fajardini <jufajardini@oisf.net>
Tue, 28 Jun 2022 20:06:50 +0000 (17:06 -0300)
committerJuliana Fajardini <jufajardini@oisf.net>
Mon, 1 Aug 2022 18:59:35 +0000 (15:59 -0300)
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 2544be4672215d8c86c68f0d03c8fd88f498f1d2)

src/source-pcap.c

index 9e49b40e178edb99ba0c51f8955bb5279dd3c964..90f81f6b7f6b21b44887104e58ab675aaa98810d 100644 (file)
@@ -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;
     }