tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: IPv6 "is unreachable" route flapping



On 22/08/2019 18:58, Roy Marples wrote:
On 22/08/2019 14:31, Roy Marples wrote:
On 22/08/2019 13:46, Paul Ripke wrote:
Does this attached patch help any?

This is for the client (dhcpcd running) side? And/or the server (rtadvd) side? I'll test it on a few machines and see what I see (I need to figure out a nice
way of upgrading the Pi).

It's for the client.

OK, while that patch is of use, it doesn't really solve the problem and it's probably of limited use, but it does restore prior behaviour.

There are two problems in play - firstly I broke dhcpcd, patch attached to solve that.

Wups, old dhcpcd patch!
New one attached here :)

Roy
diff --git a/src/if-bsd.c b/src/if-bsd.c
index 6d5531cb..91f540bd 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -674,9 +674,15 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, const struct rt_msghdr *rtm)
 		if (rt->rt_netmask.sa_family == 255) /* Why? */
 			rt->rt_netmask.sa_family = rt->rt_dest.sa_family;
 	}
-	/* dhcpcd likes an unspecified gateway to indicate via the link. */
-	if (rt->rt_flags & RTF_GATEWAY &&
-	    rti_info[RTAX_GATEWAY]->sa_family != AF_LINK)
+	/* dhcpcd likes an unspecified gateway to indicate via the link.
+	 * However we need to know if gateway was a link with an address. */
+	if (rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) {
+		const struct sockaddr_dl *sdl;
+
+		sdl = (const struct sockaddr_dl*)rti_info[RTAX_GATEWAY];
+		if (sdl->sdl_alen != 0)
+			rt->rt_dflags |= RTDF_GATELINK;
+	} else if (rtm->rtm_flags & RTF_GATEWAY)
 		if_copysa(&rt->rt_gateway, rti_info[RTAX_GATEWAY]);
 	if (rtm->rtm_addrs & RTA_IFA)
 		if_copysa(&rt->rt_ifa, rti_info[RTAX_IFA]);
@@ -1079,17 +1085,9 @@ if_rtm(struct dhcpcd_ctx *ctx, const struct rt_msghdr *rtm)
 	 * existance with a hardware address.
 	 */
 	if (rt.rt_dest.sa_family == AF_INET6 && rt.rt_flags & RTF_HOST) {
-		struct sockaddr_in6 dest;
-		struct sockaddr_dl sdl;
-
-		memcpy(&dest, &rt.rt_dest, rt.rt_dest.sa_len);
-		if (rt.rt_gateway.sa_family == AF_LINK)
-			memcpy(&sdl, &rt.rt_gateway, rt.rt_gateway.sa_len);
-		else
-			sdl.sdl_alen = 0;
-		ipv6nd_neighbour(ctx, &dest.sin6_addr,
-		    rtm->rtm_type != RTM_DELETE && sdl.sdl_alen ?
-		    IPV6ND_REACHABLE : 0);
+		ipv6nd_neighbour(ctx, &rt.rt_ss_dest.sin6.sin6_addr,
+		    rtm->rtm_type != RTM_DELETE && rt.rt_dflags & RTDF_GATELINK
+		    ? IPV6ND_REACHABLE : 0);
 	}
 #endif
 
diff --git a/src/route.h b/src/route.h
index d1613943..74570fa7 100644
--- a/src/route.h
+++ b/src/route.h
@@ -92,6 +92,7 @@ struct rt {
 #define	RTDF_RA			0x08		/* Router Advertisement */
 #define	RTDF_DHCP		0x10		/* DHCP route */
 #define	RTDF_STATIC		0x20		/* Configured in dhcpcd */
+#define	RTDF_GATELINK		0x40		/* Gateway is on link */
 	size_t			rt_order;
 	rb_node_t		rt_tree;
 };


Home | Main Index | Thread Index | Old Index