summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-11-26 12:17:20 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-11-26 12:17:20 +0000
commit5af25f38e41be51eb2ca737e2c6f867a470d9c6c (patch)
tree15e02d9d4f22c1663be2c48bbc96ce595f1e31f2
parentfee2d847a5126ec5c010619cd96b21d2d173e13d (diff)
Add SRPL_FOREACH_SAFE_LOCKED(9), needed to turn the single list of
multipath route entries mpsafe. ok dlg@
-rw-r--r--share/man/man9/srpl_rc_init.914
-rw-r--r--sys/sys/srp.h7
2 files changed, 18 insertions, 3 deletions
diff --git a/share/man/man9/srpl_rc_init.9 b/share/man/man9/srpl_rc_init.9
index 35ed5a48794..822246313b1 100644
--- a/share/man/man9/srpl_rc_init.9
+++ b/share/man/man9/srpl_rc_init.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: srpl_rc_init.9,v 1.6 2015/09/18 17:09:11 jmc Exp $
+.\" $OpenBSD: srpl_rc_init.9,v 1.7 2015/11/26 12:17:19 mpi Exp $
.\"
.\" Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 18 2015 $
+.Dd $Mdocdate: November 26 2015 $
.Dt SRPL_RC_INIT 9
.Os
.Sh NAME
@@ -28,6 +28,7 @@
.Nm SRPL_FIRST_LOCKED ,
.Nm SRPL_NEXT_LOCKED ,
.Nm SRPL_FOREACH_LOCKED ,
+.Nm SRPL_FOREACH_SAFE_LOCKED ,
.Nm SRPL_INSERT_HEAD_LOCKED ,
.Nm SRPL_INSERT_AFTER_LOCKED ,
.Nm SRPL_REMOVE_LOCKED ,
@@ -64,6 +65,7 @@
.Ft void *
.Fn "SRPL_NEXT_LOCKED" "struct TYPE *listelm" "FIELDNAME"
.Fn "SRPL_FOREACH_LOCKED" "VARNAME" "struct srpl *sl" "FIELDNAME"
+.Fn "SRPL_FOREACH_SAFE_LOCKED" "VARNAME" "struct srpl *sl" "FIELDNAME" "TEMP_VARNAME"
.Fo "SRPL_INSERT_HEAD_LOCKED"
.Fa "struct srpl_rc *rc"
.Fa "struct srpl *sl"
@@ -180,6 +182,14 @@ accesses the next element in the SRP list after
creates a loop for traversing the elements in the SRP list
.Fa sl .
.Pp
+.Fn SRPL_FOREACH_SAFE_LOCKED
+creates a loop for traversing the elements in the SRP list
+.Fa sl
+permitting to remove
+.Fa VARNAME
+as well as freeing it from within the loop safely without interfering with the
+traversal.
+.Pp
.Fn SRPL_INSERT_HEAD_LOCKED
inserts
.Fa elm
diff --git a/sys/sys/srp.h b/sys/sys/srp.h
index 5d23e87f5ce..44b9d7cc4a1 100644
--- a/sys/sys/srp.h
+++ b/sys/sys/srp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: srp.h,v 1.5 2015/09/18 08:30:23 dlg Exp $ */
+/* $OpenBSD: srp.h,v 1.6 2015/11/26 12:17:19 mpi Exp $ */
/*
* Copyright (c) 2014 Jonathan Matthew <jmatthew@openbsd.org>
@@ -137,6 +137,11 @@ _srpl_next(struct srpl_iter *si, void *elm, struct srp *nref)
(_c) != NULL; \
(_c) = SRPL_NEXT_LOCKED((_c), _ENTRY))
+#define SRPL_FOREACH_SAFE_LOCKED(_c, _sl, _ENTRY, _tc) \
+ for ((_c) = SRPL_FIRST_LOCKED(_sl); \
+ (_c) && ((_tc) = SRPL_NEXT_LOCKED(_c, _ENTRY), 1); \
+ (_c) = (_tc))
+
#define SRPL_INSERT_HEAD_LOCKED(_rc, _sl, _e, _ENTRY) do { \
void *head; \
\