changeset 2962:bfa69b762904 draft

If RTF_CLONING is supported, create a cloning network route to the host instead of a host route. This avoids the kernel printing ARP diagnositic messages.
author Roy Marples <roy@marples.name>
date Fri, 27 Feb 2015 14:33:09 +0000
parents 1ce021acb514
children cc55b7be4b6a
files if-bsd.c
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/if-bsd.c	Fri Feb 27 14:21:01 2015 +0000
+++ b/if-bsd.c	Fri Feb 27 14:33:09 2015 +0000
@@ -605,8 +605,20 @@
 	}
 	if (rt->dest.s_addr == rt->gate.s_addr &&
 	    rt->net.s_addr == INADDR_BROADCAST)
+	{
+#ifdef RTF_CLONING
+		/* We add a cloning network route for a single host.
+		 * Traffic to the host will generate a cloned route and the
+		 * hardware address will resolve correctly.
+		 * It might be more correct to use RTF_HOST instead of
+		 * RTF_CLONING, and that does work, but some OS generate
+		 * an arp warning diagnostic which we don't want to do. */
+		rtm.hdr.rtm_flags |= RTF_CLONING;
+		rtm.hdr.rtm_addrs |= RTA_NETMASK;
+#else
 		rtm.hdr.rtm_flags |= RTF_HOST;
-	else if (rt->gate.s_addr == htonl(INADDR_LOOPBACK) &&
+#endif
+	} else if (rt->gate.s_addr == htonl(INADDR_LOOPBACK) &&
 	    rt->net.s_addr == INADDR_BROADCAST)
 	{
 		rtm.hdr.rtm_flags |= RTF_HOST | RTF_GATEWAY;
@@ -625,7 +637,11 @@
 
 	ADDADDR(&rt->dest);
 	if (rtm.hdr.rtm_addrs & RTA_GATEWAY) {
+#ifdef RTF_CLONING
+		if ((rtm.hdr.rtm_flags & (RTF_HOST | RTF_CLONING) &&
+#else
 		if ((rtm.hdr.rtm_flags & RTF_HOST &&
+#endif
 		    rt->gate.s_addr != htonl(INADDR_LOOPBACK)) ||
 		    !(rtm.hdr.rtm_flags & RTF_STATIC))
 		{