device-factory: always use the factory to determine the connection's interface name

This makes things a bit simpler when determining if any connection is
activatable on an existing device.
This commit is contained in:
Lubomir Rintel 2016-02-17 15:11:02 +01:00 committed by Thomas Haller
parent fd314ed7f7
commit cd81e0bd9f
2 changed files with 7 additions and 22 deletions

View file

@ -162,14 +162,8 @@ get_connection_iface (NMDeviceFactory *factory,
NMConnection *connection,
const char *parent_iface)
{
const char *iface;
/* For any other virtual connection, NMSettingConnection:interface-name is
* the virtual device name.
*/
iface = nm_connection_get_interface_name (connection);
g_return_val_if_fail (iface != NULL, NULL);
return g_strdup (iface);
/* Default to just using NMSettingConnection:interface-name */
return g_strdup (nm_connection_get_interface_name (connection));
}
char *
@ -184,20 +178,11 @@ nm_device_factory_get_connection_iface (NMDeviceFactory *factory,
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (!error || !*error, NULL);
if (!nm_connection_is_virtual (connection)) {
g_set_error (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_FAILED,
"failed to determine virtual interface name: connection type '%s' is not a software device",
nm_connection_get_connection_type (connection));
return NULL;
}
if (!NM_DEVICE_FACTORY_GET_INTERFACE (factory)->get_connection_iface) {
g_set_error (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_FAILED,
"failed to determine virtual interface name: cannot generate name for %s",
"failed to determine interface name: cannot determine name for %s",
nm_connection_get_connection_type (connection));
return NULL;
}
@ -207,7 +192,7 @@ nm_device_factory_get_connection_iface (NMDeviceFactory *factory,
g_set_error (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_FAILED,
"failed to determine virtual interface name: error generating name for %s",
"failed to determine interface name: error determine name for %s",
nm_connection_get_connection_type (connection));
return NULL;
}
@ -216,7 +201,7 @@ nm_device_factory_get_connection_iface (NMDeviceFactory *factory,
g_set_error (error,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_FAILED,
"failed to determine virtual interface name: invalid name \"%s\" generated",
"failed to determine interface name: name \"%s\" is invalid",
ifname);
g_free (ifname);
return NULL;

View file

@ -103,8 +103,8 @@ typedef struct {
/**
* get_connection_iface:
* @factory: the #NMDeviceFactory
* @connection: the #NMConnection to return the virtual interface name for
* @parent_iface: parent interface name
* @connection: the #NMConnection to return the interface name for
* @parent_iface: optional parent interface name for virtual devices
*
* Given a connection, returns the interface name that a device activating
* that connection would have.