git: c9e9bfc22e6d - stable/13 - sctp: use consistent names for locking macros

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Thu, 11 Jan 2024 12:40:41 UTC
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=c9e9bfc22e6da6969bbb39920a7090a31ee988b5

commit c9e9bfc22e6da6969bbb39920a7090a31ee988b5
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2023-08-13 20:32:54 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-01-11 12:40:04 +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.
    
    (cherry picked from commit 6cb8b3b5cde18ac5465f1cf1df3fbac359cb09e9)
---
 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 1ff5c87a1163..4e9197917a9e 100644
--- a/sys/netinet/sctp_lock_bsd.h
+++ b/sys/netinet/sctp_lock_bsd.h
@@ -232,12 +232,12 @@
  * 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)
 
@@ -249,6 +249,11 @@
 	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 2cb3f6874df9..15f406eae32d 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -2498,7 +2498,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
 	SCTP_INP_INFO_WLOCK();
 	SCTP_INP_LOCK_INIT(inp);
 	INP_LOCK_INIT(&inp->ip_inp.inp, "inp", "sctpinp");
-	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);
@@ -3675,7 +3675,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();