Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefilter/v1 #12477

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/detect-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1908,26 +1908,41 @@ extern int g_skip_prefilter;
static void SigSetupPrefilter(DetectEngineCtx *de_ctx, Signature *s)
{
SCEnter();
if (s->init_data->prefilter_sm != NULL || s->init_data->mpm_sm != NULL) {
SCReturn;
}

SCLogDebug("s %u: set up prefilter/mpm", s->id);
RetrieveFPForSig(de_ctx, s);
if (s->init_data->mpm_sm != NULL) {
s->flags |= SIG_FLAG_PREFILTER;
SCReturn;
DEBUG_VALIDATE_BUG_ON(s->init_data->mpm_sm != NULL);

if (s->init_data->prefilter_sm != NULL) {
if (s->init_data->prefilter_sm->type == DETECT_CONTENT) {
RetrieveFPForSig(de_ctx, s);
if (s->init_data->mpm_sm != NULL) {
s->flags |= SIG_FLAG_PREFILTER;
SCLogDebug("%u: RetrieveFPForSig set", s->id);
SCReturn;
}
/* fall through, this can happen if the mpm doesn't support the pattern */
} else {
s->flags |= SIG_FLAG_PREFILTER;
SCReturn;
}
} else {
SCLogDebug("%u: RetrieveFPForSig", s->id);
RetrieveFPForSig(de_ctx, s);
if (s->init_data->mpm_sm != NULL) {
s->flags |= SIG_FLAG_PREFILTER;
SCLogDebug("%u: RetrieveFPForSig set", s->id);
SCReturn;
}
}

SCLogDebug("s %u: no mpm; prefilter? de_ctx->prefilter_setting %u "
"s->init_data->has_possible_prefilter %s",
s->id, de_ctx->prefilter_setting, BOOL2STR(s->init_data->has_possible_prefilter));

if (!s->init_data->has_possible_prefilter)
if (!s->init_data->has_possible_prefilter || !g_skip_prefilter)
SCReturn;

if (!g_skip_prefilter && de_ctx->prefilter_setting == DETECT_PREFILTER_AUTO &&
!(s->flags & SIG_FLAG_PREFILTER)) {
DEBUG_VALIDATE_BUG_ON(s->flags & SIG_FLAG_PREFILTER);
if (de_ctx->prefilter_setting == DETECT_PREFILTER_AUTO) {
int prefilter_list = DETECT_TBLSIZE;
/* get the keyword supporting prefilter with the lowest type */
for (int i = 0; i < DETECT_SM_LIST_MAX; i++) {
Expand Down
1 change: 0 additions & 1 deletion src/detect-prefilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static int DetectPrefilterSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
SCLogError("prefilter is not supported for %s", sigmatch_table[sm->type].name);
SCReturnInt(-1);
}
s->flags |= SIG_FLAG_PREFILTER;

/* make sure setup function runs for this type. */
de_ctx->sm_types_prefilter[sm->type] = true;
Expand Down
2 changes: 0 additions & 2 deletions src/detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ typedef struct SignatureInitData_ {
/** address settings for this signature */
const DetectAddressHead *src, *dst;

int prefilter_list;

/* holds built-in sm lists */
struct SigMatch_ *smlists[DETECT_SM_LIST_MAX];
/* holds built-in sm lists' tails */
Expand Down
Loading