connection: deprecate the NMSettingConnection Master property

To embrace inclusive language, deprecate the NMSettingConnection Master
property and introduce Controller property.
This commit is contained in:
Fernando Fernandez Mancera 2023-11-29 14:43:43 +01:00
parent 71b535e932
commit 00bc10b8c0
13 changed files with 1118 additions and 819 deletions

View file

@ -1956,6 +1956,7 @@ global:
nm_device_ip_tunnel_get_fwmark;
nm_ethtool_optname_is_channels;
nm_ethtool_optname_is_eee;
nm_setting_connection_get_controller;
nm_setting_hsr_get_multicast_spec;
nm_setting_hsr_get_port1;
nm_setting_hsr_get_port2;

View file

@ -779,6 +779,10 @@
dbus-type="i"
gprop-type="NMSettingConnectionAutoconnectSlaves"
/>
<property name="controller"
dbus-type="s"
gprop-type="gchararray"
/>
<property name="dns-over-tls"
dbus-type="i"
gprop-type="gint"
@ -804,6 +808,7 @@
gprop-type="gint"
/>
<property name="master"
is-deprecated="1"
dbus-type="s"
gprop-type="gchararray"
/>

View file

@ -56,6 +56,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection,
PROP_READ_ONLY,
PROP_ZONE,
PROP_MASTER,
PROP_CONTROLLER,
PROP_SLAVE_TYPE,
PROP_AUTOCONNECT_SLAVES,
PROP_SECONDARIES,
@ -80,7 +81,7 @@ typedef struct {
char *stable_id;
char *interface_name;
char *type;
char *master;
char *controller;
char *slave_type;
char *zone;
char *mud_url;
@ -709,13 +710,33 @@ nm_setting_connection_get_zone(NMSettingConnection *setting)
*
* Returns: interface name of the master device or UUID of the master
* connection.
*
* Deprecated: 1.46. Use nm_setting_connection_get_controller() instead which
* is just an alias.
*/
const char *
nm_setting_connection_get_master(NMSettingConnection *setting)
{
return nm_setting_connection_get_controller(setting);
}
/**
* nm_setting_connection_get_controller:
* @setting: the #NMSettingConnection
*
* Returns the #NMSettingConnection:controller property of the connection.
*
* Returns: interface name of the controller device or UUID of the controller
* connection.
*
* Since: 1.46
*/
const char *
nm_setting_connection_get_controller(NMSettingConnection *setting)
{
g_return_val_if_fail(NM_IS_SETTING_CONNECTION(setting), NULL);
return NM_SETTING_CONNECTION_GET_PRIVATE(setting)->master;
return NM_SETTING_CONNECTION_GET_PRIVATE(setting)->controller;
}
/**
@ -1099,7 +1120,7 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con,
}
if (is_slave) {
if (!priv->master) {
if (!priv->controller) {
g_set_error(error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_MISSING_PROPERTY,
@ -1116,7 +1137,7 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con,
normerr_slave_setting_type = slave_setting_type;
} else {
nm_assert(!slave_type);
if (priv->master) {
if (priv->controller) {
NMSetting *s_port;
if (connection
@ -1791,6 +1812,67 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
/*****************************************************************************/
gboolean
_nm_setting_connection_master_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
{
const char *str;
if (!_nm_setting_use_legacy_property(setting,
connection_dict,
NM_SETTING_CONNECTION_MASTER,
NM_SETTING_CONNECTION_CONTROLLER)) {
*out_is_modified = FALSE;
return TRUE;
}
str = g_variant_get_string(value, NULL);
g_object_set(setting, NM_SETTING_CONNECTION_MASTER, str, NULL);
return TRUE;
}
GVariant *
_nm_setting_connection_controller_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil)
{
const char *controller;
/* FIXME: `controller` is an alias of `master` property. Serializing the
* property to the clients would break them as they won't be able to drop
* it if they are not aware of the existance of `controller`. In order to
* give them time to adapt their code, NetworkManager is not serializing
* `controller` on DBus.
*/
if (_nm_utils_is_manager_process) {
return NULL;
}
controller = nm_setting_connection_get_controller(NM_SETTING_CONNECTION(setting));
if (!controller)
return NULL;
return g_variant_new_string(controller);
}
gboolean
_nm_setting_connection_controller_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
{
const char *str;
/* Ignore 'controller' if we're going to process 'master' */
if (_nm_setting_use_legacy_property(setting,
connection_dict,
NM_SETTING_CONNECTION_MASTER,
NM_SETTING_CONNECTION_CONTROLLER)) {
*out_is_modified = FALSE;
return TRUE;
}
str = g_variant_get_string(value, NULL);
g_object_set(setting, NM_SETTING_CONNECTION_CONTROLLER, str, NULL);
return TRUE;
}
/*****************************************************************************/
static void
nm_setting_connection_init(NMSettingConnection *setting)
{}
@ -1824,6 +1906,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS(klass);
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
GArray *properties_override = _nm_sett_info_property_override_create_array_sized(35);
guint prop_idx;
object_class->get_property = get_property;
object_class->set_property = set_property;
@ -2264,6 +2347,8 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
* NMSettingConnection:master:
*
* Interface name of the master device or UUID of the master connection.
*
* Deprecated 1.46. Use #NMSettingConnection:controller instead, this is just an alias.
**/
/* ---ifcfg-rh---
* property: master
@ -2274,14 +2359,44 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
* for compatibility with legacy tooling.
* ---end---
*/
_nm_setting_property_define_direct_string(properties_override,
obj_properties,
NM_SETTING_CONNECTION_MASTER,
PROP_MASTER,
NM_SETTING_PARAM_FUZZY_IGNORE
| NM_SETTING_PARAM_INFERRABLE,
NMSettingConnectionPrivate,
master);
prop_idx = _nm_setting_property_define_direct_string_full(
properties_override,
obj_properties,
NM_SETTING_CONNECTION_MASTER,
PROP_MASTER,
NM_SETTING_PARAM_INFERRABLE | NM_SETTING_PARAM_FUZZY_IGNORE,
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING,
.direct_type = NM_VALUE_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_direct,
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
.from_dbus_fcn = _nm_setting_connection_master_from_dbus, ),
NMSettingConnectionPrivate,
controller,
.is_deprecated = 1);
/**
* NMSettingConnection:controller:
*
* Interface name of the controller device or UUID of the controller connection.
**/
_nm_setting_property_define_direct_string_full(
properties_override,
obj_properties,
NM_SETTING_CONNECTION_CONTROLLER,
PROP_CONTROLLER,
NM_SETTING_PARAM_INFERRABLE | NM_SETTING_PARAM_FUZZY_IGNORE,
NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING,
.direct_type = NM_VALUE_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_direct,
.to_dbus_fcn = _nm_setting_connection_controller_to_dbus,
.from_dbus_fcn =
_nm_setting_connection_controller_from_dbus),
NMSettingConnectionPrivate,
controller,
.direct_also_notify = obj_properties[PROP_MASTER]);
nm_g_array_index(properties_override, NMSettInfoProperty, prop_idx).direct_also_notify =
obj_properties[PROP_CONTROLLER];
/**
* NMSettingConnection:slave-type:

View file

@ -399,6 +399,12 @@ gboolean _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_
gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
gboolean _nm_setting_connection_controller_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
GVariant *_nm_setting_connection_controller_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil);
gboolean _nm_setting_connection_master_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil);
GVariant *_nm_setting_to_dbus(NMSetting *setting,
NMConnection *connection,
NMConnectionSerializationFlags flags,
@ -766,7 +772,9 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
nm_assert(_property_type); \
nm_assert(g_variant_type_equal(_property_type->dbus_type, "s")); \
nm_assert(_property_type->direct_type == NM_VALUE_TYPE_STRING); \
nm_assert(_property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_direct); \
nm_assert(NM_IN_SET(_property_type->to_dbus_fcn, \
_nm_setting_property_to_dbus_fcn_direct, \
_nm_setting_connection_controller_to_dbus)); \
\
_param_spec = g_param_spec_string("" prop_name "", \
"", \

View file

@ -2566,7 +2566,8 @@ _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_
nm_assert(NM_IN_SET(property_info->property_type->to_dbus_fcn,
_nm_setting_property_to_dbus_fcn_direct,
_nm_setting_property_to_dbus_fcn_direct_mac_address));
_nm_setting_property_to_dbus_fcn_direct_mac_address,
_nm_setting_connection_controller_to_dbus));
if (!property_info->param_spec)
return nm_assert_unreachable_val(NM_TERNARY_DEFAULT);

View file

@ -4706,8 +4706,9 @@ test_setting_metadata(void)
INFINIBAND_ALEN));
} else {
g_assert(g_variant_type_equal(sip->property_type->dbus_type, "s"));
g_assert(sip->property_type->to_dbus_fcn
== _nm_setting_property_to_dbus_fcn_direct);
g_assert(NM_IN_SET(sip->property_type->to_dbus_fcn,
_nm_setting_property_to_dbus_fcn_direct,
_nm_setting_connection_controller_to_dbus));
can_have_direct_set_fcn = TRUE;
}
g_assert(sip->param_spec);
@ -4847,6 +4848,8 @@ check_done:;
g_assert(NM_IN_SET(sip->property_type->from_dbus_fcn,
_nm_setting_property_from_dbus_fcn_direct_ip_config_gateway,
_nm_setting_property_from_dbus_fcn_direct_mac_address,
_nm_setting_connection_controller_from_dbus,
_nm_setting_connection_master_from_dbus,
_nm_setting_property_from_dbus_fcn_direct));
}
}
@ -4868,7 +4871,8 @@ check_done:;
g_assert(sip->property_type->direct_type != NM_VALUE_TYPE_NONE);
g_assert(NM_IN_SET(sip->property_type->to_dbus_fcn,
_nm_setting_property_to_dbus_fcn_direct,
_nm_setting_property_to_dbus_fcn_direct_mac_address));
_nm_setting_property_to_dbus_fcn_direct_mac_address,
_nm_setting_connection_controller_to_dbus));
} else if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_ignore) {
if (NM_IN_SET(sip->property_type,
&nm_sett_info_propert_type_deprecated_ignore_i,

View file

@ -47,6 +47,7 @@ G_BEGIN_DECLS
#define NM_SETTING_CONNECTION_PERMISSIONS "permissions"
#define NM_SETTING_CONNECTION_ZONE "zone"
#define NM_SETTING_CONNECTION_MASTER "master"
#define NM_SETTING_CONNECTION_CONTROLLER "controller"
#define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type"
#define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves"
#define NM_SETTING_CONNECTION_SECONDARIES "secondaries"
@ -193,7 +194,12 @@ gboolean nm_setting_connection_remove_permission_by_value(NMSettingConnection
const char *pitem,
const char *detail);
NM_DEPRECATED_IN_1_46
const char *nm_setting_connection_get_master(NMSettingConnection *setting);
NM_AVAILABLE_IN_1_46
const char *nm_setting_connection_get_controller(NMSettingConnection *setting);
gboolean nm_setting_connection_is_slave_type(NMSettingConnection *setting, const char *type);
const char *nm_setting_connection_get_slave_type(NMSettingConnection *setting);
NM_AVAILABLE_IN_1_2

View file

@ -5630,6 +5630,18 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_ZONE,
.property_type = &_pt_gobject_string,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_CONTROLLER,
.is_cli_option = TRUE,
.property_alias = "controller",
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
.prompt = N_("Controller"),
.property_type = DEFINE_PROPERTY_TYPE (
.get_fcn = _get_fcn_gobject,
.set_fcn = _set_fcn_gobject_string,
.complete_fcn = _complete_fcn_connection_master,
.doc_format = NM_META_PROPERTY_TYPE_FORMAT_STRING,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_MASTER,
.is_cli_option = TRUE,
.property_alias = "master",

View file

@ -5,13 +5,14 @@
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY N_("The autoconnect priority in range -999 to 999. If the connection is set to autoconnect, connections with higher priority will be preferred. The higher number means higher priority. Defaults to 0. Note that this property only matters if there are more than one candidate profile to select for autoconnect. In case of equal priority, the profile used most recently is chosen.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES N_("The number of times a connection should be tried when autoactivating before giving up. Zero means forever, -1 means the global default (4 times if not overridden). Setting this to 1 means to try activation only once before blocking autoconnect. Note that after a timeout, NetworkManager will try to autoconnect again.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES N_("Whether or not slaves of this connection should be automatically brought up when NetworkManager activates this connection. This only has a real effect for master connections. The properties \"autoconnect\", \"autoconnect-priority\" and \"autoconnect-retries\" are unrelated to this setting. The permitted values are: 0: leave slave connections untouched, 1: activate all the slave connections with this connection, -1: default. If -1 (default) is set, global connection.autoconnect-slaves is read to determine the real value. If it is default as well, this fallbacks to 0.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_CONTROLLER N_("Interface name of the controller device or UUID of the controller connection.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_DNS_OVER_TLS N_("Whether DNSOverTls (dns-over-tls) is enabled for the connection. DNSOverTls is a technology which uses TLS to encrypt dns traffic. The permitted values are: \"yes\" (2) use DNSOverTls and disabled fallback, \"opportunistic\" (1) use DNSOverTls but allow fallback to unencrypted resolution, \"no\" (0) don't ever use DNSOverTls. If unspecified \"default\" depends on the plugin used. Systemd-resolved uses global setting. This feature requires a plugin which supports DNSOverTls. Otherwise, the setting has no effect. One such plugin is dns-systemd-resolved.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT N_("If greater than zero, delay success of IP addressing until either the timeout is reached, or an IP gateway replies to a ping.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_ID N_("A human readable unique identifier for the connection, like \"Work Wi-Fi\" or \"T-Mobile 3G\".")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_INTERFACE_NAME N_("The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_LLDP N_("Whether LLDP is enabled for the connection.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_LLMNR N_("Whether Link-Local Multicast Name Resolution (LLMNR) is enabled for the connection. LLMNR is a protocol based on the Domain Name System (DNS) packet format that allows both IPv4 and IPv6 hosts to perform name resolution for hosts on the same local link. The permitted values are: \"yes\" (2) register hostname and resolving for the connection, \"no\" (0) disable LLMNR for the interface, \"resolve\" (1) do not register hostname but allow resolving of LLMNR host names If unspecified, \"default\" ultimately depends on the DNS plugin (which for systemd-resolved currently means \"yes\"). This feature requires a plugin which supports LLMNR. Otherwise, the setting has no effect. One such plugin is dns-systemd-resolved.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MASTER N_("Interface name of the master device or UUID of the master connection.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MASTER N_("Interface name of the master device or UUID of the master connection. Deprecated 1.46. Use \"controller\" instead, this is just an alias.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MDNS N_("Whether mDNS is enabled for the connection. The permitted values are: \"yes\" (2) register hostname and resolving for the connection, \"no\" (0) disable mDNS for the interface, \"resolve\" (1) do not register hostname but allow resolving of mDNS host names and \"default\" (-1) to allow lookup of a global default in NetworkManager.conf. If unspecified, \"default\" ultimately depends on the DNS plugin (which for systemd-resolved currently means \"no\"). This feature requires a plugin which supports mDNS. Otherwise, the setting has no effect. One such plugin is dns-systemd-resolved.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_METERED N_("Whether the connection is metered. When updating this property on a currently activated connection, the change takes effect immediately.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MPTCP_FLAGS N_("Whether to configure MPTCP endpoints and the address flags. If MPTCP is enabled in NetworkManager, it will configure the addresses of the interface as MPTCP endpoints. Note that IPv4 loopback addresses (127.0.0.0/8), IPv4 link local addresses (169.254.0.0/16), the IPv6 loopback address (::1), IPv6 link local addresses (fe80::/10), IPv6 unique local addresses (ULA, fc00::/7) and IPv6 privacy extension addresses (rfc3041, ipv6.ip6-privacy) will be excluded from being configured as endpoints. If \"disabled\" (0x1), MPTCP handling for the interface is disabled and no endpoints are registered. The \"enabled\" (0x2) flag means that MPTCP handling is enabled. This flag can also be implied from the presence of other flags. Even when enabled, MPTCP handling will by default still be disabled unless \"/proc/sys/net/mptcp/enabled\" sysctl is on. NetworkManager does not change the sysctl and this is up to the administrator or distribution. To configure endpoints even if the sysctl is disabled, \"also-without-sysctl\" (0x4) flag can be used. In that case, NetworkManager doesn't look at the sysctl and configures endpoints regardless. Even when enabled, NetworkManager will only configure MPTCP endpoints for a certain address family, if there is a unicast default route (0.0.0.0/0 or ::/0) in the main routing table. The flag \"also-without-default-route\" (0x8) can override that. When MPTCP handling is enabled then endpoints are configured with the specified address flags \"signal\" (0x10), \"subflow\" (0x20), \"backup\" (0x40), \"fullmesh\" (0x80). See ip-mptcp(8) manual for additional information about the flags. If the flags are zero (0x0), the global connection default from NetworkManager.conf is honored. If still unspecified, the fallback is \"enabled,subflow\". Note that this means that MPTCP is by default done depending on the \"/proc/sys/net/mptcp/enabled\" sysctl. NetworkManager does not change the MPTCP limits nor enable MPTCP via \"/proc/sys/net/mptcp/enabled\". That is a host configuration which the admin can change via sysctl and ip-mptcp. Strict reverse path filtering (rp_filter) breaks many MPTCP use cases, so when MPTCP handling for IPv4 addresses on the interface is enabled, NetworkManager would loosen the strict reverse path filtering (1) to the loose setting (2).")

View file

@ -652,9 +652,13 @@
<property name="zone"
nmcli-description="The trust level of a the connection. Free form case-insensitive string (for example &quot;Home&quot;, &quot;Work&quot;, &quot;Public&quot;). NULL or unspecified zone means the connection will be placed in the default zone as defined by the firewall. When updating this property on a currently activated connection, the change takes effect immediately."
format="string" />
<property name="controller"
alias="controller"
nmcli-description="Interface name of the controller device or UUID of the controller connection."
format="string" />
<property name="master"
alias="master"
nmcli-description="Interface name of the master device or UUID of the master connection."
nmcli-description="Interface name of the master device or UUID of the master connection. Deprecated 1.46. Use &quot;controller&quot; instead, this is just an alias."
format="string" />
<property name="slave-type"
alias="slave-type"

View file

@ -502,12 +502,12 @@ NAME UUID TYPE DEVICE
con-1 5fcfd6d7-1e63-3332-8826-a7eda103792d ethernet --
<<<
size: 1373
size: 1416
location: src/tests/client/test-client.py:test_002()/23
cmd: $NMCLI c s con-1
lang: C
returncode: 0
stdout: 1245 bytes
stdout: 1288 bytes
>>>
connection.id: con-1
connection.uuid: 5fcfd6d7-1e63-3332-8826-a7eda103792d
@ -522,6 +522,7 @@ connection.auth-retries: -1
connection.timestamp: 0
connection.permissions: --
connection.zone: --
connection.controller: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)
@ -537,12 +538,12 @@ connection.wait-device-timeout: -1
connection.wait-activation-delay: -1
<<<
size: 1384
size: 1427
location: src/tests/client/test-client.py:test_002()/24
cmd: $NMCLI c s con-1
lang: pl_PL.UTF-8
returncode: 0
stdout: 1246 bytes
stdout: 1289 bytes
>>>
connection.id: con-1
connection.uuid: 5fcfd6d7-1e63-3332-8826-a7eda103792d
@ -557,6 +558,7 @@ connection.auth-retries: -1
connection.timestamp: 0
connection.permissions: --
connection.zone: --
connection.controller: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff