From 63a932b851cd569a77fbc20628d91fda0f7e01b7 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 25 Jun 2020 11:43:14 +0200 Subject: [PATCH] platform: do not rely on the presence of sriov_totalvfs sysfs file The file doesn't exist for all interfaces that support SR-IOV. In particular, netdevsim devices support SR-IOV but don't expose the file. --- src/platform/nm-linux-platform.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index b05c50de48..2ee478cdcf 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -7254,7 +7254,7 @@ link_supports_sriov (NMPlatform *platform, int ifindex) nm_auto_pop_netns NMPNetns *netns = NULL; nm_auto_close int dirfd = -1; char ifname[IFNAMSIZ]; - int total = -1; + int num = -1; if (!nm_platform_netns_push (platform, &netns)) return FALSE; @@ -7263,13 +7263,13 @@ link_supports_sriov (NMPlatform *platform, int ifindex) if (dirfd < 0) return FALSE; - total = nm_platform_sysctl_get_int32 (platform, - NMP_SYSCTL_PATHID_NETDIR (dirfd, - ifname, - "device/sriov_totalvfs"), - -1); + num = nm_platform_sysctl_get_int32 (platform, + NMP_SYSCTL_PATHID_NETDIR (dirfd, + ifname, + "device/sriov_numvfs"), + -1); - return total > 0; + return num != -1; } static int @@ -7412,15 +7412,7 @@ link_set_sriov_params_async (NMPlatform *platform, ifname, "device/sriov_totalvfs"), 10, 0, G_MAXUINT, 0); - if (errno) { - g_set_error (&error, - NM_UTILS_ERROR, - NM_UTILS_ERROR_UNKNOWN, - "failed reading sriov_totalvfs value: %s", - nm_strerror_native (errno)); - goto out_idle; - } - if (num_vfs > total) { + if (!errno && num_vfs > total) { _LOGW ("link: %d only supports %u VFs (requested %u)", ifindex, total, num_vfs); num_vfs = total; }