diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2023-10-27 18:05:13 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2023-10-27 18:05:13 +0200 |
commit | b0d606b427018116f91eac248124f33ab25664ff (patch) | |
tree | fed0e2fa0dfb6cfc9fe78952b64c443f93238577 | |
parent | a0a0ae322b77ffd2682b4179478de40c407255b0 (diff) | |
parent | d3db0883c7723a9e150ea9856bd8678480c99874 (diff) |
merge: branch 'bg/deactivate-reason'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1770
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1405
-rw-r--r-- | src/core/nm-act-request.c | 13 | ||||
-rw-r--r-- | src/core/nm-active-connection.c | 3 | ||||
-rw-r--r-- | src/core/nm-active-connection.h | 3 | ||||
-rw-r--r-- | src/core/vpn/nm-vpn-connection.c | 3 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/core/nm-act-request.c b/src/core/nm-act-request.c index dce18ba4ec..bed7ffde18 100644 --- a/src/core/nm-act-request.c +++ b/src/core/nm-act-request.c @@ -259,7 +259,8 @@ static void device_state_changed(NMActiveConnection *active, NMDevice *device, NMDeviceState new_state, - NMDeviceState old_state) + NMDeviceState old_state, + NMDeviceStateReason reason) { NMActiveConnectionState cur_ac_state = nm_active_connection_get_state(active); NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; @@ -319,14 +320,20 @@ device_state_changed(NMActiveConnection *active, active); break; case NM_DEVICE_STATE_DEACTIVATING: + if (reason == NM_DEVICE_STATE_REASON_USER_REQUESTED) + ac_state_reason = NM_ACTIVE_CONNECTION_STATE_REASON_USER_DISCONNECTED; + ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING; break; case NM_DEVICE_STATE_FAILED: case NM_DEVICE_STATE_DISCONNECTED: case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: - ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; - ac_state_reason = NM_ACTIVE_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED; + ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; + if (reason == NM_DEVICE_STATE_REASON_USER_REQUESTED) + ac_state_reason = NM_ACTIVE_CONNECTION_STATE_REASON_USER_DISCONNECTED; + else + ac_state_reason = NM_ACTIVE_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED; g_signal_handlers_disconnect_by_func(device, G_CALLBACK(device_notify), active); break; diff --git a/src/core/nm-active-connection.c b/src/core/nm-active-connection.c index 36a11f7151..5feab966de 100644 --- a/src/core/nm-active-connection.c +++ b/src/core/nm-active-connection.c @@ -636,7 +636,8 @@ device_state_changed(NMDevice *device, NM_ACTIVE_CONNECTION_GET_CLASS(self)->device_state_changed(self, device, new_state, - old_state); + old_state, + reason); } static void diff --git a/src/core/nm-active-connection.h b/src/core/nm-active-connection.h index 15db68c369..8032294f3c 100644 --- a/src/core/nm-active-connection.h +++ b/src/core/nm-active-connection.h @@ -78,7 +78,8 @@ typedef struct { void (*device_state_changed)(NMActiveConnection *connection, NMDevice *device, NMDeviceState new_state, - NMDeviceState old_state); + NMDeviceState old_state, + NMDeviceStateReason reason); void (*master_failed)(NMActiveConnection *connection); void (*device_changed)(NMActiveConnection *connection, diff --git a/src/core/vpn/nm-vpn-connection.c b/src/core/vpn/nm-vpn-connection.c index d7102a12ef..3dba9ff6c8 100644 --- a/src/core/vpn/nm-vpn-connection.c +++ b/src/core/vpn/nm-vpn-connection.c @@ -1143,7 +1143,8 @@ static void device_state_changed(NMActiveConnection *active, NMDevice *device, NMDeviceState new_state, - NMDeviceState old_state) + NMDeviceState old_state, + NMDeviceStateReason reason) { if (_service_and_connection_can_persist(NM_VPN_CONNECTION(active))) { if (new_state <= NM_DEVICE_STATE_DISCONNECTED || new_state == NM_DEVICE_STATE_FAILED) { |