From: Victor Julien Date: Thu, 12 Feb 2015 13:13:46 +0000 (+0100) Subject: detect: don't error out on no de_ctx X-Git-Tag: suricata-3.0RC1~211 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93f856a1b309f84796f182ae95483a383c3edacc;p=thirdparty%2Fsuricata.git detect: don't error out on no de_ctx This can happen on a multi-detect setup with no registered engines yet. --- diff --git a/src/detect.c b/src/detect.c index 56dab7907b..19f0da699a 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1964,6 +1964,7 @@ TmEcode Detect(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQue return 0; } + DetectEngineCtx *de_ctx = NULL; DetectEngineThreadCtx *det_ctx = (DetectEngineThreadCtx *)data; if (det_ctx == NULL) { printf("ERROR: Detect has no thread ctx\n"); @@ -1976,20 +1977,21 @@ TmEcode Detect(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQue det_ctx); } - DetectEngineCtx *de_ctx = det_ctx->de_ctx; - if (det_ctx->TenantGetId != NULL) { + /* in MT mode, but no tenants registered yet */ if (det_ctx->mt_det_ctxs == 0) { - printf("ERROR: Detect has no detection engine ctx\n"); - goto error; + return TM_ECODE_OK; } uint32_t tenant_id = det_ctx->TenantGetId(det_ctx, p); if (tenant_id > 0 && tenant_id < det_ctx->mt_det_ctxs_cnt) { det_ctx = det_ctx->mt_det_ctxs[tenant_id]; - BUG_ON(det_ctx == NULL); + if (det_ctx == NULL) + return TM_ECODE_OK; de_ctx = det_ctx->de_ctx; - BUG_ON(de_ctx == NULL); + if (de_ctx == NULL) + return TM_ECODE_OK; + if (SC_ATOMIC_GET(det_ctx->so_far_used_by_detect) == 0) { (void)SC_ATOMIC_SET(det_ctx->so_far_used_by_detect, 1); SCLogDebug("MT de_ctx %p det_ctx %p (tenant %u)", de_ctx, det_ctx, tenant_id); @@ -1997,6 +1999,8 @@ TmEcode Detect(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQue } else { return TM_ECODE_OK; } + } else { + de_ctx = det_ctx->de_ctx; } /* see if the packet matches one or more of the sigs */