aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2022-05-14 10:38:43 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2023-02-01 22:56:33 +0000
commita1742f61f4b79c84eb36ab12d83e577f714551d8 (patch)
treea65db6d6f23c94909d5536382a75dad1b50fc090 /sys/netinet
parent33b2501870c7f508b8619850cde575d0a248d42a (diff)
sctp: use sb_avail() when accessing sb_acc for reading
This is a cleanup to simplify a patch for PR 260116. PR: 260116 (cherry picked from commit edc5b6ea881d7e196fee8df7ebcd372f8f5b4469)
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/sctp_indata.c2
-rw-r--r--sys/netinet/sctp_os_bsd.h2
-rw-r--r--sys/netinet/sctp_output.c2
-rw-r--r--sys/netinet/sctp_pcb.c2
-rw-r--r--sys/netinet/sctp_usrreq.c7
-rw-r--r--sys/netinet/sctputil.c30
6 files changed, 23 insertions, 22 deletions
diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c
index 9cbbf69d2421..d3c969bb47b1 100644
--- a/sys/netinet/sctp_indata.c
+++ b/sys/netinet/sctp_indata.c
@@ -1942,7 +1942,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
* When we have NO room in the rwnd we check to make sure
* the reader is doing its job...
*/
- if (stcb->sctp_socket->so_rcv.sb_cc) {
+ if (SCTP_SBAVAIL(&stcb->sctp_socket->so_rcv) > 0) {
/* some to read, wake-up */
sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket);
}
diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h
index faca8a3b6276..8240fca64c48 100644
--- a/sys/netinet/sctp_os_bsd.h
+++ b/sys/netinet/sctp_os_bsd.h
@@ -381,6 +381,8 @@ typedef struct callout sctp_os_timer_t;
#define SCTP_SORESERVE(so, send, recv) soreserve(so, send, recv)
/* wakeup a socket */
#define SCTP_SOWAKEUP(so) wakeup(&(so)->so_timeo)
+/* number of bytes ready to read */
+#define SCTP_SBAVAIL(sb) sbavail(sb)
/* clear the socket buffer state */
#define SCTP_SB_CLEAR(sb) \
(sb).sb_cc = 0; \
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index 306755d659eb..f35bb0bbafc3 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -11517,7 +11517,7 @@ jump_out:
drp->current_onq = htonl(asoc->size_on_reasm_queue +
asoc->size_on_all_streams +
asoc->my_rwnd_control_len +
- stcb->sctp_socket->so_rcv.sb_cc);
+ SCTP_SBAVAIL(&stcb->sctp_socket->so_rcv));
} else {
/*-
* If my rwnd is 0, possibly from mbuf depletion as well as
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index be41276351fe..60aa6f175366 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -3409,7 +3409,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
if ((stcb->asoc.size_on_reasm_queue > 0) ||
(stcb->asoc.control_pdapi) ||
(stcb->asoc.size_on_all_streams > 0) ||
- (so && (so->so_rcv.sb_cc > 0))) {
+ ((so != NULL) && (SCTP_SBAVAIL(&so->so_rcv) > 0))) {
/* Left with Data unread */
struct mbuf *op_err;
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index b6eae2b061d6..78ece9dd4641 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -543,7 +543,7 @@ sctp_close(struct socket *so)
if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) {
inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP;
if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) ||
- (so->so_rcv.sb_cc > 0)) {
+ (SCTP_SBAVAIL(&so->so_rcv) > 0)) {
#ifdef SCTP_LOG_CLOSING
sctp_log_closing(inp, NULL, 13);
#endif
@@ -705,9 +705,8 @@ sctp_disconnect(struct socket *so)
return (0);
}
NET_EPOCH_ENTER(et);
- if (((so->so_options & SO_LINGER) &&
- (so->so_linger == 0)) ||
- (so->so_rcv.sb_cc > 0)) {
+ if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) ||
+ (SCTP_SBAVAIL(&so->so_rcv) > 0)) {
if (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT) {
/* Left with Data unread */
struct mbuf *op_err;
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index 23631e5a20d5..7746740ea6c1 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -76,7 +76,7 @@ sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr)
struct sctp_cwnd_log sctp_clog;
sctp_clog.x.sb.stcb = stcb;
- sctp_clog.x.sb.so_sbcc = sb->sb_cc;
+ sctp_clog.x.sb.so_sbcc = SCTP_SBAVAIL(sb);
if (stcb)
sctp_clog.x.sb.stcb_sbcc = stcb->asoc.sb_cc;
else
@@ -5565,11 +5565,11 @@ sctp_sorecvmsg(struct socket *so,
in_eeor_mode = sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR);
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) {
sctp_misc_ints(SCTP_SORECV_ENTER,
- rwnd_req, in_eeor_mode, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid);
+ rwnd_req, in_eeor_mode, SCTP_SBAVAIL(&so->so_rcv), (uint32_t)uio->uio_resid);
}
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_RECV_RWND_LOGGING_ENABLE) {
sctp_misc_ints(SCTP_SORECV_ENTERPL,
- rwnd_req, block_allowed, so->so_rcv.sb_cc, (uint32_t)uio->uio_resid);
+ rwnd_req, block_allowed, SCTP_SBAVAIL(&so->so_rcv), (uint32_t)uio->uio_resid);
}
error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(in_flags));
@@ -5588,21 +5588,21 @@ restart_nosblocks:
(inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE)) {
goto out;
}
- if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) && (so->so_rcv.sb_cc == 0)) {
+ if ((so->so_rcv.sb_state & SBS_CANTRCVMORE) && SCTP_SBAVAIL(&so->so_rcv) == 0) {
if (so->so_error) {
error = so->so_error;
if ((in_flags & MSG_PEEK) == 0)
so->so_error = 0;
goto out;
} else {
- if (so->so_rcv.sb_cc == 0) {
+ if (SCTP_SBAVAIL(&so->so_rcv) == 0) {
/* indicate EOF */
error = 0;
goto out;
}
}
}
- if (so->so_rcv.sb_cc <= held_length) {
+ if (SCTP_SBAVAIL(&so->so_rcv) <= held_length) {
if (so->so_error) {
error = so->so_error;
if ((in_flags & MSG_PEEK) == 0) {
@@ -5610,7 +5610,7 @@ restart_nosblocks:
}
goto out;
}
- if ((so->so_rcv.sb_cc == 0) &&
+ if ((SCTP_SBAVAIL(&so->so_rcv) == 0) &&
((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_CONNECTED) == 0) {
@@ -5670,7 +5670,7 @@ restart_nosblocks:
SCTP_INP_READ_LOCK(inp);
}
control = TAILQ_FIRST(&inp->read_queue);
- if ((control == NULL) && (so->so_rcv.sb_cc != 0)) {
+ if ((control == NULL) && (SCTP_SBAVAIL(&so->so_rcv) > 0)) {
#ifdef INVARIANTS
panic("Huh, its non zero and nothing on control?");
#endif
@@ -5805,8 +5805,8 @@ restart_nosblocks:
* <or> fragment interleave is NOT on. So stuff the sb_cc
* into the our held count, and its time to sleep again.
*/
- held_length = so->so_rcv.sb_cc;
- control->held_length = so->so_rcv.sb_cc;
+ held_length = SCTP_SBAVAIL(&so->so_rcv);
+ control->held_length = SCTP_SBAVAIL(&so->so_rcv);
goto restart;
}
/* Clear the held length since there is something to read */
@@ -6255,7 +6255,7 @@ wait_some_more:
(sctp_is_feature_on(inp, SCTP_PCB_FLAGS_FRAG_INTERLEAVE))) {
goto release;
}
- if (so->so_rcv.sb_cc <= control->held_length) {
+ if (SCTP_SBAVAIL(&so->so_rcv) <= control->held_length) {
error = sbwait(&so->so_rcv);
if (error) {
goto release;
@@ -6282,8 +6282,8 @@ wait_some_more:
}
goto done_with_control;
}
- if (so->so_rcv.sb_cc > held_length) {
- control->held_length = so->so_rcv.sb_cc;
+ if (SCTP_SBAVAIL(&so->so_rcv) > held_length) {
+ control->held_length = SCTP_SBAVAIL(&so->so_rcv);
held_length = 0;
}
goto wait_some_more;
@@ -6432,13 +6432,13 @@ out:
freed_so_far,
(uint32_t)((uio) ? (slen - uio->uio_resid) : slen),
stcb->asoc.my_rwnd,
- so->so_rcv.sb_cc);
+ SCTP_SBAVAIL(&so->so_rcv));
} else {
sctp_misc_ints(SCTP_SORECV_DONE,
freed_so_far,
(uint32_t)((uio) ? (slen - uio->uio_resid) : slen),
0,
- so->so_rcv.sb_cc);
+ SCTP_SBAVAIL(&so->so_rcv));
}
}
stage_left: