diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2016-09-09 04:48:27 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2016-09-09 04:48:27 +0000 |
commit | d6d452326f49a46f5bf8a6d534942b8a17e613b0 (patch) | |
tree | 10dfa111b34cfffb1e8ea8c9dc3d3e910fd746ee | |
parent | 12959784e4bf31599f27495f278f32c3ae8aa7c1 (diff) |
back out RBT for now
-rw-r--r-- | sys/net/if_pppx.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 3d183c6ba35..a3cbfe4df51 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.53 2016/09/05 07:41:22 dlg Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.54 2016/09/09 04:48:26 dlg Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -139,10 +139,12 @@ struct pppx_if_key { int pxik_protocol; }; +int pppx_if_cmp(struct pppx_if *, struct pppx_if *); + struct pppx_if { struct pppx_if_key pxi_key; /* must be first in the struct */ - RBT_ENTRY(pppx_if) pxi_entry; + RB_ENTRY(pppx_if) pxi_entry; LIST_ENTRY(pppx_if) pxi_list; int pxi_unit; @@ -152,15 +154,9 @@ struct pppx_if { struct pipex_iface_context pxi_ifcontext; }; -static inline int -pppx_if_cmp(const struct pppx_if *a, const struct pppx_if *b) -{ - return memcmp(&a->pxi_key, &b->pxi_key, sizeof(a->pxi_key)); -} - struct rwlock pppx_ifs_lk = RWLOCK_INITIALIZER("pppxifs"); -RBT_HEAD(pppx_ifs, pppx_if) pppx_ifs = RBT_INITIALIZER(&pppx_ifs); -RBT_PROTOTYPE(pppx_ifs, pppx_if, pxi_entry, pppx_if_cmp); +RB_HEAD(pppx_ifs, pppx_if) pppx_ifs = RB_INITIALIZER(&pppx_ifs); +RB_PROTOTYPE(pppx_ifs, pppx_if, pxi_entry, pppx_if_cmp); int pppx_if_next_unit(void); struct pppx_if *pppx_if_find(struct pppx_dev *, int, int); @@ -612,6 +608,12 @@ pppxclose(dev_t dev, int flags, int mode, struct proc *p) } int +pppx_if_cmp(struct pppx_if *a, struct pppx_if *b) +{ + return memcmp(&a->pxi_key, &b->pxi_key, sizeof(a->pxi_key)); +} + +int pppx_if_next_unit(void) { struct pppx_if *pxi; @@ -622,7 +624,7 @@ pppx_if_next_unit(void) /* this is safe without splnet since we're not modifying it */ do { int found = 0; - RBT_FOREACH(pxi, pppx_ifs, &pppx_ifs) { + RB_FOREACH(pxi, pppx_ifs, &pppx_ifs) { if (pxi->pxi_unit == unit) { found = 1; break; @@ -647,7 +649,7 @@ pppx_if_find(struct pppx_dev *pxd, int session_id, int protocol) s->pxi_key.pxik_protocol = protocol; rw_enter_read(&pppx_ifs_lk); - p = RBT_FIND(pppx_ifs, &pppx_ifs, s); + p = RB_FIND(pppx_ifs, &pppx_ifs, s); rw_exit_read(&pppx_ifs_lk); free(s, M_DEVBUF, 0); @@ -828,7 +830,7 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) pxi->pxi_dev = pxd; /* this is safe without splnet since we're not modifying it */ - if (RBT_FIND(pppx_ifs, &pppx_ifs, pxi) != NULL) { + if (RB_FIND(pppx_ifs, &pppx_ifs, pxi) != NULL) { pool_put(pppx_if_pl, pxi); error = EADDRINUSE; goto out; @@ -874,7 +876,7 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) #endif SET(ifp->if_flags, IFF_RUNNING); - if (RBT_INSERT(pppx_ifs, &pppx_ifs, pxi) != NULL) + if (RB_INSERT(pppx_ifs, &pppx_ifs, pxi) != NULL) panic("pppx_ifs modified while lock was held"); LIST_INSERT_HEAD(&pxd->pxd_pxis, pxi, pxi_list); @@ -982,7 +984,7 @@ pppx_if_destroy(struct pppx_dev *pxd, struct pppx_if *pxi) if_detach(ifp); rw_enter_write(&pppx_ifs_lk); - if (RBT_REMOVE(pppx_ifs, &pppx_ifs, pxi) == NULL) + if (RB_REMOVE(pppx_ifs, &pppx_ifs, pxi) == NULL) panic("pppx_ifs modified while lock was held"); LIST_REMOVE(pxi, pxi_list); rw_exit_write(&pppx_ifs_lk); @@ -1126,4 +1128,4 @@ pppx_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr) return (error); } -RBT_GENERATE(pppx_ifs, pppx_if, pxi_entry, pppx_if_cmp); +RB_GENERATE(pppx_ifs, pppx_if, pxi_entry, pppx_if_cmp); |