From: Roy Marples Date: Fri, 7 Mar 2014 10:22:37 +0000 (+0000) Subject: Add -M, --master to force dhcpcd into master mode. X-Git-Tag: v6.3.2~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b317418153ec0ff70f76ff75d306735905b0f20e;p=thirdparty%2Fdhcpcd.git Add -M, --master to force dhcpcd into master mode. --- diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 0f448077..6033ea9e 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 3, 2014 +.Dd March 7, 2014 .Dt DHCPCD 8 .Os .Sh NAME @@ -30,7 +30,7 @@ .Nd a DHCP client .Sh SYNOPSIS .Nm -.Op Fl 46ABbDdEGgHJKLpqTV +.Op Fl 46ABbDdEGgHJKLMpqTV .Op Fl C , Fl Fl nohook Ar hook .Op Fl c , Fl Fl script Ar script .Op Fl e , Fl Fl env Ar value @@ -326,6 +326,10 @@ By default .Nm does not request any lease time and leaves it in the hands of the DHCP server. +.It Fl M , Fl Fl master +Start +.Nm +in master mode even if only one interface specified on the command line. .It Fl m , Fl Fl metric Ar metric Metrics are used to prefer an interface over another one, lowest wins. .Nm diff --git a/dhcpcd.c b/dhcpcd.c index f4aa4ada..bbdeba9a 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1248,7 +1248,7 @@ main(int argc, char **argv) if (!(ctx.options & (DHCPCD_TEST | DHCPCD_DUMPLEASE))) { /* If we have any other args, we should run as a single dhcpcd * instance for that interface. */ - if (optind == argc - 1) { + if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) { if (strlen(argv[optind]) > IF_NAMESIZE) { syslog(LOG_ERR, "%s: interface name too long", argv[optind]); diff --git a/if-options.c b/if-options.c index 3c3acce7..ca311702 100644 --- a/if-options.c +++ b/if-options.c @@ -124,6 +124,7 @@ const struct option cf_options[] = { {"broadcast", no_argument, NULL, 'J'}, {"nolink", no_argument, NULL, 'K'}, {"noipv4ll", no_argument, NULL, 'L'}, + {"master", no_argument, NULL, 'M'}, {"nooption", optional_argument, NULL, 'O'}, {"require", required_argument, NULL, 'Q'}, {"static", required_argument, NULL, 'S'}, @@ -926,6 +927,9 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, case 'L': ifo->options &= ~DHCPCD_IPV4LL; break; + case 'M': + ifo->options |= DHCPCD_MASTER; + break; case 'O': arg = set_option_space(ctx, arg, &d, &dl, ifo, &request, &require, &no); diff --git a/if-options.h b/if-options.h index bba7f9d3..a7cfa5e6 100644 --- a/if-options.h +++ b/if-options.h @@ -40,7 +40,7 @@ /* Don't set any optional arguments here so we retain POSIX * compatibility with getopt */ -#define IF_OPTS "46bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLO:Q:S:TUVW:X:Z:" +#define IF_OPTS "46bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLMO:Q:S:TUVW:X:Z:" #define DEFAULT_TIMEOUT 30 #define DEFAULT_REBOOT 5