runmodes: earlier evaluation of IPS mode

Move evaluation of engine runmode to an earlier
phase so that dependend modules rely on properly
configured engine runmode.

Ticket: #5958
pull/8810/head
Lukas Sismis 3 years ago committed by Victor Julien
parent f08de8ea2e
commit 3c4bdf08de

@ -702,7 +702,7 @@ static int AFPConfigGeThreadsCount(void *conf)
int AFPRunModeIsIPS(void) int AFPRunModeIsIPS(void)
{ {
int nlive = LiveGetDeviceCount(); int nlive = LiveGetDeviceNameCount();
int ldev; int ldev;
ConfNode *if_root; ConfNode *if_root;
ConfNode *if_default = NULL; ConfNode *if_default = NULL;
@ -719,7 +719,7 @@ int AFPRunModeIsIPS(void)
if_default = ConfNodeLookupKeyValue(af_packet_node, "interface", "default"); if_default = ConfNodeLookupKeyValue(af_packet_node, "interface", "default");
for (ldev = 0; ldev < nlive; ldev++) { for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev); const char *live_dev = LiveGetDeviceNameName(ldev);
if (live_dev == NULL) { if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0; return 0;
@ -751,7 +751,7 @@ int AFPRunModeIsIPS(void)
"AF_PACKET using both IPS and TAP/IDS mode, this will not " "AF_PACKET using both IPS and TAP/IDS mode, this will not "
"be allowed in Suricata 8 due to undefined behavior. See ticket #5588."); "be allowed in Suricata 8 due to undefined behavior. See ticket #5588.");
for (ldev = 0; ldev < nlive; ldev++) { for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev); const char *live_dev = LiveGetDeviceNameName(ldev);
if (live_dev == NULL) { if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0; return 0;

@ -360,7 +360,7 @@ static int NetmapConfigGeThreadsCount(void *conf)
int NetmapRunModeIsIPS(void) int NetmapRunModeIsIPS(void)
{ {
int nlive = LiveGetDeviceCount(); int nlive = LiveGetDeviceNameCount();
int ldev; int ldev;
ConfNode *if_root; ConfNode *if_root;
ConfNode *if_default = NULL; ConfNode *if_default = NULL;
@ -377,7 +377,7 @@ int NetmapRunModeIsIPS(void)
if_default = ConfNodeLookupKeyValue(netmap_node, "interface", "default"); if_default = ConfNodeLookupKeyValue(netmap_node, "interface", "default");
for (ldev = 0; ldev < nlive; ldev++) { for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev); const char *live_dev = LiveGetDeviceNameName(ldev);
if (live_dev == NULL) { if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0; return 0;
@ -409,7 +409,7 @@ int NetmapRunModeIsIPS(void)
"Netmap using both IPS and TAP/IDS mode, this will not be " "Netmap using both IPS and TAP/IDS mode, this will not be "
"allowed in Suricata 8 due to undefined behavior. See ticket #5588."); "allowed in Suricata 8 due to undefined behavior. See ticket #5588.");
for (ldev = 0; ldev < nlive; ldev++) { for (ldev = 0; ldev < nlive; ldev++) {
const char *live_dev = LiveGetDeviceName(ldev); const char *live_dev = LiveGetDeviceNameName(ldev);
if (live_dev == NULL) { if (live_dev == NULL) {
SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file"); SCLogError(SC_ERR_INVALID_VALUE, "Problem with config file");
return 0; return 0;

@ -2453,10 +2453,8 @@ void PostConfLoadedDetectSetup(SCInstance *suri)
} }
} }
static int PostDeviceFinalizedSetup(SCInstance *suri) static void RunModeEngineIsIPS(SCInstance *suri)
{ {
SCEnter();
#ifdef HAVE_AF_PACKET #ifdef HAVE_AF_PACKET
if (suri->run_mode == RUNMODE_AFP_DEV) { if (suri->run_mode == RUNMODE_AFP_DEV) {
if (AFPRunModeIsIPS()) { if (AFPRunModeIsIPS()) {
@ -2599,6 +2597,9 @@ int PostConfLoadedSetup(SCInstance *suri)
MacSetRegisterFlowStorage(); MacSetRegisterFlowStorage();
/* set engine mode if L2 IPS */
RunModeEngineIsIPS(suri);
AppLayerSetup(); AppLayerSetup();
/* Suricata will use this umask if provided. By default it will use the /* Suricata will use this umask if provided. By default it will use the
@ -2718,11 +2719,6 @@ int PostConfLoadedSetup(SCInstance *suri)
LiveDeviceFinalize(); LiveDeviceFinalize();
/* set engine mode if L2 IPS */
if (PostDeviceFinalizedSetup(suri) != TM_ECODE_OK) {
exit(EXIT_FAILURE);
}
/* hostmode depends on engine mode being set */ /* hostmode depends on engine mode being set */
PostConfLoadedSetupHostMode(); PostConfLoadedSetupHostMode();

Loading…
Cancel
Save