From nobody Sun Apr 30 09:45:48 2023 X-Original-To: dev-commits-src-main@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 4Q8M0X59t0z46ZlD; Sun, 30 Apr 2023 09:45:48 +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 4Q8M0X3tz3z43rW; Sun, 30 Apr 2023 09:45:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682847948; 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=8cFdFDWr+URZBqhhggdOCHcBQzcUKGZAbj8az83dD6c=; b=o/XjwvpGWdYGt8jEfHK5+H/XqC+u0vdngaleKxL6mAtoO1Q4ry9ruOJHUL894xudAvr0OC NL00qvGQ57pX+iryIMBm+ZmYVJln04Bmx2E7xH+tQWz1+EE90hpghEZPo93TMPOCt5+3Q0 mn2nFUaVt3av+NaHpiMHOYOmom6naugrw9utY9lNRQvszAtGwF0THLiQkxIeSrsdGPiuJB eit0S4mhjcZZJBhq3G/XWL/wP61mxBLQ0Ic7BtYT05Bwv9zEvu3Pmedg6IpSekrOgmFoqJ Ay88rm01zZXECH0ybdTUc1dIDv9ONvDlF7x/LX2exVAfYq7bcQEeH9/btxa+OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682847948; 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=8cFdFDWr+URZBqhhggdOCHcBQzcUKGZAbj8az83dD6c=; b=QdOiMzFYc63ItTu/EctMBgl7mDilhLpibTtHO3xqRJ9q88dqZRSDtUzW0cwYMpugPVQ2Zw xIaW+35FsMrJJi8Lmlo/VQRsLsnV49pOBQzoIhRUU7SLTykPvbZS3PfjrHmRyUx9ZqH/5K jLhF15vMNR2ww5+WIWxo7Xls4pCKOvmW7p9ZtJT/K7hGiZX03kgBmLqcZ3SWTc/wgfg3wU 4dLSUVown41vl2ETGfyDyuK3HrxHmaKXgf3uAmbLH2Sn4I5MfRaJ+tkf4lbcOQr2+4DnVC aWVK+qfe1TVErhYJXsWtNN5So/gkCUOXn9EhsrfJWi418RaPRekZh3BWU7sPkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682847948; a=rsa-sha256; cv=none; b=cfKmiGBkins++ARUNjNV6H/3jfsHgONvBy11CF0i5LTZAnvRgx1YzJ0tkZ0MLlIRjGgOEa 9ZAZBVhkTJRoYR9HOEG9ooTFGxyqLxwEUQx11zcVc/yikxSejuXPjY73dszRfPIFV0pSth PadCwa0C6RjH0DB+DJjbn3z3AaM/AGnvUonpuD4thsDWbexYR3Qx/llvfxYuTj46I9zz4q Xm4qNjj2URoHJe+dxfpVnzn28aoyLJvGAA9Jjl9jNXkERm3o7M3kuNOZbbRlqD+ZiiwvK/ 5wKFSHQmW/Tm2TA+7Y+ZOTig6iFUUYNpKgbuEBPEy3CQ3iV/1wBLOGi2sRrUWQ== 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 4Q8M0X2yDnzJh7; Sun, 30 Apr 2023 09:45:48 +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 33U9jmTo053454; Sun, 30 Apr 2023 09:45:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33U9jmRb053453; Sun, 30 Apr 2023 09:45:48 GMT (envelope-from git) Date: Sun, 30 Apr 2023 09:45:48 GMT Message-Id: <202304300945.33U9jmRb053453@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: 1f0e13449bee - main - sctp: improve handling of stale cookie error causes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 1f0e13449beef3a983d9ed2faf4734075e4120d1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=1f0e13449beef3a983d9ed2faf4734075e4120d1 commit 1f0e13449beef3a983d9ed2faf4734075e4120d1 Author: Michael Tuexen AuthorDate: 2023-04-30 09:39:32 +0000 Commit: Michael Tuexen CommitDate: 2023-04-30 09:39:32 +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. MFC after: 1 week --- 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 f01c1fe710e4..26abf4953164 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;