summaryrefslogtreecommitdiffstats
path: root/sys/net/route.c
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 /sys/net/route.c
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@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c8
1 files changed, 4 insertions, 4 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);