diff options
author | Thomas Haller <thaller@redhat.com> | 2019-07-29 14:37:29 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-07-29 17:03:29 +0200 |
commit | fa14429aa6f86d478cce81a3423f3040143e570f (patch) | |
tree | 5aa79c1a0cdcb0394c85c6e8db49e9845272c69c | |
parent | 86fde5035a4e44ca89810b347ad0c3e0051924ad (diff) | |
download | NetworkManager-fa14429aa6f86d478cce81a3423f3040143e570f.tar.gz |
wireguard: refactor cleanup of NMDeviceWireGuard on disconnect/dispose
-rw-r--r-- | src/devices/nm-device-wireguard.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/devices/nm-device-wireguard.c b/src/devices/nm-device-wireguard.c index 169775146c..714dbd4740 100644 --- a/src/devices/nm-device-wireguard.c +++ b/src/devices/nm-device-wireguard.c @@ -1406,20 +1406,24 @@ get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source) } static void +_device_cleanup (NMDeviceWireGuard *self) +{ + NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (self); + + _peers_remove_all (priv); + _secrets_cancel (self); +} + +static void device_state_changed (NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason) { - NMDeviceWireGuardPrivate *priv; - if (new_state <= NM_DEVICE_STATE_ACTIVATED) return; - priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (device); - - _peers_remove_all (priv); - _secrets_cancel (NM_DEVICE_WIREGUARD (device)); + _device_cleanup (NM_DEVICE_WIREGUARD (device)); } /*****************************************************************************/ @@ -1567,11 +1571,8 @@ static void dispose (GObject *object) { NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD (object); - NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (self); - - _secrets_cancel (self); - _peers_remove_all (priv); + _device_cleanup (self); G_OBJECT_CLASS (nm_device_wireguard_parent_class)->dispose (object); } |