]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dpdk: remove redundant port checks and set copy iface socket id correctly
authorLukas Sismis <lsismis@oisf.net>
Fri, 16 Feb 2024 20:40:59 +0000 (21:40 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 21 Feb 2024 06:29:34 +0000 (07:29 +0100)
The function to retrieve port ID from the port name was used multiple times.
This commit removes the redundant usage of the function.

Additionally, in the DeviceConfigureIPS(), the socket ID was wrongly retrieved
for the original interface and not for the out port interface.

src/runmode-dpdk.c

index ed647f5910f58567310c16096a9cc10b10b35519..64f849d08596bf16940a5032a5aaac418de4b985 100644 (file)
@@ -1341,18 +1341,15 @@ static int DeviceValidateOutIfaceConfig(DPDKIfaceConfig *iconf)
 static int DeviceConfigureIPS(DPDKIfaceConfig *iconf)
 {
     SCEnter();
-    int retval;
-
     if (iconf->out_iface != NULL) {
-        retval = rte_eth_dev_get_port_by_name(iconf->out_iface, &iconf->out_port_id);
-        if (retval != 0) {
-            SCLogError("%s: failed to obtain out iface %s port id: %s", iconf->iface,
-                    iconf->out_iface, rte_strerror(-retval));
-            SCReturnInt(retval);
+        if (!rte_eth_dev_is_valid_port(iconf->out_port_id)) {
+            SCLogError("%s: retrieved copy interface port ID \"%d\" is invalid or the device is "
+                       "not attached ",
+                    iconf->iface, iconf->out_port_id);
+            SCReturnInt(-ENODEV);
         }
-
         int32_t out_port_socket_id;
-        retval = DeviceSetSocketID(iconf->port_id, &out_port_socket_id);
+        int retval = DeviceSetSocketID(iconf->out_port_id, &out_port_socket_id);
         if (retval < 0) {
             SCLogError("%s: invalid socket id: %s", iconf->out_iface, rte_strerror(-retval));
             SCReturnInt(retval);
@@ -1425,19 +1422,13 @@ static int32_t DeviceVerifyPostConfigure(
 static int DeviceConfigure(DPDKIfaceConfig *iconf)
 {
     SCEnter();
-    int32_t retval = rte_eth_dev_get_port_by_name(iconf->iface, &(iconf->port_id));
-    if (retval < 0) {
-        SCLogError("%s: interface not found: %s", iconf->iface, rte_strerror(-retval));
-        SCReturnInt(retval);
-    }
-
     if (!rte_eth_dev_is_valid_port(iconf->port_id)) {
         SCLogError("%s: retrieved port ID \"%d\" is invalid or the device is not attached ",
                 iconf->iface, iconf->port_id);
-        SCReturnInt(retval);
+        SCReturnInt(-ENODEV);
     }
 
-    retval = DeviceSetSocketID(iconf->port_id, &iconf->socket_id);
+    int32_t retval = DeviceSetSocketID(iconf->port_id, &iconf->socket_id);
     if (retval < 0) {
         SCLogError("%s: invalid socket id: %s", iconf->iface, rte_strerror(-retval));
         SCReturnInt(retval);