]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
capture: improve IDS + IPS check
authorVictor Julien <vjulien@oisf.net>
Tue, 16 Apr 2024 13:38:13 +0000 (15:38 +0200)
committerVictor Julien <vjulien@oisf.net>
Sat, 20 Apr 2024 06:50:59 +0000 (08:50 +0200)
Improve it for af-packet, dpdk, netmap. Check would not consider
an interface IDS if the `default` section contained a copy-mode
field.

(cherry picked from commit 58bff9b85508671f45f044d3fe212d29ffe1f95a)

src/runmode-af-packet.c
src/runmode-dpdk.c
src/runmode-netmap.c

index b8ad0bfac0c39c28f683ec783e9616737a8bd436..742d96855bb7b1ee8d7cd28003a91b1a69895be8 100644 (file)
@@ -90,7 +90,6 @@ static int AFPRunModeIsIPS(void)
             SCLogError("Problem with config file");
             return 0;
         }
-        const char *copymodestr = NULL;
         if_root = ConfFindDeviceConfig(af_packet_node, live_dev);
 
         if (if_root == NULL) {
@@ -101,7 +100,10 @@ static int AFPRunModeIsIPS(void)
             if_root = if_default;
         }
 
-        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", &copymodestr) == 1) {
+        const char *copymodestr = NULL;
+        const char *copyifacestr = NULL;
+        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", &copymodestr) == 1 &&
+                ConfGetChildValue(if_root, "copy-iface", &copyifacestr) == 1) {
             if (strcmp(copymodestr, "ips") == 0) {
                 has_ips = 1;
             } else {
index b4d476b95c5a750f10f68b0973fb63c8415c8fca..fb49d6ed9e01c59e4bfae6b919be6cc209d36b08 100644 (file)
@@ -1646,7 +1646,9 @@ static int DPDKRunModeIsIPS(void)
         }
 
         const char *copymodestr = NULL;
-        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", &copymodestr) == 1) {
+        const char *copyifacestr = NULL;
+        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", &copymodestr) == 1 &&
+                ConfGetChildValue(if_root, "copy-iface", &copyifacestr) == 1) {
             if (strcmp(copymodestr, "ips") == 0) {
                 has_ips = true;
             } else {
index e207cf06300fb9a37c9041e205f9c216f63a8f3d..947b381229d23c9c90190e11c77022f846ec0f87 100644 (file)
@@ -81,7 +81,6 @@ static int NetmapRunModeIsIPS(void)
             SCLogError("Problem with config file");
             return 0;
         }
-        const char *copymodestr = NULL;
         if_root = ConfNodeLookupKeyValue(netmap_node, "interface", live_dev);
 
         if (if_root == NULL) {
@@ -92,7 +91,10 @@ static int NetmapRunModeIsIPS(void)
             if_root = if_default;
         }
 
-        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", &copymodestr) == 1) {
+        const char *copymodestr = NULL;
+        const char *copyifacestr = NULL;
+        if (ConfGetChildValueWithDefault(if_root, if_default, "copy-mode", &copymodestr) == 1 &&
+                ConfGetChildValue(if_root, "copy-iface", &copyifacestr) == 1) {
             if (strcmp(copymodestr, "ips") == 0) {
                 has_ips = 1;
             } else {