Skip to content

Commit

Permalink
detect: break apart sigtable setup and initialization
Browse files Browse the repository at this point in the history
Allows initialization to be done early, so the table is ready for
dynamic registration by plugins which are loaded before signature
setup.
  • Loading branch information
jasonish committed Oct 17, 2024
1 parent 78f09d4 commit ff88c47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/detect-engine-register.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,18 +450,20 @@ void SigTableCleanup(void)
}
}

void SigTableSetup(void)
void SigTableInit(void)
{
if (sigmatch_table == NULL) {
DETECT_TBLSIZE = DETECT_TBLSIZE_STATIC + DETECT_TBLSIZE_STEP;
sigmatch_table = SCCalloc(DETECT_TBLSIZE, sizeof(SigTableElmt));
if (sigmatch_table == NULL) {
DETECT_TBLSIZE = 0;
FatalError("Could not allocate sigmatch_table");
return;
}
}
}

void SigTableSetup(void)
{
DetectSidRegister();
DetectPriorityRegister();
DetectPrefilterRegister();
Expand Down
1 change: 1 addition & 0 deletions src/detect-engine-register.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ extern int DETECT_TBLSIZE_IDX;
#define DETECT_TBLSIZE_STEP 256
int SigTableList(const char *keyword);
void SigTableCleanup(void);
void SigTableInit(void);
void SigTableSetup(void);
void SigTableRegisterTests(void);

Expand Down
1 change: 1 addition & 0 deletions src/runmode-unittests.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ void RunUnittests(int list_unittests, const char *regex_arg)
AppLayerSetup();

/* hardcoded initialization code */
SigTableInit();
SigTableSetup(); /* load the rule keywords */
TmqhSetup();

Expand Down
2 changes: 2 additions & 0 deletions src/suricata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2667,6 +2667,8 @@ int PostConfLoadedSetup(SCInstance *suri)

MacSetRegisterFlowStorage();

SigTableInit();

#ifdef HAVE_PLUGINS
SCPluginsLoad(suri->capture_plugin_name, suri->capture_plugin_args);
#endif
Expand Down

0 comments on commit ff88c47

Please sign in to comment.