merge: branch 'fix_sriov'

sriov: only valid sriov capacity when enabled

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2051
This commit is contained in:
Gris Ge
2024-10-22 02:16:20 +00:00

View File

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