diff options
author | 2015-12-03 16:27:32 +0000 | |
---|---|---|
committer | 2015-12-03 16:27:32 +0000 | |
commit | ce2f93b3c0b7a3826214a6142a185dc98797ff37 (patch) | |
tree | f2b2c2c4c140f48ecab51682f3f2fe7879bb4b7c | |
parent | add ifdef IPSEC for protoypes; requested by mpi@ (diff) | |
download | wireguard-openbsd-ce2f93b3c0b7a3826214a6142a185dc98797ff37.tar.xz wireguard-openbsd-ce2f93b3c0b7a3826214a6142a185dc98797ff37.zip |
Use SRPL_HEAD() and SRPL_ENTRY() to be consistent with and allow to
fallback to a SLIST.
ok dlg@, jasper@
-rw-r--r-- | share/man/man9/Makefile | 3 | ||||
-rw-r--r-- | share/man/man9/srpl_rc_init.9 | 32 | ||||
-rw-r--r-- | sys/net/art.h | 5 | ||||
-rw-r--r-- | sys/net/bpfdesc.h | 6 | ||||
-rw-r--r-- | sys/net/if.c | 4 | ||||
-rw-r--r-- | sys/net/if_var.h | 4 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 10 | ||||
-rw-r--r-- | sys/net/if_vlan_var.h | 4 | ||||
-rw-r--r-- | sys/net/route.h | 4 | ||||
-rw-r--r-- | sys/netinet/ip_carp.c | 8 | ||||
-rw-r--r-- | sys/sys/srp.h | 13 |
11 files changed, 49 insertions, 44 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index e987f022f9b..0c49444020d 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.265 2015/12/02 09:46:29 tedu Exp $ +# $OpenBSD: Makefile,v 1.266 2015/12/03 16:27:32 mpi Exp $ # $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -379,6 +379,7 @@ MLINKS+=srp_enter.9 srp_init.9 srp_enter.9 srp_gc_init.9 \ srp_enter.9 srp_get_locked.9 srp_enter.9 srp_finalize.9 \ srp_enter.9 SRP_INITIALIZER.9 srp_enter.9 SRP_GC_INITIALIZER.9 MLINKS+=srpl_rc_init.9 SRPL_ENTER.9 \ + srpl_rc_init.9 SRPL_HEAD.9 srpl_rc_init.9 SRPL_ENTRY.9\ srpl_rc_init.9 SRPL_NEXT.9 srpl_rc_init.9 SRPL_FOREACH.9 \ srpl_rc_init.9 SRPL_LEAVE.9 srpl_rc_init.9 SRPL_EMPTY_LOCKED.9 \ srpl_rc_init.9 SRPL_FIRST_LOCKED.9 srpl_rc_init.9 SRPL_NEXT_LOCKED.9 \ diff --git a/share/man/man9/srpl_rc_init.9 b/share/man/man9/srpl_rc_init.9 index ab726e3e41a..7009d0b3c81 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.8 2015/11/26 13:08:18 jmc Exp $ +.\" $OpenBSD: srpl_rc_init.9,v 1.9 2015/12/03 16:27:32 mpi Exp $ .\" .\" Copyright (c) 2015 David Gwynne <dlg@openbsd.org> .\" @@ -14,11 +14,13 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 26 2015 $ +.Dd $Mdocdate: December 3 2015 $ .Dt SRPL_RC_INIT 9 .Os .Sh NAME .Nm srpl_rc_init , +.Nm SRPL_HEAD , +.Nm SRPL_ENTRY , .Nm SRPL_INIT , .Nm SRPL_ENTER , .Nm SRPL_NEXT , @@ -36,8 +38,6 @@ .Nd singly-linked shared reference pointer list .Sh SYNOPSIS .In sys/srp.h -.Vt struct srpl; -.Vt struct srpl_entry; .Vt struct srpl_iter; .Vt struct srpl_rc; .Ft void @@ -47,28 +47,30 @@ .Fa "void (*unref)(void *, void *)" .Fa "void *ctx" .Fc -.Fn "SRPL_INIT" "struct srpl_head *sl" +.Fn SRPL_HEAD "HEADNAME" "TYPE" +.Fn SRPL_ENTRY "TYPE" +.Fn "SRPL_INIT" "SRPL_HEAD *sl" .Ft void * -.Fn "SRPL_ENTER" "struct srpl *sl" "struct srpl_iter *si" +.Fn "SRPL_ENTER" "SRPL_HEAD *sl" "struct srpl_iter *si" .Ft void * .Fn "SRPL_NEXT" "struct srpl_iter *si" "struct TYPE *listelm" "FIELDNAME" .Fo "SRPL_FOREACH" .Fa "VARNAME" -.Fa "struct srpl *sl" +.Fa "SRPL_HEAD *sl" .Fa "struct srpl_iter *si" .Fa "FIELDNAME" .Fc .Fn "SRPL_LEAVE" "struct srpl_iter *si" "struct TYPE *listelm" -.Fn "SRPL_EMPTY_LOCKED" "struct srpl *sl" +.Fn "SRPL_EMPTY_LOCKED" "SRPL_HEAD *sl" .Ft void * -.Fn "SRPL_FIRST_LOCKED" "struct srpl *sl" +.Fn "SRPL_FIRST_LOCKED" "SRPL_HEAD *sl" .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" +.Fn "SRPL_FOREACH_LOCKED" "VARNAME" "SRPL_HEAD *sl" "FIELDNAME" +.Fn "SRPL_FOREACH_SAFE_LOCKED" "VARNAME" "SRPL_HEAD *sl" "FIELDNAME" "TEMP_VARNAME" .Fo "SRPL_INSERT_HEAD_LOCKED" .Fa "struct srpl_rc *rc" -.Fa "struct srpl *sl" +.Fa "SRPL_HEAD *sl" .Fa "struct TYPE *elm" .Fa "FIELDNAME" .Fc @@ -80,7 +82,7 @@ .Fc .Fo "SRPL_REMOVE_LOCKED" .Fa "struct srpl_rc *rc" -.Fa "struct srpl *sl" +.Fa "SRPL_HEAD *sl" .Fa "struct TYPE *listelm" .Fa "TYPE" .Fa "FIELDNAME" @@ -98,9 +100,9 @@ This allows concurrent traversal of a linked list and access to the items on the list. .Pp SRP lists are a generic type represented by a -.Vt struct srpl . +.Vt SRPL_HEAD . The elements inserted into the list must be structures that contain a -.Vt struct srpl_entry +.Vt SRPL_ENTRY field. Further, the elements must also support reference counting as insertion and removal operations can cause items to be temporarily diff --git a/sys/net/art.h b/sys/net/art.h index 20a0d40595b..158987fb075 100644 --- a/sys/net/art.h +++ b/sys/net/art.h @@ -1,4 +1,4 @@ -/* $OpenBSD: art.h,v 1.7 2015/11/29 16:02:18 mpi Exp $ */ +/* $OpenBSD: art.h,v 1.8 2015/12/03 16:27:32 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -45,8 +45,7 @@ struct rtentry; struct art_node { struct sockaddr *an_dst; /* Destination address (key) */ int an_plen; /* Prefix length */ - - struct srpl an_rtlist; /* Route related to this node */ + SRPL_HEAD(, rtentry) an_rtlist; /* Route related to this node */ }; void art_init(void); diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h index b173f75deb1..ab7c57f5c28 100644 --- a/sys/net/bpfdesc.h +++ b/sys/net/bpfdesc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bpfdesc.h,v 1.28 2015/09/09 11:55:37 dlg Exp $ */ +/* $OpenBSD: bpfdesc.h,v 1.29 2015/12/03 16:27:32 mpi Exp $ */ /* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */ /* @@ -48,7 +48,7 @@ * Descriptor associated with each open bpf file. */ struct bpf_d { - struct srpl_entry bd_next; /* Linked list of descriptors */ + SRPL_ENTRY(bpf_d) bd_next; /* Linked list of descriptors */ /* * Buffer slots: two mbuf clusters buffer the incoming packets. * The model has three slots. Sbuf is always occupied. @@ -98,7 +98,7 @@ struct bpf_d { */ struct bpf_if { struct bpf_if *bif_next; /* list of all interfaces */ - struct srpl bif_dlist; /* descriptor list */ + SRPL_HEAD(, bpf_d) bif_dlist; /* descriptor list */ struct bpf_if **bif_driverp; /* pointer into softc */ u_int bif_dlt; /* link layer type */ u_int bif_hdrlen; /* length of header (with padding) */ diff --git a/sys/net/if.c b/sys/net/if.c index 728e9a0cdd6..249c22e25b9 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.419 2015/12/03 14:55:17 vgross Exp $ */ +/* $OpenBSD: if.c,v 1.420 2015/12/03 16:27:32 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -740,7 +740,7 @@ if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af) } struct ifih { - struct srpl_entry ifih_next; + SRPL_ENTRY(ifih) ifih_next; int (*ifih_input)(struct ifnet *, struct mbuf *, void *); void *ifih_cookie; diff --git a/sys/net/if_var.h b/sys/net/if_var.h index d411fec1ef1..f4f7419fa20 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.61 2015/12/03 12:22:51 dlg Exp $ */ +/* $OpenBSD: if_var.h,v 1.62 2015/12/03 16:27:32 mpi Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -162,7 +162,7 @@ struct ifnet { /* and the entries */ struct task *if_linkstatetask; /* task to do route updates */ /* procedure handles */ - struct srpl if_inputs; /* input routines (dequeue) */ + SRPL_HEAD(, ifih) if_inputs; /* input routines (dequeue) */ /* output routine (enqueue) */ int (*if_output)(struct ifnet *, struct mbuf *, struct sockaddr *, diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 3029b223813..06ab2da3bfc 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.147 2015/11/10 06:34:35 dlg Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.148 2015/12/03 16:27:32 mpi Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -77,7 +77,7 @@ #define TAG_HASH_SIZE (1 << TAG_HASH_BITS) #define TAG_HASH_MASK (TAG_HASH_SIZE - 1) #define TAG_HASH(tag) (tag & TAG_HASH_MASK) -struct srpl *vlan_tagh, *svlan_tagh; +SRPL_HEAD(, ifvlan) *vlan_tagh, *svlan_tagh; struct rwlock vlan_tagh_lk = RWLOCK_INITIALIZER("vlantag"); int vlan_input(struct ifnet *, struct mbuf *, void *); @@ -309,7 +309,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m, void *cookie) struct ifvlan *ifv; struct ether_vlan_header *evl; struct ether_header *eh; - struct srpl *tagh, *list; + SRPL_HEAD(, ifvlan) *tagh, *list; struct srpl_iter i; u_int tag; struct mbuf_list ml = MBUF_LIST_INITIALIZER(); @@ -400,7 +400,7 @@ int vlan_config(struct ifvlan *ifv, struct ifnet *p, u_int16_t tag) { struct sockaddr_dl *sdl1, *sdl2; - struct srpl *tagh, *list; + SRPL_HEAD(, ifvlan) *tagh, *list; u_int flags; if (p->if_type != IFT_ETHER) @@ -491,7 +491,7 @@ vlan_unconfig(struct ifnet *ifp, struct ifnet *newp) { struct sockaddr_dl *sdl; struct ifvlan *ifv; - struct srpl *tagh, *list; + SRPL_HEAD(, ifvlan) *tagh, *list; struct ifnet *p; ifv = ifp->if_softc; diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index 8b271e8a7d6..7d1e1185665 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan_var.h,v 1.30 2015/09/13 10:02:36 dlg Exp $ */ +/* $OpenBSD: if_vlan_var.h,v 1.31 2015/12/03 16:27:32 mpi Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -85,7 +85,7 @@ struct ifvlan { u_int16_t ifvm_type; /* non-standard ethertype or 0x8100 */ } ifv_mib; LIST_HEAD(__vlan_mchead, vlan_mc_entry) vlan_mc_listhead; - struct srpl_entry ifv_list; + SRPL_ENTRY(ifvlan) ifv_list; int ifv_flags; struct refcnt ifv_refcnt; void *lh_cookie; diff --git a/sys/net/route.h b/sys/net/route.h index f81fcd29055..3186e5de82b 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.128 2015/12/03 14:26:27 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.129 2015/12/03 16:27:32 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -99,7 +99,7 @@ struct rtentry { struct art_node *rt_node; /* ART entry */ struct sockaddr *rt_dest; /* destination */ struct sockaddr *rt_mask; /* mask (radix tree compat) */ - struct srpl_entry rt_next; /* Next multipath entry to our dst. */ + SRPL_ENTRY(rtentry) rt_next; /* Next multipath entry to our dst. */ #endif struct sockaddr *rt_gateway; /* value */ struct ifaddr *rt_ifa; /* the answer: interface addr to use */ diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index f8e7e66d7f6..4dbb6e5616b 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.282 2015/11/18 13:53:59 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.283 2015/12/03 16:27:32 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -94,7 +94,7 @@ struct carp_mc_entry { enum { HMAC_ORIG=0, HMAC_NOV6LL=1, HMAC_MAX=2 }; struct carp_vhost_entry { - struct srpl_entry vhost_entries; + SRPL_ENTRY(carp_vhost_entry) vhost_entries; struct refcnt vhost_refcnt; struct carp_softc *parent_sc; @@ -133,7 +133,7 @@ struct carp_softc { struct ip6_moptions sc_im6o; #endif /* INET6 */ - struct srpl_entry sc_list; + SRPL_ENTRY(carp_softc) sc_list; struct refcnt sc_refcnt; int sc_suppress; @@ -147,7 +147,7 @@ struct carp_softc { char sc_curlladdr[ETHER_ADDR_LEN]; - struct srpl carp_vhosts; + SRPL_HEAD(, carp_vhost_entry) carp_vhosts; int sc_vhe_count; u_int8_t sc_vhids[CARP_MAXNODES]; u_int8_t sc_advskews[CARP_MAXNODES]; diff --git a/sys/sys/srp.h b/sys/sys/srp.h index 44b9d7cc4a1..716d80f44ca 100644 --- a/sys/sys/srp.h +++ b/sys/sys/srp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: srp.h,v 1.6 2015/11/26 12:17:19 mpi Exp $ */ +/* $OpenBSD: srp.h,v 1.7 2015/12/03 16:27:32 mpi Exp $ */ /* * Copyright (c) 2014 Jonathan Matthew <jmatthew@openbsd.org> @@ -79,10 +79,6 @@ struct srpl { struct srp sl_head; }; -struct srpl_entry { - struct srp se_next; -}; - struct srpl_iter { struct srp * si_ref; }; @@ -96,6 +92,13 @@ void srpl_rc_init(struct srpl_rc *, void (*)(void *, void *), #define SRPL_INIT(_sl) srp_init(&(_sl)->sl_head) +#define SRPL_HEAD(name, type) struct srpl + +#define SRPL_ENTRY(type) \ +struct { \ + struct srp se_next; \ +} + static inline void * _srpl_enter(struct srpl *sl, struct srpl_iter *si) { |