vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| This patch adds a 'no-link-on "interface" [, "interface", ...];' option to dhclient.conf. This is e.g. useful in order to skip wireless dhcp when there's a cable plugged into the ethernet card (on a notebook). $ cat /etc/dhclient.conf initial-interval 1; request subnet-mask, broadcast-address, routers, domain-name, domain-name-servers, host-name; interface "ath0" { no-link-on "rl0"; } interface "rl0" { link-timeout 0; } $ sudo dhclient ath0 Found link on rl0, skipping ath0 $ It's a quick hack; works for me, but should be tested. Index: clparse.c ================================================== ================= RCS file: /cvs/src/sbin/dhclient/clparse.c,v retrieving revision 1.34 diff -u -r1.34 clparse.c --- clparse.c 14 Feb 2007 23:19:26 -0000 1.34 +++ clparse.c 17 Jun 2007 15:33:23 -0000 @@ -198,6 +198,9 @@ sizeof(config->required_options)); parse_option_list(cfile, config->required_options); return; + case TOK_NO_LINK_ON: + parse_string_list(cfile, &config->no_link_on, 1); + return; case TOK_LINK_TIMEOUT: parse_lease_time(cfile, &config->link_timeout); return; @@ -740,7 +743,7 @@ do { token = next_token(&val, cfile); if (token != TOK_STRING) { - parse_warn("Expecting media options."); + parse_warn("Invalid options. Expecting strings."); skip_to_semi(cfile); return; } Index: conflex.c ================================================== ================= RCS file: /cvs/src/sbin/dhclient/conflex.c,v retrieving revision 1.13 diff -u -r1.13 conflex.c --- conflex.c 17 Dec 2006 17:41:56 -0000 1.13 +++ conflex.c 17 Jun 2007 15:33:23 -0000 @@ -330,6 +330,7 @@ { "link-timeout", TOK_LINK_TIMEOUT }, { "media", TOK_MEDIA }, { "medium", TOK_MEDIUM }, + { "no-link-on", TOK_NO_LINK_ON }, { "option", TOK_OPTION }, { "prepend", TOK_PREPEND }, { "rebind", TOK_REBIND }, Index: dhclient.c ================================================== ================= RCS file: /cvs/src/sbin/dhclient/dhclient.c,v retrieving revision 1.111 diff -u -r1.111 dhclient.c --- dhclient.c 25 Feb 2007 18:10:43 -0000 1.111 +++ dhclient.c 17 Jun 2007 15:33:24 -0000 @@ -242,6 +242,7 @@ int ch, fd, quiet = 0, i = 0, pipe_fd[2]; extern char *__progname; struct passwd *pw; + struct string_list *nlo; /* Initially, log errors to stderr as well as to syslogd. */ openlog(__progname, LOG_PID | LOG_NDELAY, DHCPD_LOG_FACILITY); @@ -304,6 +305,17 @@ inaddr_any.s_addr = INADDR_ANY; read_client_conf(); + + nlo = config->no_link_on; + if (nlo != NULL) { + do { + if (interface_link_status(nlo->string)) { + fprintf(stderr, "Found link on %s, skipping %s\n", + nlo->string, ifi->name); + exit(1); + } + } while ((nlo = nlo->next) != NULL); + } if (!interface_link_status(ifi->name)) { int linkstat = interface_link_forceup(ifi->name); Index: dhclient.conf.5 ================================================== ================= RCS file: /cvs/src/sbin/dhclient/dhclient.conf.5,v retrieving revision 1.12 diff -u -r1.12 dhclient.conf.5 --- dhclient.conf.5 18 Dec 2006 19:11:44 -0000 1.12 +++ dhclient.conf.5 17 Jun 2007 15:33:24 -0000 @@ -161,6 +161,14 @@ out. The default value is 10 seconds, but the special value 0 requests that dhclient not wait for a link state change before timing out. +.It Xo +.Ic no-link-on Ar \&"interface\&" +.Oo , Ar \&"interface\&" , ... Oc ; +.Xc +The +.Ic no-link-on +statement causes the client to only send requests if the listed interfaces do +not have an interface link. .El .Sh LEASE REQUIREMENTS AND REQUESTS The DHCP protocol allows the client to request that the server send it Index: dhcpd.h ================================================== ================= RCS file: /cvs/src/sbin/dhclient/dhcpd.h,v retrieving revision 1.65 diff -u -r1.65 dhcpd.h --- dhcpd.h 25 Feb 2007 16:27:20 -0000 1.65 +++ dhcpd.h 17 Jun 2007 15:33:24 -0000 @@ -146,6 +146,7 @@ time_t select_interval; time_t reboot_timeout; time_t backoff_cutoff; + struct string_list *no_link_on; struct string_list *media; char *script_name; enum { IGNORE, ACCEPT, PREFER } Index: dhctoken.h ================================================== ================= RCS file: /cvs/src/sbin/dhclient/dhctoken.h,v retrieving revision 1.5 diff -u -r1.5 dhctoken.h --- dhctoken.h 15 May 2006 08:10:57 -0000 1.5 +++ dhctoken.h 17 Jun 2007 15:33:24 -0000 @@ -79,6 +79,7 @@ #define TOK_REJECT 292 #define TOK_FDDI 293 #define TOK_LINK_TIMEOUT 294 +#define TOK_NO_LINK_ON 295 #define is_identifier(x) ((x) >= TOK_FIRST_TOKEN && \ (x) != TOK_STRING && \ -- The Moon is Waxing Crescent (13% of Full) |