From: Roy Marples Date: Tue, 18 Nov 2014 10:55:44 +0000 (+0000) Subject: Loopback interfaces have routes scoped to the host only. X-Git-Tag: v6.6.3~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcf142a37165a42c5a822fe6b3022183c6db69bc;p=thirdparty%2Fdhcpcd.git Loopback interfaces have routes scoped to the host only. --- diff --git a/if-linux.c b/if-linux.c index 80f632f6..e65e91f7 100644 --- a/if-linux.c +++ b/if-linux.c @@ -1281,7 +1281,9 @@ if_route(const struct rt *rt, int action) nlm.rt.rtm_protocol = RTPROT_KERNEL; else nlm.rt.rtm_protocol = RTPROT_BOOT; - if (rt->gate.s_addr == INADDR_ANY || + if (rt->iface->flags & IFF_LOOPBACK) + nlm.rt.rtm_scope = RT_SCOPE_HOST; + else if (rt->gate.s_addr == INADDR_ANY || (rt->gate.s_addr == rt->dest.s_addr && rt->net.s_addr == INADDR_BROADCAST)) nlm.rt.rtm_scope = RT_SCOPE_LINK; @@ -1409,7 +1411,9 @@ if_route6(const struct rt6 *rt, int action) else { nlm.hdr.nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL; /* None interface subnet routes are static. */ - if (IN6_IS_ADDR_UNSPECIFIED(&rt->gate)) { + if (rt->iface->flags & IFF_LOOPBACK) + nlm.rt.rtm_scope = RT_SCOPE_HOST; + else if (IN6_IS_ADDR_UNSPECIFIED(&rt->gate)) { nlm.rt.rtm_protocol = RTPROT_KERNEL; nlm.rt.rtm_scope = RT_SCOPE_LINK; } else