summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorJonathan Matthew <jmatthew@cvs.openbsd.org>2016-05-02 22:15:50 +0000
committerJonathan Matthew <jmatthew@cvs.openbsd.org>2016-05-02 22:15:50 +0000
commit321a2ad3e7c32cbba74141d3996a71d00a191b36 (patch)
tree2b45265ec4593b84be8f0404dbc6aca28b30d7da /sys/net
parent8f0b9406f0380cff6b0b14588a4a51eaaf887dea (diff)
Simplify life for routing table implementations by requiring that rtable_walk
callbacks return EAGAIN if they modify the routing table. While we're here, simplify life for rtable_walk callers by moving the loop that restarts the walk on EAGAIN into rtable_walk itself. Flushing cloned routes on interface state changes becomes a bit more inefficient, but this can be improved later. ok mpi@ dlg@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_spppsubr.c6
-rw-r--r--sys/net/route.c20
-rw-r--r--sys/net/rtable.c14
3 files changed, 23 insertions, 17 deletions
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 0f32d19ced9..d2ad8c5d80d 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_spppsubr.c,v 1.151 2016/05/01 14:08:39 sthen Exp $ */
+/* $OpenBSD: if_spppsubr.c,v 1.152 2016/05/02 22:15:49 jmatthew Exp $ */
/*
* Synchronous PPP link level subroutines.
*
@@ -4171,9 +4171,7 @@ sppp_update_gw(struct ifnet *ifp)
/* update routing table */
for (tid = 0; tid <= RT_TABLEID_MAX; tid++) {
- while (rtable_walk(tid, AF_INET, sppp_update_gw_walker,
- ifp) == EAGAIN)
- ; /* nothing */
+ rtable_walk(tid, AF_INET, sppp_update_gw_walker, ifp);
}
}
diff --git a/sys/net/route.c b/sys/net/route.c
index 3517ef5c679..33f9a42a43b 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.299 2016/04/27 14:47:27 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.300 2016/05/02 22:15:49 jmatthew Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -669,6 +669,7 @@ rtflushclone1(struct rtentry *rt, void *arg, u_int id)
{
struct rtentry *parent = arg;
struct ifnet *ifp;
+ int error;
ifp = if_get(rt->rt_ifidx);
@@ -680,11 +681,14 @@ rtflushclone1(struct rtentry *rt, void *arg, u_int id)
if (ifp == NULL)
return 0;
- if (ISSET(rt->rt_flags, RTF_CLONED) && rtequal(rt->rt_parent, parent))
+ if (ISSET(rt->rt_flags, RTF_CLONED) && rtequal(rt->rt_parent, parent)) {
rtdeletemsg(rt, ifp, id);
+ error = EAGAIN;
+ } else
+ error = 0;
if_put(ifp);
- return 0;
+ return error;
}
void
@@ -1708,9 +1712,7 @@ rt_if_remove(struct ifnet *ifp)
if (rtable_l2(tid) != ifp->if_rdomain)
continue;
for (i = 1; i <= AF_MAX; i++) {
- while (rtable_walk(tid, i, rt_if_remove_rtdelete,
- ifp) == EAGAIN)
- ; /* nothing */
+ rtable_walk(tid, i, rt_if_remove_rtdelete, ifp);
}
}
}
@@ -1751,9 +1753,7 @@ rt_if_track(struct ifnet *ifp)
if (!rtable_mpath_capable(tid, i))
continue;
- while (rtable_walk(tid, i,
- rt_if_linkstate_change, ifp) == EAGAIN)
- ; /* nothing */
+ rtable_walk(tid, i, rt_if_linkstate_change, ifp);
}
}
}
@@ -1790,7 +1790,7 @@ rt_if_linkstate_change(struct rtentry *rt, void *arg, u_int id)
*/
if (rt->rt_flags & RTF_CLONED) {
rtdeletemsg(rt, ifp, id);
- return (0);
+ return (EAGAIN);
}
/* take route down */
rt->rt_flags &= ~RTF_UP;
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index 2221a492a23..0a3a09e0111 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.40 2016/04/13 08:04:14 mpi Exp $ */
+/* $OpenBSD: rtable.c,v 1.41 2016/05/02 22:15:49 jmatthew Exp $ */
/*
* Copyright (c) 2014-2015 Martin Pieuchot
@@ -459,12 +459,16 @@ rtable_walk(unsigned int rtableid, sa_family_t af,
{
struct radix_node_head *rnh;
int (*f)(struct radix_node *, void *, unsigned int) = (void *)func;
+ int error;
rnh = rtable_get(rtableid, af);
if (rnh == NULL)
return (EAFNOSUPPORT);
- return (rn_walktree(rnh, f, arg));
+ while ((error = rn_walktree(rnh, f, arg)) == EAGAIN)
+ ; /* nothing */
+
+ return (error);
}
#ifndef SMALL_KERNEL
@@ -846,6 +850,7 @@ rtable_walk(unsigned int rtableid, sa_family_t af,
{
struct art_root *ar;
struct rtable_walk_cookie rwc;
+ int error;
ar = rtable_get(rtableid, af);
if (ar == NULL)
@@ -855,7 +860,10 @@ rtable_walk(unsigned int rtableid, sa_family_t af,
rwc.rwc_arg = arg;
rwc.rwc_rid = rtableid;
- return (art_walk(ar, rtable_walk_helper, &rwc));
+ while ((error = art_walk(ar, rtable_walk_helper, &rwc)) == EAGAIN)
+ ; /* nothing */
+
+ return (error);
}
#ifndef SMALL_KERNEL