vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Wed, Mar 08, 2006 at 08:57:13PM +0000, Thordur I. Bjornsson wrote: > It always botherd me too not be able too set a timeout for dhclient > link wait (while booting without a link), [...] looking at it again, I think, I would leave out the extra check here: > --- dhclient.c 2006/03/06 10:45:56 1.82 > +++ dhclient.c 2006/03/08 20:49:53 > @@ -307,15 +307,20 @@ main(int argc, char *argv[]) > inaddr_any.s_addr = INADDR_ANY; > > read_client_conf(); > - > + > if (!interface_link_status(ifi->name)) { > + if(ifi->client->config->link_timeout == (time_t)0) { > + fprintf(stderr, "%s: no link\n", ifi->name); > + fflush(stderr); > + exit(1); > + } it adds a few lines for almost no gain. I'd put it this way (way smaller change, and yes in the case of 'link-timeout 0' one would now wait a second for it to timeout, but the code stays way easier and does not add redundant fprintf statments, personal preference I guess), furthermore the variables in the struct are correctly ordered. Index: sbin/dhclient/clparse.c ================================================== ================= RCS file: /data/OpenBSD/src/openbsd/src/sbin/dhclient/clparse.c,v retrieving revision 1.26 diff -u -r1.26 clparse.c --- sbin/dhclient/clparse.c 2 Aug 2005 02:34:03 -0000 1.26 +++ sbin/dhclient/clparse.c 17 Apr 2006 18:08:50 -0000 @@ -64,6 +64,7 @@ new_parse(path_dhclient_conf); /* Set some defaults... */ + config->link_timeout = 10; config->timeout = 60; config->select_interval = 0; config->reboot_timeout = 10; @@ -144,6 +145,7 @@ * hardware-declaration | * REQUEST option-list | * REQUIRE option-list | + * LINK_TIMEOUT number | * TIMEOUT number | * RETRY number | * REBOOT number | @@ -198,6 +200,9 @@ memset(config->required_options, 0, sizeof(config->required_options)); parse_option_list(cfile, config->required_options); + return; + case LINK_TIMEOUT: + parse_lease_time(cfile, &config->link_timeout); return; case TIMEOUT: parse_lease_time(cfile, &config->timeout); Index: sbin/dhclient/conflex.c ================================================== ================= RCS file: /data/OpenBSD/src/openbsd/src/sbin/dhclient/conflex.c,v retrieving revision 1.10 diff -u -r1.10 conflex.c --- sbin/dhclient/conflex.c 2 Aug 2005 18:26:49 -0000 1.10 +++ sbin/dhclient/conflex.c 17 Apr 2006 18:08:50 -0000 @@ -412,6 +412,8 @@ case 'l': if (!strcasecmp(atom + 1, "ease")) return (LEASE); + if (!strcasecmp(atom +1, "ink-timeout")) + return (LINK_TIMEOUT); break; case 'm': if (!strcasecmp(atom + 1, "ax-lease-time")) Index: sbin/dhclient/dhclient.c ================================================== ================= RCS file: /data/OpenBSD/src/openbsd/src/sbin/dhclient/dhclient.c,v retrieving revision 1.82 diff -u -r1.82 dhclient.c --- sbin/dhclient/dhclient.c 6 Mar 2006 10:45:56 -0000 1.82 +++ sbin/dhclient/dhclient.c 17 Apr 2006 18:08:52 -0000 @@ -315,7 +315,7 @@ while (!interface_link_status(ifi->name)) { fprintf(stderr, "."); fflush(stderr); - if (++i > 10) { + if (++i > ifi->client->config->link_timeout) { fprintf(stderr, " giving up\n"); exit(1); } Index: sbin/dhclient/dhclient.conf.5 ================================================== ================= RCS file: /data/OpenBSD/src/openbsd/src/sbin/dhclient/dhclient.conf.5,v retrieving revision 1.6 diff -u -r1.6 dhclient.conf.5 --- sbin/dhclient/dhclient.conf.5 30 Sep 2005 20:34:23 -0000 1.6 +++ sbin/dhclient/dhclient.conf.5 17 Apr 2006 18:08:54 -0000 @@ -154,6 +154,12 @@ If it is greater than the backoff-cutoff amount, it is set to that amount. It defaults to ten seconds. +.It Ic link-timeout Ar time ; +The +.Ic link-timeout +statement sets the amount of time too wait for an interface link before timing +out. Theres a default value of 10 and the special value 0 says that dhclient +should not wait for a link state change before timing out. .El .Sh LEASE REQUIREMENTS AND REQUESTS The DHCP protocol allows the client to request that the server send it Index: sbin/dhclient/dhcpd.h ================================================== ================= RCS file: /data/OpenBSD/src/openbsd/src/sbin/dhclient/dhcpd.h,v retrieving revision 1.47 diff -u -r1.47 dhcpd.h --- sbin/dhclient/dhcpd.h 5 Aug 2005 16:23:30 -0000 1.47 +++ sbin/dhclient/dhcpd.h 17 Apr 2006 18:08:54 -0000 @@ -156,6 +156,7 @@ int requested_option_count; time_t timeout; time_t initial_interval; + time_t link_timeout; time_t retry_interval; time_t select_interval; time_t reboot_timeout; Index: sbin/dhclient/dhctoken.h ================================================== ================= RCS file: /data/OpenBSD/src/openbsd/src/sbin/dhclient/dhctoken.h,v retrieving revision 1.2 diff -u -r1.2 dhctoken.h --- sbin/dhclient/dhctoken.h 4 Feb 2004 12:16:56 -0000 1.2 +++ sbin/dhclient/dhctoken.h 17 Apr 2006 18:08:54 -0000 @@ -129,6 +129,7 @@ #define AUTHORITATIVE 333 #define TOKEN_NOT 334 #define ALWAYS_REPLY_RFC1048 335 +#define LINK_TIMEOUT 336 #define is_identifier(x) ((x) >= FIRST_TOKEN && \ (x) != STRING && \ |