diff options
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.8 | 7 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 18 |
2 files changed, 20 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.8 b/sbin/dhclient/dhclient.8 index 281159f..bbe922f 100644 --- a/sbin/dhclient/dhclient.8 +++ b/sbin/dhclient/dhclient.8 @@ -46,7 +46,7 @@ .Nd "Dynamic Host Configuration Protocol (DHCP) client" .Sh SYNOPSIS .Nm -.Op Fl bdqu +.Op Fl bdpqu .Op Fl c Ar file .Op Fl l Ar file .Ar interface @@ -83,6 +83,11 @@ will revert to running in the background. Specify an alternate location, .Ar file , for the leases file. +.It Fl p +Tells dhclient to persist in trying to configure the interface, despite +an inability to gain carrier. +This is used to survive switch outages and when dhclient is required as +soon as the cable is connected. .It Fl q Forces .Nm diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index ce40562..22e69ba 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -295,13 +295,14 @@ main(int argc, char *argv[]) int ch, fd, quiet = 0, i = 0; int pipe_fd[2]; int immediate_daemon = 0; + int persist = 0; struct passwd *pw; /* Initially, log errors to stderr as well as to syslogd. */ openlog(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY); setlogmask(LOG_UPTO(LOG_INFO)); - while ((ch = getopt(argc, argv, "bc:dl:qu")) != -1) + while ((ch = getopt(argc, argv, "bc:dl:pqu")) != -1) switch (ch) { case 'b': immediate_daemon = 1; @@ -315,6 +316,9 @@ main(int argc, char *argv[]) case 'l': path_dhclient_db = optarg; break; + case 'p': + persist = 1; + break; case 'q': quiet = 1; break; @@ -362,12 +366,18 @@ main(int argc, char *argv[]) fprintf(stderr, "."); fflush(stderr); if (++i > 10) { - fprintf(stderr, " giving up\n"); - exit(1); + if (persist) { + fprintf(stderr, " giving up for now\n"); + break; + } else { + fprintf(stderr, " giving up\n"); + exit(1); + } } sleep(1); } - fprintf(stderr, " got link\n"); + if (i <= 10) + fprintf(stderr, " got link\n"); } if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) |