all: change handling of connection.type for bluetooth NAP and in general
Branch f9b1bc16e9
added bluetooth NAP
support. A NAP connection is of connection.type "bluetooth", but it
also has a "bridge" setting. Also, it is primarily handled by NMDeviceBridge
and NMBridgeDeviceFactory (with help from NMBluezManager).
However, don't let nm_connection_get_connection_type() and
nm_connnection_is_type() lie about what the connection.type is.
The type is "bluetooth" for most purposes -- at least, as far as
the client is concerned (and the public API of libnm). This restores
previous API behavior, where nm_connection_get_connection_type()
and nm_connection_is_type() would be simple accessors to the
"connection.type" property.
Only a few places care about the bridge aspect, and those places need special
treatment. For example NMDeviceBridge needs to be fully aware that it can
handle bluetooth NAP connection. That is nothing new: if you handle a
connection of any type, you must know which fields matter and what they
mean. It's not enough that nm_connection_get_connection_type() for bluetooth
NAP connectins is claiming to be a bridge.
Counter examples, where the original behavior is right:
src/nm-manager.c- g_set_error (error,
src/nm-manager.c- NM_MANAGER_ERROR,
src/nm-manager.c- NM_MANAGER_ERROR_FAILED,
src/nm-manager.c- "NetworkManager plugin for '%s' unavailable",
src/nm-manager.c: nm_connection_get_connection_type (connection));
the correct message is: "no bluetooth plugin available", not "bridge".
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: if ( ( nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: && !nm_connection_get_setting_pppoe (connection))
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: || nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: || nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: || nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: || nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: || nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c: || nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME))
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c- return TRUE;
the correct behavior is for ifcfg-rh plugin to reject bluetooth NAP
connections, not proceed and store it.
This commit is contained in:
@@ -1664,16 +1664,9 @@ nm_connection_to_dbus (NMConnection *connection,
|
||||
gboolean
|
||||
nm_connection_is_type (NMConnection *connection, const char *type)
|
||||
{
|
||||
NMSetting *setting;
|
||||
g_return_val_if_fail (type, FALSE);
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||
g_return_val_if_fail (type != NULL, FALSE);
|
||||
|
||||
setting = nm_connection_get_setting_by_name (connection, type);
|
||||
if (!setting)
|
||||
return FALSE;
|
||||
|
||||
return _nm_setting_get_base_type_priority (setting) != NM_SETTING_PRIORITY_INVALID;
|
||||
return nm_streq0 (type, nm_connection_get_connection_type (connection));
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1902,19 +1895,22 @@ nm_connection_get_id (NMConnection *connection)
|
||||
* nm_connection_get_connection_type:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* Returns: the connection's base type.
|
||||
* A shortcut to return the type from the connection's #NMSettingConnection.
|
||||
*
|
||||
* Returns: the type from the connection's 'connection' setting
|
||||
**/
|
||||
const char *
|
||||
nm_connection_get_connection_type (NMConnection *connection)
|
||||
{
|
||||
NMSetting *setting;
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
setting = _nm_connection_find_base_type_setting (connection);
|
||||
if (!setting)
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if (!s_con)
|
||||
return NULL;
|
||||
return nm_setting_get_name (setting);
|
||||
|
||||
return nm_setting_connection_get_connection_type (s_con);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1949,10 +1945,12 @@ nm_connection_is_virtual (NMConnection *connection)
|
||||
NMSettingInfiniband *s_ib;
|
||||
|
||||
s_ib = nm_connection_get_setting_infiniband (connection);
|
||||
g_return_val_if_fail (s_ib != NULL, FALSE);
|
||||
return nm_setting_infiniband_get_virtual_interface_name (s_ib) != NULL;
|
||||
return s_ib && nm_setting_infiniband_get_virtual_interface_name (s_ib);
|
||||
}
|
||||
|
||||
if (nm_streq (type, NM_SETTING_BLUETOOTH_SETTING_NAME))
|
||||
return !!_nm_connection_get_setting_bluetooth_for_nap (connection);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user