changeset 2754:828f089d255c draft

Use RTF_PINNED if available. Allows us to delete in-use subnet routes on FreeBSD.
author Roy Marples <roy@marples.name>
date Tue, 07 Oct 2014 12:27:46 +0000
parents 236b1a9a546a
children b0b41984a62e
files README dhcpcd.c if-bsd.c
diffstat 3 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/README	Mon Oct 06 18:00:25 2014 +0000
+++ b/README	Tue Oct 07 12:27:46 2014 +0000
@@ -35,8 +35,9 @@
 Some BSD systems do not allow the manipulation of automatically added subnet
 routes. You can find discussion here:
     http://mail-index.netbsd.org/tech-net/2008/12/03/msg000896.html
-BSD systems where this has been fixed are:
+BSD systems where this has been fixed or is known to work are:
     NetBSD-5.0
+    FreeBSD-10.0
 
 Some BSD systems protect against IPv6 NS/NA messages by ensuring that the
 source address matches an address/prefix on the interface.
@@ -47,8 +48,6 @@
     Occured in NetBSD-5.0, fixed in NetBSD-6.99.29
     Occured in OpenBSD-4.2, fixed in OpenBSD-5.0
 
-On FreeBSD-10 dhcpcd cannot delete IPv4 subnet routes.
-
 We try and detect how dhcpcd should interact with system services at runtime.
 If we cannot auto-detect how do to this, or it is wrong then
 you can change this by passing shell commands to --serviceexists,
--- a/dhcpcd.c	Mon Oct 06 18:00:25 2014 +0000
+++ b/dhcpcd.c	Tue Oct 07 12:27:46 2014 +0000
@@ -1610,11 +1610,6 @@
 	}
 #endif
 
-#ifdef __FreeBSD__
-	syslog(LOG_WARNING, "FreeBSD errors that are worked around:");
-	syslog(LOG_WARNING, "IPv4 subnet routes cannot be deleted");
-#endif
-
 	/* When running dhcpcd against a single interface, we need to retain
 	 * the old behaviour of waiting for an IP address */
 	if (ctx.ifc == 1 && !(ctx.options & DHCPCD_BACKGROUND))
--- a/if-bsd.c	Mon Oct 06 18:00:25 2014 +0000
+++ b/if-bsd.c	Tue Oct 07 12:27:46 2014 +0000
@@ -491,6 +491,10 @@
 	} else
 		rtm.hdr.rtm_type = RTM_DELETE;
 	rtm.hdr.rtm_flags = RTF_UP;
+#ifdef RTM_PINNED
+	if (rtm.hdr.rtm_type != RTM_ADD)
+		rtm.hdr.rtm_flags |= RTF_PINNED;
+#endif
 #ifdef SIOCGIFPRIORITY
 	rtm.hdr.rtm_priority = rt->metric;
 #endif
@@ -668,6 +672,10 @@
 	else
 		rtm.hdr.rtm_type = RTM_DELETE;
 	rtm.hdr.rtm_flags = RTF_UP | (int)rt->flags;
+#ifdef RTM_PINNED
+	if (rtm.hdr.rtm_type != RTM_ADD)
+		rtm.hdr.rtm_flags |= RTF_PINNED;
+#endif
 	rtm.hdr.rtm_addrs = RTA_DST | RTA_NETMASK;
 #ifdef SIOCGIFPRIORITY
 	rtm.hdr.rtm_priority = rt->metric;