diff options
author | Thomas Haller <thaller@redhat.com> | 2016-01-10 15:19:58 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-01-11 14:05:49 +0100 |
commit | a602b18f74e17d479aa5690c861172707571bd60 (patch) | |
tree | e7c148000f41646cfdd24ab935196d8389ad0b8d | |
parent | ec3613f27c30bfbd0cf1f2c55b1afd5b520dc7de (diff) | |
download | NetworkManager-a602b18f74e17d479aa5690c861172707571bd60.tar.gz |
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.
-rw-r--r-- | src/devices/nm-device-ip-tunnel.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device-tun.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device-vxlan.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device.c | 23 | ||||
-rw-r--r-- | 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); |