diff mbox series

[v2,1/2] netconfig: limit DHCPv4 attempts to avoid extended netconfig times

Message ID 20240130175038.77908-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [v2,1/2] netconfig: limit DHCPv4 attempts to avoid extended netconfig times | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-alpine-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood Jan. 30, 2024, 5:50 p.m. UTC
ELL now has a setting to limit the number of DHCP attempts. This
will now be set in IWD and if reached will result in a failure
event, and in turn a disconnect.

IWD will set a maximum of 4 retries which should keep the maximum
DHCP time to ~60 seconds roughly.
---
 src/netconfig.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Denis Kenzior Jan. 30, 2024, 8 p.m. UTC | #1
Hi James,

On 1/30/24 11:50, James Prestwood wrote:
> ELL now has a setting to limit the number of DHCP attempts. This
> will now be set in IWD and if reached will result in a failure
> event, and in turn a disconnect.
> 
> IWD will set a maximum of 4 retries which should keep the maximum
> DHCP time to ~60 seconds roughly.
> ---
>   src/netconfig.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 

All applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/netconfig.c b/src/netconfig.c
index 52307025..b31209cf 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -50,6 +50,8 @@ 
 #include "src/netconfig.h"
 #include "src/sysfs.h"
 
+#define DHCP_ATTEMPTS 4
+
 /*
  * Routing priority offset, configurable in main.conf. The route with lower
  * priority offset is preferred.
@@ -696,6 +698,7 @@  struct netconfig *netconfig_new(uint32_t ifindex)
 	int dhcp_priority = L_LOG_INFO;
 	struct l_dhcp6_client *dhcp6;
 	struct l_icmp6_client *icmp6;
+	struct l_dhcp_client *dhcp;
 
 	l_debug("Creating netconfig for interface: %d", ifindex);
 
@@ -723,8 +726,8 @@  struct netconfig *netconfig_new(uint32_t ifindex)
 	l_netconfig_set_event_handler(netconfig->nc, netconfig_event_handler,
 					netconfig, NULL);
 
-	l_dhcp_client_set_debug(l_netconfig_get_dhcp_client(netconfig->nc),
-				do_debug, "[DHCPv4] ", NULL, dhcp_priority);
+	dhcp = l_netconfig_get_dhcp_client(netconfig->nc);
+	l_dhcp_client_set_max_attempts(dhcp, DHCP_ATTEMPTS);
 
 	dhcp6 = l_netconfig_get_dhcp6_client(netconfig->nc);
 	l_dhcp6_client_set_lla_randomized(dhcp6, true);
@@ -735,6 +738,8 @@  struct netconfig *netconfig_new(uint32_t ifindex)
 	if (debug_level) {
 		l_dhcp6_client_set_debug(dhcp6, do_debug, "[DHCPv6] ", NULL);
 		l_icmp6_client_set_debug(icmp6, do_debug, "[ICMPv6] ", NULL);
+		l_dhcp_client_set_debug(dhcp, do_debug, "[DHCPv4] ", NULL,
+					dhcp_priority);
 	}
 
 	return netconfig;