summaryrefslogtreecommitdiff
path: root/src/platform/nm-linux-platform.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-06-25 11:43:14 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-07-10 10:19:08 +0200
commit63a932b851cd569a77fbc20628d91fda0f7e01b7 (patch)
tree7a002e28dfe6ff09829950b62ebd3e6327c805b4 /src/platform/nm-linux-platform.c
parent3a3c436571a55997ef53d21756ad58628fd8250e (diff)
downloadNetworkManager-63a932b851cd569a77fbc20628d91fda0f7e01b7.tar.gz
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.
Diffstat (limited to 'src/platform/nm-linux-platform.c')
-rw-r--r--src/platform/nm-linux-platform.c24
1 files 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;
}