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.
pull/10475/head
Lukas Sismis 2 years ago committed by Victor Julien
parent 9185ca8f38
commit 2a085ccb83

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

Loading…
Cancel
Save