diff options
author | 2016-11-20 11:46:45 +0000 | |
---|---|---|
committer | 2016-11-20 11:46:45 +0000 | |
commit | 1c3d6e8f77058de0d815640fac996f16270d79ba (patch) | |
tree | 0eab1ec0248df0d50473fbdf75053e67aa0f2928 | |
parent | Rename SRPL_ENTER() to SRPL_FIRST() and SRPL_NEXT() to SRPL_FOLLOW(). (diff) | |
download | wireguard-openbsd-1c3d6e8f77058de0d815640fac996f16270d79ba.tar.xz wireguard-openbsd-1c3d6e8f77058de0d815640fac996f16270d79ba.zip |
Make rtable_iterate(9) mpsafe by using the new SRPL_NEXT(9).
ok dlg@, jmatthew@
-rw-r--r-- | sys/net/rtable.c | 16 | ||||
-rw-r--r-- | sys/netinet/if_ether.c | 4 |
2 files changed, 7 insertions, 13 deletions
diff --git a/sys/net/rtable.c b/sys/net/rtable.c index 7656b943bf5..b8012deb648 100644 --- a/sys/net/rtable.c +++ b/sys/net/rtable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtable.c,v 1.55 2016/11/20 11:40:58 mpi Exp $ */ +/* $OpenBSD: rtable.c,v 1.56 2016/11/20 11:46:45 mpi Exp $ */ /* * Copyright (c) 2014-2016 Martin Pieuchot @@ -869,21 +869,17 @@ rtable_walk(unsigned int rtableid, sa_family_t af, struct rtentry * rtable_iterate(struct rtentry *rt0) { + struct rtentry *rt = NULL; #ifndef SMALL_KERNEL - struct rtentry *rt; + struct srp_ref sr; - KERNEL_ASSERT_LOCKED(); - - rt = SRPL_NEXT_LOCKED(rt0, rt_next); + rt = SRPL_NEXT(&sr, rt0, rt_next); if (rt != NULL) rtref(rt); + SRPL_LEAVE(&sr); +#endif /* SMALL_KERNEL */ rtfree(rt0); - return (rt); -#else - rtfree(rt0); - return (NULL); -#endif /* SMALL_KERNEL */ } #ifndef SMALL_KERNEL diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index a88149bbf28..fe4630975f1 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.225 2016/11/07 09:19:46 mpi Exp $ */ +/* $OpenBSD: if_ether.c,v 1.226 2016/11/20 11:46:45 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -731,13 +731,11 @@ arplookup(struct in_addr *inp, int create, int proxy, u_int tableid) if (proxy && !ISSET(rt->rt_flags, RTF_ANNOUNCE)) { #ifdef ART - KERNEL_LOCK(); while ((rt = rtable_iterate(rt)) != NULL) { if (ISSET(rt->rt_flags, RTF_ANNOUNCE)) { break; } } - KERNEL_UNLOCK(); #endif /* ART */ } |