summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/defaults/rc.conf1
-rwxr-xr-xetc/rc.d/dhclient13
-rw-r--r--sbin/dhclient/dhclient.87
-rw-r--r--sbin/dhclient/dhclient.c18
-rw-r--r--share/man/man5/rc.conf.512
5 files changed, 45 insertions, 6 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index ee14139..3f4e150 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -94,6 +94,7 @@ hostname="" # Set this!
nisdomainname="NO" # Set to NIS domain if using NIS (or NO).
dhclient_program="/sbin/dhclient" # Path to dhcp client program.
dhclient_flags="" # Additional flags to pass to dhcp client.
+dhclient_flags_fxp0="" # Additional dhclient flags for fxp0 only
background_dhclient="NO" # Start dhcp client in the background.
synchronous_dhclient="YES" # Start dhclient directly on configured
# interfaces during startup.
diff --git a/etc/rc.d/dhclient b/etc/rc.d/dhclient
index 4d6d733..8dae28e 100755
--- a/etc/rc.d/dhclient
+++ b/etc/rc.d/dhclient
@@ -27,7 +27,18 @@ dhclient_start()
fi
fi
- if checkyesno background_dhclient; then
+ # Override for $ifn specific flags (see rc.subr for $flags setting)
+ eval specific=\$dhclient_flags_$ifn
+ if [ -z "$flags" -a -n "$specific" ]; then
+ rc_flags=$specific
+ fi
+
+ eval specific=\$background_dhclient_$ifn
+ if [ -n "$specific ]; then
+ if checkyesno background_dhclient_$ifn; then
+ rc_flags="${rc_flags} -b"
+ fi
+ elif checkyesno background_dhclient; then
rc_flags="${rc_flags} -b"
fi
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)
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 55b5b00..524d64d 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -356,6 +356,12 @@ For the
DHCP client, see the
.Xr dhclient 8
manpage for a description of the command line options available.
+.It Va dhclient_flags_ Ns Va iface
+Additional flags to pass to the DHCP client program running on
+.Va iface
+only.
+When specified, this variable overrides
+.Va dhclient_flags .
.It Va background_dhclient
.Pq Vt bool
Set to
@@ -364,6 +370,12 @@ to start the DHCP client in background.
This can cause trouble with applications depending on
a working network, but it will provide a faster startup
in many cases.
+.It Va background_dhclient_ Ns Va iface
+When specified, this variable overrides the
+.Va background_dhclient
+variable for interface
+.Va iface
+only.
.It Va synchronous_dhclient
.Pq Bt bool
Set to
OpenPOWER on IntegriCloud