Skip to contentSkip to conversation

dhcp: Stop client before notifying owner

PATCH In review Tim Kourt 2 participants 3 messages Oct 16, 2019 – Oct 17, 2019

lore
Share & tools
lore

Tim Kourt

author
#0 lore raw

PATCH 1/2 dhcp: Stop client before notifying owner

This enables the owner of the client object to restart it.

---
 ell/dhcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ell/dhcp.c +3 -1
index 22d903e..132d973 100644
@@ -950,9 +950,11 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
 	case DHCP_STATE_RENEWING:
 	case DHCP_STATE_REBINDING:
 		if (msg_type == DHCP_MESSAGE_TYPE_NAK) {
+			l_dhcp_client_stop(client);
+
 			dhcp_client_event_notify(client,
 					L_DHCP_CLIENT_EVENT_NO_LEASE);
-			goto error;
+			return;
 		}
 
 		if (msg_type != DHCP_MESSAGE_TYPE_ACK)
Signature · 1 line
2.13.6
author
#1 lore raw

PATCH 2/2 dhcp: Move error handling

With a single use case of 'error' label, eliminate it and move the error handling into the block where it is used.

---
 ell/dhcp.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
ell/dhcp.c +5 -7
index 132d973..2b7d472 100644
@@ -941,8 +941,11 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
 		CLIENT_ENTER_STATE(DHCP_STATE_REQUESTING);
 		client->attempt = 1;
 
-		if (dhcp_client_send_request(client) < 0)
-			goto error;
+		if (dhcp_client_send_request(client) < 0) {
+			l_dhcp_client_stop(client);
+
+			return;
+		}
 
 		l_timeout_modify_ms(client->timeout_resend, dhcp_fuzz_secs(4));
 		break;
@@ -995,11 +998,6 @@ static void dhcp_client_rx_message(const void *data, size_t len, void *userdata)
 	case DHCP_STATE_BOUND:
 		break;
 	}
-
-	return;
-
-error:
-	l_dhcp_client_stop(client);
 }
 
 LIB_EXPORT struct l_dhcp_client *l_dhcp_client_new(uint32_t ifindex)
Signature · 1 line
2.13.6
#2 lore raw
In reply to Tim Kourt

Hi Tim,

Quoted 5 lines · Tim Kourt

This enables the owner of the client object to restart it.

---
  ell/dhcp.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Both applied, thanks.

Regards,
-Denis