-/* $OpenBSD: route.c,v 1.171 2014/06/16 19:47:21 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.172 2014/07/12 14:26:00 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
if (ifa->ifa_rtrequest)
ifa->ifa_rtrequest(RTM_ADD, rt);
}
- rt_newaddrmsg(RTM_ADD, ifa, error, nrt);
+ if (flags & RTF_LOCAL)
+ rt_newaddrmsg(RTM_ADD, ifa, error, nrt);
}
return (error);
}
error = rtrequest1(RTM_DELETE, &info, prio, &nrt, rtableid);
if (error == 0 && (rt = nrt) != NULL) {
- rt_newaddrmsg(RTM_DELETE, ifa, error, nrt);
+ if (flags & RTF_LOCAL)
+ rt_newaddrmsg(RTM_DELETE, ifa, error, nrt);
if (rt->rt_refcnt <= 0) {
rt->rt_refcnt++;
rtfree(rt);
{
struct rtentry *rt;
+ /*
+ * If the configured address correspond to the magical "any"
+ * address do not add a local route entry because that might
+ * corrupt the routing tree which uses this value for the
+ * default routes.
+ */
+ switch (ifa->ifa_addr->sa_family) {
+ case AF_INET:
+ if (satosin(ifa->ifa_addr)->sin_addr.s_addr == INADDR_ANY)
+ return;
+ break;
+ case AF_INET6:
+ if (IN6_ARE_ADDR_EQUAL(&satosin6(ifa->ifa_addr)->sin6_addr,
+ &in6addr_any))
+ return;
+ break;
+ default:
+ break;
+ }
+
/* If there is no loopback entry, allocate one. */
rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain);
if (rt == NULL || (rt->rt_flags & RTF_HOST) == 0 ||
{
struct rtentry *rt;
+ /*
+ * We do not add local routes for such address, so do not bother
+ * removing them.
+ */
+ switch (ifa->ifa_addr->sa_family) {
+ case AF_INET:
+ if (satosin(ifa->ifa_addr)->sin_addr.s_addr == INADDR_ANY)
+ return;
+ break;
+ case AF_INET6:
+ if (IN6_ARE_ADDR_EQUAL(&satosin6(ifa->ifa_addr)->sin6_addr,
+ &in6addr_any))
+ return;
+ break;
+ default:
+ break;
+ }
+
/*
* Before deleting, check if a corresponding loopbacked host
* route surely exists. With this check, we can avoid to
-/* $OpenBSD: if_ether.c,v 1.129 2014/06/16 19:47:21 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.130 2014/07/12 14:26:00 mpi Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
if ((rt->rt_flags & RTF_HOST) == 0 && rt_mask(rt) &&
satosin(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
rt->rt_flags |= RTF_CLONING;
- if (rt->rt_flags & RTF_CLONING) {
+ if (rt->rt_flags & RTF_CLONING ||
+ ((rt->rt_flags & RTF_LLINFO) && !la)) {
/*
* Case 1: This route should come from a route to iface.
*/
* from it do not need their expiration time set.
*/
rt->rt_expire = time_second;
- break;
+ if ((rt->rt_flags & RTF_CLONING) != 0)
+ break;
}
/* Announce a new entry if requested. */
if (rt->rt_flags & RTF_ANNOUNCE)
-/* $OpenBSD: in.c,v 1.99 2014/06/26 13:08:25 mpi Exp $ */
+/* $OpenBSD: in.c,v 1.100 2014/07/12 14:26:00 mpi Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
* Always remove the address from the tree to make sure its
* position gets updated in case the key changes.
*/
- if (!newaddr)
+ if (!newaddr) {
+ rt_ifa_delloop(&ia->ia_ifa);
ifa_del(ifp, &ia->ia_ifa);
+ }
oldaddr = ia->ia_addr;
ia->ia_addr = *sin;
* carp(4).
*/
ifa_add(ifp, &ia->ia_ifa);
+ rt_ifa_addloop(&ia->ia_ifa);
if (error && newaddr)
in_purgeaddr(&ia->ia_ifa);
in_ifscrub(ifp, ia);
+ rt_ifa_delloop(&ia->ia_ifa);
ifa_del(ifp, &ia->ia_ifa);
+
TAILQ_REMOVE(&in_ifaddr, ia, ia_list);
if (ia->ia_allhosts != NULL) {
in_delmulti(ia->ia_allhosts);