diff options
| author | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-01-17 20:25:09 +0100 |
| commit | 58f8be580039b0575b197b9573a1c92745d96d30 (patch) | |
| tree | 2c226233f623a0dcb529be0eb8cdf97e4a2ae0c0 /src/devices/nm-device-bond.c | |
| parent | 45cb5bb3c0e6edb887cf69b417fcaf7053814a9b (diff) | |
New upstream version 1.5.90 upstream/1.5.90
Diffstat (limited to 'src/devices/nm-device-bond.c')
| -rw-r--r-- | src/devices/nm-device-bond.c | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 75b2e315..5dba19d9 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -20,32 +20,36 @@ #include "nm-default.h" +#include "nm-device-bond.h" + #include <errno.h> #include <stdlib.h> -#include "nm-device-bond.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" -#include "nm-platform.h" -#include "nm-enum-types.h" +#include "platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-core-internal.h" #include "nm-ip4-config.h" -#include "nmdbus-device-bond.h" +#include "introspection/org.freedesktop.NetworkManager.Device.Bond.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceBond); -G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) +/*****************************************************************************/ + +struct _NMDeviceBond { + NMDevice parent; +}; -#define NM_DEVICE_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_BOND, NMDeviceBondPrivate)) +struct _NMDeviceBondClass { + NMDeviceClass parent; +}; -typedef struct { - int dummy; -} NMDeviceBondPrivate; +G_DEFINE_TYPE (NMDeviceBond, nm_device_bond, NM_TYPE_DEVICE) -/******************************************************************/ +/*****************************************************************************/ static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) @@ -115,7 +119,7 @@ complete_connection (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static gboolean set_bond_attr (NMDevice *device, NMBondMode mode, const char *attr, const char *value) @@ -372,30 +376,13 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) /* Interface must be down to set bond options */ nm_device_take_down (dev, TRUE); ret = apply_bonding_config (dev); + if (ret) + ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE); nm_device_bring_up (dev, TRUE, &no_firmware); return ret; } -static void -ip4_config_pre_commit (NMDevice *self, NMIP4Config *config) -{ - NMConnection *connection; - NMSettingWired *s_wired; - guint32 mtu; - - connection = nm_device_get_applied_connection (self); - g_assert (connection); - s_wired = nm_connection_get_setting_wired (connection); - - if (s_wired) { - /* MTU override */ - mtu = nm_setting_wired_get_mtu (s_wired); - if (mtu) - nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER); - } -} - static gboolean enslave_slave (NMDevice *device, NMDevice *slave, @@ -432,8 +419,14 @@ release_slave (NMDevice *device, { NMDeviceBond *self = NM_DEVICE_BOND (device); gboolean success, no_firmware = FALSE; + gs_free char *address = NULL; if (configure) { + /* When the last slave is released the bond MAC will be set to a random + * value by kernel; remember the current one and restore it afterwards. + */ + address = g_strdup (nm_device_get_hw_address (device)); + success = nm_platform_link_release (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); @@ -446,6 +439,10 @@ release_slave (NMDevice *device, nm_device_get_ip_iface (slave)); } + nm_platform_process_events (NM_PLATFORM_GET); + if (nm_device_update_hw_address (device)) + nm_device_hw_addr_set (device, address, "restore", FALSE); + /* Kernel bonding code "closes" the slave when releasing it, (which clears * IFF_UP), so we must bring it back up here to ensure carrier changes and * other state is noticed by the now-released slave. @@ -482,7 +479,7 @@ create_and_realize (NMDevice *device, return TRUE; } -/******************************************************************/ +/*****************************************************************************/ static void nm_device_bond_init (NMDeviceBond * self) @@ -492,11 +489,8 @@ nm_device_bond_init (NMDeviceBond * self) static void nm_device_bond_class_init (NMDeviceBondClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); - g_type_class_add_private (object_class, sizeof (NMDeviceBondPrivate)); - NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_BOND_SETTING_NAME, NM_LINK_TYPE_BOND) parent_class->get_generic_capabilities = get_generic_capabilities; @@ -510,7 +504,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) 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->get_configured_mtu = nm_device_get_configured_mtu_for_wired; parent_class->enslave_slave = enslave_slave; parent_class->release_slave = release_slave; @@ -519,10 +513,10 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) NULL); } -/*************************************************************/ +/*****************************************************************************/ -#define NM_TYPE_BOND_FACTORY (nm_bond_factory_get_type ()) -#define NM_BOND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BOND_FACTORY, NMBondFactory)) +#define NM_TYPE_BOND_DEVICE_FACTORY (nm_bond_device_factory_get_type ()) +#define NM_BOND_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BOND_DEVICE_FACTORY, NMBondDeviceFactory)) static NMDevice * create_device (NMDeviceFactory *factory, @@ -544,6 +538,5 @@ create_device (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->create_device = create_device; - ) - + factory_class->create_device = create_device; +); |