From nobody Tue Feb 22 22:53:29 2022 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 1E53119E7B43; Tue, 22 Feb 2022 22:53:30 +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 4K3Dwn5LTgz3jRd; Tue, 22 Feb 2022 22:53:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645570409; 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=K7BZsS48RIGuWiYC7xzC2uoInkSu5MHD2stGOpwWAnM=; b=AeDKzVZufKgXX5ABiA7d+w3WK7mMk+u5RxXgTxNuumqQOk/oAvnFX6eIjMzBgrZkZBOeRu uXjC+PovoO9ixadS7HaJPi5WM75zfMmh7v1+zcPO1Sp/+yyl13vI/SkVhOrRQd/YuROfsr k40Nhrjs1tomtaS/6s5ymzLYvCdCwuSfO6fYeyPo+q75g3Tkp8G1E5HC+Y/GEN5QR5MI71 oladSzM5n5SqyTDGP3Bg89z66pkaCjCI20+jaIe999htxlubx1zEhU2NimQXOwpxgRO77/ FarGYW5ItDitViI1m7C7YRpzURnvbeIfPQ0KjNxFk+meNQo1Aw6ThqQlGX0uSQ== 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 374BF4F72; Tue, 22 Feb 2022 22:53:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21MMrTvf069355; Tue, 22 Feb 2022 22:53:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MMrTtR069354; Tue, 22 Feb 2022 22:53:29 GMT (envelope-from git) Date: Tue, 22 Feb 2022 22:53:29 GMT Message-Id: <202202222253.21MMrTtR069354@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 1df7036fdd48 - stable/13 - sctp: improve consistency when calling stream scheduler 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 1df7036fdd48057885b50233f80b6050204aa91f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645570409; 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=K7BZsS48RIGuWiYC7xzC2uoInkSu5MHD2stGOpwWAnM=; b=K8AsebURPjnFHepXxKsM1sV80dtuydOmXqXMr5uI9alH9iCLj2N2V2gWfu01MhkFn60kJ3 ZmExPuiSmsHmV2B1XjuvfdVRxB0hw5UEK+ofeLGkb8U/zWJOAvbKwgdLeOs34BhtUbQPKL PGWb6FnVHQ+wgEyRharMrpoJ4pgwQ1lUHlIzMU3uOXyRlBnyv7p5LkqMQBFAxNCZ2MxcFO Tvdhz6MiNGq2r08eI92I+SHCXcYbdghhHuD9wcez08JjZu2jXBRLLmXy46fSl2USFf9DTp hGKeHfySztHg3+xt6SeZ09w/lHWOhX9QHun5Xmj8JXi/uDzZPIAEjBnBZrb+aQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645570409; a=rsa-sha256; cv=none; b=ugUx2UyXiQP0ryK/E9KGnshNTKzwA/FAL3SuhAtMoZEMt3FPY8yVPqRJ/w2wwUb5NQ5xp9 X6eaSuhO9dlpU7DwDFp6yHiGcaVk6AWvO+fG+aeBxs0rYVnUWd4/RN6CrOtgpVC17FPg2M xbCZO9jjuEEFfFKjqULa794wx3uDNoZM3d9yupmmHYnni7/LXzYj2dLXUMtI3gvqKCaJFE zE0RoPkfx1j/zt55iLByyX+v4Uy4QhKrvKS7itPgL86/bMkTpestiD7mW/paBFjvmoSlPA cqn9j6C+EVbFgziE4MMGs9dd+gKhlRY9eLHpvQ5xS2t19++d09etck0f67iefg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=1df7036fdd48057885b50233f80b6050204aa91f commit 1df7036fdd48057885b50233f80b6050204aa91f Author: Michael Tuexen AuthorDate: 2021-09-20 22:54:13 +0000 Commit: Michael Tuexen CommitDate: 2022-02-22 22:53:07 +0000 sctp: improve consistency when calling stream scheduler Hold always the stcb send lock when calling sctp_ss_init() and sctp_ss_remove_from_stream(). (cherry picked from commit 0b79a76f848768068d409edcb36f2a58cdd17e61) --- sys/netinet/sctp_output.c | 8 ++++---- sys/netinet/sctp_timer.c | 17 +++++++++-------- sys/netinet/sctputil.c | 4 +++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 80d4b8c52773..dbb62343c355 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -7207,13 +7207,13 @@ one_more_time: sp->put_last_out, send_lock_up); } - if ((TAILQ_NEXT(sp, next) == NULL) && (send_lock_up == 0)) { + if (send_lock_up == 0) { SCTP_TCB_SEND_LOCK(stcb); send_lock_up = 1; } atomic_subtract_int(&asoc->stream_queue_cnt, 1); TAILQ_REMOVE(&strq->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp, send_lock_up); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp, 1); if ((strq->state == SCTP_STREAM_RESET_PENDING) && (strq->chunks_on_queues == 0) && TAILQ_EMPTY(&strq->outqueue)) { @@ -7638,13 +7638,13 @@ dont_do_it: sp->put_last_out, send_lock_up); } - if ((send_lock_up == 0) && (TAILQ_NEXT(sp, next) == NULL)) { + if (send_lock_up == 0) { SCTP_TCB_SEND_LOCK(stcb); send_lock_up = 1; } atomic_subtract_int(&asoc->stream_queue_cnt, 1); TAILQ_REMOVE(&strq->outqueue, sp, next); - stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp, send_lock_up); + stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, strq, sp, 1); if ((strq->state == SCTP_STREAM_RESET_PENDING) && (strq->chunks_on_queues == 0) && TAILQ_EMPTY(&strq->outqueue)) { diff --git a/sys/netinet/sctp_timer.c b/sys/netinet/sctp_timer.c index e657bc280ccc..72a0a2c32c88 100644 --- a/sys/netinet/sctp_timer.c +++ b/sys/netinet/sctp_timer.c @@ -1344,18 +1344,18 @@ sctp_shutdownack_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, } static void -sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, - struct sctp_tcb *stcb) +sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, struct sctp_tcb *stcb) { struct sctp_stream_queue_pending *sp; unsigned int i, chks_in_queue = 0; int being_filled = 0; - /* - * This function is ONLY called when the send/sent queues are empty. - */ - if ((stcb == NULL) || (inp == NULL)) - return; + KASSERT(inp != NULL, ("inp is NULL")); + KASSERT(stcb != NULL, ("stcb is NULL")); + + SCTP_TCB_SEND_LOCK(stcb); + KASSERT(TAILQ_EMPTY(&stcb->asoc.send_queue), ("send_queue not empty")); + KASSERT(TAILQ_EMPTY(&stcb->asoc.sent_queue), ("sent_queue not empty")); if (stcb->asoc.sent_queue_retran_cnt) { SCTP_PRINTF("Hmm, sent_queue_retran_cnt is non-zero %d\n", @@ -1364,7 +1364,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, } if (stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) { /* No stream scheduler information, initialize scheduler */ - stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 0); + stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1); if (!stcb->asoc.ss_functions.sctp_ss_is_empty(stcb, &stcb->asoc)) { /* yep, we lost a stream or two */ SCTP_PRINTF("Found additional streams NOT managed by scheduler, corrected\n"); @@ -1406,6 +1406,7 @@ sctp_audit_stream_queues_for_size(struct sctp_inpcb *inp, (u_long)stcb->asoc.total_output_queue_size); stcb->asoc.total_output_queue_size = 0; } + SCTP_TCB_SEND_UNLOCK(stcb); } int diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 4ec801ce25d7..68bb65b525cf 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -1288,6 +1288,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ENOMEM); return (ENOMEM); } + SCTP_TCB_SEND_LOCK(stcb); for (i = 0; i < asoc->streamoutcnt; i++) { /* * inbound side must be set to 0xffff, also NOTE when we get @@ -1315,7 +1316,8 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, asoc->strmout[i].last_msg_incomplete = 0; asoc->strmout[i].state = SCTP_STREAM_OPENING; } - asoc->ss_functions.sctp_ss_init(stcb, asoc, 0); + asoc->ss_functions.sctp_ss_init(stcb, asoc, 1); + SCTP_TCB_SEND_UNLOCK(stcb); /* Now the mapping array */ asoc->mapping_array_size = SCTP_INITIAL_MAPPING_ARRAY;