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_utils_ensure_gtypes;
nm_version_info_capability_get_type;
nm_setting_connection_get_controller;
} libnm_1_40_0;

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;
@ -673,20 +674,22 @@ nm_setting_connection_get_zone(NMSettingConnection *setting)
}
/**
* nm_setting_connection_get_master:
* nm_setting_connection_get_controller:
* @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.
*
* Since: 1.42
*/
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);
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 (!priv->master) {
if (!priv->controller) {
g_set_error(error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("Slave connections need a valid '%s' property"),
NM_SETTING_CONNECTION_MASTER);
NM_SETTING_CONNECTION_CONTROLLER);
g_prefix_error(error,
"%s.%s: ",
NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_MASTER);
NM_SETTING_CONNECTION_CONTROLLER);
return FALSE;
}
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;
} else {
nm_assert(!slave_type);
if (priv->master) {
if (priv->controller) {
NMSetting *s_port;
if (connection
@ -1110,7 +1113,7 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("Cannot set '%s' without '%s'"),
NM_SETTING_CONNECTION_MASTER,
NM_SETTING_CONNECTION_CONTROLLER,
NM_SETTING_CONNECTION_SLAVE_TYPE);
g_prefix_error(error,
"%s.%s: ",
@ -1556,7 +1559,7 @@ after_interface_name:
NM_CONNECTION_ERROR_MISSING_PROPERTY,
_("Detect a slave connection with '%s' set and a port type '%s'. '%s' should "
"be set to '%s'"),
NM_SETTING_CONNECTION_MASTER,
NM_SETTING_CONNECTION_CONTROLLER,
normerr_missing_slave_type_port,
NM_SETTING_CONNECTION_SLAVE_TYPE,
normerr_missing_slave_type);
@ -2232,14 +2235,14 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
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---
* property: master
* property: controller
* 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 variant without *_UUID is ignored. NetworkManager attempts to write both
* for compatibility with legacy tooling.
@ -2247,19 +2250,34 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
*/
_nm_setting_property_define_direct_string(properties_override,
obj_properties,
NM_SETTING_CONNECTION_MASTER,
PROP_MASTER,
NM_SETTING_CONNECTION_CONTROLLER,
PROP_CONTROLLER,
NM_SETTING_PARAM_FUZZY_IGNORE
| NM_SETTING_PARAM_INFERRABLE,
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:
*
* Setting name of the device type of this slave's master connection (eg,
* %NM_SETTING_BOND_SETTING_NAME), or %NULL if this connection is not a
* slave.
* Setting name of the device type of this slave's controller connection
* (eg, %NM_SETTING_BOND_SETTING_NAME), or %NULL if this connection is
* not a slave.
**/
/* ---ifcfg-rh---
* 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
* 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
* are unrelated to this setting.
* 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_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"
@ -67,12 +68,12 @@ G_BEGIN_DECLS
* NMSettingConnectionAutoconnectSlaves:
* @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT: default value
* @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
* master is activated
* controller is activated
*
* #NMSettingConnectionAutoconnectSlaves values indicate whether slave connections
* should be activated when master is activated.
* should be activated when controller is activated.
*
* Since: 1.2
*/
@ -191,7 +192,22 @@ gboolean nm_setting_connection_remove_permission_by_value(NMSettingConnection
const char *pitem,
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);
const char *nm_setting_connection_get_slave_type(NMSettingConnection *setting);
NM_AVAILABLE_IN_1_2