summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-01-10 15:19:58 +0100
committerThomas Haller <thaller@redhat.com>2016-01-11 12:22:19 +0100
commitcab65aeec2c1b3ee753a25a8cac8390961a4f497 (patch)
tree6f2581a8e658aa7d8d3052931372b84dc1c1b276
parenta51306a0ec3f08a243ee993757d9813cfe4121be (diff)
downloadNetworkManager-th/device-realize-bgo760450.tar.gz
device: refactor virtual function NMDevice:unrealize_notify() to only clear propertiesth/device-realize-bgo760450
Change the meaning of unrealize_notify() similar to realize_start_notify(), which only resets device properites during unrealize.
-rw-r--r--src/devices/nm-device-ip-tunnel.c4
-rw-r--r--src/devices/nm-device-tun.c4
-rw-r--r--src/devices/nm-device-vlan.c4
-rw-r--r--src/devices/nm-device-vxlan.c4
-rw-r--r--src/devices/nm-device.c23
-rw-r--r--src/devices/nm-device.h8
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 ac3ab16f74..8476d93b9c 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..a6cf236aa4 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 clears 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);