sriov: only valid sriov capacity when enabled

NetworkManager current code will refuse to activate a connection if its
interface has no SRIOV capacity but holding a empty SRIOV settings.

This patch only valid SRIOV capacity when it is enabled(total_vfs > 0).

Resolves: https://issues.redhat.com/browse/RHEL-58397

Signed-off-by: Gris Ge <fge@redhat.com>
This commit is contained in:
Gris Ge
2024-10-21 21:13:29 +08:00
parent c691dd7ecf
commit 421ccf8b4c

View File

@@ -9507,6 +9507,7 @@ check_connection_compatible(NMDevice *self,
NMSettingMatch *s_match;
const GSList *specs;
gboolean has_match = FALSE;
NMSettingSriov *s_sriov = NULL;
klass = NM_DEVICE_GET_CLASS(self);
if (klass->connection_type_check_compatible) {
@@ -9524,13 +9525,15 @@ check_connection_compatible(NMDevice *self,
return FALSE;
}
if (!nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)
&& nm_connection_get_setting(connection, NM_TYPE_SETTING_SRIOV)) {
if (!nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)) {
s_sriov = (NMSettingSriov *) nm_connection_get_setting(connection, NM_TYPE_SETTING_SRIOV);
if (s_sriov && nm_setting_sriov_get_total_vfs(s_sriov)) {
nm_utils_error_set_literal(error,
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
"device does not support SR-IOV");
return FALSE;
}
}
conn_iface = nm_manager_get_connection_iface(NM_MANAGER_GET, connection, NULL, NULL, &local);
@@ -10140,7 +10143,7 @@ activate_stage1_device_prepare(NMDevice *self)
s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV);
}
if (s_sriov) {
if (s_sriov && nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)) {
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
gs_free_error GError *error = NULL;
NMSriovVF *vf;
@@ -10148,8 +10151,6 @@ activate_stage1_device_prepare(NMDevice *self)
guint num;
guint i;
nm_assert(nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV));
autoprobe = nm_setting_sriov_get_autoprobe_drivers(s_sriov);
if (autoprobe == NM_TERNARY_DEFAULT) {
autoprobe = nm_config_data_get_connection_default_int64(