From nobody Tue Nov 01 20:33:42 2022 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 4N21vC25jnz4hD2J; Tue, 1 Nov 2022 20:33:43 +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 4N21vB398hz3Dw2; Tue, 1 Nov 2022 20:33:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667334822; 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=UxV8k30Z13yZKQzIXXMWkvOGT7dWOE4QFFEuJ/DDAIo=; b=ApXcVib6ZN7e20rOaSIYf38tQIA9hvaEwB2tWrHIk4FeGKgBCrM2UOOCpUiP8pPcRjL4N0 8C9GaI7UOkQIfYi57gCHMOitls6oZayl17B3i2JLLMIUQwiczY1FP4IKKUJQaG619lyoDs 9NEhkBplSPdiiaQ73b81fdk1NAonAPPOncTnkr+aizt2eqOvj6/tyXr1uf3mCEaqkVnDO+ 0AQzJMmD142DcZbWauuJ5ntooyxmSj2SSSa3YLWTaeiA2PABb05nyrlmMsTISc10+ycI00 H0LJMpwhZzSgGWgTcd7R6tZp4+5BdlMlFpqd4ID3iBN9K1pLoWk/Bo4BCpkAbg== 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 4N21vB1BJtzV8x; Tue, 1 Nov 2022 20:33:42 +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 2A1KXgcE026288; Tue, 1 Nov 2022 20:33:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A1KXgGE026287; Tue, 1 Nov 2022 20:33:42 GMT (envelope-from git) Date: Tue, 1 Nov 2022 20:33:42 GMT Message-Id: <202211012033.2A1KXgGE026287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: dd35207e2025 - releng/13.1 - tcp: finish SACK loss recovery on sudden lack of SACK blocks 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.1 X-Git-Reftype: branch X-Git-Commit: dd35207e2025fd0056417ad4d7846086b09cf059 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667334822; 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=UxV8k30Z13yZKQzIXXMWkvOGT7dWOE4QFFEuJ/DDAIo=; b=lJhCrORGkqBARixQ7NRzvDIRWVOcnGs1o6cDCxHqEbfOf2H+TNg0fMrgYMC3uDKgAS15gw bzhiVc4UCHwWGzzv85i87KiefDSZBL1ltqwxTFGw5XiBQh1fVAsmRTjL26DoGIQDu/rgU9 3B23MmMyCk/vYkP7NV2z2C5NXKK670OTYSyJSaO849xUj3avrRhznLA9m+aJbio6O9jl2Q OUnfIQzkog3Zd19WnTzsX6zqLXVqmvFbxoxiWdiHoAozmiosdKA0ScOKXza6ncJxAf3+dF 24LvDTa5h94wUNUnHcXAsokAud6pFDz2az325abqtFoAIQUAFNpYdP1uzRDAfw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667334822; a=rsa-sha256; cv=none; b=HFWFy6f4liCDfayd5FaaYNxvyyKReLubxX4sFQf5pRTGZ7aV0x+6E3dVzRXCR/hwRL8pgY 9U8afRkod9/xWYeym23YsePUSyrbVZQWVsuBNVU1DtiU0jCsY53y5KG3OWl+MoVRZ5EyPl PqOAaU42nC9PkxK2lJ/x6GQ1PLPIoeDLKHCVCOaHLdosBLv2P8pBA6zx1+mW7L6Gy9US8c VaN6GaukqatSPGOXSInODMexALEzkzm3E796ValSEvUkLqH05ma2Nr0jAjTAD5Ywj2jxbD HNqV06wEL0adthIk+D0v3omVA4OVkVmEBzXhfpRz+ADgmREhn1EED5/UZFdxZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=dd35207e2025fd0056417ad4d7846086b09cf059 commit dd35207e2025fd0056417ad4d7846086b09cf059 Author: Richard Scheffenegger AuthorDate: 2022-08-31 12:49:25 +0000 Commit: Mark Johnston CommitDate: 2022-11-01 13:28:11 +0000 tcp: finish SACK loss recovery on sudden lack of SACK blocks While a receiver should continue sending SACK blocks for the duration of a SACK loss recovery, if for some reason the TCP options no longer contain these SACK blocks, but we already started maintaining the Scoreboard, keep on handling incoming ACKs (without SACK) as belonging to the SACK recovery. Approved by: so Security: FreeBSD-EN-22:25.tcp Reported by: thj Reviewed by: tuexen, #transport MFC after: 2 weeks Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D36046 (cherry picked from commit c21b7b55bea2cc2bf3b420c70a9018e703ed6f00) (cherry picked from commit 2b8ee332b9384596cefc91fead1c294fdd9252b4) --- sys/netinet/tcp_input.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 2c7d15368483..b1846822b207 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -287,6 +287,20 @@ kmod_tcpstat_add(int statnum, int val) counter_u64_add(VNET(tcpstat)[statnum], val); } +/* + * Make sure that we only start a SACK loss recovery when + * receiving a duplicate ACK with a SACK block, and also + * complete SACK loss recovery in case the other end + * reneges. + */ +static bool inline +tcp_is_sack_recovery(struct tcpcb *tp, struct tcpopt *to) +{ + return ((tp->t_flags & TF_SACK_PERMIT) && + ((to->to_flags & TOF_SACK) || + (!TAILQ_EMPTY(&tp->snd_holes)))); +} + #ifdef TCP_HHOOK /* * Wrapper for the TCP established input helper hook. @@ -2525,9 +2539,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, TCPSTAT_INC(tcps_rcvacktoomuch); goto dropafterack; } - if ((tp->t_flags & TF_SACK_PERMIT) && - ((to.to_flags & TOF_SACK) || - !TAILQ_EMPTY(&tp->snd_holes))) + if (tcp_is_sack_recovery(tp, &to)) sack_changed = tcp_sack_doack(tp, &to, th->th_ack); else /* @@ -2597,8 +2609,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, * duplicating packets or a possible DoS attack. */ if (th->th_ack != tp->snd_una || - ((tp->t_flags & TF_SACK_PERMIT) && - (to.to_flags & TOF_SACK) && + (tcp_is_sack_recovery(tp, &to) && !sack_changed)) break; else if (!tcp_timer_active(tp, TT_REXMT)) @@ -2610,8 +2621,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (V_tcp_do_prr && IN_FASTRECOVERY(tp->t_flags)) { tcp_do_prr_ack(tp, th, &to); - } else if ((tp->t_flags & TF_SACK_PERMIT) && - (to.to_flags & TOF_SACK) && + } else if (tcp_is_sack_recovery(tp, &to) && IN_FASTRECOVERY(tp->t_flags)) { int awnd; @@ -2684,8 +2694,7 @@ enter_recovery: * snd_ssthresh is already updated by * cc_cong_signal. */ - if ((tp->t_flags & TF_SACK_PERMIT) && - (to.to_flags & TOF_SACK)) { + if (tcp_is_sack_recovery(tp, &to)) { tp->sackhint.prr_delivered = tp->sackhint.sacked_bytes; } else { @@ -2697,8 +2706,7 @@ enter_recovery: tp->sackhint.recover_fs = max(1, tp->snd_nxt - tp->snd_una); } - if ((tp->t_flags & TF_SACK_PERMIT) && - (to.to_flags & TOF_SACK)) { + if (tcp_is_sack_recovery(tp, &to)) { TCPSTAT_INC( tcps_sack_recovery_episode); tp->snd_recover = tp->snd_nxt; @@ -2790,8 +2798,7 @@ enter_recovery: * from the left side. Such partial ACKs should not be * counted as dupacks here. */ - if ((tp->t_flags & TF_SACK_PERMIT) && - (to.to_flags & TOF_SACK) && + if (tcp_is_sack_recovery(tp, &to) && sack_changed) { tp->t_dupacks++; /* limit overhead by setting maxseg last */ @@ -3973,8 +3980,7 @@ tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to) * (del_data) and an estimate of how many bytes are in the * network. */ - if (((tp->t_flags & TF_SACK_PERMIT) && - (to->to_flags & TOF_SACK)) || + if (tcp_is_sack_recovery(tp, to) || (IN_CONGRECOVERY(tp->t_flags) && !IN_FASTRECOVERY(tp->t_flags))) { del_data = tp->sackhint.delivered_data; @@ -4018,8 +4024,7 @@ tcp_do_prr_ack(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to) * accordingly. */ if (IN_FASTRECOVERY(tp->t_flags)) { - if ((tp->t_flags & TF_SACK_PERMIT) && - (to->to_flags & TOF_SACK)) { + if (tcp_is_sack_recovery(tp, to)) { tp->snd_cwnd = tp->snd_nxt - tp->snd_recover + tp->sackhint.sack_bytes_rexmit + (snd_cnt * maxseg);