mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-20 00:21:29 +00:00
core: make nm_device_check_connection_compatible() check interface-name
If an NMConnection specifies an interface-name, it is only compatible with a device with the same iface. https://bugzilla.gnome.org/show_bug.cgi?id=693684
This commit is contained in:
parent
cda65e1802
commit
611df342af
|
@ -143,6 +143,9 @@ check_connection_compatible (NMDevice *device,
|
|||
NMSettingAdsl *s_adsl;
|
||||
const char *protocol;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_adsl_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_ADSL_SETTING_NAME)) {
|
||||
g_set_error (error,
|
||||
NM_ADSL_ERROR, NM_ADSL_ERROR_CONNECTION_NOT_ADSL,
|
||||
|
|
|
@ -124,6 +124,9 @@ check_connection_compatible (NMDevice *device,
|
|||
const char *iface;
|
||||
NMSettingBond *s_bond;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_bond_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_bond = nm_connection_get_setting_bond (connection);
|
||||
if (!s_bond || !nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
|
||||
g_set_error (error, NM_BOND_ERROR, NM_BOND_ERROR_CONNECTION_NOT_BOND,
|
||||
|
|
|
@ -124,6 +124,9 @@ check_connection_compatible (NMDevice *device,
|
|||
const char *iface;
|
||||
NMSettingBridge *s_bridge;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||
if (!s_bridge || !nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
|
||||
g_set_error (error, NM_BRIDGE_ERROR, NM_BRIDGE_ERROR_CONNECTION_NOT_BRIDGE,
|
||||
|
|
|
@ -170,6 +170,9 @@ check_connection_compatible (NMDevice *device,
|
|||
int addr_match = FALSE;
|
||||
guint32 bt_type;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
||||
|
|
|
@ -553,6 +553,9 @@ check_connection_compatible (NMDevice *device,
|
|||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
||||
NMSettingWired *s_wired;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
|
||||
if (nm_connection_is_type (connection, NM_SETTING_PPPOE_SETTING_NAME)) {
|
||||
|
|
|
@ -220,6 +220,9 @@ check_connection_compatible (NMDevice *device,
|
|||
NMSettingInfiniband *s_infiniband;
|
||||
const GByteArray *mac;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) {
|
||||
g_set_error (error,
|
||||
NM_INFINIBAND_ERROR,
|
||||
|
|
|
@ -228,6 +228,9 @@ check_connection_compatible (NMDevice *device,
|
|||
{
|
||||
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device);
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
return nm_modem_check_connection_compatible (priv->modem, connection, error);
|
||||
}
|
||||
|
||||
|
|
|
@ -231,6 +231,9 @@ check_connection_compatible (NMDevice *device,
|
|||
NMSettingConnection *s_con;
|
||||
NMSettingOlpcMesh *s_mesh;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
||||
|
|
|
@ -248,6 +248,9 @@ check_connection_compatible (NMDevice *device,
|
|||
NMSettingVlan *s_vlan;
|
||||
const char *parent, *iface = NULL;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_vlan_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_vlan = nm_connection_get_setting_vlan (connection);
|
||||
if (!s_vlan) {
|
||||
g_set_error (error, NM_VLAN_ERROR, NM_VLAN_ERROR_CONNECTION_INVALID,
|
||||
|
|
|
@ -1022,6 +1022,9 @@ check_connection_compatible (NMDevice *device,
|
|||
const GSList *mac_blacklist, *mac_blacklist_iter;
|
||||
const char *mode;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
||||
|
|
|
@ -1461,6 +1461,25 @@ nm_device_complete_connection (NMDevice *self,
|
|||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_connection_compatible (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
const char *config_iface, *device_iface;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
||||
config_iface = nm_setting_connection_get_interface_name (s_con);
|
||||
device_iface = nm_device_get_iface (device);
|
||||
if (config_iface && strcmp (config_iface, device_iface) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_device_check_connection_compatible (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
|
@ -1469,9 +1488,7 @@ nm_device_check_connection_compatible (NMDevice *device,
|
|||
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||
|
||||
if (NM_DEVICE_GET_CLASS (device)->check_connection_compatible)
|
||||
return NM_DEVICE_GET_CLASS (device)->check_connection_compatible (device, connection, error);
|
||||
return TRUE;
|
||||
return NM_DEVICE_GET_CLASS (device)->check_connection_compatible (device, connection, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -4748,6 +4765,7 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||
|
||||
klass->spec_match_list = spec_match_list;
|
||||
klass->can_auto_connect = can_auto_connect;
|
||||
klass->check_connection_compatible = check_connection_compatible;
|
||||
klass->check_connection_available = check_connection_available;
|
||||
klass->hw_is_up = hw_is_up;
|
||||
klass->hw_bring_up = hw_bring_up;
|
||||
|
|
|
@ -420,6 +420,9 @@ check_connection_compatible (NMDevice *device,
|
|||
const char *connection_type;
|
||||
const GByteArray *mac;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->check_connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
||||
|
|
Loading…
Reference in a new issue