Beniamino Galvani
2025-06-18 13:22:35 +02:00
12 changed files with 140 additions and 2 deletions

4
NEWS
View File

@@ -9,6 +9,10 @@ the later release.
USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE! USE AT YOUR OWN RISK. NOT RECOMMENDED FOR PRODUCTION USE!
* nmcli now supports viewing and managing WireGuard peers. * nmcli now supports viewing and managing WireGuard peers.
* Add a new "sriov.preserve-on-down" property that controls whether
NetworkManager preserves the SR-IOV parameters set on the device
when the connection is deactivated, or whether it resets them to
their default value.
============================================= =============================================
NetworkManager-1.54 NetworkManager-1.54

View File

@@ -1093,6 +1093,12 @@ ipv6.ip6-privacy=0
<term><varname>sriov.autoprobe-drivers</varname></term> <term><varname>sriov.autoprobe-drivers</varname></term>
<listitem><para>If left unspecified, drivers are autoprobed when the SR-IOV VF gets created.</para></listitem> <listitem><para>If left unspecified, drivers are autoprobed when the SR-IOV VF gets created.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>sriov.preserve-on-down</varname></term>
<listitem><para>Set to 0 or 1 to select whether the SR-IOV parameters are
preserved when the connection is deactivated. If left unspecified, default
to 0 (parameters are not preserved). </para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>vpn.timeout</varname></term> <term><varname>vpn.timeout</varname></term>
<listitem><para>If left unspecified, default value of 60 seconds is used.</para></listitem> <listitem><para>If left unspecified, default value of 60 seconds is used.</para></listitem>

View File

