]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Linux: IP6 forwaring only applies to "all" interface
authorRoy Marples <roy@marples.name>
Mon, 3 Aug 2020 15:15:39 +0000 (16:15 +0100)
committerRoy Marples <roy@marples.name>
Mon, 3 Aug 2020 15:15:39 +0000 (16:15 +0100)
Per interface forwarding is apparently only for setting things
like IsRouter in NA messages.

src/ipv6.c
src/ipv6nd.c

index c42b3d6df8866819cc3875a025a1149af6005ab7..5a8b08be876a1316c735e04c4f97288223ff99e0 100644 (file)
@@ -1092,33 +1092,22 @@ ipv6_anyglobal(struct interface *sifp)
        struct interface *ifp;
        struct ipv6_state *state;
        struct ipv6_addr *ia;
-#ifdef BSD
        bool forwarding;
 
-#if defined(PRIVSEP) && defined(HAVE_PLEDGE)
+       /* BSD forwarding is either on or off.
+        * Linux forwarding is technically the same as it's
+        * configured by the "all" interface.
+        * Per interface only affects IsRouter of NA messages. */
+#if defined(PRIVSEP) && (defined(HAVE_PLEDGE) || defined(__linux__))
        if (IN_PRIVSEP(sifp->ctx))
-               forwarding = ps_root_ip6forwarding(sifp->ctx, NULL) == 1;
+               forwarding = ps_root_ip6forwarding(sifp->ctx, "all") != 0;
        else
 #endif
-               forwarding = ip6_forwarding(NULL) == 1;
-#endif
-
+               forwarding = ip6_forwarding("all") != 0;
 
        TAILQ_FOREACH(ifp, sifp->ctx->ifaces, next) {
-#ifdef BSD
                if (ifp != sifp && !forwarding)
                        continue;
-#else
-#if defined(PRIVSEP) && defined(__linux__)
-       if (IN_PRIVSEP(sifp->ctx)) {
-               if (ifp != sifp &&
-                   ps_root_ip6forwarding(sifp->ctx, ifp->name) != 1)
-                       continue;
-       } else
-#endif
-               if (ifp != sifp && ip6_forwarding(ifp->name) != 1)
-                       continue;
-#endif
 
                state = IPV6_STATE(ifp);
                if (state == NULL)
index 009792dce3a4ea99719cd3a8187d58dca9256cc7..d1cc4efab7732e17500f4823352b45fdabaa8019 100644 (file)
@@ -544,11 +544,11 @@ ipv6nd_advertise(struct ipv6_addr *ia)
        na->nd_na_flags_reserved = ND_NA_FLAG_OVERRIDE;
 #if defined(PRIVSEP) && (defined(__linux__) || defined(HAVE_PLEDGE))
        if (IN_PRIVSEP(ctx)) {
-               if (ps_root_ip6forwarding(ctx, ifp->name) == 1)
+               if (ps_root_ip6forwarding(ctx, ifp->name) != 0)
                        na->nd_na_flags_reserved |= ND_NA_FLAG_ROUTER;
        } else
 #endif
-       if (ip6_forwarding(ifp->name) == 1)
+       if (ip6_forwarding(ifp->name) != 0)
                na->nd_na_flags_reserved |= ND_NA_FLAG_ROUTER;
        na->nd_na_target = ia->addr;