device-factory: always use the factory to determine the connection's interface name
authorLubomir Rintel <lkundrak@v3.sk>
Wed, 17 Feb 2016 14:11:02 +0000 (15:11 +0100)
committerThomas Haller <thaller@redhat.com>
Wed, 17 Feb 2016 17:43:33 +0000 (18:43 +0100)
This makes things a bit simpler when determining if any connection is
activatable on an existing device.

src/devices/nm-device-factory.c
src/devices/nm-device-factory.h

index b2c9050..ddf798d 100644 (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;
index 4cd12e1..ae78968 100644 (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.