@@ -1416,6 +1416,26 @@ _prop_get_connection_mdns(NMDevice *self)
NM_SETTING_CONNECTION_MDNS_DEFAULT); NM_SETTING_CONNECTION_MDNS_DEFAULT);
} }
static gboolean
_prop_get_sriov_preserve_on_down(NMDevice *self, NMSettingSriov *s_sriov)
{
NMSriovPreserveOnDown preserve;
g_return_val_if_fail(NM_IS_DEVICE(self), FALSE);
g_return_val_if_fail(NM_IS_SETTING_SRIOV(s_sriov), FALSE);
preserve = nm_setting_sriov_get_preserve_on_down(s_sriov);
if (NM_IN_SET(preserve, NM_SRIOV_PRESERVE_ON_DOWN_NO, NM_SRIOV_PRESERVE_ON_DOWN_YES))
return preserve;
return nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA,
NM_CON_DEFAULT("sriov.preserve-on-down"),
self,
NM_SRIOV_PRESERVE_ON_DOWN_NO,
NM_SRIOV_PRESERVE_ON_DOWN_YES,
NM_SRIOV_PRESERVE_ON_DOWN_NO);
}
static NMSettingConnectionLlmnr static NMSettingConnectionLlmnr
_prop_get_connection_llmnr(NMDevice *self) _prop_get_connection_llmnr(NMDevice *self)
{ {
@@ -14030,6 +14050,13 @@ can_reapply_change(NMDevice *self,
goto out_fail; goto out_fail;
} }
if (nm_streq(setting_name, NM_SETTING_SRIOV_SETTING_NAME)) {
return nm_device_hash_check_invalid_keys(diffs,
NM_SETTING_SRIOV_SETTING_NAME,
error,
NM_SETTING_SRIOV_PRESERVE_ON_DOWN);
}
out_fail: out_fail:
g_set_error(error, g_set_error(error,
NM_DEVICE_ERROR, NM_DEVICE_ERROR,
@@ -17478,7 +17505,8 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
} }
if (priv->ifindex > 0 if (priv->ifindex > 0
&& (s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV))) { && (s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV))
&& (!_prop_get_sriov_preserve_on_down(self, s_sriov))) {
priv->sriov_reset_pending++; priv->sriov_reset_pending++;
sriov_op_queue(self, sriov_op_queue(self,
0, 0,
@@ -17533,7 +17561,8 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
nm_settings_connection_update_timestamp(sett_conn, (guint64) 0); nm_settings_connection_update_timestamp(sett_conn, (guint64) 0);
if (priv->ifindex > 0 if (priv->ifindex > 0
&& (s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV))) { && (s_sriov = nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV))
&& (!_prop_get_sriov_preserve_on_down(self, s_sriov))) {
priv->sriov_reset_pending++; priv->sriov_reset_pending++;
sriov_op_queue(self, sriov_op_queue(self,
0, 0,

View File

@@ -2074,3 +2074,9 @@ global:
nm_setting_prefix_delegation_get_type; nm_setting_prefix_delegation_get_type;
nm_setting_prefix_delegation_new; nm_setting_prefix_delegation_new;
} libnm_1_52_0; } libnm_1_52_0;
libnm_1_56_0 {
global:
nm_setting_sriov_get_preserve_on_down;
nm_sriov_preserve_on_down_get_type;
} libnm_1_54_0;

View File

@@ -2386,6 +2386,10 @@
dbus-type="i" dbus-type="i"
gprop-type="gint" gprop-type="gint"
/> />
<property name="preserve-on-down"
dbus-type="i"
gprop-type="gint"
/>
<property name="total-vfs" <property name="total-vfs"
dbus-type="u" dbus-type="u"
gprop-type="guint" gprop-type="guint"

View File

@@ -22,6 +22,7 @@
NM_GOBJECT_PROPERTIES_DEFINE(NMSettingSriov, NM_GOBJECT_PROPERTIES_DEFINE(NMSettingSriov,
PROP_TOTAL_VFS, PROP_TOTAL_VFS,
PROP_VFS, PROP_VFS,
PROP_PRESERVE_ON_DOWN,
PROP_AUTOPROBE_DRIVERS, PROP_AUTOPROBE_DRIVERS,
PROP_ESWITCH_MODE, PROP_ESWITCH_MODE,
PROP_ESWITCH_INLINE_MODE, PROP_ESWITCH_INLINE_MODE,
@@ -39,6 +40,7 @@ struct _NMSettingSriov {
GPtrArray *vfs; GPtrArray *vfs;
int autoprobe_drivers; int autoprobe_drivers;
guint32 total_vfs; guint32 total_vfs;
int preserve_on_down;
int eswitch_mode; int eswitch_mode;
int eswitch_inline_mode; int eswitch_inline_mode;
int eswitch_encap_mode; int eswitch_encap_mode;
@@ -826,6 +828,22 @@ nm_setting_sriov_clear_vfs(NMSettingSriov *setting)
} }
} }
/**
* nm_setting_sriov_get_preserve_on_down:
* @setting: the #NMSettingSriov
*
* Returns: the value contained in the #NMSettingSriov:preserve-on-down property.
*
* Since: 1.56
*/
NMSriovPreserveOnDown
nm_setting_sriov_get_preserve_on_down(NMSettingSriov *setting)
{
g_return_val_if_fail(NM_IS_SETTING_SRIOV(setting), NM_SRIOV_PRESERVE_ON_DOWN_DEFAULT);
return setting->preserve_on_down;
}
/** /**
* nm_setting_sriov_get_autoprobe_drivers: * nm_setting_sriov_get_autoprobe_drivers:
* @setting: the #NMSettingSriov * @setting: the #NMSettingSriov
@@ -1462,6 +1480,35 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass)
NMSettingSriov, NMSettingSriov,
eswitch_encap_mode); eswitch_encap_mode);
/**
* NMSettingSriov:preserve-on-down
*
* This controls whether NetworkManager preserves the SR-IOV parameters set on
* the device when the connection is deactivated, or whether it resets them to
* their default value. The SR-IOV parameters are those specified in this setting
* (the "sriov" setting), like the number of VFs to create, the eswitch
* configuration, etc.
*
* If set to %NM_SRIOV_PRESERVE_ON_DOWN_NO, NetworkManager resets the SR-IOV
* parameters when the connection is deactivated. When set to
* %NM_SRIOV_PRESERVE_ON_DOWN_YES, NetworkManager preserves those parameters
* on the device. If the value is %NM_SRIOV_PRESERVE_ON_DOWN_DEFAULT, NetworkManager
* looks up a global default value in the configuration; in case no such value is
* defined, it uses %NM_SRIOV_PRESERVE_ON_DOWN_NO as fallback.
*
* Since: 1.56
*/
_nm_setting_property_define_direct_enum(properties_override,
obj_properties,
NM_SETTING_SRIOV_PRESERVE_ON_DOWN,
PROP_PRESERVE_ON_DOWN,
NM_TYPE_SRIOV_PRESERVE_ON_DOWN,
NM_SRIOV_PRESERVE_ON_DOWN_DEFAULT,
NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingSriov,
preserve_on_down);
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
_nm_setting_class_commit(setting_class, _nm_setting_class_commit(setting_class,

View File

@@ -28,6 +28,7 @@ G_BEGIN_DECLS
#define NM_SETTING_SRIOV_TOTAL_VFS "total-vfs" #define NM_SETTING_SRIOV_TOTAL_VFS "total-vfs"
#define NM_SETTING_SRIOV_VFS "vfs" #define NM_SETTING_SRIOV_VFS "vfs"
#define NM_SETTING_SRIOV_PRESERVE_ON_DOWN "preserve-on-down"
#define NM_SETTING_SRIOV_AUTOPROBE_DRIVERS "autoprobe-drivers" #define NM_SETTING_SRIOV_AUTOPROBE_DRIVERS "autoprobe-drivers"
#define NM_SETTING_SRIOV_ESWITCH_MODE "eswitch-mode" #define NM_SETTING_SRIOV_ESWITCH_MODE "eswitch-mode"
#define NM_SETTING_SRIOV_ESWITCH_INLINE_MODE "eswitch-inline-mode" #define NM_SETTING_SRIOV_ESWITCH_INLINE_MODE "eswitch-inline-mode"
@@ -56,6 +57,22 @@ typedef enum {
NM_SRIOV_VF_VLAN_PROTOCOL_802_1AD = 1, NM_SRIOV_VF_VLAN_PROTOCOL_802_1AD = 1,
} NMSriovVFVlanProtocol; } NMSriovVFVlanProtocol;
/**
* NMSriovPreserveOnDown:
* @NM_SRIOV_PRESERVE_ON_DOWN_DEFAULT: use the default value
* @NM_SRIOV_PRESERVE_ON_DOWN_NO: reset the SR-IOV parameters when the
* connection is deactivated
* @NM_SRIOV_PRESERVE_ON_DOWN_YES: preserve the SR-IOV parameters set on
* the device when the connection is deactivated
*
* Since: 1.56
*/
typedef enum {
NM_SRIOV_PRESERVE_ON_DOWN_DEFAULT = -1,
NM_SRIOV_PRESERVE_ON_DOWN_NO = 0,
NM_SRIOV_PRESERVE_ON_DOWN_YES = 1,
} NMSriovPreserveOnDown;
/** /**
* NMSriovEswitchMode: * NMSriovEswitchMode:
* @NM_SRIOV_ESWITCH_MODE_PRESERVE: don't modify current eswitch mode * @NM_SRIOV_ESWITCH_MODE_PRESERVE: don't modify current eswitch mode
@@ -123,6 +140,8 @@ NM_AVAILABLE_IN_1_14
gboolean nm_setting_sriov_remove_vf_by_index(NMSettingSriov *setting, guint index); gboolean nm_setting_sriov_remove_vf_by_index(NMSettingSriov *setting, guint index);
NM_AVAILABLE_IN_1_14 NM_AVAILABLE_IN_1_14
void nm_setting_sriov_clear_vfs(NMSettingSriov *setting); void nm_setting_sriov_clear_vfs(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_56
NMSriovPreserveOnDown nm_setting_sriov_get_preserve_on_down(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_14 NM_AVAILABLE_IN_1_14
NMTernary nm_setting_sriov_get_autoprobe_drivers(NMSettingSriov *setting); NMTernary nm_setting_sriov_get_autoprobe_drivers(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46 NM_AVAILABLE_IN_1_46

View File

@@ -78,6 +78,7 @@
#define NM_VERSION_1_50 (NM_ENCODE_VERSION(1, 50, 0)) #define NM_VERSION_1_50 (NM_ENCODE_VERSION(1, 50, 0))
#define NM_VERSION_1_52 (NM_ENCODE_VERSION(1, 52, 0)) #define NM_VERSION_1_52 (NM_ENCODE_VERSION(1, 52, 0))
#define NM_VERSION_1_54 (NM_ENCODE_VERSION(1, 54, 0)) #define NM_VERSION_1_54 (NM_ENCODE_VERSION(1, 54, 0))
#define NM_VERSION_1_56 (NM_ENCODE_VERSION(1, 56, 0))
/* For releases, NM_API_VERSION is equal to NM_VERSION. /* For releases, NM_API_VERSION is equal to NM_VERSION.
* *

View File

@@ -439,6 +439,20 @@
#define NM_AVAILABLE_IN_1_54 #define NM_AVAILABLE_IN_1_54
#endif #endif
#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_56
#define NM_DEPRECATED_IN_1_56 G_DEPRECATED
#define NM_DEPRECATED_IN_1_56_FOR(f) G_DEPRECATED_FOR(f)
#else
#define NM_DEPRECATED_IN_1_56
#define NM_DEPRECATED_IN_1_56_FOR(f)
#endif
#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_56
#define NM_AVAILABLE_IN_1_56 G_UNAVAILABLE(1, 56)
#else
#define NM_AVAILABLE_IN_1_56
#endif
/* /*
* Synchronous API for calling D-Bus in libnm is deprecated. See * Synchronous API for calling D-Bus in libnm is deprecated. See
* https://networkmanager.dev/docs/libnm/latest/usage.html#sync-api * https://networkmanager.dev/docs/libnm/latest/usage.html#sync-api

View File

@@ -7674,6 +7674,9 @@ static const NMMetaPropertyInfo *const property_infos_SRIOV[] = {
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE, PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE,
.property_type = &_pt_gobject_enum, .property_type = &_pt_gobject_enum,
), ),
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_PRESERVE_ON_DOWN,
.property_type = &_pt_gobject_enum,
),
NULL NULL
}; };

View File

@@ -353,6 +353,7 @@
#define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE N_("Select the eswitch encapsulation support. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch encap-mode won't be modified by NetworkManager.") #define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE N_("Select the eswitch encapsulation support. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch encap-mode won't be modified by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_INLINE_MODE N_("Select the eswitch inline-mode of the device. Some HWs need the VF driver to put part of the packet headers on the TX descriptor so the e-switch can do proper matching and steering. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch inline-mode won't be modified by NetworkManager.") #define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_INLINE_MODE N_("Select the eswitch inline-mode of the device. Some HWs need the VF driver to put part of the packet headers on the TX descriptor so the e-switch can do proper matching and steering. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch inline-mode won't be modified by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_MODE N_("Select the eswitch mode of the device. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch mode won't be modified by NetworkManager.") #define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_MODE N_("Select the eswitch mode of the device. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch mode won't be modified by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_PRESERVE_ON_DOWN N_("This controls whether NetworkManager preserves the SR-IOV parameters set on the device when the connection is deactivated, or whether it resets them to their default value. The SR-IOV parameters are those specified in this setting (the \"sriov\" setting), like the number of VFs to create, the eswitch configuration, etc. If set to \"no\" (0), NetworkManager resets the SR-IOV parameters when the connection is deactivated. When set to \"yes\" (1), NetworkManager preserves those parameters on the device. If the value is \"default\" (-1), NetworkManager looks up a global default value in the configuration; in case no such value is defined, it uses \"no\" (0) as fallback.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_TOTAL_VFS N_("The total number of virtual functions to create. Note that when the sriov setting is present NetworkManager enforces the number of virtual functions on the interface (also when it is zero) during activation and resets it upon deactivation. To prevent any changes to SR-IOV parameters don't add a sriov setting to the connection.") #define DESCRIBE_DOC_NM_SETTING_SRIOV_TOTAL_VFS N_("The total number of virtual functions to create. Note that when the sriov setting is present NetworkManager enforces the number of virtual functions on the interface (also when it is zero) during activation and resets it upon deactivation. To prevent any changes to SR-IOV parameters don't add a sriov setting to the connection.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_VFS N_("Array of virtual function descriptors. Each VF descriptor is a dictionary mapping attribute names to GVariant values. The 'index' entry is mandatory for each VF. When represented as string a VF is in the form: \"INDEX [ATTR=VALUE[ ATTR=VALUE]...]\". for example: \"2 mac=00:11:22:33:44:55 spoof-check=true\". Multiple VFs can be specified using a comma as separator. Currently, the following attributes are supported: mac, spoof-check, trust, min-tx-rate, max-tx-rate, vlans. The \"vlans\" attribute is represented as a semicolon-separated list of VLAN descriptors, where each descriptor has the form \"ID[.PRIORITY[.PROTO]]\". PROTO can be either 'q' for 802.1Q (the default) or 'ad' for 802.1ad.") #define DESCRIBE_DOC_NM_SETTING_SRIOV_VFS N_("Array of virtual function descriptors. Each VF descriptor is a dictionary mapping attribute names to GVariant values. The 'index' entry is mandatory for each VF. When represented as string a VF is in the form: \"INDEX [ATTR=VALUE[ ATTR=VALUE]...]\". for example: \"2 mac=00:11:22:33:44:55 spoof-check=true\". Multiple VFs can be specified using a comma as separator. Currently, the following attributes are supported: mac, spoof-check, trust, min-tx-rate, max-tx-rate, vlans. The \"vlans\" attribute is represented as a semicolon-separated list of VLAN descriptors, where each descriptor has the form \"ID[.PRIORITY[.PROTO]]\". PROTO can be either 'q' for 802.1Q (the default) or 'ad' for 802.1ad.")
#define DESCRIBE_DOC_NM_SETTING_TC_CONFIG_QDISCS N_("Array of TC queueing disciplines. When the \"tc\" setting is present, qdiscs from this property are applied upon activation. If the property is empty, all qdiscs are removed and the device will only have the default qdisc assigned by kernel according to the \"net.core.default_qdisc\" sysctl. If the \"tc\" setting is not present, NetworkManager doesn't touch the qdiscs present on the interface.") #define DESCRIBE_DOC_NM_SETTING_TC_CONFIG_QDISCS N_("Array of TC queueing disciplines. When the \"tc\" setting is present, qdiscs from this property are applied upon activation. If the property is empty, all qdiscs are removed and the device will only have the default qdisc assigned by kernel according to the \"net.core.default_qdisc\" sysctl. If the \"tc\" setting is not present, NetworkManager doesn't touch the qdiscs present on the interface.")

View File

@@ -1984,6 +1984,10 @@
nmcli-description="Select the eswitch encapsulation support. Currently it&apos;s only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to &quot;preserve&quot; (-1) (default) the eswitch encap-mode won&apos;t be modified by NetworkManager." nmcli-description="Select the eswitch encapsulation support. Currently it&apos;s only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to &quot;preserve&quot; (-1) (default) the eswitch encap-mode won&apos;t be modified by NetworkManager."
format="choice (NMSriovEswitchEncapMode)" format="choice (NMSriovEswitchEncapMode)"
values="preserve (-1), none (0), basic (1)" /> values="preserve (-1), none (0), basic (1)" />
<property name="preserve-on-down"
nmcli-description="This controls whether NetworkManager preserves the SR-IOV parameters set on the device when the connection is deactivated, or whether it resets them to their default value. The SR-IOV parameters are those specified in this setting (the &quot;sriov&quot; setting), like the number of VFs to create, the eswitch configuration, etc. If set to &quot;no&quot; (0), NetworkManager resets the SR-IOV parameters when the connection is deactivated. When set to &quot;yes&quot; (1), NetworkManager preserves those parameters on the device. If the value is &quot;default&quot; (-1), NetworkManager looks up a global default value in the configuration; in case no such value is defined, it uses &quot;no&quot; (0) as fallback."
format="choice (NMSriovPreserveOnDown)"
values="default (-1), no (0), yes (1)" />
</setting> </setting>
<setting name="tc" > <setting name="tc" >
<property name="qdiscs" <property name="qdiscs"