]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Restore -G, --nogateway.
authorRoy Marples <roy@marples.name>
Tue, 9 May 2017 11:06:18 +0000 (12:06 +0100)
committerRoy Marples <roy@marples.name>
Tue, 9 May 2017 11:06:18 +0000 (12:06 +0100)
Because T116 is not fixed.
This reverts 0b27f5d7cf4c.

src/dhcpcd.8.in
src/dhcpcd.conf.5.in
src/if-options.c
src/if-options.h
src/route.c

index a989dd0bb69a1ec940ccb00e8f9813aedc2c95d8..17dbe5fe47357d040ff1a96d481f325c446bbe27 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 11, 2017
+.Dd May 9, 2017
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -610,6 +610,8 @@ So to stop
 .Nm
 from touching your DNS settings you would do:-
 .D1 dhcpcd -C resolv.conf eth0
+.It Fl G , Fl Fl nogateway
+Don't set any default routes.
 .It Fl H , Fl Fl xidhwaddr
 Use the last four bytes of the hardware address as the DHCP xid instead
 of a randomly generated number.
index 0013f73f92f5df98b2b59c99b478806ca6c834dc..d53cfa4e7a6dd78f3cc3413828d6d69a083995bd 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 24, 2017
+.Dd May 9, 2017
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -458,6 +458,10 @@ This is only useful when allowing IPv4LL.
 .It Ic nodhcp6
 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 2c6a7b878127cbe953c8e9bdcfad6fa220d1bf6d..0f5be07129a2d2786d19483107b35c93dfe803c3 100644 (file)
@@ -93,7 +93,7 @@
 #define O_IPV6                 O_BASE + 33
 #define O_CONTROLGRP           O_BASE + 34
 #define O_SLAAC                        O_BASE + 35
-// unused                      O_BASE + 36
+#define O_GATEWAY              O_BASE + 36
 #define O_NOUP                 O_BASE + 37
 #define O_IPV6RA_AUTOCONF      O_BASE + 38
 #define O_IPV6RA_NOAUTOCONF    O_BASE + 39
@@ -196,6 +196,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",         no_argument,       NULL, O_GATEWAY},
        {"reject",          required_argument, NULL, O_REJECT},
        {"bootp",           no_argument,       NULL, O_BOOTP},
        {"nodelay",         no_argument,       NULL, O_NODELAY},
@@ -978,6 +979,9 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        return -1;
                }
                break;
+       case 'G':
+               ifo->options &= ~DHCPCD_GATEWAY;
+               break;
        case 'H':
                ifo->options |= DHCPCD_XID_HWADDR;
                break;
@@ -2078,6 +2082,9 @@ err_sla:
                ctx->control_group = grp->gr_gid;
 #endif
                break;
+       case O_GATEWAY:
+               ifo->options |= DHCPCD_GATEWAY;
+               break;
        case O_NOUP:
                ifo->options &= ~DHCPCD_IF_UP;
                break;
@@ -2257,7 +2264,7 @@ read_config(struct dhcpcd_ctx *ctx,
        /* Seed our default options */
        if ((ifo = default_config(ctx)) == NULL)
                return NULL;
-       ifo->options |= DHCPCD_DAEMONISE;
+       ifo->options |= DHCPCD_DAEMONISE | DHCPCD_GATEWAY;
 #ifdef PLUGIN_DEV
        ifo->options |= DHCPCD_DEV;
 #endif
index c63fb8c68edcb451fe099693e84dfed458ec9fa9..a7a4538401bc2e775ae571529654fa5558b5088c 100644 (file)
@@ -43,7 +43,7 @@
 /* Don't set any optional arguments here so we retain POSIX
  * compatibility with getopt */
 #define IF_OPTS "146bc:de:f:gh:i:j:kl:m:no:pqr:s:t:u:v:wxy:z:" \
-               "ABC:DEF:HI:JKLMNO:PQ:S:TUVW:X:Z:"
+               "ABC:DEF:GHI:JKLMNO:PQ:S:TUVW:X:Z:"
 #define NOERR_IF_OPTS          ":" IF_OPTS
 
 #define DEFAULT_TIMEOUT                30
@@ -61,7 +61,7 @@
 #define DHCPCD_ARP                     (1ULL << 0)
 #define DHCPCD_RELEASE                 (1ULL << 1)
 // unused                              (1ULL << 2)
-// unused                              (1ULL << 3)
+#define DHCPCD_GATEWAY                 (1ULL << 3)
 #define DHCPCD_STATIC                  (1ULL << 4)
 #define DHCPCD_DEBUG                   (1ULL << 5)
 #define DHCPCD_LASTLEASE               (1ULL << 7)
index 4cd267137cbad1e044d6dabaad8565ca90ce2106..08ac7c058e5ec4e3e11f7633bff7da4199181fa7 100644 (file)
@@ -281,6 +281,21 @@ rt_add(struct rt *nrt, struct rt *ort)
        assert(nrt != NULL);
        ctx = nrt->rt_ifp->ctx;
 
+       /*
+        * Don't install a gateway if not asked to.
+        * This option is mainly for VPN users who want their VPN to be the
+        * default route.
+        * Because VPN's generally don't care about route management
+        * beyond their own, a longer term solution would be to remove this
+        * and get the VPN to inject the default route into dhcpcd somehow.
+        */
+       if (((nrt->rt_ifp->active &&
+           !(nrt->rt_ifp->options->options & DHCPCD_GATEWAY)) ||
+           (!nrt->rt_ifp->active && !(ctx->options & DHCPCD_GATEWAY))) &&
+           sa_is_unspecified(&nrt->rt_dest) &&
+           sa_is_unspecified(&nrt->rt_netmask))
+               return false;
+
        rt_desc(ort == NULL ? "adding" : "changing", nrt);
 
        change = false;