summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2016-11-20 11:40:59 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2016-11-20 11:40:59 +0000
commit6f3180e68d292446fa0aadf1d6823e2decb5daa4 (patch)
tree891917ce60713f7453a825a06bdeecaf03bd2dba /sys
parent1da087c079beaa659ed3eb5fded14dde11745f4c (diff)
Rename SRPL_ENTER() to SRPL_FIRST() and SRPL_NEXT() to SRPL_FOLLOW().
This allows us to introduce SRPL_NEXT() that can be used to start iterating on an arbitrary member of an srp list, hence without calling SRPL_ENTER(). ok dlg@, jmatthew@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/rtable.c10
-rw-r--r--sys/netinet/ip_carp.c8
-rw-r--r--sys/sys/srp.h13
3 files changed, 15 insertions, 16 deletions
diff --git a/sys/net/rtable.c b/sys/net/rtable.c
index a82ee8452ca..7656b943bf5 100644
--- a/sys/net/rtable.c
+++ b/sys/net/rtable.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtable.c,v 1.54 2016/11/14 10:32:46 mpi Exp $ */
+/* $OpenBSD: rtable.c,v 1.55 2016/11/20 11:40:58 mpi Exp $ */
/*
* Copyright (c) 2014-2016 Martin Pieuchot
@@ -536,7 +536,7 @@ rtable_lookup(unsigned int rtableid, struct sockaddr *dst,
}
#ifdef SMALL_KERNEL
- rt = SRPL_ENTER(&sr, &an->an_rtlist);
+ rt = SRPL_FIRST(&sr, &an->an_rtlist);
#else
SRPL_FOREACH(rt, &sr, &an->an_rtlist, rt_next) {
if (prio != RTP_ANY &&
@@ -583,7 +583,7 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src)
if (an == NULL)
goto out;
- rt = SRPL_ENTER(&sr, &an->an_rtlist);
+ rt = SRPL_FIRST(&sr, &an->an_rtlist);
rtref(rt);
SRPL_LEAVE(&sr);
@@ -614,11 +614,11 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src)
* the end of the list and then pick the first route.
*/
- mrt = SRPL_ENTER(&sr, &an->an_rtlist);
+ mrt = SRPL_FIRST(&sr, &an->an_rtlist);
while (hash > threshold && mrt != NULL) {
if (mrt->rt_priority == rt->rt_priority)
hash -= threshold;
- mrt = SRPL_NEXT(&sr, mrt, rt_next);
+ mrt = SRPL_FOLLOW(&sr, mrt, rt_next);
}
if (mrt != NULL) {
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index ff3ae78600d..73d959eac26 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.295 2016/10/25 07:21:02 yasuoka Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.296 2016/11/20 11:40:58 mpi Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -1329,7 +1329,7 @@ carp_iamatch(struct ifnet *ifp)
struct srp_ref sr;
int match = 0;
- vhe = SRPL_ENTER(&sr, &sc->carp_vhosts); /* head */
+ vhe = SRPL_FIRST(&sr, &sc->carp_vhosts);
if (vhe->state == MASTER)
match = 1;
SRPL_LEAVE(&sr);
@@ -1381,7 +1381,7 @@ carp_vhe_match(struct carp_softc *sc, uint8_t *ena)
struct srp_ref sr;
int match = 0;
- vhe = SRPL_ENTER(&sr, &sc->carp_vhosts); /* head */
+ vhe = SRPL_FIRST(&sr, &sc->carp_vhosts);
match = (vhe->state == MASTER || sc->sc_balancing >= CARP_BAL_IP) &&
!memcmp(ena, sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN);
SRPL_LEAVE(&sr);
@@ -2312,7 +2312,7 @@ carp_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa,
KASSERT(sc->sc_carpdev != NULL);
if (sc->cur_vhe == NULL) {
- vhe = SRPL_ENTER(&sr, &sc->carp_vhosts); /* head */
+ vhe = SRPL_FIRST(&sr, &sc->carp_vhosts);
ismaster = (vhe->state == MASTER);
SRPL_LEAVE(&sr);
} else {
diff --git a/sys/sys/srp.h b/sys/sys/srp.h
index cedbd20bd87..383135432af 100644
--- a/sys/sys/srp.h
+++ b/sys/sys/srp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: srp.h,v 1.12 2016/10/21 06:27:50 dlg Exp $ */
+/* $OpenBSD: srp.h,v 1.13 2016/11/20 11:40:58 mpi Exp $ */
/*
* Copyright (c) 2014 Jonathan Matthew <jmatthew@openbsd.org>
@@ -110,15 +110,14 @@ struct { \
struct srp se_next; \
}
-#define SRPL_ENTER(_sr, _sl) srp_enter((_sr), &(_sl)->sl_head)
-
-#define SRPL_NEXT(_sr, _e, _ENTRY) \
- srp_follow((_sr), &(_e)->_ENTRY.se_next)
+#define SRPL_FIRST(_sr, _sl) srp_enter((_sr), &(_sl)->sl_head)
+#define SRPL_NEXT(_sr, _e, _ENTRY) srp_enter((_sr), &(_e)->_ENTRY.se_next)
+#define SRPL_FOLLOW(_sr, _e, _ENTRY) srp_follow((_sr), &(_e)->_ENTRY.se_next)
#define SRPL_FOREACH(_c, _sr, _sl, _ENTRY) \
- for ((_c) = SRPL_ENTER(_sr, _sl); \
+ for ((_c) = SRPL_FIRST(_sr, _sl); \
(_c) != NULL; \
- (_c) = SRPL_NEXT(_sr, _c, _ENTRY))
+ (_c) = SRPL_FOLLOW(_sr, _c, _ENTRY))
#define SRPL_LEAVE(_sr) srp_leave((_sr))