]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dpdk: support multiple same EAL arguments
authorliaozhiyuan <798389647@qq.com>
Thu, 1 Jun 2023 02:38:04 +0000 (10:38 +0800)
committerVictor Julien <vjulien@oisf.net>
Fri, 16 Jun 2023 08:38:48 +0000 (10:38 +0200)
DPDK apps can specify multiple arguments of the same
type. YAML format only allows unique keys within a single
node. This commit adds support for multiple EAL arguments
of the same type to be used within suricata.yaml.

Ticket: #5964

doc/userguide/configuration/suricata-yaml.rst
src/runmode-dpdk.c

index 63ce9a8fca60c1ae9b9f6bce8d8f419553ee9298..fdb1aed3c4108b2902f48ef359a51869ff3758f3 100644 (file)
@@ -1965,6 +1965,7 @@ The whole DPDK configuration resides in the `dpdk:` node. This node encapsulates
     dpdk:
       eal-params:
         proc-type: primary
+        allow: ["0000:3b:00.0", "0000:3b:00.1"]
       interfaces:
         - interface: 0000:3b:00.0
           threads: auto
@@ -1988,7 +1989,14 @@ are typically provided through the command line, are contained in the node
 parameters. There are two ways to specify arguments: lengthy and short.
 Dashes are omitted when describing the arguments. This setup node can be
 used to set up the memory configuration, accessible NICs, and other EAL-related
-parameters, among other things. The definition of lcore affinity as an EAL
+parameters, among other things. The node `dpdk.eal-params` also supports 
+multiple arguments of the same type. This can be useful for EAL arguments 
+such as `--vdev`, `--allow`, or `--block`. Values for these EAL arguments 
+are specified as a comma-separated list. 
+An example of such usage can be found in the example above where the `allow` 
+argument only makes `0000:3b:00.0` and `0000:3b:00.1` accessible to Suricata. 
+arguments with list node. such as --vdev, --allow, --block eal options.
+The definition of lcore affinity as an EAL
 parameter is a standard practice. However, lcore parameters like `-l`, `-c`,
 and `--lcores`` are specified within the `suricata-yaml-threading`_ section
 to prevent configuration overlap.
index 82e6aee57f27e87f130e4b5d8899c7f58cf9c9d9..687d88871a3db0ee044f759e671811064bc37437 100644 (file)
@@ -272,6 +272,14 @@ static void InitEal(void)
     ArgumentsAdd(&args, AllocAndSetArgument("suricata"));
 
     TAILQ_FOREACH (param, &eal_params->head, next) {
+        if (ConfNodeIsSequence(param)) {
+            const char *key = param->name;
+            ConfNode *val;
+            TAILQ_FOREACH (val, &param->head, next) {
+                ArgumentsAddOptionAndArgument(&args, key, (const char *)val->val);
+            }
+            continue;
+        }
         ArgumentsAddOptionAndArgument(&args, param->name, param->val);
     }