git: f141ff9935fd - stable/13 - sctp: keep sb_acc and sb_ccc in sync
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 11 Jan 2024 12:21:00 UTC
The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=f141ff9935fde0ab9790a7687605bf3e455d1300 commit f141ff9935fde0ab9790a7687605bf3e455d1300 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2023-07-28 13:16:23 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2024-01-11 12:20:06 +0000 sctp: keep sb_acc and sb_ccc in sync PR: 260116 (cherry picked from commit c620788150d274c09a070ab486602c98407d73b0) --- sys/netinet/sctp_os_bsd.h | 18 ++++++++++++------ sys/netinet/sctp_output.c | 2 +- sys/netinet/sctp_pcb.c | 2 +- sys/netinet/sctp_var.h | 4 ++-- sys/netinet/sctputil.c | 4 ++-- sys/netinet/sctputil.h | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index dfa7c906b6b9..01ab8f2823b8 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -370,11 +370,6 @@ typedef struct callout sctp_os_timer_t; #define SCTP_CLEAR_SO_NBIO(so) ((so)->so_state &= ~SS_NBIO) /* get the socket type */ #define SCTP_SO_TYPE(so) ((so)->so_type) -/* Use a macro for renaming sb_cc to sb_acc. - * Initially sb_ccc was used, but this broke select() when used - * with SCTP sockets. - */ -#define sb_cc sb_acc /* reserve sb space for a socket */ #define SCTP_SORESERVE(so, send, recv) soreserve(so, send, recv) /* wakeup a socket */ @@ -382,8 +377,19 @@ typedef struct callout sctp_os_timer_t; /* number of bytes ready to read */ #define SCTP_SBAVAIL(sb) sbavail(sb) /* clear the socket buffer state */ +#define SCTP_SB_INCR(sb, incr) \ +{ \ + atomic_add_int(&(sb)->sb_acc, incr); \ + atomic_add_int(&(sb)->sb_ccc, incr); \ +} +#define SCTP_SB_DECR(sb, decr) \ +{ \ + SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_acc, decr); \ + SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_ccc, decr); \ +} #define SCTP_SB_CLEAR(sb) \ - (sb).sb_cc = 0; \ + (sb).sb_acc = 0; \ + (sb).sb_ccc = 0; \ (sb).sb_mb = NULL; \ (sb).sb_mbcnt = 0; diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 91abe158c5a2..56de9cb860c6 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -7246,7 +7246,7 @@ one_more_time: if ((stcb->sctp_socket != NULL) && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { - atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc, sp->length); + SCTP_SB_DECR(&stcb->sctp_socket->so_snd, sp->length); } if (sp->data) { sctp_m_freem(sp->data); diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index b5c78bb67745..2cb3f6874df9 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -3609,7 +3609,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) TAILQ_REMOVE(&inp->read_queue, sq, next); sctp_free_remote_addr(sq->whoFrom); if (so) - so->so_rcv.sb_cc -= sq->length; + SCTP_SB_DECR(&so->so_rcv, sq->length); if (sq->data) { sctp_m_freem(sq->data); sq->data = NULL; diff --git a/sys/netinet/sctp_var.h b/sys/netinet/sctp_var.h index d9576709909c..144ab77c5dec 100644 --- a/sys/netinet/sctp_var.h +++ b/sys/netinet/sctp_var.h @@ -196,7 +196,7 @@ extern struct pr_usrreqs sctp_usrreqs; } #define sctp_sbfree(ctl, stcb, sb, m) { \ - SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \ + SCTP_SB_DECR(sb, SCTP_BUF_LEN((m))); \ SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \ if (((ctl)->do_not_ref_stcb == 0) && stcb) {\ SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ @@ -208,7 +208,7 @@ extern struct pr_usrreqs sctp_usrreqs; } #define sctp_sballoc(stcb, sb, m) { \ - atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \ + SCTP_SB_INCR(sb, SCTP_BUF_LEN((m))); \ atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ if (stcb) { \ atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \ diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index e34cadd27bc8..0f9c0af623b0 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -5040,7 +5040,7 @@ sctp_free_bufspace(struct sctp_tcb *stcb, struct sctp_association *asoc, if ((stcb->sctp_socket != NULL) && (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) || ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE)))) { - SCTP_SAVE_ATOMIC_DECREMENT(&stcb->sctp_socket->so_snd.sb_cc, tp1->book_size); + SCTP_SB_DECR(&stcb->sctp_socket->so_snd, tp1->book_size); } } @@ -6117,7 +6117,7 @@ get_more_data: if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) { sctp_sblog(&so->so_rcv, control->do_not_ref_stcb ? NULL : stcb, SCTP_LOG_SBFREE, (int)cp_len); } - SCTP_SAVE_ATOMIC_DECREMENT(&so->so_rcv.sb_cc, (int)cp_len); + SCTP_SB_DECR(&so->so_rcv, (int)cp_len); if ((control->do_not_ref_stcb == 0) && stcb) { atomic_subtract_int(&stcb->asoc.sb_cc, (int)cp_len); diff --git a/sys/netinet/sctputil.h b/sys/netinet/sctputil.h index 9026fd09a0be..f0f6d6bccfc7 100644 --- a/sys/netinet/sctputil.h +++ b/sys/netinet/sctputil.h @@ -251,7 +251,7 @@ do { \ } \ if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \ (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \ - SCTP_SAVE_ATOMIC_DECREMENT(&stcb->sctp_socket->so_snd.sb_cc, sp->length); \ + SCTP_SB_DECR(&stcb->sctp_socket->so_snd, sp->length); \ } \ } \ } while (0) @@ -262,7 +262,7 @@ do { \ if ((stcb->sctp_socket != NULL) && \ ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \ (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \ - atomic_add_int(&stcb->sctp_socket->so_snd.sb_cc,sz); \ + SCTP_SB_INCR(&stcb->sctp_socket->so_snd, sz); \ } \ } while (0)