device: add support for reapplying the sriov.vfs property

Adds support for reapplying the `sriov.vfs` property. Note this
does not include `num_vfs`, as the configuration needs to be reset
and reconfigured from scratch in that case.

Previously, if an existing VF is modified (e.g. if we change the `trust`
flag), we reset all VF configurations, and started from scratch. But in
some cases, this is unnecessarily disruptive.

Resolves: https://issues.redhat.com/browse/RHEL-95844
This commit is contained in:
Jan Vaclav 2025-08-14 13:00:53 +02:00
parent 588a69cd1b
commit 4ba3ffee67

View file

@ -14086,7 +14086,8 @@ can_reapply_change(NMDevice *self,
return nm_device_hash_check_invalid_keys(diffs,
NM_SETTING_SRIOV_SETTING_NAME,
error,
NM_SETTING_SRIOV_PRESERVE_ON_DOWN);
NM_SETTING_SRIOV_PRESERVE_ON_DOWN,
NM_SETTING_SRIOV_VFS);
}
out_fail:
@ -14264,9 +14265,35 @@ check_and_reapply_connection(NMDevice *self,
nm_device_link_properties_set(self, TRUE);
if (priv->state >= NM_DEVICE_STATE_CONFIG)
if (priv->state >= NM_DEVICE_STATE_CONFIG) {
GHashTable *sriov_diff;
lldp_setup(self, NM_TERNARY_DEFAULT);
sriov_diff = nm_g_hash_table_lookup(diffs, NM_SETTING_SRIOV_SETTING_NAME);
if (sriov_diff && nm_g_hash_table_lookup(sriov_diff, NM_SETTING_SRIOV_VFS)) {
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
NMSettingSriov *s_sriov;
s_sriov = (NMSettingSriov *) nm_connection_get_setting(applied, NM_TYPE_SETTING_SRIOV);
if (s_sriov) {
gs_free_error GError *local = NULL;
if (!sriov_gen_platform_vfs(self, s_sriov, &plat_vfs, &local)
|| !nm_platform_link_set_sriov_vfs(nm_device_get_platform(self),
priv->ifindex,
(const NMPlatformVF *const *) plat_vfs)) {
_LOGE(LOGD_DEVICE,
"failed to reapply SRIOV VFs%s%s",
local ? ": " : "",
local ? local->message : "");
}
}
}
}
if (priv->state >= NM_DEVICE_STATE_IP_CONFIG) {
/* Allow reapply of MTU */
priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE;