summaryrefslogtreecommitdiffstats
path: root/src/plugins/snort
diff options
context:
space:
mode:
authorSivaprasad Tummala <Sivaprasad.Tummala@intel.com>2021-08-11 01:54:15 +0530
committerDamjan Marion <dmarion@me.com>2021-08-27 09:01:11 +0000
commita13100f3aa21a39de991df9fff84cd91e4be3b80 (patch)
tree65b641df48673f7e9d4ae18995569721aabc50b2 /src/plugins/snort
parentce5075823f8c3629d8233994d129a6835e7226a0 (diff)
snort: fix snort hang issue when interrupted
fix vpp daq to break out-of-loop when interrupted. Type: fix Signed-off-by: Sivaprasad Tummala <Sivaprasad.Tummala@intel.com> Change-Id: I04594a0b872d16f803d7d7c3b7d9bb60e94bc707
Diffstat (limited to 'src/plugins/snort')
-rw-r--r--src/plugins/snort/daq_vpp.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/snort/daq_vpp.c b/src/plugins/snort/daq_vpp.c
index 090b28af6f4..ec89b0c114e 100644
--- a/src/plugins/snort/daq_vpp.c
+++ b/src/plugins/snort/daq_vpp.c
@@ -113,6 +113,7 @@ typedef struct _vpp_context
daq_vpp_input_mode_t input_mode;
const char *socket_name;
+ volatile bool interrupted;
} VPP_Context_t;
static VPP_Context_t *global_vpp_ctx = 0;
@@ -480,6 +481,16 @@ vpp_daq_start (void *handle)
}
static int
+vpp_daq_interrupt (void *handle)
+{
+ VPP_Context_t *vc = (VPP_Context_t *) handle;
+
+ vc->interrupted = true;
+
+ return DAQ_SUCCESS;
+}
+
+static int
vpp_daq_get_stats (void *handle, DAQ_Stats_t *stats)
{
memset (stats, 0, sizeof (DAQ_Stats_t));
@@ -552,6 +563,14 @@ vpp_daq_msg_receive (void *handle, const unsigned max_recv,
uint32_t n_qpairs_left = vc->num_qpairs;
uint32_t n, n_events, n_recv = 0;
+ /* If the receive has been interrupted, break out of loop and return. */
+ if (vc->interrupted)
+ {
+ vc->interrupted = false;
+ *rstat = DAQ_RSTAT_INTERRUPTED;
+ return 0;
+ }
+
/* first, we visit all qpairs. If we find any work there then we can give
* it back immediatelly. To avoid bias towards qpair 0 we remeber what
* next qpair */
@@ -676,7 +695,7 @@ const DAQ_ModuleAPI_t DAQ_MODULE_DATA = {
/* .start = */ vpp_daq_start,
/* .inject = */ NULL,
/* .inject_relative = */ NULL,
- /* .interrupt = */ NULL,
+ /* .interrupt = */ vpp_daq_interrupt,
/* .stop = */ NULL,
/* .ioctl = */ NULL,
/* .get_stats = */ vpp_daq_get_stats,