The branch main has been updated by rscheff:

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

commit dded4e9e524ca1fcf4ad1c8822817ec010caf5e6
Author:     Richard Scheffenegger <rsch...@freebsd.org>
AuthorDate: 2024-11-13 23:41:44 +0000
Commit:     Richard Scheffenegger <rsch...@freebsd.org>
CommitDate: 2024-11-14 01:08:12 +0000

    tcp: change SOCKBUF_* macros to SOCK_[RECV|SEND]BUF_* macros
    
    Change the older LOCK related macros over to the
    dedicated send/recv buffer macros in the base tcp stack.
    
    No functional change intended.
    
    Reviewed By: tuexen, #transport
    Sponsored by: NetApp, Inc.
    Differential Revision: https://reviews.freebsd.org/D47567
---
 sys/netinet/tcp_input.c  | 28 ++++++++++++++--------------
 sys/netinet/tcp_output.c | 22 +++++++++++-----------
 sys/netinet/tcp_reass.c  |  4 ++--
 sys/netinet/tcp_subr.c   |  4 ++--
 sys/netinet/tcp_usrreq.c | 10 +++++-----
 5 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index e5f5e09e57d8..3dfdb13994a5 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1512,7 +1512,7 @@ tcp_handle_wakeup(struct tcpcb *tp)
                struct socket *so = tptosocket(tp);
 
                tp->t_flags &= ~TF_WAKESOR;
-               SOCKBUF_LOCK_ASSERT(&so->so_rcv);
+               SOCK_RECVBUF_LOCK_ASSERT(so);
                sorwakeup_locked(so);
        }
 }
@@ -1939,7 +1939,7 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct 
tcphdr *th,
                        newsize = tcp_autorcvbuf(m, th, so, tp, tlen);
 
                        /* Add data to socket buffer. */
-                       SOCKBUF_LOCK(&so->so_rcv);
+                       SOCK_RECVBUF_LOCK(so);
                        if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
                                m_freem(m);
                        } else {
@@ -2819,9 +2819,9 @@ enter_recovery:
                                         * is new data available to be sent
                                         * or we need to send an ACK.
                                         */
-                                       SOCKBUF_LOCK(&so->so_snd);
+                                       SOCK_SENDBUF_LOCK(so);
                                        avail = sbavail(&so->so_snd);
-                                       SOCKBUF_UNLOCK(&so->so_snd);
+                                       SOCK_SENDBUF_UNLOCK(so);
                                        if (tp->t_flags & TF_ACKNOW ||
                                            (avail >=
                                             SEQ_SUB(tp->snd_nxt, 
tp->snd_una))) {
@@ -2998,7 +2998,7 @@ process_ACK:
                        tcp_xmit_timer(tp, ticks - tp->t_rtttime);
                }
 
-               SOCKBUF_LOCK(&so->so_snd);
+               SOCK_SENDBUF_LOCK(so);
                /*
                 * Clear t_acktime if remote side has ACKd all data in the
                 * socket buffer and FIN (if applicable).
@@ -3029,7 +3029,7 @@ process_ACK:
                 *    skip rest of ACK processing.
                 */
                if (acked == 0) {
-                       SOCKBUF_UNLOCK(&so->so_snd);
+                       SOCK_SENDBUF_UNLOCK(so);
                        goto step6;
                }
 
@@ -3165,11 +3165,11 @@ step6:
                 * soreceive.  It's hard to imagine someone
                 * actually wanting to send this much urgent data.
                 */
-               SOCKBUF_LOCK(&so->so_rcv);
+               SOCK_RECVBUF_LOCK(so);
                if (th->th_urp + sbavail(&so->so_rcv) > sb_max) {
                        th->th_urp = 0;                 /* XXX */
                        thflags &= ~TH_URG;             /* XXX */
-                       SOCKBUF_UNLOCK(&so->so_rcv);    /* XXX */
+                       SOCK_RECVBUF_UNLOCK(so);        /* XXX */
                        goto dodata;                    /* XXX */
                }
                /*
@@ -3195,7 +3195,7 @@ step6:
                        sohasoutofband(so);
                        tp->t_oobflags &= ~(TCPOOB_HAVEDATA | TCPOOB_HADDATA);
                }
-               SOCKBUF_UNLOCK(&so->so_rcv);
+               SOCK_RECVBUF_UNLOCK(so);
                /*
                 * Remove out of band data so doesn't get presented to user.
                 * This can happen independent of advancing the URG pointer,
@@ -3268,7 +3268,7 @@ dodata:                                                   
/* XXX */
                        thflags = tcp_get_flags(th) & TH_FIN;
                        TCPSTAT_INC(tcps_rcvpack);
                        TCPSTAT_ADD(tcps_rcvbyte, tlen);
-                       SOCKBUF_LOCK(&so->so_rcv);
+                       SOCK_RECVBUF_LOCK(so);
                        if (so->so_rcv.sb_state & SBS_CANTRCVMORE)
                                m_freem(m);
                        else
@@ -3980,7 +3980,7 @@ tcp_mss(struct tcpcb *tp, int offer)
         * if the mss is larger than the socket buffer, decrease the mss.
         */
        so = inp->inp_socket;
-       SOCKBUF_LOCK(&so->so_snd);
+       SOCK_SENDBUF_LOCK(so);
        if ((so->so_snd.sb_hiwat == V_tcp_sendspace) && metrics.rmx_sendpipe)
                bufsize = metrics.rmx_sendpipe;
        else
@@ -3994,7 +3994,7 @@ tcp_mss(struct tcpcb *tp, int offer)
                if (bufsize > so->so_snd.sb_hiwat)
                        (void)sbreserve_locked(so, SO_SND, bufsize, NULL);
        }
