From: Eric Leblond Date: Tue, 11 Jun 2019 22:40:23 +0000 (+0200) Subject: flow-bypass: registration of non periodic check X-Git-Tag: suricata-5.0.0-rc1~282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ba02830b6705a6f46e931ac9fb9ea65e79c2e6c;p=thirdparty%2Fsuricata.git flow-bypass: registration of non periodic check This patch adds the capability to register a set of functions without providing a periodic check function. This permit to run a task only at init. --- diff --git a/src/flow-bypass.c b/src/flow-bypass.c index 5c8445a016..fb00d40398 100644 --- a/src/flow-bypass.c +++ b/src/flow-bypass.c @@ -73,6 +73,17 @@ static TmEcode BypassedFlowManager(ThreadVars *th_v, void *thread_data) } } + /* check if we have a periodic check function */ + bool found = false; + for (i = 0; i < g_bypassed_func_max_index; i++) { + if (bypassedfunclist[i].FuncInit) { + found = true; + break; + } + } + if (!found) + return TM_ECODE_OK; + while (1) { SCLogDebug("Dumping the table"); if (clock_gettime(CLOCK_REALTIME, &curtime) != 0) { @@ -81,6 +92,8 @@ static TmEcode BypassedFlowManager(ThreadVars *th_v, void *thread_data) } for (i = 0; i < g_bypassed_func_max_index; i++) { struct flows_stats bypassstats = { 0, 0, 0}; + if (bypassedfunclist[i].Func == NULL) + continue; tcount = bypassedfunclist[i].Func(th_v, &bypassstats, &curtime, bypassedfunclist[i].data); if (tcount) { StatsAddUI64(th_v, ftd->flow_bypassed_cnt_clo, (uint64_t)bypassstats.count); @@ -164,9 +177,6 @@ int BypassedFlowManagerRegisterCheckFunc(BypassedCheckFunc CheckFunc, BypassedCheckFuncInit CheckFuncInit, void *data) { - if (!CheckFunc) { - return -1; - } if (g_bypassed_func_max_index < BYPASSFUNCMAX) { bypassedfunclist[g_bypassed_func_max_index].Func = CheckFunc; bypassedfunclist[g_bypassed_func_max_index].FuncInit = CheckFuncInit;