From: mpi Date: Tue, 19 Jul 2016 10:51:44 +0000 (+0000) Subject: Revert use of the _SAFE version of SRPL_FOREACH() now that the offending X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=48938141b0df9db8c42e5b18527595e809680875;p=openbsd Revert use of the _SAFE version of SRPL_FOREACH() now that the offending function has been fixed. Functions passed to rtable_walk() must return EAGAIN if they delete an entry from the tree, no matter if it is a leaf or not. --- diff --git a/sys/net/art.c b/sys/net/art.c index bbbf759c40f..9183157b0a7 100644 --- a/sys/net/art.c +++ b/sys/net/art.c @@ -1,4 +1,4 @@ -/* $OpenBSD: art.c,v 1.21 2016/07/04 08:11:48 mpi Exp $ */ +/* $OpenBSD: art.c,v 1.22 2016/07/19 10:51:44 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -706,11 +706,11 @@ art_walk_apply(struct art_root *ar, { int error = 0; - KERNEL_ASSERT_LOCKED(); - if ((an != NULL) && (an != next)) { /* this assumes an->an_dst is not used by f */ + KERNEL_UNLOCK(); error = (*f)(an, arg); + KERNEL_LOCK(); } return (error); diff --git a/sys/net/rtable.c b/sys/net/rtable.c index 9a3298c7c00..df50e81ee5d 100644 --- a/sys/net/rtable.c +++ b/sys/net/rtable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtable.c,v 1.49 2016/07/04 08:11:48 mpi Exp $ */ +/* $OpenBSD: rtable.c,v 1.50 2016/07/19 10:51:44 mpi Exp $ */ /* * Copyright (c) 2014-2015 Martin Pieuchot @@ -853,19 +853,16 @@ struct rtable_walk_cookie { int rtable_walk_helper(struct art_node *an, void *xrwc) { + struct srp_ref sr; struct rtable_walk_cookie *rwc = xrwc; - struct rtentry *rt, *nrt; + struct rtentry *rt; int error = 0; - KERNEL_ASSERT_LOCKED(); - - SRPL_FOREACH_SAFE_LOCKED(rt, &an->an_rtlist, rt_next, nrt) { - KERNEL_UNLOCK(); - error = (*rwc->rwc_func)(rt, rwc->rwc_arg, rwc->rwc_rid); - KERNEL_LOCK(); - if (error) + SRPL_FOREACH(rt, &sr, &an->an_rtlist, rt_next) { + if ((error = (*rwc->rwc_func)(rt, rwc->rwc_arg, rwc->rwc_rid))) break; } + SRPL_LEAVE(&sr); return (error); }