|
|
|
@ -84,15 +84,13 @@
|
|
|
|
|
|
|
|
|
|
#define DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT 3000
|
|
|
|
|
|
|
|
|
|
static uint32_t detect_engine_ctx_id = 1;
|
|
|
|
|
|
|
|
|
|
static DetectEngineThreadCtx *DetectEngineThreadCtxInitForReload(
|
|
|
|
|
ThreadVars *tv, DetectEngineCtx *new_de_ctx, int mt);
|
|
|
|
|
|
|
|
|
|
static int DetectEngineCtxLoadConf(DetectEngineCtx *);
|
|
|
|
|
|
|
|
|
|
static DetectEngineMasterCtx g_master_de_ctx = { SCMUTEX_INITIALIZER,
|
|
|
|
|
0, NULL, NULL, TENANT_SELECTOR_UNKNOWN, NULL, NULL, 0};
|
|
|
|
|
0, 99, NULL, NULL, TENANT_SELECTOR_UNKNOWN, NULL, NULL, 0};
|
|
|
|
|
|
|
|
|
|
static uint32_t TenantIdHash(HashTable *h, void *data, uint16_t data_len);
|
|
|
|
|
static char TenantIdCompare(void *d1, uint16_t d1_len, void *d2, uint16_t d2_len);
|
|
|
|
@ -906,7 +904,8 @@ static DetectEngineCtx *DetectEngineCtxInitReal(int minimal, const char *prefix)
|
|
|
|
|
|
|
|
|
|
if (minimal) {
|
|
|
|
|
de_ctx->minimal = 1;
|
|
|
|
|
de_ctx->id = detect_engine_ctx_id++;
|
|
|
|
|
de_ctx->version = DetectEngineGetVersion();
|
|
|
|
|
SCLogDebug("minimal with version %u", de_ctx->version);
|
|
|
|
|
return de_ctx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -958,7 +957,8 @@ static DetectEngineCtx *DetectEngineCtxInitReal(int minimal, const char *prefix)
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
de_ctx->id = detect_engine_ctx_id++;
|
|
|
|
|
de_ctx->version = DetectEngineGetVersion();
|
|
|
|
|
SCLogDebug("dectx with version %u", de_ctx->version);
|
|
|
|
|
return de_ctx;
|
|
|
|
|
error:
|
|
|
|
|
if (de_ctx != NULL) {
|
|
|
|
@ -2054,6 +2054,25 @@ int DetectEngineEnabled(void)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t DetectEngineGetVersion(void)
|
|
|
|
|
{
|
|
|
|
|
uint32_t version;
|
|
|
|
|
DetectEngineMasterCtx *master = &g_master_de_ctx;
|
|
|
|
|
SCMutexLock(&master->lock);
|
|
|
|
|
version = master->version;
|
|
|
|
|
SCMutexUnlock(&master->lock);
|
|
|
|
|
return version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DetectEngineBumpVersion(void)
|
|
|
|
|
{
|
|
|
|
|
DetectEngineMasterCtx *master = &g_master_de_ctx;
|
|
|
|
|
SCMutexLock(&master->lock);
|
|
|
|
|
master->version++;
|
|
|
|
|
SCLogDebug("master version now %u", master->version);
|
|
|
|
|
SCMutexUnlock(&master->lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DetectEngineCtx *DetectEngineGetCurrent(void)
|
|
|
|
|
{
|
|
|
|
|
DetectEngineMasterCtx *master = &g_master_de_ctx;
|
|
|
|
@ -2827,6 +2846,8 @@ int DetectEngineReload(SCInstance *suri)
|
|
|
|
|
/* walk free list, freeing the old_de_ctx */
|
|
|
|
|
DetectEnginePruneFreeList();
|
|
|
|
|
|
|
|
|
|
DetectEngineBumpVersion();
|
|
|
|
|
|
|
|
|
|
SCLogDebug("old_de_ctx should have been freed");
|
|
|
|
|
|
|
|
|
|
SCLogNotice("rule reload complete");
|
|
|
|
|