From: Roy Marples Date: Fri, 6 Jun 2014 19:19:29 +0000 (+0000) Subject: Add gateway option to enable the gateway or an interface/profile. X-Git-Tag: v6.4.0~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee56a47d7b9fe69bbe8826f30248e0ef7ca79a6e;p=thirdparty%2Fdhcpcd.git Add gateway option to enable the gateway or an interface/profile. Ensure the option and require options disable the nooption option - last wins. --- diff --git a/dhcpcd.conf.5.in b/dhcpcd.conf.5.in index 7bed0bcc..d53e8285 100644 --- a/dhcpcd.conf.5.in +++ b/dhcpcd.conf.5.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 2, 2014 +.Dd June 6, 2014 .Dt DHCPCD.CONF 5 .Os .Sh NAME @@ -360,6 +360,8 @@ Don't start DHCPv6 or listen to DHCPv6 messages. Normally DHCPv6 is started by a RA instruction or configuration. .It Ic nogateway Don't install any default routes. +.It Ic gateway +Install a default route if available (default). .It Ic nohook Ar script Don't run this hook script. Matches full name, or prefixed with 2 numbers optionally ending with diff --git a/if-options.c b/if-options.c index b388f40f..8a2acffd 100644 --- a/if-options.c +++ b/if-options.c @@ -92,6 +92,7 @@ #define O_IPV6 O_BASE + 33 #define O_CONTROLGRP O_BASE + 34 #define O_SLAAC O_BASE + 35 +#define O_GATEWAY O_BASE + 36 const struct option cf_options[] = { {"background", no_argument, NULL, 'b'}, @@ -177,6 +178,7 @@ const struct option cf_options[] = { {"nodhcp6", no_argument, NULL, O_NODHCP6}, {"controlgroup", required_argument, NULL, O_CONTROLGRP}, {"slaac", required_argument, NULL, O_SLAAC}, + {"gateway", required_argument, NULL, O_GATEWAY}, {NULL, 0, NULL, '\0'} }; @@ -733,7 +735,9 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, case 'o': arg = set_option_space(ctx, arg, &d, &dl, ifo, &request, &require, &no); - if (make_option_mask(d, dl, request, arg, 1) != 0) { + if (make_option_mask(d, dl, request, arg, 1) != 0 || + make_option_mask(d, dl, no, arg, -1) != 0) + { syslog(LOG_ERR, "unknown option `%s'", arg); return -1; } @@ -962,7 +966,8 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, arg = set_option_space(ctx, arg, &d, &dl, ifo, &request, &require, &no); if (make_option_mask(d, dl, require, arg, 1) != 0 || - make_option_mask(d, dl, request, arg, 1) != 0) + make_option_mask(d, dl, request, arg, 1) != 0 || + make_option_mask(d, dl, no, arg, -1) != 0) { syslog(LOG_ERR, "unknown option `%s'", arg); return -1; @@ -1837,6 +1842,9 @@ err_sla: ctx->control_group = grp->gr_gid; #endif break; + case O_GATEWAY: + ifo->options |= DHCPCD_GATEWAY; + break; case O_SLAAC: if (strcmp(arg, "private") == 0 || strcmp(arg, "stableprivate") == 0 ||