git: bc85442bf6c9 - stable/13 - tcp_fill_info(): Change lock assertion on INPCB to locked only

From: Marius Strobl <marius_at_FreeBSD.org>
Date: Sat, 06 Jan 2024 19:25:30 UTC
The branch stable/13 has been updated by marius:

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

commit bc85442bf6c9effcea7d7ef24651998b35c04dc9
Author:     Marius Strobl <marius@FreeBSD.org>
AuthorDate: 2023-08-22 17:03:42 +0000
Commit:     Marius Strobl <marius@FreeBSD.org>
CommitDate: 2024-01-05 22:48:34 +0000

    tcp_fill_info(): Change lock assertion on INPCB to locked only
    
    This function actually only ever reads from the TCP PCB. Consequently,
    also make the pointer to its TCP PCB parameter const.
    
    Sponsored by:   NetApp, Inc. (originally)
    
    (cherry picked from commit 8c6104c48ea3f0ffaabeb9784b0f2327db04e7af)
    
    Conflicts (due tue missing 9eb0e832):
            sys/dev/cxgbe/tom/t4_tom.c
            sys/netinet/tcp_offload.c
            sys/netinet/tcp_usrreq.c
---
 sys/dev/cxgbe/tom/t4_tom.c | 4 ++--
 sys/netinet/tcp_offload.c  | 4 ++--
 sys/netinet/tcp_offload.h  | 2 +-
 sys/netinet/tcp_usrreq.c   | 8 ++++----
 sys/netinet/toecore.c      | 2 +-
 sys/netinet/toecore.h      | 2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index c423ca011977..b1982341f4d5 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -817,12 +817,12 @@ fill_tcp_info(struct adapter *sc, u_int tid, struct tcp_info *ti)
  * the tcp_info for an offloaded connection.
  */
 static void
-t4_tcp_info(struct toedev *tod, struct tcpcb *tp, struct tcp_info *ti)
+t4_tcp_info(struct toedev *tod, const struct tcpcb *tp, struct tcp_info *ti)
 {
 	struct adapter *sc = tod->tod_softc;
 	struct toepcb *toep = tp->t_toe;
 
-	INP_WLOCK_ASSERT(tp->t_inpcb);
+	INP_LOCK_ASSERT(tp->t_inpcb);
 	MPASS(ti != NULL);
 
 	fill_tcp_info(sc, toep->tid, ti);
diff --git a/sys/netinet/tcp_offload.c b/sys/netinet/tcp_offload.c
index 71a5d51b5f22..b04251712580 100644
--- a/sys/netinet/tcp_offload.c
+++ b/sys/netinet/tcp_offload.c
@@ -185,12 +185,12 @@ tcp_offload_ctloutput(struct tcpcb *tp, int sopt_dir, int sopt_name)
 }
 
 void
-tcp_offload_tcp_info(struct tcpcb *tp, struct tcp_info *ti)
+tcp_offload_tcp_info(const struct tcpcb *tp, struct tcp_info *ti)
 {
 	struct toedev *tod = tp->tod;
 
 	KASSERT(tod != NULL, ("%s: tp->tod is NULL, tp %p", __func__, tp));
-	INP_WLOCK_ASSERT(tp->t_inpcb);
+	INP_LOCK_ASSERT(tp->t_inpcb);
 
 	tod->tod_tcp_info(tod, tp, ti);
 }
diff --git a/sys/netinet/tcp_offload.h b/sys/netinet/tcp_offload.h
index 855c28e01385..8f299f57fd33 100644
--- a/sys/netinet/tcp_offload.h
+++ b/sys/netinet/tcp_offload.h
@@ -43,7 +43,7 @@ void tcp_offload_input(struct tcpcb *, struct mbuf *);
 int  tcp_offload_output(struct tcpcb *);
 void tcp_offload_rcvd(struct tcpcb *);
 void tcp_offload_ctloutput(struct tcpcb *, int, int);
-void tcp_offload_tcp_info(struct tcpcb *, struct tcp_info *);
+void tcp_offload_tcp_info(const struct tcpcb *, struct tcp_info *);
 int  tcp_offload_alloc_tls_session(struct tcpcb *, struct ktls_session *, int);
 void tcp_offload_detach(struct tcpcb *);
 
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index df322b03a59a..7e9c871df87a 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -129,7 +129,7 @@ static int	tcp6_connect(struct tcpcb *, struct sockaddr *,
 #endif /* INET6 */
 static void	tcp_disconnect(struct tcpcb *);
 static void	tcp_usrclosed(struct tcpcb *);
-static void	tcp_fill_info(struct tcpcb *, struct tcp_info *);
+static void	tcp_fill_info(const struct tcpcb *, struct tcp_info *);
 
 static int	tcp_pru_options_support(struct tcpcb *tp, int flags);
 
@@ -1631,11 +1631,11 @@ out:
  * constants -- for example, the numeric values for tcpi_state will differ
  * from Linux.
  */
-static void
-tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
+void
+tcp_fill_info(const struct tcpcb *tp, struct tcp_info *ti)
 {
 
-	INP_WLOCK_ASSERT(tp->t_inpcb);
+	INP_LOCK_ASSERT(tp->t_inpcb);
 	bzero(ti, sizeof(*ti));
 
 	ti->tcpi_state = tp->t_state;
diff --git a/sys/netinet/toecore.c b/sys/netinet/toecore.c
index 7ccff2c3eeed..4bb5f706de06 100644
--- a/sys/netinet/toecore.c
+++ b/sys/netinet/toecore.c
@@ -182,7 +182,7 @@ toedev_ctloutput(struct toedev *tod __unused, struct tcpcb *tp __unused,
 }
 
 static void
-toedev_tcp_info(struct toedev *tod __unused, struct tcpcb *tp __unused,
+toedev_tcp_info(struct toedev *tod __unused, const struct tcpcb *tp __unused,
     struct tcp_info *ti __unused)
 {
 
diff --git a/sys/netinet/toecore.h b/sys/netinet/toecore.h
index 8a25a95799d5..6523c3a110fc 100644
--- a/sys/netinet/toecore.h
+++ b/sys/netinet/toecore.h
@@ -106,7 +106,7 @@ struct toedev {
 	void (*tod_ctloutput)(struct toedev *, struct tcpcb *, int, int);
 
 	/* Update software state */
-	void (*tod_tcp_info)(struct toedev *, struct tcpcb *,
+	void (*tod_tcp_info)(struct toedev *, const struct tcpcb *,
 	    struct tcp_info *);
 
 	/* Create a TLS session */