git: 7bdd17d8d30a - stable/14 - dhclient: Make arp_timeout configurable

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Tue, 20 Aug 2024 04:58:18 UTC
The branch stable/14 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=7bdd17d8d30a2c29dd5d8ea733435917be39eefe

commit 7bdd17d8d30a2c29dd5d8ea733435917be39eefe
Author:     Isaac Cilia Attard <icattard@FreeBSD.org>
AuthorDate: 2024-07-08 06:33:13 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-08-20 04:57:08 +0000

    dhclient: Make arp_timeout configurable
    
    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:   https://github.com/freebsd/freebsd-src/pull/1368
    
    (cherry picked from commit b51569ad3c806688befc00dad51d15a7e61659fb)
---
 sbin/dhclient/dhclient.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 043f7808bb9d..4a674cec5888 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -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;
@@ -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;
@@ -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;
@@ -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);
 }