summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-09-05 10:56:05 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-09-05 10:56:05 +0000
commit8eb5d17917397aa1ee106e16373b78b8b55fb6ea (patch)
treebfdd64d3a478558d9ef49ff2fc637e56ed96edb9
parenta4b500858de38fe1d3fdc341bf4156fb89807203 (diff)
Restart the iteration when a multipath list is re-ordered to make sure
no entry are missed. While here do not re-ordered or send messages for route entries that are already in the expected state. Make rttest30 pass. ok gerhard@
-rw-r--r--sys/net/route.c56
-rw-r--r--sys/net/rtable.c3
2 files changed, 30 insertions, 29 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 61914bab2e0..d766f14a9ce 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.366 2017/08/11 21:24:19 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.367 2017/09/05 10:56:04 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1550,6 +1550,7 @@ rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
{
struct ifnet *ifp = arg;
struct sockaddr_in6 sa_mask;
+ int error;
if (rt->rt_ifidx != ifp->if_index)
return (0);
@@ -1561,38 +1562,37 @@ rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
}
if (LINK_STATE_IS_UP(ifp->if_link_state) && ifp->if_flags & IFF_UP) {
- if (!(rt->rt_flags & RTF_UP)) {
- /* bring route up */
- rt->rt_flags |= RTF_UP;
- rtable_mpath_reprio(id, rt_key(rt),
- rt_plen2mask(rt, &sa_mask),
- rt->rt_priority & RTP_MASK, rt);
- }
- } else {
- if (rt->rt_flags & RTF_UP) {
- /*
- * Remove redirected and cloned routes (mainly ARP)
- * from down interfaces so we have a chance to get
- * new routes from a better source.
- */
- if (ISSET(rt->rt_flags, RTF_CLONED|RTF_DYNAMIC) &&
- !ISSET(rt->rt_flags, RTF_CACHED|RTF_BFD)) {
- int error;
+ if (ISSET(rt->rt_flags, RTF_UP))
+ return (0);
- if ((error = rtdeletemsg(rt, ifp, id)))
- return (error);
- return (EAGAIN);
- }
- /* take route down */
- rt->rt_flags &= ~RTF_UP;
- rtable_mpath_reprio(id, rt_key(rt),
- rt_plen2mask(rt, &sa_mask),
- rt->rt_priority | RTP_DOWN, rt);
+ /* bring route up */
+ rt->rt_flags |= RTF_UP;
+ error = rtable_mpath_reprio(id, rt_key(rt),
+ rt_plen2mask(rt, &sa_mask), rt->rt_priority & RTP_MASK, rt);
+ } else {
+ /*
+ * Remove redirected and cloned routes (mainly ARP)
+ * from down interfaces so we have a chance to get
+ * new routes from a better source.
+ */
+ if (ISSET(rt->rt_flags, RTF_CLONED|RTF_DYNAMIC) &&
+ !ISSET(rt->rt_flags, RTF_CACHED|RTF_BFD)) {
+ if ((error = rtdeletemsg(rt, ifp, id)))
+ return (error);
+ return (EAGAIN);
}
+
+ if (!ISSET(rt->rt_flags, RTF_UP))
+ return (0);
+
+ /* take route down */
+ rt->rt_flags &= ~RTF_UP;
+ error = rtable_mpath_reprio(id, rt_key(rt),
+ rt_plen2mask(rt, &sa_mask), rt->rt_priority | RTP_DOWN, rt);
}
if_group_routechange(rt_key(rt), rt_plen2mask(rt, &sa_mask));
- return (0);
+ return (error);
}
struct sockaddr *
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index 526b49b630d..3a8027f537d 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.61 2017/07/30 18:18:08 florian Exp $ */
+/* $OpenBSD: rtable.c,v 1.62 2017/09/05 10:56:04 mpi Exp $ */
/*
* Copyright (c) 2014-2016 Martin Pieuchot
@@ -751,6 +751,7 @@ rtable_mpath_reprio(unsigned int rtableid, struct sockaddr *dst,
rt->rt_priority = prio;
rtable_mpath_insert(an, rt);
rtfree(rt);
+ error = EAGAIN;
}
rw_exit_write(&ar->ar_lock);