]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use RTF_PINNED if available.
authorRoy Marples <roy@marples.name>
Tue, 7 Oct 2014 12:27:46 +0000 (12:27 +0000)
committerRoy Marples <roy@marples.name>
Tue, 7 Oct 2014 12:27:46 +0000 (12:27 +0000)
Allows us to delete in-use subnet routes on FreeBSD.

README
dhcpcd.c
if-bsd.c

diff --git a/README b/README
index 2a2d4542390bace2bf2bcd3f49713d89b71cfb77..92e36f24efd5ec8f02d8b59f8949c5c33492c59a 100644 (file)
--- a/README
+++ b/README
@@ -35,8 +35,9 @@ set CSTD=gnu99 to work around this.
 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 @@ BSD systems where this is known to be a problem
     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,
index 4b86c045fdb39e8b63fb531991574fdcd6d4f870..3740ce1e9a2210a3d868b8bf31f571bb83583c16 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1610,11 +1610,6 @@ main(int argc, char **argv)
        }
 #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))
index 3c6ce062989867ed744c3776f8305d6ccffcdc57..cc4c3f2b1ee0c88b7b0915441c03b8855d0cee2b 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -491,6 +491,10 @@ if_route(const struct rt *rt, int action)
        } 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 @@ if_route6(const struct rt6 *rt, int action)
        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;