-       SOCKBUF_UNLOCK(&so->so_snd);
+       SOCK_SENDBUF_UNLOCK(so);
        /*
         * Sanity check: make sure that maxseg will be large
         * enough to allow some data on segments even if the
@@ -4015,7 +4015,7 @@ tcp_mss(struct tcpcb *tp, int offer)
                tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT;
        }
 
-       SOCKBUF_LOCK(&so->so_rcv);
+       SOCK_RECVBUF_LOCK(so);
        if ((so->so_rcv.sb_hiwat == V_tcp_recvspace) && metrics.rmx_recvpipe)
                bufsize = metrics.rmx_recvpipe;
        else
@@ -4027,7 +4027,7 @@ tcp_mss(struct tcpcb *tp, int offer)
                if (bufsize > so->so_rcv.sb_hiwat)
                        (void)sbreserve_locked(so, SO_RCV, bufsize, NULL);
        }
-       SOCKBUF_UNLOCK(&so->so_rcv);
+       SOCK_RECVBUF_UNLOCK(so);
 
        /* Check the interface for TSO capabilities. */
        if (cap.ifcap & CSUM_TSO) {
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 860b785b631b..8f19885f6b9b 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -359,7 +359,7 @@ after_sack_rexmit:
        if (tp->t_flags & TF_NEEDSYN)
                flags |= TH_SYN;
 
-       SOCKBUF_LOCK(&so->so_snd);
+       SOCK_SENDBUF_LOCK(so);
        /*
         * If in persist timeout with window of 0, send 1 byte.
         * Otherwise, if window is small but nonzero
@@ -752,11 +752,11 @@ dontupdate:
         * No reason to send a segment, just return.
         */
 just_return:
-       SOCKBUF_UNLOCK(&so->so_snd);
+       SOCK_SENDBUF_UNLOCK(so);
        return (0);
 
 send:
-       SOCKBUF_LOCK_ASSERT(&so->so_snd);
+       SOCK_SENDBUF_LOCK_ASSERT(so);
        if (len > 0) {
                if (len >= tp->t_maxseg)
                        tp->t_flags2 |= TF2_PLPMTU_MAXSEGSNT;
@@ -886,7 +886,7 @@ send:
        if (tp->t_port) {
                if (V_tcp_udp_tunneling_port == 0) {
                        /* The port was removed?? */
-                       SOCKBUF_UNLOCK(&so->so_snd);
+                       SOCK_SENDBUF_UNLOCK(so);
                        return (EHOSTUNREACH);
                }
                hdrlen += sizeof(struct udphdr);
@@ -978,7 +978,7 @@ send:
                                 * byte of the payload can be put into the
                                 * TCP segment.
                                 */
-                               SOCKBUF_UNLOCK(&so->so_snd);
+                               SOCK_SENDBUF_UNLOCK(so);
                                error = EMSGSIZE;
                                sack_rxmit = 0;
                                goto out;
@@ -1060,7 +1060,7 @@ send:
                        m = m_gethdr(M_NOWAIT, MT_DATA);
 
                if (m == NULL) {
-                       SOCKBUF_UNLOCK(&so->so_snd);
+                       SOCK_SENDBUF_UNLOCK(so);
                        error = ENOBUFS;
                        sack_rxmit = 0;
                        goto out;
@@ -1103,7 +1103,7 @@ send:
                                tso = 0;
                        }
                        if (m->m_next == NULL) {
-                               SOCKBUF_UNLOCK(&so->so_snd);
+                               SOCK_SENDBUF_UNLOCK(so);
                                (void) m_free(m);
                                error = ENOBUFS;
                                sack_rxmit = 0;
@@ -1120,9 +1120,9 @@ send:
                if (((uint32_t)off + (uint32_t)len == sbused(&so->so_snd)) &&
                    !(flags & TH_SYN))
                        flags |= TH_PUSH;
-               SOCKBUF_UNLOCK(&so->so_snd);
+               SOCK_SENDBUF_UNLOCK(so);
        } else {
-               SOCKBUF_UNLOCK(&so->so_snd);
+               SOCK_SENDBUF_UNLOCK(so);
                if (tp->t_flags & TF_ACKNOW)
                        TCPSTAT_INC(tcps_sndacks);
                else if (flags & (TH_SYN|TH_FIN|TH_RST))
@@ -1147,7 +1147,7 @@ send:
                m->m_data += max_linkhdr;
                m->m_len = hdrlen;
        }
-       SOCKBUF_UNLOCK_ASSERT(&so->so_snd);
+       SOCK_SENDBUF_UNLOCK_ASSERT(so);
        m->m_pkthdr.rcvif = (struct ifnet *)0;
 #ifdef MAC
        mac_inpcb_create_mbuf(inp, m);
@@ -1687,7 +1687,7 @@ timer:
                        if (IN_RECOVERY(tp->t_flags))
                                tp->sackhint.prr_out -= len;
                }
-               SOCKBUF_UNLOCK_ASSERT(&so->so_snd);     /* Check gotos. */
+               SOCK_SENDBUF_UNLOCK_ASSERT(so); /* Check gotos. */
                switch (error) {
                case EACCES:
                case EPERM:
diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c
index 5768d90a9337..5f73e83dc8a9 100644
--- a/sys/netinet/tcp_reass.c
+++ b/sys/netinet/tcp_reass.c
@@ -957,7 +957,7 @@ new_entry:
                flags = tcp_get_flags(th) & TH_FIN;
                TCPSTAT_INC(tcps_rcvoopack);
                TCPSTAT_ADD(tcps_rcvoobyte, *tlenp);
-               SOCKBUF_LOCK(&so->so_rcv);
+               SOCK_RECVBUF_LOCK(so);
                if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
                        m_freem(m);
                } else {
@@ -1058,7 +1058,7 @@ present:
 #endif
                return (0);
        }
-       SOCKBUF_LOCK(&so->so_rcv);
+       SOCK_RECVBUF_LOCK(so);
        do {
                tp->rcv_nxt += q->tqe_len;
                flags = q->tqe_flags & TH_FIN;
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 668d218b34a8..8bf011afe855 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -3346,7 +3346,7 @@ tcp_mtudisc(struct inpcb *inp, int mtuoffer)
        tcp_mss_update(tp, -1, mtuoffer, NULL, NULL);
 
        so = inp->inp_socket;
-       SOCKBUF_LOCK(&so->so_snd);
+       SOCK_SENDBUF_LOCK(so);
        /* If the mss is larger than the socket buffer, decrease the mss. */
        if (so->so_snd.sb_hiwat < tp->t_maxseg) {
                tp->t_maxseg = so->so_snd.sb_hiwat;
@@ -3361,7 +3361,7 @@ tcp_mtudisc(struct inpcb *inp, int mtuoffer)
                        tp->t_flags2 &= ~TF2_PROC_SACK_PROHIBIT;
                }
        }
-       SOCKBUF_UNLOCK(&so->so_snd);
+       SOCK_SENDBUF_UNLOCK(so);
 
        TCPSTAT_INC(tcps_mturesent);
        tp->t_rtttime = 0;
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 8326c67cf085..9a6e80363f0c 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1125,9 +1125,9 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
                /*
                 * XXXRW: PRUS_EOF not implemented with PRUS_OOB?
                 */
-               SOCKBUF_LOCK(&so->so_snd);
+               SOCK_SENDBUF_LOCK(so);
                if (sbspace(&so->so_snd) < -512) {
-                       SOCKBUF_UNLOCK(&so->so_snd);
+                       SOCK_SENDBUF_UNLOCK(so);
                        error = ENOBUFS;
                        goto out;
                }
@@ -1142,7 +1142,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
                if (tp->t_acktime == 0)
                        tp->t_acktime = ticks;
                sbappendstream_locked(&so->so_snd, m, flags);
-               SOCKBUF_UNLOCK(&so->so_snd);
+               SOCK_SENDBUF_UNLOCK(so);
                m = NULL;
                if (nam && tp->t_state < TCPS_SYN_SENT) {
                        /*
@@ -1237,9 +1237,9 @@ tcp_usr_ready(struct socket *so, struct mbuf *m, int 
count)
        }
        tp = intotcpcb(inp);
 
-       SOCKBUF_LOCK(&so->so_snd);
+       SOCK_SENDBUF_LOCK(so);
        error = sbready(&so->so_snd, m, count);
-       SOCKBUF_UNLOCK(&so->so_snd);
+       SOCK_SENDBUF_UNLOCK(so);
        if (error) {
                INP_WUNLOCK(inp);
                return (error);

Reply via email to