-.\" $OpenBSD: dhclient.8,v 1.35 2017/10/27 15:10:16 krw Exp $
+.\" $OpenBSD: dhclient.8,v 1.36 2018/02/06 00:25:09 krw Exp $
.\"
.\" Copyright (c) 1997 The Internet Software Consortium.
.\" All rights reserved.
.\" Enterprises. To learn more about the Internet Software Consortium,
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
-.Dd $Mdocdate: October 27 2017 $
+.Dd $Mdocdate: February 6 2018 $
.Dt DHCLIENT 8
.Os
.Sh NAME
.Nd Dynamic Host Configuration Protocol (DHCP) client
.Sh SYNOPSIS
.Nm
-.Op Fl dnq
+.Op Fl dnv
.Op Fl c Ar file
.Op Fl i Ar options
.Op Fl L Ar file
.It Fl n
Configtest mode.
Only check the configuration file for validity.
-.It Fl q
-Forces
+.It Fl v
+Causes
.Nm
-to be less verbose on startup.
-.Fl q
-has no effect if either
+to log more information.
+.Fl v
+is implied if either
.Fl d
or
.Fl n
-is also present.
+is present.
.El
.Pp
The DHCP protocol allows a host to contact a central server which
-/* $OpenBSD: dhclient.c,v 1.554 2018/02/05 09:33:50 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.555 2018/02/06 00:25:09 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
else
log_init(0, LOG_DEBUG); /* can't log to stderr */
- log_setverbose(1); /* Show log_debug() messages. */
+ log_setverbose(0); /* Don't show log_debug() messages. */
- while ((ch = getopt(argc, argv, "c:di:l:L:nq")) != -1)
+ while ((ch = getopt(argc, argv, "c:di:l:L:nv")) != -1)
switch (ch) {
case 'c':
path_dhclient_conf = optarg;
case 'n':
cmd_opts |= OPT_NOACTION;
break;
- case 'q':
- cmd_opts |= OPT_QUIET;
+ case 'v':
+ cmd_opts |= OPT_VERBOSE;
break;
default:
usage();
usage();
if ((cmd_opts & (OPT_FOREGROUND | OPT_NOACTION)) != 0)
- cmd_opts &= ~OPT_QUIET;
+ cmd_opts |= OPT_VERBOSE;
- if ((cmd_opts & OPT_QUIET) != 0)
- log_setverbose(0); /* Don't show log_debug() */
+ if ((cmd_opts & OPT_VERBOSE) != 0)
+ log_setverbose(1); /* Show log_debug() messages. */
ifi = calloc(1, sizeof(*ifi));
if (ifi == NULL)
extern char *__progname;
fprintf(stderr,
- "usage: %s [-dnq] [-c file] [-i options] [-L file] "
+ "usage: %s [-dnv] [-c file] [-i options] [-L file] "
"[-l file] interface\n", __progname);
exit(1);
}
* If the backoff would take us to the panic timeout, just use that
* as the interval.
*/
- if (cur_time + ifi->interval >
- ifi->first_sending + config->timeout)
+ if (cur_time + ifi->interval > ifi->first_sending + config->timeout)
ifi->interval = (ifi->first_sending +
config->timeout) - cur_time + 1;
+ /*
+ * If we are still starting up, backoff 1 second. If we are past
+ * link_timeout we just go daemon and finish things up in the
+ * background.
+ */
+ if (cur_time - ifi->startup_time < config->link_timeout)
+ ifi->interval = 1;
+ else {
+ if (isatty(STDERR_FILENO) != 0)
+ fprintf(stderr, "no lease .... sleeping\n");
+ go_daemon();
+ }
+
/* Record the number of seconds since we started sending. */
if (interval < UINT16_MAX)
packet->secs = htons(interval);
packet->secs = htons(UINT16_MAX);
ifi->secs = packet->secs;
-
rslt = send_packet(ifi, inaddr_any, inaddr_broadcast, "DHCPDISCOVER");
if (rslt != -1)
log_debug("%s: DHCPDISCOVER - interval %lld", log_procname,
ifi->expiry)
ifi->interval = ifi->expiry - cur_time + 1;
+ /*
+ * If we are still starting up, backoff 1 second. If we are past
+ * link_timeout we just go daemon and finish things up in the
+ * background.
+ */
+ if (cur_time - ifi->startup_time < config->link_timeout)
+ ifi->interval = 1;
+ else {
+ if (isatty(STDERR_FILENO) != 0)
+ fprintf(stderr, "no lease .... sleeping");
+ go_daemon();
+ }
+
/*
* If the reboot timeout has expired, or the lease rebind time has
* elapsed, or if we're not yet bound, broadcast the DHCPREQUEST rather
packet->secs = htons(UINT16_MAX);
}
-
rslt = send_packet(ifi, from, destination.sin_addr, "DHCPREQUEST");
if (rslt != -1)
log_debug("%s: DHCPREQUEST to %s", log_procname,
/* Stop logging to stderr. */
log_init(0, LOG_DAEMON);
- if ((cmd_opts & OPT_QUIET) == 0)
- log_setverbose(1); /* show log_debug() messages. */
+ if ((cmd_opts & OPT_VERBOSE) != 0)
+ log_setverbose(1); /* Show log_debug() messages. */
log_procinit(log_procname);
setproctitle("%s", log_procname);
-.\" $OpenBSD: dhclient.conf.5,v 1.39 2017/12/13 18:45:08 krw Exp $
+.\" $OpenBSD: dhclient.conf.5,v 1.40 2018/02/06 00:25:09 krw Exp $
.\"
.\" Copyright (c) 1997 The Internet Software Consortium.
.\" All rights reserved.
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
.\"
-.Dd $Mdocdate: December 13 2017 $
+.Dd $Mdocdate: February 6 2018 $
.Dt DHCLIENT.CONF 5
.Os
.Sh NAME
The default is 1 second.
.It Ic link-timeout Ar seconds ;
Sets the number of seconds
-to wait for interface link before going into the background as a daemon.
+to wait for a lease before going into the background as a daemon.
The default is 10 seconds.
.It Ic reboot Ar seconds ;
Sets the number of seconds to wait