From c56871c9e638d5d1204d11ce1a57f7d8aa3ba67f Mon Sep 17 00:00:00 2001 From: Juliana Fajardini Date: Tue, 28 Jun 2022 17:06:50 -0300 Subject: [PATCH] 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 2544be4672215d8c86c68f0d03c8fd88f498f1d2) --- src/source-pcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source-pcap.c b/src/source-pcap.c index 9e49b40e17..90f81f6b7f 100644 --- a/src/source-pcap.c +++ b/src/source-pcap.c @@ -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; } -- 2.47.2