diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-05-26 03:11:50 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-05-26 03:11:50 +0000 |
commit | 8d813c432df9889a3cf670142ee04a360cbb1164 (patch) | |
tree | d782fadcfc72288878e1e5110ece773618e43646 /sbin/dhclient/dhclient.c | |
parent | 4891b3ab6d24848f99aad7876e6f6e868587f511 (diff) |
If an interface has no link at startup, try to force it up, and then
give it about 4 seconds of (silent) grace period before doing the verbose
search for a link...
tested by various developers who got burned a bit
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r-- | sbin/dhclient/dhclient.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 15dfcf1b1e5..dbeea0631aa 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.118 2008/05/09 05:19:14 reyk Exp $ */ +/* $OpenBSD: dhclient.c,v 1.119 2008/05/26 03:11:48 deraadt Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -319,25 +319,27 @@ main(int argc, char *argv[]) read_client_conf(); - if (!(ifi->linkstat = interface_link_status(ifi->name))) { - fprintf(stderr, "%s: no link ...", ifi->name); - if (config->link_timeout == 0) { + if (interface_status(ifi->name) == 0) { + interface_link_forceup(ifi->name); + /* Give it up to 4 seconds of silent grace to find link */ + i = -4; + } else + i = 0; + + while (!(ifi->linkstat = interface_link_status(ifi->name))) { + if (i == 0) + fprintf(stderr, "%s: no link ...", ifi->name); + else if (i > 0) + fprintf(stderr, "."); + fflush(stderr); + if (++i > config->link_timeout) { fprintf(stderr, " sleeping\n"); goto dispatch; } - fflush(stderr); sleep(1); - while (!(ifi->linkstat = interface_link_status(ifi->name))) { - fprintf(stderr, "."); - fflush(stderr); - if (++i > config->link_timeout) { - fprintf(stderr, " sleeping\n"); - goto dispatch; - } - sleep(1); - } - fprintf(stderr, " got link\n"); } + if (i >= 0) + fprintf(stderr, " got link\n"); dispatch: if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) |