]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add gateway option to enable the gateway or an interface/profile.
authorRoy Marples <roy@marples.name>
Fri, 6 Jun 2014 19:19:29 +0000 (19:19 +0000)
committerRoy Marples <roy@marples.name>
Fri, 6 Jun 2014 19:19:29 +0000 (19:19 +0000)
Ensure the option and require options disable the nooption option - last wins.

dhcpcd.conf.5.in
if-options.c

index 7bed0bccf7beb245d9f3c7fe5dc051b94d903b96..d53e8285df8e81c1858d13490cba60cb05a1da3f 100644 (file)
@@ -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
index b388f40f838c7ee4c54f623d04dbea6f3325ff9a..8a2acffdbac5d4846170ae24e35ab784d92de81c 100644 (file)
@@ -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 ||