When the MANA VF net directory appears after PCI rescan, udev may rename
the interface (e.g. eth1 → ens1) before DPDK can query its MAC address
via SIOCGIFHWADDR. The ioctl fails because the interface name is stale
during the rename window.

Instead of giving up when SIOCGIFHWADDR fails, close the directory and
schedule another retry. The next attempt will re-read the directory with
the updated interface name (e.g. ens1 instead of eth1) and succeed.

This was observed on Azure VMs where the MANA kernel driver takes >30
seconds to probe after PCI rescan, and udev renames the interface
immediately after registration.

Fixes: a2a23a794b3a ("net/netvsc: support VF device hot add/remove")
Cc: [email protected]
Signed-off-by: Long Li <[email protected]>
---
 drivers/net/netvsc/hn_ethdev.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 61e5aa464d..8bb2df3c19 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -667,10 +667,17 @@ static void netvsc_hotplug_retry(void *args)
                ret = ioctl(s, SIOCGIFHWADDR, &req);
                close(s);
                if (ret == -1) {
-                       PMD_DRV_LOG(ERR,
-                                   "Failed to send SIOCGIFHWADDR for device 
%s",
+                       /* Interface may be renamed by udev (e.g. eth1 → ens1),
+                        * retry instead of giving up.
+                        */
+                       PMD_DRV_LOG(NOTICE,
+                                   "Failed to send SIOCGIFHWADDR for device 
%s, "
+                                   "interface may be renaming, retrying",
                                    dir->d_name);
-                       break;
+                       closedir(di);
+                       rte_eal_alarm_set(NETVSC_HOTADD_RETRY_INTERVAL,
+                                         netvsc_hotplug_retry, hot_ctx);
+                       return;
                }
                if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER)
                        continue;
-- 
2.43.0

Reply via email to