git: 6cb8b3b5cde1 - main - sctp: use consistent names for locking macros
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 14 Aug 2023 06:42:48 UTC
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=6cb8b3b5cde18ac5465f1cf1df3fbac359cb09e9 commit 6cb8b3b5cde18ac5465f1cf1df3fbac359cb09e9 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2023-08-13 20:32:54 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2023-08-13 20:35:53 +0000 sctp: use consistent names for locking macros While there, add also a macro for an assert. Will be used shortly. No functional change intended. MFC after: 1 week --- sys/netinet/sctp_lock_bsd.h | 9 +++++++-- sys/netinet/sctp_pcb.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/netinet/sctp_lock_bsd.h b/sys/netinet/sctp_lock_bsd.h index 2087db337a37..a0cff81e706e 100644 --- a/sys/netinet/sctp_lock_bsd.h +++ b/sys/netinet/sctp_lock_bsd.h @@ -234,12 +234,12 @@ __FBSDID("$FreeBSD$"); * or cookie secrets we lock the INP level. */ -#define SCTP_INP_READ_INIT(_inp) do { \ +#define SCTP_INP_READ_LOCK_INIT(_inp) do { \ mtx_init(&(_inp)->inp_rdata_mtx, "sctp-read", "inpr", \ MTX_DEF | MTX_DUPOK); \ } while (0) -#define SCTP_INP_READ_DESTROY(_inp) do { \ +#define SCTP_INP_READ_LOCK_DESTROY(_inp) do { \ mtx_destroy(&(_inp)->inp_rdata_mtx); \ } while (0) @@ -251,6 +251,11 @@ __FBSDID("$FreeBSD$"); mtx_unlock(&(_inp)->inp_rdata_mtx); \ } while (0) +#define SCTP_INP_READ_LOCK_ASSERT(_inp) do { \ + KASSERT(mtx_owned(&(_inp)->inp_rdata_mtx), \ + ("Don't own INP read queue lock")); \ +} while (0) + #define SCTP_INP_LOCK_INIT(_inp) do { \ mtx_init(&(_inp)->inp_mtx, "sctp-inp", "inp", \ MTX_DEF | MTX_DUPOK); \ diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 220d8b72667d..aad5879afe63 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -2501,7 +2501,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id) SCTP_INP_LOCK_INIT(inp); rw_init_flags(&inp->ip_inp.inp.inp_lock, "sctpinp", RW_RECURSE | RW_DUPOK); - SCTP_INP_READ_INIT(inp); + SCTP_INP_READ_LOCK_INIT(inp); SCTP_ASOC_CREATE_LOCK_INIT(inp); /* lock the new ep */ SCTP_INP_WLOCK(inp); @@ -3678,7 +3678,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) crfree(inp->ip_inp.inp.inp_cred); INP_LOCK_DESTROY(&inp->ip_inp.inp); SCTP_INP_LOCK_DESTROY(inp); - SCTP_INP_READ_DESTROY(inp); + SCTP_INP_READ_LOCK_DESTROY(inp); SCTP_ASOC_CREATE_LOCK_DESTROY(inp); SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_ep), inp); SCTP_DECR_EP_COUNT();