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.
This commit is contained in:
Thomas Haller 2016-01-10 15:19:58 +01:00
parent ec3613f27c
commit a602b18f74
6 changed files with 23 additions and 24 deletions

View file

@ -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);
}

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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;

View file

@ -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);