mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 18:40:16 +01:00
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.
This commit is contained in:
parent
3a3c436571
commit
63a932b851
1 changed files with 8 additions and 16 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue