From: Roy Marples Date: Tue, 7 Oct 2014 12:27:46 +0000 (+0000) Subject: Use RTF_PINNED if available. X-Git-Tag: v6.5.1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb30935e5be3cac6350e7e5cb05465513813486f;p=thirdparty%2Fdhcpcd.git Use RTF_PINNED if available. Allows us to delete in-use subnet routes on FreeBSD. --- diff --git a/README b/README index 2a2d4542..92e36f24 100644 --- 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, diff --git a/dhcpcd.c b/dhcpcd.c index 4b86c045..3740ce1e 100644 --- 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)) diff --git a/if-bsd.c b/if-bsd.c index 3c6ce062..cc4c3f2b 100644 --- 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;