summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-10-04 14:04:19 +0000
committermpi <mpi@openbsd.org>2016-10-04 14:04:19 +0000
commitf68cfd0e8024f94a57744009c5480c070bcbca0a (patch)
treec845d1858cb595fdb0a1d248446b8988a3a92284
parentOne more timeout_set_proc(9) conversion. (diff)
downloadwireguard-openbsd-f68cfd0e8024f94a57744009c5480c070bcbca0a.tar.xz
wireguard-openbsd-f68cfd0e8024f94a57744009c5480c070bcbca0a.zip
Correct the flag checks inside rt_ifa_addlocal(9) and rt_ifa_dellocal(9).
There's no need to insert an RTF_LOCAL route if it is already there, not if a route with the same destination exist. This fixes a KASSERT() triggered by adding an alias for an address already present in the ARP cache as reported by weerd@ and Peter J. Philipp. This should also fix a KASSERT() triggered by a NDP change reported by Sebastien Marie. ok bluhm@
-rw-r--r--sys/net/route.c8
-rw-r--r--sys/netinet6/in6.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index b80fbc459a8..e3ab2267a12 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.330 2016/09/17 07:35:05 phessler Exp $ */
+/* $OpenBSD: route.c,v 1.331 2016/10/04 14:04:19 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1324,9 +1324,9 @@ rt_ifa_addlocal(struct ifaddr *ifa)
if (!ISSET(ifa->ifa_ifp->if_flags, (IFF_LOOPBACK|IFF_POINTOPOINT)))
flags |= RTF_LLINFO;
- /* If there is no loopback entry, allocate one. */
+ /* If there is no local entry, allocate one. */
rt = rtalloc(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain);
- if (rt == NULL || !ISSET(rt->rt_flags, flags))
+ if (rt == NULL || ISSET(rt->rt_flags, flags) != flags)
error = rt_ifa_add(ifa, flags, ifa->ifa_addr);
rtfree(rt);
@@ -1375,7 +1375,7 @@ rt_ifa_dellocal(struct ifaddr *ifa)
* to a shared medium.
*/
rt = rtalloc(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain);
- if (rt != NULL && ISSET(rt->rt_flags, flags))
+ if (rt != NULL && ISSET(rt->rt_flags, flags) == flags)
error = rt_ifa_del(ifa, flags, ifa->ifa_addr);
rtfree(rt);
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 941e3640dee..55d8d98f79d 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6.c,v 1.193 2016/10/03 12:33:21 mpi Exp $ */
+/* $OpenBSD: in6.c,v 1.194 2016/10/04 14:04:19 mpi Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@@ -1217,7 +1217,7 @@ in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia6, int newhost)
}
if (newhost)
- rt_ifa_addlocal(&(ia6->ia_ifa));
+ error = rt_ifa_addlocal(&(ia6->ia_ifa));
return (error);
}