From: Lukas Sismis Date: Fri, 16 Feb 2024 20:40:59 +0000 (+0100) Subject: dpdk: remove redundant port checks and set copy iface socket id correctly X-Git-Tag: suricata-8.0.0-beta1~1723 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a085ccb83bbfdd3a1ec055c952653a6713e9308;p=thirdparty%2Fsuricata.git dpdk: remove redundant port checks and set copy iface socket id correctly 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. --- diff --git a/src/runmode-dpdk.c b/src/runmode-dpdk.c index ed647f5910..64f849d085 100644 --- a/src/runmode-dpdk.c +++ b/src/runmode-dpdk.c @@ -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);