changeset 2972:7738b7a39516 draft

Stop pretending that OpenBSD route priority is like Linux route metric.
author Roy Marples <roy@marples.name>
date Mon, 02 Mar 2015 09:39:34 +0000
parents c106f733c6ea
children 61bb23f4fe72
files if-bsd.c if.h
diffstat 2 files changed, 9 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/if-bsd.c	Sat Feb 28 19:22:58 2015 +0000
+++ b/if-bsd.c	Mon Mar 02 09:39:34 2015 +0000
@@ -514,9 +514,6 @@
 	else
 		rt->net.s_addr = INADDR_BROADCAST;
 	COPYOUT(rt->gate, rti_info[RTAX_GATEWAY]);
-#ifdef SIOCGIFPRIORITY
-	rt->metric = rtm->rtm_priority;
-#endif
 
 	if (rtm->rtm_index)
 		rt->iface = if_findindex(ctx, rtm->rtm_index);
@@ -591,9 +588,6 @@
 	if (cmd != RTM_ADD)
 		rtm.hdr.rtm_flags |= RTF_PINNED;
 #endif
-#ifdef SIOCGIFPRIORITY
-	rtm.hdr.rtm_priority = rt->metric;
-#endif
 
 	if (cmd != RTM_DELETE) {
 		rtm.hdr.rtm_addrs |= RTA_IFA | RTA_IFP;
@@ -602,6 +596,11 @@
 		    rt->net.s_addr != state->net.s_addr ||
 		    rt->dest.s_addr != (state->addr.s_addr & state->net.s_addr))
 			rtm.hdr.rtm_flags |= RTF_STATIC;
+		else {
+#ifdef RTF_CLONING
+			rtm.hdr.rtm_flags |= RTF_CLONING;
+#endif
+		}
 	}
 	if (rt->dest.s_addr == rt->gate.s_addr &&
 	    rt->net.s_addr == INADDR_BROADCAST)
@@ -879,9 +878,6 @@
 	} else
 		ipv6_mask(&rt->net, 128);
 	COPYOUT6(rt->gate, rti_info[RTAX_GATEWAY]);
-#ifdef SIOCGIFPRIORITY
-	rt->metric = rtm->rtm_priority;
-#endif
 
 	if (rtm->rtm_index)
 		rt->iface = if_findindex(ctx, rtm->rtm_index);
@@ -952,15 +948,12 @@
 		rtm.hdr.rtm_flags |= RTF_PINNED;
 #endif
 	rtm.hdr.rtm_addrs = RTA_DST | RTA_NETMASK;
-#ifdef SIOCGIFPRIORITY
-	rtm.hdr.rtm_priority = rt->metric;
-#endif
 	/* None interface subnet routes are static. */
 	if (IN6_IS_ADDR_UNSPECIFIED(&rt->gate)) {
 #ifdef RTF_CLONING
 		rtm.hdr.rtm_flags |= RTF_CLONING;
 #endif
-	 } else
+	} else
 		rtm.hdr.rtm_flags |= RTF_GATEWAY | RTF_STATIC;
 
 	if (cmd == RTM_ADD)
--- a/if.h	Sat Feb 28 19:22:58 2015 +0000
+++ b/if.h	Mon Mar 02 09:39:34 2015 +0000
@@ -28,15 +28,14 @@
 #ifndef INTERFACE_H
 #define INTERFACE_H
 
-#include <sys/ioctl.h>		/* for SIOCGIFPRIORITY */
-
 #include <net/if.h>
 #include <net/route.h>		/* for RTM_ADD et all */
 #include <netinet/in.h>
 
-/* Some systems have route metrics */
+/* Some systems have route metrics.
+ * OpenBSD route priority is not this. */
 #ifndef HAVE_ROUTE_METRIC
-# if defined(__linux__) || defined(SIOCGIFPRIORITY)
+# if defined(__linux__)
 #  define HAVE_ROUTE_METRIC 1
 # endif
 #endif