WIP: core/setting-connection: introduce controller, deprecate master

This commit is contained in:
Lubomir Rintel 2023-01-17 18:33:38 +01:00
parent 10863ba1cb
commit f3ce911d29
3 changed files with 62 additions and 27 deletions

View file

@ -1918,4 +1918,5 @@ global:
nm_setting_vlan_get_protocol; nm_setting_vlan_get_protocol;
nm_utils_ensure_gtypes; nm_utils_ensure_gtypes;
nm_version_info_capability_get_type; nm_version_info_capability_get_type;
nm_setting_connection_get_controller;
} libnm_1_40_0; } libnm_1_40_0;

View file

@ -56,6 +56,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection,
PROP_READ_ONLY, PROP_READ_ONLY,
PROP_ZONE, PROP_ZONE,
PROP_MASTER, PROP_MASTER,
PROP_CONTROLLER,
PROP_SLAVE_TYPE, PROP_SLAVE_TYPE,
PROP_AUTOCONNECT_SLAVES, PROP_AUTOCONNECT_SLAVES,
PROP_SECONDARIES, PROP_SECONDARIES,
@ -80,7 +81,7 @@ typedef struct {
char *stable_id; char *stable_id;
char *interface_name; char *interface_name;
char *type; char *type;
char *master; char *controller;
char *slave_type; char *slave_type;
char *zone; char *zone;
char *mud_url; char *mud_url;
@ -673,20 +674,22 @@ nm_setting_connection_get_zone(NMSettingConnection *setting)
} }
/** /**
* nm_setting_connection_get_master: * nm_setting_connection_get_controller:
* @setting: the #NMSettingConnection * @setting: the #NMSettingConnection
* *
* Returns the #NMSettingConnection:master property of the connection. * Returns the #NMSettingConnection:controller property of the connection.
* *
* Returns: interface name of the master device or UUID of the master * Returns: interface name of the controller device or UUID of the controller
* connection. * connection.
*
* Since: 1.42
*/ */
const char * const char *
nm_setting_connection_get_master(NMSettingConnection *setting) nm_setting_connection_get_controller(NMSettingConnection *setting)
{ {
g_return_val_if_fail(NM_IS_SETTING_CONNECTION(setting), NULL); 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;
} }
/** /**
@ -1081,16 +1084,16 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con,
} }
if (is_slave) { if (is_slave) {
if (!priv->master) { if (!priv->controller) {
g_set_error(error, g_set_error(error,
NM_CONNECTION_ERROR, NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_MISSING_PROPERTY, NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("Slave connections need a valid '%s' property"), _("Slave connections need a valid '%s' property"),
NM_SETTING_CONNECTION_MASTER); NM_SETTING_CONNECTION_CONTROLLER);
g_prefix_error(error, g_prefix_error(error,
"%s.%s: ", "%s.%s: ",
NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_MASTER); NM_SETTING_CONNECTION_CONTROLLER);
return FALSE; return FALSE;
} }
if (slave_setting_type && connection if (slave_setting_type && connection
@ -1098,7 +1101,7 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con,
normerr_slave_setting_type = slave_setting_type; normerr_slave_setting_type = slave_setting_type;
} else { } else {
nm_assert(!slave_type); nm_assert(!slave_type);
if (priv->master) { if (priv->controller) {
NMSetting *s_port; NMSetting *s_port;
if (connection if (connection
@ -1110,7 +1113,7 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con,
NM_CONNECTION_ERROR, NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_MISSING_PROPERTY, NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("Cannot set '%s' without '%s'"), _("Cannot set '%s' without '%s'"),
NM_SETTING_CONNECTION_MASTER, NM_SETTING_CONNECTION_CONTROLLER,
NM_SETTING_CONNECTION_SLAVE_TYPE); NM_SETTING_CONNECTION_SLAVE_TYPE);
g_prefix_error(error, g_prefix_error(error,
"%s.%s: ", "%s.%s: ",
@ -1556,7 +1559,7 @@ after_interface_name:
NM_CONNECTION_ERROR_MISSING_PROPERTY, NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("Detect a slave connection with '%s' set and a port type '%s'. '%s' should " _("Detect a slave connection with '%s' set and a port type '%s'. '%s' should "
"be set to '%s'"), "be set to '%s'"),
NM_SETTING_CONNECTION_MASTER, NM_SETTING_CONNECTION_CONTROLLER,
normerr_missing_slave_type_port, normerr_missing_slave_type_port,
NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_CONNECTION_SLAVE_TYPE,
normerr_missing_slave_type); normerr_missing_slave_type);
@ -2232,14 +2235,14 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
zone); zone);
/** /**
* NMSettingConnection:master: * NMSettingConnection:controller:
* *
* Interface name of the master device or UUID of the master connection. * Interface name of the controller device or UUID of the controller connection.
**/ **/
/* ---ifcfg-rh--- /* ---ifcfg-rh---
* property: master * property: controller
* variable: MASTER, MASTER_UUID, TEAM_MASTER, TEAM_MASTER_UUID, BRIDGE, BRIDGE_UUID * variable: MASTER, MASTER_UUID, TEAM_MASTER, TEAM_MASTER_UUID, BRIDGE, BRIDGE_UUID
* description: Reference to master connection. The variable used depends on * description: Reference to controller connection. The variable used depends on
* the connection type and the value. In general, if the *_UUID variant is present, * the connection type and the value. In general, if the *_UUID variant is present,
* the variant without *_UUID is ignored. NetworkManager attempts to write both * the variant without *_UUID is ignored. NetworkManager attempts to write both
* for compatibility with legacy tooling. * for compatibility with legacy tooling.
@ -2247,19 +2250,34 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
*/ */
_nm_setting_property_define_direct_string(properties_override, _nm_setting_property_define_direct_string(properties_override,
obj_properties, obj_properties,
NM_SETTING_CONNECTION_MASTER, NM_SETTING_CONNECTION_CONTROLLER,
PROP_MASTER, PROP_CONTROLLER,
NM_SETTING_PARAM_FUZZY_IGNORE NM_SETTING_PARAM_FUZZY_IGNORE
| NM_SETTING_PARAM_INFERRABLE, | NM_SETTING_PARAM_INFERRABLE,
NMSettingConnectionPrivate, NMSettingConnectionPrivate,
master); controller,
.alias_prop_name = NM_SETTING_CONNECTION_MASTER);
/**
* NMSettingConnection:master:
*
* Obsolete alias for #NMSettingConnection:controller property
*
* Deprecated: 1.42: Deprecated in favor of the #NMSettingConnection:controller property.
**/
_nm_setting_property_define_alias(properties_override,
obj_properties,
NM_SETTING_CONNECTION_MASTER,
PROP_MASTER,
NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE,
.alias_prop_name = NM_SETTING_CONNECTION_CONTROLLER);
/** /**
* NMSettingConnection:slave-type: * NMSettingConnection:slave-type:
* *
* Setting name of the device type of this slave's master connection (eg, * Setting name of the device type of this slave's controller connection
* %NM_SETTING_BOND_SETTING_NAME), or %NULL if this connection is not a * (eg, %NM_SETTING_BOND_SETTING_NAME), or %NULL if this connection is
* slave. * not a slave.
**/ **/
/* ---ifcfg-rh--- /* ---ifcfg-rh---
* property: slave-type * property: slave-type
@ -2285,7 +2303,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
* *
* Whether or not slaves of this connection should be automatically brought up * Whether or not slaves of this connection should be automatically brought up
* when NetworkManager activates this connection. This only has a real effect * when NetworkManager activates this connection. This only has a real effect
* for master connections. The properties #NMSettingConnection:autoconnect, * for controller connections. The properties #NMSettingConnection:autoconnect,
* #NMSettingConnection:autoconnect-priority and #NMSettingConnection:autoconnect-retries * #NMSettingConnection:autoconnect-priority and #NMSettingConnection:autoconnect-retries
* are unrelated to this setting. * are unrelated to this setting.
* The permitted values are: 0: leave slave connections untouched, * The permitted values are: 0: leave slave connections untouched,

View file

@ -47,6 +47,7 @@ G_BEGIN_DECLS
#define NM_SETTING_CONNECTION_PERMISSIONS "permissions" #define NM_SETTING_CONNECTION_PERMISSIONS "permissions"
#define NM_SETTING_CONNECTION_ZONE "zone" #define NM_SETTING_CONNECTION_ZONE "zone"
#define NM_SETTING_CONNECTION_MASTER "master" #define NM_SETTING_CONNECTION_MASTER "master"
#define NM_SETTING_CONNECTION_CONTROLLER "controller"
#define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type" #define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type"
#define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves" #define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves"
#define NM_SETTING_CONNECTION_SECONDARIES "secondaries" #define NM_SETTING_CONNECTION_SECONDARIES "secondaries"
@ -67,12 +68,12 @@ G_BEGIN_DECLS
* NMSettingConnectionAutoconnectSlaves: * NMSettingConnectionAutoconnectSlaves:
* @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT: default value * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT: default value
* @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO: slaves are not brought up when * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO: slaves are not brought up when
* master is activated * controller is activated
* @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES: slaves are brought up when * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES: slaves are brought up when
* master is activated * controller is activated
* *
* #NMSettingConnectionAutoconnectSlaves values indicate whether slave connections * #NMSettingConnectionAutoconnectSlaves values indicate whether slave connections
* should be activated when master is activated. * should be activated when controller is activated.
* *
* Since: 1.2 * Since: 1.2
*/ */
@ -191,7 +192,22 @@ gboolean nm_setting_connection_remove_permission_by_value(NMSettingConnection
const char *pitem, const char *pitem,
const char *detail); const char *detail);
const char *nm_setting_connection_get_master(NMSettingConnection *setting); NM_AVAILABLE_IN_1_42
const char *nm_setting_connection_get_controller(NMSettingConnection *setting);
/**
* nm_setting_connection_get_master:
* @setting: the #NMSettingConnection
*
* Deprecated: 1.42: Use nm_setting_connection_get_controller() instead
*/
NM_DEPRECATED_IN_1_42
static inline const char *
nm_setting_connection_get_master(NMSettingConnection *setting)
{
return nm_setting_connection_get_controller(setting);
}
gboolean nm_setting_connection_is_slave_type(NMSettingConnection *setting, const char *type); gboolean nm_setting_connection_is_slave_type(NMSettingConnection *setting, const char *type);
const char *nm_setting_connection_get_slave_type(NMSettingConnection *setting); const char *nm_setting_connection_get_slave_type(NMSettingConnection *setting);
NM_AVAILABLE_IN_1_2 NM_AVAILABLE_IN_1_2