From nobody Wed May 03 15:34:02 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 4QBLZz1nqXz48y7n; Wed, 3 May 2023 15:34:03 +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 4QBLZz14Djz462Y; Wed, 3 May 2023 15:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683128043; 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=nXLLHM7qGn5YRdjbLOmeaVWGLXRhZ8S1TRRvvq7VL4I=; b=j8A2SMPLqjQ20TbpF5roqP/MHV66XQOwGWpcaSBT8sK5m9odO/1qL6etpM8aGRS5KaFgUP I2ruQSe9YSskC85H0eFzu75rQgWXeWGgWgAeEsXKfM/PB+R108zcWv/RMUU8DFNOwq/SzB 1lQapGrfPUz7wf4j2o0jx8T4J2clrGgjyvpPD7fnprEOeQ5a5VOCz7dGYNggN4hD7bJoLp XXug2R+FeYiS+IXWcN0newvv3YTIC99C0cKP+Z3DiAswuRbIKcMYKpzLgVKbxgzRFaIBE3 q10bnK1MqSIr/cIkgUshVgTQyIRnmksdzYx1Wz35elJ5S7Wo9mXJBvapUCTNkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683128043; 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=nXLLHM7qGn5YRdjbLOmeaVWGLXRhZ8S1TRRvvq7VL4I=; b=YTTuFRG6k37wmfOCU93gDz4mOYuNGltdx/VHlzg3yb4QKRrjez0dSaUY1Tet6rbnMJhLYk kAXBzEQUyH+cE7nSbX4yrzlIucbDVLSQ2qAA/drI0HzH1mgGgbDGXdttJjuMWd5WaeydJ1 gmpl6ymIq4uKSIHPkSiaza78TaoQR1HYkDUGsNQNMz10OTTvXOefiqNEHq5OdBv2T0cmED L1omGeeAtvHXzoOUApqA7GqoyD+H6rwLpHelbp85ghY7VglRxQSBj/ABBkwXiEcXx7U6Z6 d3VL66qqg750Dyef1Mqp8KGLOcVrmN8zSH1o320MxHHbsCzJD+Wu2L+RuvaYwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683128043; a=rsa-sha256; cv=none; b=xlkpyxXouXuBT6YAhYfZr771eERx866lnYV4TY+7QKoqVbUoFu2rE8Uzg5yRnFZe+78egU DZfYOse7nImYGBcd62c9MwtgDBPt2XkqLZAXBRX6+ajrStKGxzrXlf3wkU9ZPKIPJddvDl tOd2XLM656K74wkaZGco34jiSE2Xrt+CS+ak+OpAzDgbMdklOpgRuUCdqnjRubXgVy8XNr 7Svspe9diHd0vhXRPoFpYvuPL2AytBk2y00aTSliJYonJ4f7FgQ8Bi0iiYFvFB8NfA7ZhS L8th8xEZZyDBRmTamg+/Cfcg/5lPPjFZ0aEG+EopMg7oprbY4s1+pl1ovUDURw== 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 4QBLZz07g2zbRw; Wed, 3 May 2023 15:34:03 +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 343FY2OI074325; Wed, 3 May 2023 15:34:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 343FY2Zu074324; Wed, 3 May 2023 15:34:02 GMT (envelope-from git) Date: Wed, 3 May 2023 15:34:02 GMT Message-Id: <202305031534.343FY2Zu074324@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: d9ae4adff271 - main - sctp: improve shutdown(..., SHUT_WR) handling 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: d9ae4adff2715cfab4a941037ec15aa07108efa1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=d9ae4adff2715cfab4a941037ec15aa07108efa1 commit d9ae4adff2715cfab4a941037ec15aa07108efa1 Author: Michael Tuexen AuthorDate: 2023-05-03 15:30:50 +0000 Commit: Michael Tuexen CommitDate: 2023-05-03 15:33:49 +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. MFC after: 1 week --- 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 26abf4953164..fc362d091a22 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -2782,16 +2782,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); @@ -2815,6 +2812,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 @@ -2850,8 +2862,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) {