Skip to content

Commit

Permalink
dhclient: Make arp_timeout configurable
Browse files Browse the repository at this point in the history
Make arp_timeout available to dhclient.c, set the default timeout to 250
ms, and provide a new command-line argument, 'n' for setting the timeout
to 0.

Sponsored by:	Google LLC (GSoC 2024)
Signed-off-by:	Isaac Cilia Attard <icattard@FreeBSD.org>
MFC after:	10 days
Reviwed by:	cperciva, brooks, Tom Hukins, Alexander Ziaee
Pull Request:	#1368

(cherry picked from commit b51569a)
  • Loading branch information
ica574 authored and cperciva committed Aug 20, 2024
1 parent 7ee6831 commit 7bdd17d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sbin/dhclient/dhclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct pidfh *pidfile;
*/
#define TIME_MAX ((((time_t) 1 << (sizeof(time_t) * CHAR_BIT - 2)) - 1) * 2 + 1)

static struct timespec arp_timeout = { .tv_sec = 2, .tv_nsec = 0 };
static struct timespec arp_timeout = { .tv_sec = 0, .tv_nsec = 250 * 1000 * 1000 };
static const struct timespec zero_timespec = { .tv_sec = 0, .tv_nsec = 0 };
int log_priority;
static int no_daemon;
Expand Down Expand Up @@ -386,7 +386,7 @@ main(int argc, char *argv[])
cap_openlog(capsyslog, getprogname(), LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY);
cap_setlogmask(capsyslog, LOG_UPTO(LOG_DEBUG));

while ((ch = getopt(argc, argv, "bc:dl:p:qu")) != -1)
while ((ch = getopt(argc, argv, "bc:dl:np:qu")) != -1)
switch (ch) {
case 'b':
immediate_daemon = 1;
Expand All @@ -400,6 +400,9 @@ main(int argc, char *argv[])
case 'l':
path_dhclient_db = optarg;
break;
case 'n':
arp_timeout = zero_timespec;
break;
case 'p':
path_dhclient_pidfile = optarg;
break;
Expand Down Expand Up @@ -576,7 +579,7 @@ void
usage(void)
{

fprintf(stderr, "usage: %s [-bdqu] ", getprogname());
fprintf(stderr, "usage: %s [-bdnqu] ", getprogname());
fprintf(stderr, "[-c conffile] [-l leasefile] interface\n");
exit(1);
}
Expand Down

0 comments on commit 7bdd17d

Please sign in to comment.