From 9761e38f7eeb50d33ee103dccae2cdc7d25cbd4b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 10 May 2022 11:10:56 +0200 Subject: [PATCH] dhcp: fix handling of NM_DHCP_STATE_NOOP The "noop" state is almost unused, however, nm_dhcp_set_state() has a check "if (new_state >= NM_DHCP_STATE_TIMEOUT)", so the order of the NOOP state matters. Fix that by reordering. Also, just return right away from NOOP. --- src/core/dhcp/nm-dhcp-client.c | 2 +- src/core/dhcp/nm-dhcp-client.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 7875a04adf..157e6950d3 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -971,7 +971,7 @@ nm_dhcp_client_handle_event(gpointer unused, else if (NM_IN_STRSET_ASCII_CASE(reason, "fail", "abend")) new_state = NM_DHCP_STATE_FAIL; else if (NM_IN_STRSET_ASCII_CASE(reason, "preinit")) - new_state = NM_DHCP_STATE_NOOP; + return TRUE; else new_state = NM_DHCP_STATE_UNKNOWN; } diff --git a/src/core/dhcp/nm-dhcp-client.h b/src/core/dhcp/nm-dhcp-client.h index 249bd013ff..b172a72a44 100644 --- a/src/core/dhcp/nm-dhcp-client.h +++ b/src/core/dhcp/nm-dhcp-client.h @@ -28,6 +28,7 @@ typedef enum { NM_DHCP_STATE_UNKNOWN = 0, + NM_DHCP_STATE_NOOP, /* state is a non operation for NetworkManager */ NM_DHCP_STATE_BOUND, /* new lease */ NM_DHCP_STATE_EXTENDED, /* lease extended */ NM_DHCP_STATE_TIMEOUT, /* timed out contacting server */ @@ -35,7 +36,6 @@ typedef enum { NM_DHCP_STATE_EXPIRE, /* lease expired or NAKed */ NM_DHCP_STATE_FAIL, /* failed for some reason */ NM_DHCP_STATE_TERMINATED, /* client is no longer running */ - NM_DHCP_STATE_NOOP, /* state is a non operation for NetworkManager */ } NMDhcpState; typedef enum _nm_packed {