device: cleanup DHCP before devices removed

Add _dev_ipdhcpx_cleanup in __set_state_full in DEACTIVATING STATE
before STATE_CHANGED signal is emitted to ensure DHCP RELEASE
packet is sent.

Assisted-by: Cursor with Claude Opus 4.5
This commit is contained in:
Rahul Rajesh 2026-04-20 16:23:20 -04:00
parent 9303996b44
commit 09784fcce3

View file

@ -17980,6 +17980,14 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE);
}
break;
case NM_DEVICE_STATE_DEACTIVATING:
/* When deactivating, certain devices are removed/disconnected after the
* STATE_CHANGED signal is sent and before the DHCP release packet
* can be sent. To ensure the release packet is sent, we cleanup DHCP
* before the signal is emitted*/
_dev_ipdhcpx_cleanup(self, AF_INET, TRUE, FALSE);
_dev_ipdhcpx_cleanup(self, AF_INET6, TRUE, FALSE);
break;
case NM_DEVICE_STATE_DISCONNECTED:
if (old_state > NM_DEVICE_STATE_DISCONNECTED) {
/* Ensure devices that previously assumed a connection now have
@ -18029,6 +18037,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
(guint32) state,
(guint32) old_state,
(guint32) reason);
g_signal_emit(self,
signals[STATE_CHANGED],
0,