detect: reload-rules shouldn't reload a stub

pull/3420/merge
Victor Julien 7 years ago
parent 4eaec2dff0
commit 5bcae21653

@ -3433,6 +3433,13 @@ int DetectEngineReload(const SCInstance *suri)
return -1; return -1;
SCLogDebug("get ref to old_de_ctx %p", old_de_ctx); SCLogDebug("get ref to old_de_ctx %p", old_de_ctx);
/* only reload a regular 'normal' detect engine */
if (old_de_ctx->type == DETECT_ENGINE_TYPE_STUB) {
DetectEngineDeReference(&old_de_ctx);
SCLogNotice("rule reload complete");
return -1;
}
/* get new detection engine */ /* get new detection engine */
new_de_ctx = DetectEngineCtxInitWithPrefix(prefix); new_de_ctx = DetectEngineCtxInitWithPrefix(prefix);
if (new_de_ctx == NULL) { if (new_de_ctx == NULL) {
@ -3502,24 +3509,27 @@ int DetectEngineMTApply(void)
} }
DetectEngineCtx *stub_de_ctx = NULL; DetectEngineCtx *stub_de_ctx = NULL;
/* if we have no tenants, we need a stub */ DetectEngineCtx *list = master->list;
if (master->list == NULL) { for ( ; list != NULL; list = list->next) {
stub_de_ctx = master->list = DetectEngineCtxInitStub(); SCLogDebug("list %p tenant %u", list, list->tenant_id);
SCLogDebug("no tenants, using stub %p", stub_de_ctx);
} else if (master->list->next == NULL && master->list->type == DETECT_ENGINE_TYPE_STUB) {
stub_de_ctx = master->list;
SCLogDebug("no tenants, using original %p", stub_de_ctx);
/* the default de_ctx should be in the list */ if (list->type == DETECT_ENGINE_TYPE_NORMAL || list->type == DETECT_ENGINE_TYPE_STUB) {
} else { stub_de_ctx = list;
DetectEngineCtx *list = master->list; break;
for ( ; list != NULL; list = list->next) { }
SCLogDebug("list %p tenant %u", list, list->tenant_id); }
if (stub_de_ctx == NULL) {
stub_de_ctx = DetectEngineCtxInitStub();
if (stub_de_ctx == NULL) {
SCMutexUnlock(&master->lock);
return -1;
}
if (list->type == DETECT_ENGINE_TYPE_NORMAL) { if (master->list == NULL) {
stub_de_ctx = list; master->list = stub_de_ctx;
break; } else {
} stub_de_ctx->next = master->list;
master->list = stub_de_ctx;
} }
} }

Loading…
Cancel
Save