From nobody Fri Jul 28 22:17:28 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RCMSn3nlpz4pt7Z; Fri, 28 Jul 2023 22:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RCMSn2mCCz4T5L; Fri, 28 Jul 2023 22:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690582649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w2Bp233HSBMuPlZ9ZYT1eAV8d/1Hu6QBoox1qW2lK/M=; b=tyN20ZIQhvEtGo43HecSfICY2pSkktZHqV+ULvtcQ5uadH4UaLoGpfmqpz/UP4tQmn/nqR sEWH7+WniTybhaaErHkSVNKUQ4FUR24iarvlPeUY95owjdopsxW6oc40jM8kAid5gwTHUN wJT5oESqInQw4vJKK52MaU/KTtWtKF2LelKH9he6jyXjtiApWkZjvX9q46dm3r3XKiahV6 VisINh3B7MaQLcjQE5X3KDr8hLIzTsY9N1rG8napMISxfWKK2WcEDZfiAzMr1q5i6k7Pve aXqJGg/mjYvVIeEIko0jPspdrC/bReW/R44kZ8UOmc7zriJUwlYjvnzZ+jX25w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690582649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w2Bp233HSBMuPlZ9ZYT1eAV8d/1Hu6QBoox1qW2lK/M=; b=DBYVBkKTAX1/is7smSqBtnnR24ztDG2cGGhx13jkZhVmVOYvZth8WZYzo+MbfYeQ7JbSfv d++S+8FLu0NqyjFfueL79nXbbBVOQ2eQO+KJCi2Nqc3K/Kks7epAHBrM4JYha5OgUbwABA E8VEZ06jq5gNMes/QZtyP1DvZ+KUhn0K+w54vGYKkHVevQss+ztglJ8zFPweb1uFqAE/PJ gOY/en7EhahpeONRHZdVWnMlZayTWtra9BxkUmR/tqhrm4nroNkiDaVHN02WuCAWNi+8BR sMkZfJAyDgdsKGbKST+VXI00EGzctiTEvY0jz5KzmcghlgXOSfseKSpxEVD+Ng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690582649; a=rsa-sha256; cv=none; b=l0SMr3CjOgDrVw1J7hTkywbL4CJbB2SF/oXEfURJPaNY39otQQn7mHkHdb8TSHJqiHLWFb 6b40doqTe9YsE+kSGbrypoVr28zxOjHpQc3z9PnhD8mVbl6g/O/D2q61VVvDXC3nhEf10/ hO7f9kJF2Wq0xtsRmuIg/zPeod2bXsnGerkpgbwYgFS/Ohp388NnpKTJgb5Jk1MfB3agBM aRGQUPPhBHa18jfeYAZRF1iqDsjscIdfHIYDoHeb4OeEdjEABwmKscipawWb920EuhO/5u qxcBzpbNw1hdYePqiB/DpYtqu8qHOMToEhtskGaJA1IxgLNZ+CMPhG/HFzCFoQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RCMSn1SmHz17Ms; Fri, 28 Jul 2023 22:17:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36SMHSZ6073302; Fri, 28 Jul 2023 22:17:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36SMHSJD073301; Fri, 28 Jul 2023 22:17:28 GMT (envelope-from git) Date: Fri, 28 Jul 2023 22:17:28 GMT Message-Id: <202307282217.36SMHSJD073301@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: c620788150d2 - main - sctp: keep sb_acc and sb_ccc in sync List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c620788150d274c09a070ab486602c98407d73b0 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=c620788150d274c09a070ab486602c98407d73b0 commit c620788150d274c09a070ab486602c98407d73b0 Author: Michael Tuexen AuthorDate: 2023-07-28 13:16:23 +0000 Commit: Michael Tuexen CommitDate: 2023-07-28 13:16:23 +0000 sctp: keep sb_acc and sb_ccc in sync PR: 260116 MFC after: 1 week --- 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 80c187b3c5ef..0d88377523c8 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -372,11 +372,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 */ @@ -384,8 +379,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 a146ad401b30..7e32cc662f38 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -7290,7 +7290,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 9df2f82bdaa6..220d8b72667d 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -3612,7 +3612,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 8301ec38cf6e..ef01b0b6c3bd 100644 --- a/sys/netinet/sctp_var.h +++ b/sys/netinet/sctp_var.h @@ -198,7 +198,7 @@ extern struct protosw sctp_seqpacket_protosw, sctp_stream_protosw; } #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))); \ @@ -210,7 +210,7 @@ extern struct protosw sctp_seqpacket_protosw, sctp_stream_protosw; } #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 ef8d763efabf..a4d4e806c00e 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -5044,7 +5044,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); } } @@ -6121,7 +6121,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 60b5661c309c..d74780cdccf7 100644 --- a/sys/netinet/sctputil.h +++ b/sys/netinet/sctputil.h @@ -253,7 +253,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) @@ -264,7 +264,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)