From: Roy Marples Date: Mon, 3 Aug 2020 15:15:39 +0000 (+0100) Subject: Linux: IP6 forwaring only applies to "all" interface X-Git-Tag: v9.2.0~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=670f1d7519c50679bc4627b57b3250ad56b02898;p=thirdparty%2Fdhcpcd.git Linux: IP6 forwaring only applies to "all" interface Per interface forwarding is apparently only for setting things like IsRouter in NA messages. --- diff --git a/src/ipv6.c b/src/ipv6.c index c42b3d6d..5a8b08be 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -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) diff --git a/src/ipv6nd.c b/src/ipv6nd.c index 009792dc..d1cc4efa 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -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;