diff options
Diffstat (limited to 'src/devices/nm-device-bond.c')
-rw-r--r-- | src/devices/nm-device-bond.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index f00f618fa9..b352e513dd 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -464,6 +464,32 @@ release_slave (NMDevice *device, return success; } +static gboolean +create_and_realize (NMDevice *device, + NMConnection *connection, + NMDevice *parent, + NMPlatformLink *out_plink, + GError **error) +{ + const char *iface = nm_device_get_iface (device); + NMPlatformError plerr; + + g_assert (iface); + g_assert (nm_device_get_ifindex (device) <= 0); + g_assert (out_plink); + + plerr = nm_platform_bond_add (NM_PLATFORM_GET, iface, out_plink); + if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, + "Failed to create bond interface '%s' for '%s': %s", + iface, + nm_connection_get_id (connection), + nm_platform_error_to_string (plerr)); + return FALSE; + } + return TRUE; +} + /******************************************************************/ static void @@ -524,6 +550,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) parent_class->update_connection = update_connection; parent_class->master_update_slave_connection = master_update_slave_connection; + parent_class->create_and_realize = create_and_realize; parent_class->act_stage1_prepare = act_stage1_prepare; parent_class->ip4_config_pre_commit = ip4_config_pre_commit; parent_class->enslave_slave = enslave_slave; @@ -547,38 +574,12 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) #define NM_BOND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BOND_FACTORY, NMBondFactory)) static NMDevice * -new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error) -{ - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND, - NM_DEVICE_PLATFORM_DEVICE, plink, - NM_DEVICE_DRIVER, "bonding", - NM_DEVICE_TYPE_DESC, "Bond", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND, - NM_DEVICE_IS_MASTER, TRUE, - NULL); -} - -static NMDevice * -create_virtual_device_for_connection (NMDeviceFactory *factory, - NMConnection *connection, - NMDevice *parent, - GError **error) +create_device (NMDeviceFactory *factory, + const char *iface, + NMPlatformLink *plink, + NMConnection *connection, + gboolean *out_ignore) { - const char *iface = nm_connection_get_interface_name (connection); - NMPlatformError plerr; - - g_assert (iface); - - plerr = nm_platform_bond_add (NM_PLATFORM_GET, iface, NULL); - if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, - "Failed to create bond interface '%s' for '%s': %s", - iface, - nm_connection_get_id (connection), - nm_platform_error_to_string (plerr)); - return NULL; - } - return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND, NM_DEVICE_IFACE, iface, NM_DEVICE_DRIVER, "bonding", @@ -591,7 +592,6 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, NM_DEVICE_FACTORY_DEFINE_INTERNAL (BOND, Bond, bond, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BOND) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BOND_SETTING_NAME), - factory_iface->new_link = new_link; - factory_iface->create_virtual_device_for_connection = create_virtual_device_for_connection; + factory_iface->create_device = create_device; ) |