From 72e118716eca83de2c44ad4db57a202d6dc7262a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 8 Jan 2016 16:11:41 +0100 Subject: [PATCH 01/12] trivial: fix whitespace --- src/devices/nm-device-bond.c | 14 +++++++------- src/nm-manager.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 5f72ebdae5..84ddffde5f 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -518,13 +518,13 @@ create_device (NMDeviceFactory *factory, gboolean *out_ignore) { return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND, - NM_DEVICE_IFACE, iface, - NM_DEVICE_DRIVER, "bonding", - NM_DEVICE_TYPE_DESC, "Bond", - NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND, - NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BOND, - NM_DEVICE_IS_MASTER, TRUE, - NULL); + NM_DEVICE_IFACE, iface, + NM_DEVICE_DRIVER, "bonding", + NM_DEVICE_TYPE_DESC, "Bond", + NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND, + NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BOND, + NM_DEVICE_IS_MASTER, TRUE, + NULL); } NM_DEVICE_FACTORY_DEFINE_INTERNAL (BOND, Bond, bond, diff --git a/src/nm-manager.c b/src/nm-manager.c index 02dcc6f6f8..85832223a1 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1086,7 +1086,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) /* Create any backing resources the device needs */ if (!nm_device_create_and_realize (device, connection, parent, &error)) { nm_log_warn (LOGD_DEVICE, "(%s) couldn't create the device: %s", - nm_connection_get_id (connection), error->message); + nm_connection_get_id (connection), error->message); g_error_free (error); remove_device (self, device, FALSE, TRUE); return NULL; From 1dbee32150869a0c7a06632a3853714193a6a71d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 8 Jan 2016 16:53:47 +0100 Subject: [PATCH 02/12] device: add realize_start_setup() function Don't call the virtual function directly. Instead add a wrapper function. --- src/devices/nm-device.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 0e5993a79c..f7d0250ed2 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -75,6 +75,7 @@ static gboolean ip_config_valid (NMDeviceState state); static NMActStageReturn dhcp4_start (NMDevice *self, NMConnection *connection, NMDeviceStateReason *reason); static gboolean dhcp6_start (NMDevice *self, gboolean wait_for_ll, NMDeviceStateReason *reason); static void nm_device_start_ip_check (NMDevice *self); +static void realize_start_setup (NMDevice *self, const NMPlatformLink *plink); G_DEFINE_ABSTRACT_TYPE (NMDevice, nm_device, NM_TYPE_EXPORTED_OBJECT) @@ -1737,7 +1738,7 @@ nm_device_realize (NMDevice *self, return FALSE; } - NM_DEVICE_GET_CLASS (self)->setup_start (self, plink); + realize_start_setup (self, plink); return TRUE; } @@ -1775,7 +1776,7 @@ nm_device_create_and_realize (NMDevice *self, plink = &plink_copy; } - NM_DEVICE_GET_CLASS (self)->setup_start (self, plink); + realize_start_setup (self, plink); nm_device_setup_finish (self, plink); g_return_val_if_fail (nm_device_check_connection_compatible (self, connection), TRUE); @@ -1925,6 +1926,14 @@ setup_start (NMDevice *self, const NMPlatformLink *plink) priv->real = TRUE; } +static void +realize_start_setup (NMDevice *self, const NMPlatformLink *plink) +{ + g_return_if_fail (NM_IS_DEVICE (self)); + + NM_DEVICE_GET_CLASS (self)->setup_start (self, plink); +} + static void setup_finish (NMDevice *self, const NMPlatformLink *plink) { From 0311a0eae3a5f3449e5ab7806206abb728480503 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 8 Jan 2016 17:08:54 +0100 Subject: [PATCH 03/12] device: remove unused virtual function NMDevice:setup_finish() --- src/devices/nm-device.c | 24 +++++++++++++----------- src/devices/nm-device.h | 11 ----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index f7d0250ed2..a1f81bd170 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1934,21 +1934,24 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) NM_DEVICE_GET_CLASS (self)->setup_start (self, plink); } -static void -setup_finish (NMDevice *self, const NMPlatformLink *plink) -{ - if (plink) { - update_device_from_platform_link (self, plink); - device_recheck_slave_status (self, plink); - } -} - +/** + * nm_device_setup_finish(): + * @self: the #NMDevice + * @plink: the #NMPlatformLink if backed by a kernel netdevice + * + * Update the device's master/slave or parent/child relationships from + * backing resource properties. After this function finishes, the device + * is ready for network connectivity. + */ void nm_device_setup_finish (NMDevice *self, const NMPlatformLink *plink) { g_return_if_fail (!plink || link_type_compatible (self, plink->type, NULL, NULL)); - NM_DEVICE_GET_CLASS (self)->setup_finish (self, plink); + if (plink) { + update_device_from_platform_link (self, plink); + device_recheck_slave_status (self, plink); + } NM_DEVICE_GET_PRIVATE (self)->real = TRUE; g_object_notify (G_OBJECT (self), NM_DEVICE_REAL); @@ -10866,7 +10869,6 @@ nm_device_class_init (NMDeviceClass *klass) klass->check_connection_available = check_connection_available; klass->can_unmanaged_external_down = can_unmanaged_external_down; klass->setup_start = setup_start; - klass->setup_finish = setup_finish; klass->unrealize = unrealize; klass->is_up = is_up; klass->bring_up = bring_up; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 8c864e6ff4..ce49320e64 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -201,17 +201,6 @@ typedef struct { */ void (*setup_start) (NMDevice *self, const NMPlatformLink *plink); - /** - * setup_finish(): - * @self: the #NMDevice - * @plink: the #NMPlatformLink if backed by a kernel netdevice - * - * Update the device's master/slave or parent/child relationships from - * backing resource properties. After this function finishes, the device - * is ready for network connectivity. - */ - void (*setup_finish) (NMDevice *self, const NMPlatformLink *plink); - /** * unrealize(): * @self: the #NMDevice From 4c6b991bb04210d98878e2b0fb106deb3dfbb865 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 8 Jan 2016 17:24:24 +0100 Subject: [PATCH 04/12] device: move implementation of NMDevice:setup_start() to realize_start_setup() All implementations of NMDevice:setup_start() in derived classes invoke the parent implementation first. Enforce that by moving NMDevice:setup_start() to realize_start_setup() and only notify derived classes afterwards via NMDevice:realize_start_notify(). --- src/devices/nm-device-ethernet.c | 6 ++-- src/devices/nm-device-generic.c | 6 ++-- src/devices/nm-device-ip-tunnel.c | 6 ++-- src/devices/nm-device-macvlan.c | 6 ++-- src/devices/nm-device-tun.c | 6 ++-- src/devices/nm-device-vlan.c | 6 ++-- src/devices/nm-device-vxlan.c | 6 ++-- src/devices/nm-device.c | 48 ++++++++++++++++++++++--------- src/devices/nm-device.h | 11 +++---- src/devices/wifi/nm-device-wifi.c | 6 ++-- 10 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index e341cc730a..b99f0671f5 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -305,9 +305,9 @@ nm_device_ethernet_init (NMDeviceEthernet *self) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { - NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->realize_start_notify (device, plink); g_object_notify (G_OBJECT (device), NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS); } @@ -1731,7 +1731,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) object_class->set_property = set_property; parent_class->get_generic_capabilities = get_generic_capabilities; - parent_class->setup_start = setup_start; + parent_class->realize_start_notify = realize_start_notify; parent_class->check_connection_compatible = check_connection_compatible; parent_class->complete_connection = complete_connection; parent_class->new_default_connection = new_default_connection; diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index b6fe16be65..b05bdb1cc5 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -61,13 +61,13 @@ get_type_description (NMDevice *device) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { NMDeviceGeneric *self = NM_DEVICE_GENERIC (device); NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (self); int ifindex; - NM_DEVICE_CLASS (nm_device_generic_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_generic_parent_class)->realize_start_notify (device, plink); g_clear_pointer (&priv->type_description, g_free); ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self)); @@ -203,7 +203,7 @@ nm_device_generic_class_init (NMDeviceGenericClass *klass) object_class->get_property = get_property; object_class->set_property = set_property; - parent_class->setup_start = setup_start; + parent_class->realize_start_notify = realize_start_notify; parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->get_type_description = get_type_description; parent_class->check_connection_compatible = check_connection_compatible; diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 2fa6bee19d..8fff4dfb9c 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -771,9 +771,9 @@ create_and_realize (NMDevice *device, } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->realize_start_notify (device, plink); update_properties (device); } @@ -886,7 +886,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) device_class->create_and_realize = create_and_realize; device_class->ip4_config_pre_commit = ip4_config_pre_commit; device_class->realize = realize; - device_class->setup_start = setup_start; + device_class->realize_start_notify = realize_start_notify; device_class->unrealize = unrealize; NM_DEVICE_CLASS_DECLARE_TYPES (klass, diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 907d480b2d..fb6a50b97b 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -558,9 +558,9 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { - NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_macvlan_parent_class)->realize_start_notify (device, plink); update_properties (device); } @@ -653,7 +653,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) device_class->link_changed = link_changed; device_class->notify_new_device_added = notify_new_device_added; device_class->realize = realize; - device_class->setup_start = setup_start; + device_class->realize_start_notify = realize_start_notify; device_class->update_connection = update_connection; /* properties */ diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index e1ec520363..5f150522df 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -242,9 +242,9 @@ realize (NMDevice *device, NMPlatformLink *plink, GError **error) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { - NM_DEVICE_CLASS (nm_device_tun_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_tun_parent_class)->realize_start_notify (device, plink); reload_tun_properties (device); } @@ -447,7 +447,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->realize = realize; - device_class->setup_start = setup_start; + device_class->realize_start_notify = realize_start_notify; device_class->unrealize = unrealize; device_class->update_connection = update_connection; device_class->act_stage1_prepare = act_stage1_prepare; diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 5ccddbde38..47047b1999 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -152,12 +152,12 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { NMDeviceVlan *self = NM_DEVICE_VLAN (device); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); - NM_DEVICE_CLASS (nm_device_vlan_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink); _LOGI (LOGD_HW | LOGD_VLAN, "VLAN ID %d with parent %s", priv->vlan_id, nm_device_get_iface (priv->parent)); @@ -692,7 +692,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) parent_class->create_and_realize = create_and_realize; parent_class->realize = realize; - parent_class->setup_start = setup_start; + parent_class->realize_start_notify = realize_start_notify; parent_class->unrealize = unrealize; parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->bring_up = bring_up; diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index a2dfa7d91a..01e93ba975 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -145,11 +145,11 @@ link_changed (NMDevice *device, NMPlatformLink *info) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { g_assert (plink->type == NM_LINK_TYPE_VXLAN); - NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->realize_start_notify (device, plink); update_properties (device); } @@ -666,7 +666,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) object_class->dispose = dispose; device_class->link_changed = link_changed; - device_class->setup_start = setup_start; + device_class->realize_start_notify = realize_start_notify; device_class->unrealize = unrealize; device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME; device_class->create_and_realize = create_and_realize; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a1f81bd170..a7357c5486 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1840,15 +1840,41 @@ check_carrier (NMDevice *self) } static void -setup_start (NMDevice *self, const NMPlatformLink *plink) +realize_start_notify (NMDevice *self, const NMPlatformLink *plink) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + /* Stub implementation for realize_start_notify(). It does nothing, + * but allows derived classes to uniformly invoke the parent + * implementation. */ +} + +/** + * realize_start_setup(): + * @self: the #NMDevice + * @plink: the #NMPlatformLink if backed by a kernel netdevice + * + * Update the device from backing resource properties (like hardware + * addresses, carrier states, driver/firmware info, etc). This function + * should only change properties for this device, and should not perform + * any tasks that affect other interfaces (like master/slave or parent/child + * stuff). + */ +static void +realize_start_setup (NMDevice *self, const NMPlatformLink *plink) +{ + NMDevicePrivate *priv; + NMDeviceClass *klass; static guint32 id = 0; + g_return_if_fail (NM_IS_DEVICE (self)); + + priv = NM_DEVICE_GET_PRIVATE (self); + /* The device should not be realized */ g_return_if_fail (priv->ip_ifindex <= 0); g_return_if_fail (priv->ip_iface == NULL); + klass = NM_DEVICE_GET_CLASS (self); + /* Balanced by a thaw in nm_device_setup_finish() */ g_object_freeze_notify (G_OBJECT (self)); @@ -1858,7 +1884,7 @@ setup_start (NMDevice *self, const NMPlatformLink *plink) } if (priv->ifindex > 0) { - _LOGD (LOGD_DEVICE, "setup_start(): %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex); + _LOGD (LOGD_DEVICE, "start setup of %s, kernel ifindex %d", G_OBJECT_TYPE_NAME (self), priv->ifindex); priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex); g_object_notify (G_OBJECT (self), NM_DEVICE_PHYSICAL_PORT_ID); @@ -1885,8 +1911,8 @@ setup_start (NMDevice *self, const NMPlatformLink *plink) priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ifindex); } - if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities) - priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self); + if (klass->get_generic_capabilities) + priv->capabilities |= klass->get_generic_capabilities (self); if (!priv->udi) { /* Use a placeholder UDI until we get a real one */ @@ -1924,14 +1950,8 @@ setup_start (NMDevice *self, const NMPlatformLink *plink) g_object_notify (G_OBJECT (self), NM_DEVICE_CAPABILITIES); priv->real = TRUE; -} -static void -realize_start_setup (NMDevice *self, const NMPlatformLink *plink) -{ - g_return_if_fail (NM_IS_DEVICE (self)); - - NM_DEVICE_GET_CLASS (self)->setup_start (self, plink); + klass->realize_start_notify (self, plink); } /** @@ -1958,7 +1978,7 @@ nm_device_setup_finish (NMDevice *self, const NMPlatformLink *plink) nm_device_recheck_available_connections (self); - /* Balanced by a freeze in setup_start() */ + /* Balanced by a freeze in realize_start_setup() */ g_object_thaw_notify (G_OBJECT (self)); } @@ -10868,7 +10888,7 @@ nm_device_class_init (NMDeviceClass *klass) klass->check_connection_compatible = check_connection_compatible; klass->check_connection_available = check_connection_available; klass->can_unmanaged_external_down = can_unmanaged_external_down; - klass->setup_start = setup_start; + klass->realize_start_notify = realize_start_notify; klass->unrealize = unrealize; klass->is_up = is_up; klass->bring_up = bring_up; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index ce49320e64..edcbb443a1 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -189,17 +189,14 @@ typedef struct { GError **error); /** - * setup_start(): + * realize_start_notify(): * @self: the #NMDevice * @plink: the #NMPlatformLink if backed by a kernel netdevice * - * Update the device from backing resource properties (like hardware - * addresses, carrier states, driver/firmware info, etc). This function - * should only change properties for this device, and should not perform - * any tasks that affect other interfaces (like master/slave or parent/child - * stuff). + * Hook for derived classes to be notfied during realize_start_setup() + * and perform additional setup. */ - void (*setup_start) (NMDevice *self, const NMPlatformLink *plink); + void (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink); /** * unrealize(): diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 247534d17e..64da03e1c8 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -404,9 +404,9 @@ periodic_update_cb (gpointer user_data) } static void -setup_start (NMDevice *device, const NMPlatformLink *plink) +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { - NM_DEVICE_CLASS (nm_device_wifi_parent_class)->setup_start (device, plink); + NM_DEVICE_CLASS (nm_device_wifi_parent_class)->realize_start_notify (device, plink); g_object_notify (G_OBJECT (device), NM_DEVICE_WIFI_PERMANENT_HW_ADDRESS); } @@ -3016,7 +3016,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) object_class->dispose = dispose; object_class->finalize = finalize; - parent_class->setup_start = setup_start; + parent_class->realize_start_notify = realize_start_notify; parent_class->bring_up = bring_up; parent_class->can_auto_connect = can_auto_connect; parent_class->is_available = is_available; From 492691dfb2e4f839b30bc693e7a2756facb9e3ca Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 8 Jan 2016 17:40:04 +0100 Subject: [PATCH 05/12] device: remove unneeded implementations of realize() The virtual function NMDevice:realize() is only called by nm_device_realize() and immediately followed by nm_device_setup_start(). Devices already overwrite setup_start_notify() to update their properties. No need to duplicate that in realize(). --- src/devices/nm-device-ip-tunnel.c | 8 -------- src/devices/nm-device-macvlan.c | 8 -------- src/devices/nm-device-tun.c | 8 -------- src/devices/nm-device-vxlan.c | 11 ----------- 4 files changed, 35 deletions(-) diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 8fff4dfb9c..a428e749af 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -448,13 +448,6 @@ update_connection (NMDevice *device, NMConnection *connection) } } -static gboolean -realize (NMDevice *self, NMPlatformLink *plink, GError **error) -{ - update_properties (self); - return TRUE; -} - static gboolean match_parent (NMDevice *dev_parent, const char *setting_parent) { @@ -885,7 +878,6 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->ip4_config_pre_commit = ip4_config_pre_commit; - device_class->realize = realize; device_class->realize_start_notify = realize_start_notify; device_class->unrealize = unrealize; diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index fb6a50b97b..28421b4b3c 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -209,13 +209,6 @@ link_changed (NMDevice *device, NMPlatformLink *info) update_properties (device); } -static gboolean -realize (NMDevice *device, NMPlatformLink *plink, GError **error) -{ - update_properties (device); - return TRUE; -} - static gboolean create_and_realize (NMDevice *device, NMConnection *connection, @@ -652,7 +645,6 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) device_class->is_available = is_available; device_class->link_changed = link_changed; device_class->notify_new_device_added = notify_new_device_added; - device_class->realize = realize; device_class->realize_start_notify = realize_start_notify; device_class->update_connection = update_connection; diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 5f150522df..d04cd7e641 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -234,13 +234,6 @@ create_and_realize (NMDevice *device, return TRUE; } -static gboolean -realize (NMDevice *device, NMPlatformLink *plink, GError **error) -{ - reload_tun_properties (NM_DEVICE_TUN (device)); - return TRUE; -} - static void realize_start_notify (NMDevice *device, const NMPlatformLink *plink) { @@ -446,7 +439,6 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) device_class->complete_connection = complete_connection; device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; - device_class->realize = realize; device_class->realize_start_notify = realize_start_notify; device_class->unrealize = unrealize; device_class->update_connection = update_connection; diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 01e93ba975..3dc238ec55 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -236,16 +236,6 @@ create_and_realize (NMDevice *device, return TRUE; } -static gboolean -realize (NMDevice *device, NMPlatformLink *plink, GError **error) -{ - g_assert (plink->type == NM_LINK_TYPE_VXLAN); - - update_properties (device); - - return TRUE; -} - static gboolean match_parent (NMDeviceVxlan *self, const char *parent) { @@ -670,7 +660,6 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) device_class->unrealize = unrealize; device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME; device_class->create_and_realize = create_and_realize; - device_class->realize = realize; device_class->check_connection_compatible = check_connection_compatible; device_class->complete_connection = complete_connection; device_class->update_connection = update_connection; From 225ce48b8ad37029cee0bddac4575e44755ccfb7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 12:52:10 +0100 Subject: [PATCH 06/12] device/vlan: remove unreachable code from realize() plnk->id is unsigned. It cannot be negative. --- src/devices/nm-device-vlan.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 47047b1999..a6bb8123da 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -183,18 +183,12 @@ realize (NMDevice *device, return FALSE; } - if (plnk->id < 0) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "(%s): VLAN ID invalid", plink->name); - return FALSE; - } - if (plink->parent != NM_PLATFORM_LINK_OTHER_NETNS) { parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent); if (!parent) { nm_log_dbg (LOGD_HW, "(%s): VLAN parent interface unknown", plink->name); g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "(%s): VLAN parent interface unknown", plink->name); + "(%s): VLAN parent interface unknown", plink->name); return FALSE; } } else From eee00a8355108130c680e4df9c3c1eb0979d88ae Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 14:31:10 +0100 Subject: [PATCH 07/12] device/vlan: refactor handling platform properties for NMDeviceVlan Extract a function update_properties() similar to other device implementations. It reads the device specific data from platform and raises property-changed notifications. update_properties() is now called by realize_start_notify(). NMDeviceVlan:realize() -- which previously implemented something like update_properties() -- now does nothing. Note that previously realize() might have failed, but this is different from other device implementations and it was unclear what a failure really meant. Ok, it might fail because the link was not found in the platform cache. But other implementations don't check that either, so why vlan? And how to handle that properly anyway? Therefore realize()'s implementation is no longer needed because nm_device_realize() already calls realize_start_setup(), which calls realize_start_notify() and update_properties(). update_connection() no longer refreshes the device properties. Instead it only modifies the passed-in NMConnection. It's a bit ugly that update_connection() uses both cached properties from NMDeviceVlan (vlan_id) and platform properties (xgress maps). Also, update_connection() doesn't return early on error but continues trying to update the NMConnection. The reason is that update_connection() cannot return a failure status. --- src/devices/nm-device-vlan.c | 142 +++++++++++++++++------------------ 1 file changed, 68 insertions(+), 74 deletions(-) diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index a6bb8123da..16f2bda077 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -51,7 +51,7 @@ typedef struct { NMDevice *parent; gulong parent_state_id; gulong parent_hwaddr_id; - int vlan_id; + guint vlan_id; } NMDeviceVlanPrivate; enum { @@ -152,53 +152,47 @@ nm_device_vlan_set_parent (NMDeviceVlan *self, NMDevice *parent) } static void -realize_start_notify (NMDevice *device, const NMPlatformLink *plink) +update_properties (NMDevice *device) { - NMDeviceVlan *self = NM_DEVICE_VLAN (device); - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self); + NMDeviceVlanPrivate *priv; + const NMPlatformLink *plink = NULL; + const NMPlatformLnkVlan *plnk = NULL; + NMDevice *parent = NULL; + int ifindex; + guint vlan_id; - NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink); + g_return_if_fail (NM_IS_DEVICE_VLAN (device)); - _LOGI (LOGD_HW | LOGD_VLAN, "VLAN ID %d with parent %s", - priv->vlan_id, nm_device_get_iface (priv->parent)); -} + priv = NM_DEVICE_VLAN_GET_PRIVATE (device); -static gboolean -realize (NMDevice *device, - NMPlatformLink *plink, - GError **error) -{ - NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); - NMDevice *parent; - const NMPlatformLnkVlan *plnk; + ifindex = nm_device_get_ifindex (device); - g_return_val_if_fail (plink, FALSE); + if (ifindex > 0) + plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, ifindex, &plink); + if ( plnk + && plink->parent + && plink->parent != NM_PLATFORM_LINK_OTHER_NETNS) + parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent); - g_assert (plink->type == NM_LINK_TYPE_VLAN); + g_object_freeze_notify ((GObject *) device); - plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, plink->ifindex, NULL); - if (!plnk) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "(%s): failed to get VLAN properties", plink->name); - return FALSE; + nm_device_vlan_set_parent ((NMDeviceVlan *) device, parent); + + vlan_id = plnk ? plnk->id : 0; + if (vlan_id != priv->vlan_id) { + priv->vlan_id = vlan_id; + g_object_notify ((GObject *) device, NM_DEVICE_VLAN_ID); } - if (plink->parent != NM_PLATFORM_LINK_OTHER_NETNS) { - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent); - if (!parent) { - nm_log_dbg (LOGD_HW, "(%s): VLAN parent interface unknown", plink->name); - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "(%s): VLAN parent interface unknown", plink->name); - return FALSE; - } - } else - parent = NULL; + g_object_thaw_notify ((GObject *) device); +} - g_warn_if_fail (priv->parent == NULL); - nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent); - priv->vlan_id = plnk->id; +static void +realize_start_notify (NMDevice *device, const NMPlatformLink *plink) +{ + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->realize_start_notify (device, plink); - return TRUE; + update_properties (device); } static gboolean @@ -211,7 +205,8 @@ create_and_realize (NMDevice *device, NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); const char *iface = nm_device_get_iface (device); NMSettingVlan *s_vlan; - int parent_ifindex, vlan_id; + int parent_ifindex; + guint vlan_id; NMPlatformError plerr; s_vlan = nm_connection_get_setting_vlan (connection); @@ -247,7 +242,10 @@ create_and_realize (NMDevice *device, g_warn_if_fail (priv->parent == NULL); nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent); - priv->vlan_id = vlan_id; + if (vlan_id != priv->vlan_id) { + priv->vlan_id = vlan_id; + g_object_notify ((GObject *) device, NM_DEVICE_VLAN_ID); + } return TRUE; } @@ -311,10 +309,8 @@ notify_new_device_added (NMDevice *device, NMDevice *new_device) return; plnk = nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, nm_device_get_ifindex (device), &plink); - if (!plnk) { - _LOGW (LOGD_VLAN, "failed to get VLAN interface info while checking added component."); + if (!plnk) return; - } if ( plink->parent <= 0 || nm_device_get_ifindex (new_device) != plink->parent) @@ -478,15 +474,14 @@ complete_connection (NMDevice *device, static void update_connection (NMDevice *device, NMConnection *connection) { - NMDeviceVlan *self = NM_DEVICE_VLAN (device); NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device); NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection); int ifindex = nm_device_get_ifindex (device); - NMDevice *parent; const char *setting_parent, *new_parent; const NMPlatformLink *plink; const NMPObject *polnk; - nm_auto_nmpobj NMPObject *polnk_ref = NULL; + guint vlan_id; + guint vlan_flags; if (!s_vlan) { s_vlan = (NMSettingVlan *) nm_setting_vlan_new (); @@ -494,36 +489,27 @@ update_connection (NMDevice *device, NMConnection *connection) } polnk = nm_platform_link_get_lnk (NM_PLATFORM_GET, ifindex, NM_LINK_TYPE_VLAN, &plink); - if (!polnk) { - _LOGW (LOGD_VLAN, "failed to get VLAN interface info while updating connection."); - return; - } - polnk_ref = nmp_object_ref ((NMPObject *) polnk); - if (priv->vlan_id != polnk->lnk_vlan.id) { - priv->vlan_id = polnk->lnk_vlan.id; - g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_ID); - } - - if (polnk->lnk_vlan.id != nm_setting_vlan_get_id (s_vlan)) - g_object_set (s_vlan, NM_SETTING_VLAN_ID, priv->vlan_id, NULL); - - if (plink->parent != NM_PLATFORM_LINK_OTHER_NETNS) - parent = nm_manager_get_device_by_ifindex (nm_manager_get (), plink->parent); + if (polnk) + vlan_id = polnk->lnk_vlan.id; else - parent = NULL; - nm_device_vlan_set_parent (NM_DEVICE_VLAN (device), parent); + vlan_id = priv->vlan_id; + if (vlan_id != nm_setting_vlan_get_id (s_vlan)) + g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL); /* Update parent in the connection; default to parent's interface name */ - if (parent) { - new_parent = nm_device_get_iface (parent); + if ( priv->parent + && polnk + && plink->parent > 0 + && nm_device_get_ifindex (priv->parent) == plink->parent) { + new_parent = nm_device_get_iface (priv->parent); setting_parent = nm_setting_vlan_get_parent (s_vlan); if (setting_parent && nm_utils_is_uuid (setting_parent)) { NMConnection *parent_connection; /* Don't change a parent specified by UUID if it's still valid */ parent_connection = nm_connection_provider_get_connection_by_uuid (nm_connection_provider_get (), setting_parent); - if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection)) + if (parent_connection && nm_device_check_connection_compatible (priv->parent, parent_connection)) new_parent = NULL; } if (new_parent) @@ -531,15 +517,24 @@ update_connection (NMDevice *device, NMConnection *connection) } else g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, NULL, NULL); - if (polnk->lnk_vlan.flags != nm_setting_vlan_get_flags (s_vlan)) - g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, (NMVlanFlags) polnk->lnk_vlan.flags, NULL); + if (polnk) + vlan_flags = polnk->lnk_vlan.flags; + else + vlan_flags = NM_VLAN_FLAG_REORDER_HEADERS; + if (vlan_flags != nm_setting_vlan_get_flags (s_vlan)) + g_object_set (s_vlan, NM_SETTING_VLAN_FLAGS, (NMVlanFlags) vlan_flags, NULL); - _nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_INGRESS_MAP, - polnk->_lnk_vlan.ingress_qos_map, - polnk->_lnk_vlan.n_ingress_qos_map); - _nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_EGRESS_MAP, - polnk->_lnk_vlan.egress_qos_map, - polnk->_lnk_vlan.n_egress_qos_map); + if (polnk) { + _nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_INGRESS_MAP, + polnk->_lnk_vlan.ingress_qos_map, + polnk->_lnk_vlan.n_ingress_qos_map); + _nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_EGRESS_MAP, + polnk->_lnk_vlan.egress_qos_map, + polnk->_lnk_vlan.n_egress_qos_map); + } else { + _nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_INGRESS_MAP, NULL, 0); + _nm_setting_vlan_set_priorities (s_vlan, NM_VLAN_EGRESS_MAP, NULL, 0); + } } static NMActStageReturn @@ -685,7 +680,6 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) object_class->dispose = dispose; parent_class->create_and_realize = create_and_realize; - parent_class->realize = realize; parent_class->realize_start_notify = realize_start_notify; parent_class->unrealize = unrealize; parent_class->get_generic_capabilities = get_generic_capabilities; From 169c5b7a525d3ebf6f203db5a248fd92438b6040 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 14:48:13 +0100 Subject: [PATCH 08/12] device: remove unused virtual function NMDevice:realize() The idea of NMDevice:realize() was to (1) update the device properties (2) fail realization if some critical properties are missing (1) is already done during nm_device_setup_start(). (2) was only implemented by NMDeviceVlan:realize(), but it basically was just checking whether such a platform device exists. Other implementations don't do that either and it opens up for a race when the device gets deleted externally. --- src/devices/nm-device.c | 6 ------ src/devices/nm-device.h | 21 --------------------- 2 files changed, 27 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a7357c5486..9b65afee74 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1732,12 +1732,6 @@ nm_device_realize (NMDevice *self, return FALSE; } - /* Try to realize the device from existing resources */ - if (NM_DEVICE_GET_CLASS (self)->realize) { - if (!NM_DEVICE_GET_CLASS (self)->realize (self, plink, error)) - return FALSE; - } - realize_start_setup (self, plink); return TRUE; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index edcbb443a1..6b004a48ca 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -144,27 +144,6 @@ typedef struct { void (* link_changed) (NMDevice *self, NMPlatformLink *info); - /** - * realize(): - * @self: the #NMDevice - * @plink: the #NMPlatformLink if backed by a kernel netdevice - * @error: location to store error, or %NULL - * - * Realize the device from existing backing resources. No resources - * should be created as a side-effect of this function. This function - * should only fail if critical device properties/resources (eg, VLAN ID) - * fail to be read or initialized, that would cause the device to be - * unusable. For example, for any properties required to realize the device - * during create_and_realize(), if reading those properties in realize() - * should fail, this function should probably return %FALSE and an error. - * - * Returns: %TRUE on success, %FALSE if some error ocurred when realizing - * the device from backing resources - */ - gboolean (*realize) (NMDevice *self, - NMPlatformLink *plink, - GError **error); - /** * create_and_realize(): * @self: the #NMDevice From 633e105455516f0f8a53a59d6ea15e5abe6d03cd Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 14:56:05 +0100 Subject: [PATCH 09/12] device/trivial: rename realize/setup function in NMDevice --- src/devices/nm-device.c | 20 ++++++++++---------- src/devices/nm-device.h | 6 +++--- src/nm-manager.c | 12 ++++++------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 9b65afee74..a2db743b56 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1700,23 +1700,23 @@ link_type_compatible (NMDevice *self, } /** - * nm_device_realize(): + * nm_device_realize_start(): * @self: the #NMDevice * @plink: an existing platform link or %NULL * @out_compatible: %TRUE on return if @self is compatible with @plink * @error: location to store error, or %NULL * * Initializes and sets up the device using existing backing resources. Before - * the device is ready for use nm_device_setup_finish() must be called. + * the device is ready for use nm_device_realize_finish() must be called. * @out_compatible will only be set if @plink is not %NULL, and * * Returns: %TRUE on success, %FALSE on error */ gboolean -nm_device_realize (NMDevice *self, - NMPlatformLink *plink, - gboolean *out_compatible, - GError **error) +nm_device_realize_start (NMDevice *self, + NMPlatformLink *plink, + gboolean *out_compatible, + GError **error) { NM_SET_OUT (out_compatible, TRUE); @@ -1771,7 +1771,7 @@ nm_device_create_and_realize (NMDevice *self, } realize_start_setup (self, plink); - nm_device_setup_finish (self, plink); + nm_device_realize_finish (self, plink); g_return_val_if_fail (nm_device_check_connection_compatible (self, connection), TRUE); return TRUE; @@ -1869,7 +1869,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) klass = NM_DEVICE_GET_CLASS (self); - /* Balanced by a thaw in nm_device_setup_finish() */ + /* Balanced by a thaw in nm_device_realize_finish() */ g_object_freeze_notify (G_OBJECT (self)); if (plink) { @@ -1949,7 +1949,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) } /** - * nm_device_setup_finish(): + * nm_device_realize_finish(): * @self: the #NMDevice * @plink: the #NMPlatformLink if backed by a kernel netdevice * @@ -1958,7 +1958,7 @@ realize_start_setup (NMDevice *self, const NMPlatformLink *plink) * is ready for network connectivity. */ void -nm_device_setup_finish (NMDevice *self, const NMPlatformLink *plink) +nm_device_realize_finish (NMDevice *self, const NMPlatformLink *plink) { g_return_if_fail (!plink || link_type_compatible (self, plink->type, NULL, NULL)); diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 6b004a48ca..997dd2d456 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -467,16 +467,16 @@ gboolean nm_device_get_is_nm_owned (NMDevice *device); gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps); -gboolean nm_device_realize (NMDevice *device, +gboolean nm_device_realize_start (NMDevice *device, NMPlatformLink *plink, gboolean *out_compatible, GError **error); +void nm_device_realize_finish (NMDevice *self, + const NMPlatformLink *plink); gboolean nm_device_create_and_realize (NMDevice *self, NMConnection *connection, NMDevice *parent, GError **error); -void nm_device_setup_finish (NMDevice *self, - const NMPlatformLink *plink); gboolean nm_device_unrealize (NMDevice *device, gboolean remove_resources, GError **error); diff --git a/src/nm-manager.c b/src/nm-manager.c index 85832223a1..ac3c5001af 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1895,9 +1895,9 @@ factory_device_added_cb (NMDeviceFactory *factory, { GError *error = NULL; - if (nm_device_realize (device, NULL, NULL, &error)) { + if (nm_device_realize_start (device, NULL, NULL, &error)) { add_device (NM_MANAGER (user_data), device, NULL); - nm_device_setup_finish (device, NULL); + nm_device_realize_finish (device, NULL); } else { nm_log_warn (LOGD_DEVICE, "(%s): failed to realize device: %s", nm_device_get_iface (device), error->message); @@ -1967,9 +1967,9 @@ platform_link_added (NMManager *self, * device with the link's name. */ return; - } else if (nm_device_realize (candidate, plink, &compatible, &error)) { + } else if (nm_device_realize_start (candidate, plink, &compatible, &error)) { /* Success */ - nm_device_setup_finish (candidate, plink); + nm_device_realize_finish (candidate, plink); return; } @@ -2016,9 +2016,9 @@ platform_link_added (NMManager *self, if (device) { if (nm_plugin_missing) nm_device_set_nm_plugin_missing (device, TRUE); - if (nm_device_realize (device, plink, NULL, &error)) { + if (nm_device_realize_start (device, plink, NULL, &error)) { add_device (self, device, NULL); - nm_device_setup_finish (device, plink); + nm_device_realize_finish (device, plink); } else { nm_log_warn (LOGD_DEVICE, "%s: failed to realize device: %s", plink->name, error->message); From 2550850f54164c46f746a6f3a768e29f09961b10 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 15:13:20 +0100 Subject: [PATCH 10/12] device: pass NMPlatformLink instance as const pointer --- src/devices/bluetooth/nm-bluez-manager.c | 2 +- src/devices/nm-device-bond.c | 2 +- src/devices/nm-device-bridge.c | 2 +- src/devices/nm-device-ethernet.c | 2 +- src/devices/nm-device-factory.c | 2 +- src/devices/nm-device-factory.h | 4 ++-- src/devices/nm-device-generic.c | 2 +- src/devices/nm-device-generic.h | 2 +- src/devices/nm-device-infiniband.c | 2 +- src/devices/nm-device-ip-tunnel.c | 2 +- src/devices/nm-device-macvlan.c | 2 +- src/devices/nm-device-tun.c | 2 +- src/devices/nm-device-veth.c | 2 +- src/devices/nm-device-vlan.c | 2 +- src/devices/nm-device-vxlan.c | 2 +- src/devices/nm-device.c | 2 +- src/devices/nm-device.h | 2 +- src/devices/team/nm-team-factory.c | 2 +- src/devices/wifi/nm-wifi-factory.c | 2 +- src/devices/wwan/nm-wwan-factory.c | 2 +- src/nm-manager.c | 2 +- 21 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c index db98d2808c..6903356c8c 100644 --- a/src/devices/bluetooth/nm-bluez-manager.c +++ b/src/devices/bluetooth/nm-bluez-manager.c @@ -411,7 +411,7 @@ nm_bluez_manager_init (NMBluezManager *self) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 84ddffde5f..dfd1de6dfb 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -513,7 +513,7 @@ nm_device_bond_class_init (NMDeviceBondClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 69b67c259e..843c5be499 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -461,7 +461,7 @@ nm_device_bridge_class_init (NMDeviceBridgeClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index b99f0671f5..a2396ec83f 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1784,7 +1784,7 @@ nm_device_ethernet_class_init (NMDeviceEthernetClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index 07804da758..75731b14f2 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -83,7 +83,7 @@ nm_device_factory_start (NMDeviceFactory *factory) NMDevice * nm_device_factory_create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore, GError **error) diff --git a/src/devices/nm-device-factory.h b/src/devices/nm-device-factory.h index 7568b0fdfb..9b7cb35a1d 100644 --- a/src/devices/nm-device-factory.h +++ b/src/devices/nm-device-factory.h @@ -135,7 +135,7 @@ typedef struct { */ NMDevice * (*create_device) (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore); @@ -183,7 +183,7 @@ void nm_device_factory_start (NMDeviceFactory *factory); NMDevice * nm_device_factory_create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore, GError **error); diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index b05bdb1cc5..2e9c134a3d 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -111,7 +111,7 @@ update_connection (NMDevice *device, NMConnection *connection) /**************************************************************/ NMDevice * -nm_device_generic_new (NMPlatformLink *plink) +nm_device_generic_new (const NMPlatformLink *plink) { g_return_val_if_fail (plink != NULL, NULL); diff --git a/src/devices/nm-device-generic.h b/src/devices/nm-device-generic.h index 1b3fa7f9bc..9303a27891 100644 --- a/src/devices/nm-device-generic.h +++ b/src/devices/nm-device-generic.h @@ -45,7 +45,7 @@ typedef struct { GType nm_device_generic_get_type (void); -NMDevice *nm_device_generic_new (NMPlatformLink *plink); +NMDevice *nm_device_generic_new (const NMPlatformLink *plink); G_END_DECLS diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 5a8bfbd43c..45df49fe02 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -364,7 +364,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index a428e749af..11aabcbcad 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -980,7 +980,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 28421b4b3c..8123a7931f 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -691,7 +691,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index d04cd7e641..b62b1beae8 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -496,7 +496,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 986c93d8f9..a1bf0d219d 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -181,7 +181,7 @@ nm_device_veth_class_init (NMDeviceVethClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 16f2bda077..27112c5a14 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -721,7 +721,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 3dc238ec55..aaa26cf06a 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -792,7 +792,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a2db743b56..26a1584a8e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1714,7 +1714,7 @@ link_type_compatible (NMDevice *self, */ gboolean nm_device_realize_start (NMDevice *self, - NMPlatformLink *plink, + const NMPlatformLink *plink, gboolean *out_compatible, GError **error) { diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 997dd2d456..7c37be5e4c 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -468,7 +468,7 @@ gboolean nm_device_get_is_nm_owned (NMDevice *device); gboolean nm_device_has_capability (NMDevice *self, NMDeviceCapabilities caps); gboolean nm_device_realize_start (NMDevice *device, - NMPlatformLink *plink, + const NMPlatformLink *plink, gboolean *out_compatible, GError **error); void nm_device_realize_finish (NMDevice *self, diff --git a/src/devices/team/nm-team-factory.c b/src/devices/team/nm-team-factory.c index d30aa31747..5f9e142adb 100644 --- a/src/devices/team/nm-team-factory.c +++ b/src/devices/team/nm-team-factory.c @@ -50,7 +50,7 @@ nm_device_factory_create (GError **error) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c index 8fa16e728f..7f56dc744c 100644 --- a/src/devices/wifi/nm-wifi-factory.c +++ b/src/devices/wifi/nm-wifi-factory.c @@ -61,7 +61,7 @@ nm_device_factory_create (GError **error) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c index 97ef4161c9..2fd9e0bd97 100644 --- a/src/devices/wwan/nm-wwan-factory.c +++ b/src/devices/wwan/nm-wwan-factory.c @@ -98,7 +98,7 @@ NM_DEVICE_FACTORY_DECLARE_TYPES ( static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, - NMPlatformLink *plink, + const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { diff --git a/src/nm-manager.c b/src/nm-manager.c index ac3c5001af..338b3cd68a 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1941,7 +1941,7 @@ _register_device_factory (NMDeviceFactory *factory, gpointer user_data) static void platform_link_added (NMManager *self, int ifindex, - NMPlatformLink *plink) + const NMPlatformLink *plink) { NMDeviceFactory *factory; NMDevice *device = NULL; From ec3613f27c30bfbd0cf1f2c55b1afd5b520dc7de Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 15:18:31 +0100 Subject: [PATCH 11/12] device/trivial: rename virtual function NMDevice:unrealize() to unrealize_notify() --- src/devices/nm-device-ip-tunnel.c | 6 +++--- src/devices/nm-device-tun.c | 6 +++--- src/devices/nm-device-vlan.c | 6 +++--- src/devices/nm-device-vxlan.c | 6 +++--- src/devices/nm-device.c | 8 ++++---- src/devices/nm-device.h | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 11aabcbcad..764c65066e 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -790,9 +790,9 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) } static void -unrealize (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device, gboolean remove_resources) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->unrealize (device, remove_resources); + NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->unrealize_notify (device, remove_resources); update_properties_from_ifindex (device, 0); } @@ -879,7 +879,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) device_class->create_and_realize = create_and_realize; device_class->ip4_config_pre_commit = ip4_config_pre_commit; device_class->realize_start_notify = realize_start_notify; - device_class->unrealize = unrealize; + device_class->unrealize_notify = unrealize_notify; NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_IP_TUNNEL_SETTING_NAME, diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index b62b1beae8..e774bb7b39 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -337,14 +337,14 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) } static void -unrealize (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device, gboolean remove_resources) { NMDeviceTun *self = NM_DEVICE_TUN (device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); GParamSpec **properties; guint n_properties, i; - NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize (device, remove_resources); + NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize_notify (device, remove_resources); memset (&priv->props, 0, sizeof (NMPlatformTunProperties)); @@ -440,7 +440,7 @@ nm_device_tun_class_init (NMDeviceTunClass *klass) device_class->check_connection_compatible = check_connection_compatible; device_class->create_and_realize = create_and_realize; device_class->realize_start_notify = realize_start_notify; - device_class->unrealize = unrealize; + device_class->unrealize_notify = unrealize_notify; device_class->update_connection = update_connection; device_class->act_stage1_prepare = act_stage1_prepare; device_class->ip4_config_pre_commit = ip4_config_pre_commit; diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 27112c5a14..6118a5a1fc 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -251,9 +251,9 @@ create_and_realize (NMDevice *device, } static void -unrealize (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device, gboolean remove_resources) { - NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize (device, remove_resources); + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device, remove_resources); NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id = 0; g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_ID); @@ -681,7 +681,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) parent_class->create_and_realize = create_and_realize; parent_class->realize_start_notify = realize_start_notify; - parent_class->unrealize = unrealize; + parent_class->unrealize_notify = unrealize_notify; parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->bring_up = bring_up; parent_class->act_stage1_prepare = act_stage1_prepare; diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index aaa26cf06a..32b1681052 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -155,14 +155,14 @@ realize_start_notify (NMDevice *device, const NMPlatformLink *plink) } static void -unrealize (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device, gboolean remove_resources) { NMDeviceVxlan *self = NM_DEVICE_VXLAN (device); NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self); GParamSpec **properties; guint n_properties, i; - NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize (device, remove_resources); + NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize_notify (device, remove_resources); memset (&priv->props, 0, sizeof (NMPlatformLnkVxlan)); @@ -657,7 +657,7 @@ nm_device_vxlan_class_init (NMDeviceVxlanClass *klass) device_class->link_changed = link_changed; device_class->realize_start_notify = realize_start_notify; - device_class->unrealize = unrealize; + device_class->unrealize_notify = unrealize_notify; device_class->connection_type = NM_SETTING_VXLAN_SETTING_NAME; device_class->create_and_realize = create_and_realize; device_class->check_connection_compatible = check_connection_compatible; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 26a1584a8e..ef3d407719 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1977,7 +1977,7 @@ nm_device_realize_finish (NMDevice *self, const NMPlatformLink *plink) } static void -unrealize (NMDevice *self, gboolean remove_resources) +unrealize_notify (NMDevice *self, gboolean remove_resources) { int ifindex; @@ -2021,8 +2021,8 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) g_object_freeze_notify (G_OBJECT (self)); - if (NM_DEVICE_GET_CLASS (self)->unrealize) - NM_DEVICE_GET_CLASS (self)->unrealize (self, remove_resources); + if (NM_DEVICE_GET_CLASS (self)->unrealize_notify) + NM_DEVICE_GET_CLASS (self)->unrealize_notify (self, remove_resources); if (priv->ifindex > 0) { priv->ifindex = 0; @@ -10883,7 +10883,7 @@ nm_device_class_init (NMDeviceClass *klass) klass->check_connection_available = check_connection_available; klass->can_unmanaged_external_down = can_unmanaged_external_down; klass->realize_start_notify = realize_start_notify; - klass->unrealize = unrealize; + klass->unrealize_notify = unrealize_notify; klass->is_up = is_up; klass->bring_up = bring_up; klass->take_down = take_down; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 7c37be5e4c..75b04cbcc9 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -178,7 +178,7 @@ typedef struct { void (*realize_start_notify) (NMDevice *self, const NMPlatformLink *plink); /** - * unrealize(): + * unrealize_notify(): * @self: the #NMDevice * @remove_resources: if %TRUE remove backing resources * @error: location to store error, or %NULL @@ -186,7 +186,7 @@ typedef struct { * Clears any properties that depend on backing resources (kernel devices, * etc) and removes those resources if @remove_resources is %TRUE. */ - void (*unrealize) (NMDevice *self, gboolean remove_resources); + void (*unrealize_notify) (NMDevice *self, gboolean remove_resources); /* Hardware state (IFF_UP) */ gboolean (*can_unmanaged_external_down) (NMDevice *self); From a602b18f74e17d479aa5690c861172707571bd60 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 10 Jan 2016 15:19:58 +0100 Subject: [PATCH 12/12] device: refactor virtual function NMDevice:unrealize_notify() to only clear properties Change the meaning of unrealize_notify() similar to realize_start_notify(), which only resets device properites during unrealize. --- src/devices/nm-device-ip-tunnel.c | 4 ++-- src/devices/nm-device-tun.c | 4 ++-- src/devices/nm-device-vlan.c | 4 ++-- src/devices/nm-device-vxlan.c | 4 ++-- src/devices/nm-device.c | 23 ++++++++++++----------- src/devices/nm-device.h | 8 +++----- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 764c65066e..6d0df059e8 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -790,9 +790,9 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) } static void -unrealize_notify (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device) { - NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->unrealize_notify (device, remove_resources); + NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->unrealize_notify (device); update_properties_from_ifindex (device, 0); } diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index e774bb7b39..91ef8fe704 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -337,14 +337,14 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) } static void -unrealize_notify (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device) { NMDeviceTun *self = NM_DEVICE_TUN (device); NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); GParamSpec **properties; guint n_properties, i; - NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize_notify (device, remove_resources); + NM_DEVICE_CLASS (nm_device_tun_parent_class)->unrealize_notify (device); memset (&priv->props, 0, sizeof (NMPlatformTunProperties)); diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 6118a5a1fc..48604135ba 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -251,9 +251,9 @@ create_and_realize (NMDevice *device, } static void -unrealize_notify (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device) { - NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device, remove_resources); + NM_DEVICE_CLASS (nm_device_vlan_parent_class)->unrealize_notify (device); NM_DEVICE_VLAN_GET_PRIVATE (device)->vlan_id = 0; g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_ID); diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 32b1681052..aab9053970 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -155,14 +155,14 @@ realize_start_notify (NMDevice *device, const NMPlatformLink *plink) } static void -unrealize_notify (NMDevice *device, gboolean remove_resources) +unrealize_notify (NMDevice *device) { NMDeviceVxlan *self = NM_DEVICE_VXLAN (device); NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE (self); GParamSpec **properties; guint n_properties, i; - NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize_notify (device, remove_resources); + NM_DEVICE_CLASS (nm_device_vxlan_parent_class)->unrealize_notify (device); memset (&priv->props, 0, sizeof (NMPlatformLnkVxlan)); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ef3d407719..05cdb51970 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1977,16 +1977,11 @@ nm_device_realize_finish (NMDevice *self, const NMPlatformLink *plink) } static void -unrealize_notify (NMDevice *self, gboolean remove_resources) +unrealize_notify (NMDevice *self) { - int ifindex; - - if (remove_resources) { - ifindex = nm_device_get_ifindex (self); - if ( ifindex > 0 - && nm_device_is_software (self)) - nm_platform_link_delete (NM_PLATFORM_GET, ifindex); - } + /* Stub implementation for unrealize_notify(). It does nothing, + * but allows derived classes to uniformly invoke the parent + * implementation. */ } /** @@ -2004,6 +1999,7 @@ gboolean nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) { NMDevicePrivate *priv; + int ifindex; g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); @@ -2021,8 +2017,13 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) g_object_freeze_notify (G_OBJECT (self)); - if (NM_DEVICE_GET_CLASS (self)->unrealize_notify) - NM_DEVICE_GET_CLASS (self)->unrealize_notify (self, remove_resources); + if (remove_resources) { + ifindex = nm_device_get_ifindex (self); + if (ifindex > 0) + nm_platform_link_delete (NM_PLATFORM_GET, ifindex); + } + + NM_DEVICE_GET_CLASS (self)->unrealize_notify (self); if (priv->ifindex > 0) { priv->ifindex = 0; diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 75b04cbcc9..5b96eacd12 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -180,13 +180,11 @@ typedef struct { /** * unrealize_notify(): * @self: the #NMDevice - * @remove_resources: if %TRUE remove backing resources - * @error: location to store error, or %NULL * - * Clears any properties that depend on backing resources (kernel devices, - * etc) and removes those resources if @remove_resources is %TRUE. + * Hook for derived classes to clear any properties that depend on backing resources + * (kernel devices, etc). This is called by nm_device_unrealize() during unrealization. */ - void (*unrealize_notify) (NMDevice *self, gboolean remove_resources); + void (*unrealize_notify) (NMDevice *self); /* Hardware state (IFF_UP) */ gboolean (*can_unmanaged_external_down) (NMDevice *self);