diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-05-26 07:01:55 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-05-26 07:01:55 +0000 |
commit | ab45da8bcbb00a5abf1d1153a264a0b384d1ce04 (patch) | |
tree | d799db06e78234274515fdb2ba7d4ad9f80c950d /sys/net/if_pppx.c | |
parent | 70c9c87b1e2bff3d97b15445a3e8f987cc9acf0c (diff) |
Kill unecessary `pppx_ifs_lk' lock.
Premature locking is causing more trouble than it is solving issue. In this
case the lifetime of descriptors is protected by the KERNEL_LOCK() so using
a rwlock for the lookup introduce sleeping points and possible new races
without benefit.
From Vitaliy Makkoveev.
Diffstat (limited to 'sys/net/if_pppx.c')
-rw-r--r-- | sys/net/if_pppx.c | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 4dcbe1d5695..5fc62d8e05d 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.84 2020/04/18 04:03:56 yasuoka Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.85 2020/05/26 07:01:54 mpi Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -165,7 +165,6 @@ 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); @@ -620,8 +619,6 @@ pppx_if_next_unit(void) struct pppx_if *pxi; int unit = 0; - rw_assert_wrlock(&pppx_ifs_lk); - /* this is safe without splnet since we're not modifying it */ do { int found = 0; @@ -650,11 +647,9 @@ pppx_if_find(struct pppx_dev *pxd, int session_id, int protocol) key.pxik_session_id = session_id; key.pxik_protocol = protocol; - rw_enter_read(&pppx_ifs_lk); pxi = RBT_FIND(pppx_ifs, &pppx_ifs, (struct pppx_if *)&key); if (pxi && pxi->pxi_ready == 0) pxi = NULL; - rw_exit_read(&pppx_ifs_lk); return pxi; } @@ -828,12 +823,10 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) #endif /* try to set the interface up */ - rw_enter_write(&pppx_ifs_lk); unit = pppx_if_next_unit(); if (unit < 0) { pool_put(pppx_if_pl, pxi); error = ENOMEM; - rw_exit_write(&pppx_ifs_lk); goto out; } @@ -846,14 +839,12 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) if (RBT_FIND(pppx_ifs, &pppx_ifs, pxi) != NULL) { pool_put(pppx_if_pl, pxi); error = EADDRINUSE; - rw_exit_write(&pppx_ifs_lk); goto out; } if (RBT_INSERT(pppx_ifs, &pppx_ifs, pxi) != NULL) panic("%s: pppx_ifs modified while lock was held", __func__); LIST_INSERT_HEAD(&pxd->pxd_pxis, pxi, pxi_list); - rw_exit_write(&pppx_ifs_lk); snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d", "pppx", unit); ifp->if_mtu = req->pr_peer_mru; /* XXX */ @@ -935,9 +926,7 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) } else { if_addrhooks_run(ifp); } - rw_enter_write(&pppx_ifs_lk); pxi->pxi_ready = 1; - rw_exit_write(&pppx_ifs_lk); out: return (error); @@ -1038,11 +1027,9 @@ pppx_if_destroy(struct pppx_dev *pxd, struct pppx_if *pxi) if_detach(ifp); NET_LOCK(); - rw_enter_write(&pppx_ifs_lk); if (RBT_REMOVE(pppx_ifs, &pppx_ifs, pxi) == NULL) panic("%s: pppx_ifs modified while lock was held", __func__); LIST_REMOVE(pxi, pxi_list); - rw_exit_write(&pppx_ifs_lk); pool_put(pppx_if_pl, pxi); } |