From nobody Sun Jun 25 19:37:27 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 4Qq1TN0hC3z4hWhJ; Sun, 25 Jun 2023 19:37:28 +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 4Qq1TN0BCKz3Hm3; Sun, 25 Jun 2023 19:37:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687721848; 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=VEQ7r5TpkRmkfFo/pVIOZQE2ENohmljf8yGYQUJmPWc=; b=scWQsXc19hbPNnpUM4BpeXDeDTJzYO8f1/nC5160LhsgvOtp1W1VZIDHxxoWq/BStUD5VB 5gI0Cni05fsMK84vryKlUEKBXenphO1kgwFVakoyZMadsMsIHZA6jNh4hqb6YWMYh5ApWK nNU2Qbk5dJImO+bHza0voxnsg+uPz5uzCh2wORRL7cwi5bYVDHVfFxubK+sKuF+yZn6JWw HeH3ec/AiOy7MYMGQbfRyQXg6sHb0+D7rE/0zPRGgbxE7wQiYEFjFXVDvuYdPjyA5WhriF TUkSmz92kEWHfPkM0mSRqYwdMAYX5FZGAqWV7ncUvY5oumcjJre5WPjwX68Lxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687721848; 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=VEQ7r5TpkRmkfFo/pVIOZQE2ENohmljf8yGYQUJmPWc=; b=OBP+lhfRfXyqQugUXm/I1wRGhpajnaXJkOPPYu1bvZdLVBy1N+vXBfYIYSe8NlLfyaHT61 2o15bgrskDOxZmaCwnLmJR2T6c+QmoFCOjoib5pOfr1Sxq8PjSsMDdcjMqNDb3Xx3B8jjU H+vbftGxqVeGfCexnMCb4g/ZJnB2kZL8eV3/gt5oP7Z7IggZlRf4VabBFyNu2JJ+1FQIv9 d0ccl8PGvHp8mLeVQWBKS2vWbyLOm4Gv3VV2OO3zsqDqOUgCV2o8yO/ZzIRSutQOve7aFE YrEl33uNivxZ9J54rqR1pu/6BhEEluOL8k+s8YAHj1czmuJrNu2h58xqzAErbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687721848; a=rsa-sha256; cv=none; b=UIj57Q0N+wH6vWHLoMgbRjMsrzAxkxDDm4eGvjaN7nMXbbimmmufvnOam2TQ0GjHDcupiD IUmN18xs+PkA4/fRq7fjvg4BEFyJSQU0vy59N+3/nnPMCRCPP/kaa+AVkDATjfRR1QDh+t Uvz/v7T7X9gQrsxC984lSCQ4p98l0zE98vipWymVGk+1RRcwEWagM63vK1ruLqwP58FJ1c ir/F5BeGNc+e4AI2Uznk4BVAwBA0d1J1vJk2tkD0pMfdqoeMChSZm+Ni6GE01Mz8LLwBXc q6Udq/Lts9T4W9aqzTuPhFYhd6mUyxkCbxcUoS4fWfwohmq2rckLTOVF3NUQkQ== 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 4Qq1TM6JNMzg0c; Sun, 25 Jun 2023 19:37:27 +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 35PJbRP8042046; Sun, 25 Jun 2023 19:37:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35PJbRG8042045; Sun, 25 Jun 2023 19:37:27 GMT (envelope-from git) Date: Sun, 25 Jun 2023 19:37:27 GMT Message-Id: <202306251937.35PJbRG8042045@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: 27de3c310c02 - stable/13 - sctp: improve handling of stale cookie error causes 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: 27de3c310c0211362015ab26ac66c806afcf1b39 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=27de3c310c0211362015ab26ac66c806afcf1b39 commit 27de3c310c0211362015ab26ac66c806afcf1b39 Author: Michael Tuexen AuthorDate: 2023-04-30 09:39:32 +0000 Commit: Michael Tuexen CommitDate: 2023-06-25 19:37:04 +0000 sctp: improve handling of stale cookie error causes * If a measure of staleness of 0 is reported, use the RTT instead. * Ensure that we always send a cookie preservative parameter by rounding up during the calculation. * If allowed, perform a round trip time measurement. * Clear the overall error counter, since the error cause also acts like an ACK. (cherry picked from commit 1f0e13449beef3a983d9ed2faf4734075e4120d1) --- sys/netinet/sctp_input.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 9eeb8f3fbd23..38d57194b02d 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1133,26 +1133,47 @@ sctp_handle_error(struct sctp_chunkhdr *ch, */ if ((cause_length >= sizeof(struct sctp_error_stale_cookie)) && (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) { + struct timeval now; struct sctp_error_stale_cookie *stale_cookie; + uint64_t stale_time; - stale_cookie = (struct sctp_error_stale_cookie *)cause; - /* stable_time is in usec, convert to msec. */ - asoc->cookie_preserve_req = ntohl(stale_cookie->stale_time) / 1000; - /* Double it to be more robust on RTX. */ - asoc->cookie_preserve_req *= 2; asoc->stale_cookie_count++; - if (asoc->stale_cookie_count > - asoc->max_init_times) { + if (asoc->stale_cookie_count > asoc->max_init_times) { sctp_abort_notification(stcb, false, true, 0, NULL, SCTP_SO_NOT_LOCKED); - /* now free the asoc */ (void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC, SCTP_FROM_SCTP_INPUT + SCTP_LOC_12); return (-1); } - /* blast back to INIT state */ + stale_cookie = (struct sctp_error_stale_cookie *)cause; + stale_time = ntohl(stale_cookie->stale_time); + if (stale_time == 0) { + /* Use an RTT as an approximation. */ + (void)SCTP_GETTIME_TIMEVAL(&now); + timevalsub(&now, &asoc->time_entered); + stale_time = (uint64_t)1000000 * (uint64_t)now.tv_sec + (uint64_t)now.tv_usec; + if (stale_time == 0) { + stale_time = 1; + } + } + /* + * stale_time is in usec, convert it to + * msec. Round upwards, to ensure that it is + * non-zero. + */ + stale_time = (stale_time + 999) / 1000; + /* Double it, to be more robust on RTX. */ + stale_time = 2 * stale_time; + asoc->cookie_preserve_req = (uint32_t)stale_time; + if (asoc->overall_error_count == 0) { + sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered, + SCTP_RTT_FROM_NON_DATA); + } + asoc->overall_error_count = 0; + /* Blast back to INIT state */ sctp_toss_old_cookies(stcb, &stcb->asoc); - SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); sctp_stop_all_cookie_timers(stcb); + SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT); + (void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered); sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED); } break;