@@ -1114,10 +1114,12 @@ netdev_dpdk_lookup_by_port_id(int port_id)
static int
netdev_dpdk_process_devargs(const char *devargs, char **errp)
{
+ /* Get the name up to the first comma. */
+ char *name = xmemdup0(devargs, strcspn(devargs, ","));
uint8_t new_port_id = UINT8_MAX;
if (!rte_eth_dev_count()
- || rte_eth_dev_get_port_by_name(devargs, &new_port_id)
+ || rte_eth_dev_get_port_by_name(name, &new_port_id)
|| !rte_eth_dev_is_valid_port(new_port_id)) {
/* Device not found in DPDK, attempt to attach it */
if (!rte_eth_dev_attach(devargs, &new_port_id)) {
@@ -1130,6 +1132,7 @@ netdev_dpdk_process_devargs(const char *devargs, char **errp)
}
}
+ free(name);
return new_port_id;
}
'devargs' for virtual devices contains not only name but also a list of arguments like this: 'net_pcap0,rx_pcap=file_rx.pcap,tx_pcap=file_tx.pcap' or 'eth_af_packet0,iface=eth0' We must cut off the arguments from this string before calling 'rte_eth_dev_get_port_by_name()' to avoid double attaching of the same device. CC: Ciara Loftus <ciara.loftus@intel.com> Fixes: 69876ed78611 ("netdev-dpdk: Add support for virtual DPDK PMDs (vdevs)") Signed-off-by: Ilya Maximets <i.maximets@samsung.com> --- lib/netdev-dpdk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)