summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-04-13 18:04:10 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-04-13 18:04:10 +0000
commit71ca3a86dc0feb2c7f267a36a07a9002d16eb49a (patch)
tree2bfb9c2be51e6982a54185fec0460987bb757ba0 /sbin/dhclient/dhclient.c
parent82ffd6945096d369c4436c9987f335fa145d3f2d (diff)
unfortunately we have to wait a little if the nic does not have a link and
check again, theo help & ok
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r--sbin/dhclient/dhclient.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 5779e0affd9..a23b0caefda 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.35 2004/04/08 15:36:38 henning Exp $ */
+/* $OpenBSD: dhclient.c,v 1.36 2004/04/13 18:04:09 henning Exp $ */
/* DHCP Client. */
@@ -207,7 +207,7 @@ int
main(int argc, char *argv[])
{
extern char *__progname;
- int ch, fd, quiet = 0;
+ int ch, fd, quiet = 0, i = 0;
/* Initially, log errors to stderr as well as to syslogd. */
openlog(__progname, LOG_NDELAY, DHCPD_LOG_FACILITY);
@@ -268,13 +268,26 @@ main(int argc, char *argv[])
rewrite_client_leases();
close(fd);
- if (interface_link_status(ifi->name)) {
- script_init(ifi, "PREINIT", NULL);
- if (ifi->client->alias)
- script_write_params(ifi, "alias_", ifi->client->alias);
- script_go(ifi);
- } else
- error("no link on interface %s", ifi->name);
+ if (!interface_link_status(ifi->name)) {
+ fprintf(stderr, "%s: no link ", ifi->name);
+ fflush(stderr);
+ sleep(1);
+ while (!interface_link_status(ifi->name)) {
+ fprintf(stderr, ".");
+ fflush(stderr);
+ if (++i > 10) {
+ fprintf(stderr, " giving up\n");
+ exit(1);
+ }
+ sleep(1);
+ }
+ fprintf(stderr, "got link\n");
+ }
+
+ script_init(ifi, "PREINIT", NULL);
+ if (ifi->client->alias)
+ script_write_params(ifi, "alias_", ifi->client->alias);
+ script_go(ifi);
if ((routefd = socket(PF_ROUTE, SOCK_RAW, 0)) != -1)
add_protocol("AF_ROUTE", routefd, routehandler, ifi);