From nobody Sun Jun 25 19:39:10 2023 X-Original-To: dev-commits-src-branches@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 4Qq1WM0MPTz4hYDq; Sun, 25 Jun 2023 19:39:11 +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 4Qq1WL72DKz3Jgh; Sun, 25 Jun 2023 19:39:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687721951; 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=o3jiwNSfzWocEsotg711GsjElwYpcKxPGMD6CL4hUtw=; b=X7kg8c1+ispX4bUb5F2nkQ7nU95l0CSC+BqUienFwscgCu+bW9x9py0JbKcGVC68WFjdBs dHSa8RyDNVWrjVR0T+3gk7Q1JohiS1xPITrUTZzbB1vfgMPcdFZgl7IFaoFvJcA3dONsup biJ4YryW38mEIiJtbUT4Z74Hxh19ZufhwkOD0ZSqUmvywwvb0TJkmoIPqxEo2KegHDEL4+ qwigg+iIUo9koBaTelLHlrcPcHnYesONhsfHvrRDPbBeIBAG0dOVnzY8AaANRBMJAyotwh cRvZOU/+oPhqqqbzhvhG/08+fkjHIyk/UHY9UHJtmhtwnz1KyPZ+IQOPNsXz2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687721951; 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=o3jiwNSfzWocEsotg711GsjElwYpcKxPGMD6CL4hUtw=; b=A+FC057VQrkgo/zYoa07KMmeKAFP6KBCVloAbBzDpoe+qvGMkUrvb74gFD+AveXXPvf2Bo 9jOjZUsWFMuukut5gHNK7XyJ/piKs8tW7RnlbIwC8Yx5+o2VHhMHILKh5VSguuTNUu+H2/ OtuXjDVilxSkj06EobIew2agkCSLKHe062//IlcRyj/YEhImnSlTYmsZlxHFunBQT/mSKp AzhdD4IE0wY0JVejQXSqdij3aXSMTtbYJi0y82ZsePZhQ+F9nEcEG54I8uQ4JscPs3lZlD ocDkIxEo62y7JabVM5uSvqqozjDY5aV/8ai3FQafc2Rntg/vRmkE1QFhhnvpvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687721951; a=rsa-sha256; cv=none; b=qOFbGdLlN0gvJKPDlxi6eD1wi8/mye6mwdWO6eqd/UHV6OEVtPFj+ssGpFU8HycIntQZqG 9yyyzgbz9y7z2dA0okYct91gUpOuCgdxbtLGmgaLembfK5GyEM9DKUGfCX3xuF9Z2+L8Cr z3YgH0lPZgJhcQWkoMAHjzYu1XRz+7dlsgI0DgiZIZT6tXYslt1ysvm852O1MRM5ur/e3E dYP7h860vOD2zKWRLnrEhp9zLmwkBFaPS/B6hRVkoJ2K0lTc6uXDQ24pYozECtE9TtOlCz c8nFbhctyAQUdDPqNHf1Q/PudzU82Ac7w1LghAg/Hu112CYjGysUYGllxKaBLg== 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 4Qq1WL67sszfsC; Sun, 25 Jun 2023 19:39:10 +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 35PJdAXQ042375; Sun, 25 Jun 2023 19:39:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35PJdARW042374; Sun, 25 Jun 2023 19:39:10 GMT (envelope-from git) Date: Sun, 25 Jun 2023 19:39:10 GMT Message-Id: <202306251939.35PJdARW042374@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: 6b218e45a9ca - stable/13 - sctp: improve shutdown(..., SHUT_WR) handling List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: 6b218e45a9ca4759e9693ed7c3579567f522e7ba Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=6b218e45a9ca4759e9693ed7c3579567f522e7ba commit 6b218e45a9ca4759e9693ed7c3579567f522e7ba Author: Michael Tuexen AuthorDate: 2023-05-03 15:30:50 +0000 Commit: Michael Tuexen CommitDate: 2023-06-25 19:37:50 +0000 sctp: improve shutdown(..., SHUT_WR) handling When shutdown(..., SHUT_WR) is called in the front states, send a SHUTDOWN chunk when a COOKIE ACK chunk is received and there is no outstanding data. (cherry picked from commit d9ae4adff2715cfab4a941037ec15aa07108efa1) --- sys/netinet/sctp_input.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 38d57194b02d..61c248b1efdb 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -2780,16 +2780,13 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, __LINE__); } sctp_stop_all_cookie_timers(stcb); + sctp_toss_old_cookies(stcb, asoc); /* process according to association state */ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) { /* state change only needed when I am in right state */ SCTPDBG(SCTP_DEBUG_INPUT2, "moving to OPEN state\n"); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); sctp_start_net_timers(stcb); - if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, NULL); - } /* update RTO */ SCTP_STAT_INCR_COUNTER32(sctps_activeestab); SCTP_STAT_INCR_GAUGE32(sctps_currestab); @@ -2813,6 +2810,21 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, } } + if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) && + TAILQ_EMPTY(&asoc->send_queue) && + TAILQ_EMPTY(&asoc->sent_queue) && + (asoc->stream_queue_cnt == 0)) { + SCTP_STAT_DECR_GAUGE32(sctps_currestab); + SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT); + sctp_stop_timers_for_shutdown(stcb); + sctp_send_shutdown(stcb, net); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, + stcb->sctp_ep, stcb, net); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, + stcb->sctp_ep, stcb, NULL); + sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); + } + if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) { /* * We don't need to do the asconf thing, nor hb or @@ -2848,8 +2860,6 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED, } } closed_socket: - /* Toss the cookie if I can */ - sctp_toss_old_cookies(stcb, asoc); /* Restart the timer if we have pending data */ TAILQ_FOREACH(chk, &asoc->sent_queue, sctp_next) { if (chk->whoTo != NULL) {