changeset 2531:7458be0ef8c9 draft

Add gateway option to enable the gateway or an interface/profile. Ensure the option and require options disable the nooption option - last wins.
author Roy Marples <roy@marples.name>
date Fri, 06 Jun 2014 19:19:29 +0000
parents 959391cdb761
children 764b6bb7a59b
files dhcpcd.conf.5.in if-options.c
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.conf.5.in	Fri Jun 06 17:31:55 2014 +0000
+++ b/dhcpcd.conf.5.in	Fri Jun 06 19:19:29 2014 +0000
@@ -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 @@
 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
--- a/if-options.c	Fri Jun 06 17:31:55 2014 +0000
+++ b/if-options.c	Fri Jun 06 19:19:29 2014 +0000
@@ -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 @@
 	{"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 @@
 	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 @@
 		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 @@
 		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 ||