mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 12:28:11 +02:00
device: fix restricting Generic connection by interface-name
NMDeviceGeneric:check_connection_compatible() doesn't check for a matching interface name. It relies on the parent implementation to do that. The parent implementation calls nm_manager_get_connection_iface(). That fails for NM_SETTING_GENERIC_SETTING_NAME, because that one has no factory. Maybe this imbalance of having no factory for the Generic device is wrong, but usually factories only match a distinct set of device types, while the generic factory would handle them all (as last resort). Without this, activating a generic connection might activate the wrong interface. (cherry picked from commit3876b10a47) (cherry picked from commit753a2cc4d9)
This commit is contained in:
parent
2ebc390734
commit
bd72919b47
1 changed files with 17 additions and 9 deletions
|
|
@ -1137,6 +1137,11 @@ nm_manager_get_connection_iface (NMManager *self,
|
||||||
|
|
||||||
factory = nm_device_factory_manager_find_factory_for_connection (connection);
|
factory = nm_device_factory_manager_find_factory_for_connection (connection);
|
||||||
if (!factory) {
|
if (!factory) {
|
||||||
|
if (nm_streq0 (nm_connection_get_connection_type (connection), NM_SETTING_GENERIC_SETTING_NAME)) {
|
||||||
|
/* the generic type doesn't have a factory. */
|
||||||
|
goto return_ifname_fom_connection;
|
||||||
|
}
|
||||||
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
NM_MANAGER_ERROR,
|
NM_MANAGER_ERROR,
|
||||||
NM_MANAGER_ERROR_FAILED,
|
NM_MANAGER_ERROR_FAILED,
|
||||||
|
|
@ -1148,15 +1153,7 @@ nm_manager_get_connection_iface (NMManager *self,
|
||||||
if ( !out_parent
|
if ( !out_parent
|
||||||
&& !NM_DEVICE_FACTORY_GET_CLASS (factory)->get_connection_iface) {
|
&& !NM_DEVICE_FACTORY_GET_CLASS (factory)->get_connection_iface) {
|
||||||
/* optimization. Shortcut lookup of the partent device. */
|
/* optimization. Shortcut lookup of the partent device. */
|
||||||
iface = g_strdup (nm_connection_get_interface_name (connection));
|
goto return_ifname_fom_connection;
|
||||||
if (!iface) {
|
|
||||||
g_set_error (error,
|
|
||||||
NM_MANAGER_ERROR,
|
|
||||||
NM_MANAGER_ERROR_FAILED,
|
|
||||||
"failed to determine interface name: error determine name for %s",
|
|
||||||
nm_connection_get_connection_type (connection));
|
|
||||||
}
|
|
||||||
return iface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = find_parent_device_for_connection (self, connection, factory);
|
parent = find_parent_device_for_connection (self, connection, factory);
|
||||||
|
|
@ -1170,6 +1167,17 @@ nm_manager_get_connection_iface (NMManager *self,
|
||||||
if (out_parent)
|
if (out_parent)
|
||||||
*out_parent = parent;
|
*out_parent = parent;
|
||||||
return iface;
|
return iface;
|
||||||
|
|
||||||
|
return_ifname_fom_connection:
|
||||||
|
iface = g_strdup (nm_connection_get_interface_name (connection));
|
||||||
|
if (!iface) {
|
||||||
|
g_set_error (error,
|
||||||
|
NM_MANAGER_ERROR,
|
||||||
|
NM_MANAGER_ERROR_FAILED,
|
||||||
|
"failed to determine interface name: error determine name for %s",
|
||||||
|
nm_connection_get_connection_type (connection));
|
||||||
|
}
|
||||||
|
return iface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue