From patchwork Tue Oct 15 10:28:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836071 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2081.outbound.protection.outlook.com [40.107.105.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C25F61E3798 for ; Tue, 15 Oct 2024 10:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988224; cv=fail; b=oKRBqkQgPzicBT6uweGyrt//J2ABb/qVxJs9EeebrPun/Buoc4FyBhToVY6bHdzrsieoVz51HqDt+OrFrr/DLqCh8kxOx2cFBFCVw9KjgjBGzrL0x17+/3/9d3pYbPUoidblA1fthHauSOUN2eJRidNI6Rqrm8vjYCi8tTL3dtw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988224; c=relaxed/simple; bh=cQhHdn667mNhxJy0DNFxLCqexzVwV4UNDewEZBRQUzg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=qpRM95cn5JkwlkyQA8xlTYrOgPFeEp4EjX5cPzSdhbHAW7FZK7HZS1fc/UPCHefEO+p8UsaIsT0mpq0pLJxNLpgVpXRgyr7NWS0PtV2Ak/YzllNfxKq9NG5xU/ElbrO+LUIKnuvrwjErHw3ctqgXjs/OQdjlt1z+3kUJ/22Mvv8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=Uin/V8j1; arc=fail smtp.client-ip=40.107.105.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="Uin/V8j1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XA9gVVbVXy4YLWT8xtI0FnkFZkjpWqZKroiyZfsCWiTO0r3n/Q05fJeOJ21A+qjOHgW94SAelSL6UNMESxPkTbrCXipN42aUat/IU3+AkjCduXtQj63ZUluKZ7ZFX8P5571TJML0kNrSu9u9tKyWlrWEwruY0NFbfAME14VFnz0G4K73/UM3s+LdUhx+HGbAGEMxNgTPeaoiuSaiTx1n4nwPhpu4s7mKrfnFXTJwt6Fb+nRvTZI04a5g+kxOSJbPzlNOf4Nkgi1c1JtIJO7UWh3soWkatXvPKu91wJteVy0uwQDXBTCW/0ZUJecdlg0deYwwl0IIsHURj3KTE2Q1Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=97pAqxalwiS82lrBpGsX+n/GgkiCvMAVijlnJp6pKjs=; b=JpuxnOOKfvvwFCtK21t7G7LueymmIh8WC9hjyh3jiHNZoE6NtDXcS0PxSY1ep5CYSB7SxLIbTqQJfvID0Yu9GBBRZCbLS75CPindqW94O8DcLfgEHZaeqbniCuQ10RXDKsQz2zgT2WhIB0k5ZuNV6Q3PokRvKQJgR8vCObO8Q5LSa9nq3O08GyqsD/FcXxUfZCFEeV4tDZW3PlSNcFlP/CAq+f0F5ToqlTxXnXAq8DfZhGkdAeyyAqZuvKh5KuTfMLzquBvf77e9rrxUBdypbnAnIH9Jh8hAWAK3dvX7ANcWO3gd58LLmtEM0lypkuxZAdeis4cOwoOhMZCq6O+BpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=97pAqxalwiS82lrBpGsX+n/GgkiCvMAVijlnJp6pKjs=; b=Uin/V8j14OezYymC+xu0yN58L5/IfqIBx3M0S0/1jTd6WQoVpy0NBeuYGGDnvC1YY2A0Hmn83TZExzyYuJNOkj5AcFKwI82xR60TzfwjCKxX1/PmOE8728Izu/k7dKyh/nRb5DJBc8MiwA4FKcueJVgqw4U/X+4JLDyFpwoVr7fFQ8gwHWyzmmOQwjHZBKAfxwZNhAYLieUWxNFZpkRVpLmZnBZNzlejYieo4YcrYRsm7DBgn57j9Hlp/r9kj0G+QiGqtMW70dHaigvORTk6loS7ESIzGxj5Qd8nHKTZGA1NjdK78GPUcydYQxBS371wb5p4vei9F8F2I1mGNvRzmA== Received: from AS9PR06CA0001.eurprd06.prod.outlook.com (2603:10a6:20b:462::31) by AS4PR07MB8558.eurprd07.prod.outlook.com (2603:10a6:20b:4f9::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:14 +0000 Received: from AMS0EPF0000019A.eurprd05.prod.outlook.com (2603:10a6:20b:462:cafe::8a) by AS9PR06CA0001.outlook.office365.com (2603:10a6:20b:462::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF0000019A.mail.protection.outlook.com (10.167.16.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtn5029578; Tue, 15 Oct 2024 10:30:11 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Olga Albisser , Olivier Tilmans , Henrik Steen , Bob Briscoe , Chia-Yu Chang Subject: [PATCH net-next 01/44] sched: Add dualpi2 qdisc Date: Tue, 15 Oct 2024 12:28:57 +0200 Message-Id: <20241015102940.26157-2-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019A:EE_|AS4PR07MB8558:EE_ X-MS-Office365-Filtering-Correlation-Id: fede6535-48cc-477a-3a12-08dced045afa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?a+z+PwvoEWhmFmN2WH67fQ5BnQzNWjL?= =?utf-8?q?UFq+z7PUt4l1jQXmvtpHOeeN8kzUnlmZLMiekv+GBeApFtd8eZdwArVXRg3QcroSj?= =?utf-8?q?XEq0rlRCf5yXn2k5P1PuNrDaBvIR8kfPcE+gDoScLwKaAHOV0JToo7vzf1VlVdsZ5?= =?utf-8?q?Awi2zUb4fc/hKLHXzrR4481nPSSZ+DCDe5eNuT99wJY4/a3R1A1Zck3h4KlovNLl+?= =?utf-8?q?3OtTeAMd6qW5KO8nCByZ+8Mw9wlh1U1HPdsfrHXplpWJn6CUSKHLFQIkpT9o2m0TA?= =?utf-8?q?a83bJGKzN2SpcsslG9N0/Fbb6aaexZ5/plW1viorBuG4yIWRPNJdddluCKsMhuGH9?= =?utf-8?q?Mv8S99Ta1EdUlWkD9QSLD8ErvfvKLmOgrG5koGsXIWUn/Uwn/PdDD63I17Wcm4Tbx?= =?utf-8?q?f7uJ3TRfp/r+Rfr5Cc2INg89yRueegWuwgbb/0VkEqZYCo2zrmslUdHzzWRN0Lfer?= =?utf-8?q?7GHre9Aj92Nf1CqfZGMA5PyWExpNr5Eqt59icbpUF9dtsuomQRqamIvjkiKKHyI9p?= =?utf-8?q?0DBo00vU9cMi0Zrxwck6frm/zln43u4qPQxVqE3sW3Ic5h0IL4XkM/uQvQVAElSvz?= =?utf-8?q?TLmY+ONWtcjJcbywry5K5nHw4TOhMtL0S2FaQmHn9/b1XeS8YjtG+3WcunGLNpJjp?= =?utf-8?q?iXsMKKhP7nZDfB4/P5OscsGC+6vDhlPtcKnxWKAg1Zqpu8oMWUPRcLLCOIugrkxLe?= =?utf-8?q?5T5L2Qk7etYaduqPtNg/LC3TVJmRoZj5OormX8+U6vLEvohzoWUtNtSTC4+g/GbmQ?= =?utf-8?q?bOrI8Nok/qxmQ/uHVJu3tDLdm0OjlkBSXUmWyJPWeNLsGVo36O7P4cx3UPDQG9AGj?= =?utf-8?q?7DKa9PkM9+XpWkaR6i38qRLkyRyGokyncES/05+9avxe55anZa5yi1suexOquMLCo?= =?utf-8?q?CSoQKrPN8T3S4o7ftpcAk7MnPr4WF2lI2nvnDPOz6ypDARxhwiQlIWmCYy4K5OWcj?= =?utf-8?q?CybGgqGYWk1EVnHyxHS+SovVYndoeDNlffKsFPmcAucJBDXeQHErsqt1pVhSbdj4P?= =?utf-8?q?8AlDwXOsjeKhHGT8XoUm2Hs6I7M8FyGIUbXR87XJy4I7posaCuS++0x05nl3O8+H3?= =?utf-8?q?JVGftXiNDlgTwebjpZXcyf8K8G5uM+YIaaB/C+6HyEWtvkI7HUISLZ5Iaz/relREv?= =?utf-8?q?+kyecdPcFoO+CQ2DgMiPCq68tPuTtnXkGuPgzBewgMLmGjQ+XHWpsmHWbxwFYLJHZ?= =?utf-8?q?7rfOQIMWOMkSGb0WcDmNt4wdRyFyt5IUJ2jGG+47DkjIh3vivMKDS+/tWlmbzgujv?= =?utf-8?q?Bt/arbklcj4UF58AWLDJOX5wsFF8TEGoWBEbYRpuQ+sXTDX87v3gUN5PHf6L9w7EQ?= =?utf-8?q?wU+TGIhevLOrvNNfRLsE6FN6KOYMbvuqrA=3D=3D?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:14.0518 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fede6535-48cc-477a-3a12-08dced045afa X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF0000019A.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR07MB8558 X-Patchwork-Delegate: kuba@kernel.org From: Koen De Schepper DualPI2 provides L4S-type low latency & loss to traffic that uses a scalable congestion controller (e.g. TCP-Prague, DCTCP) without degrading the performance of 'classic' traffic (e.g. Reno, Cubic etc.). It is intended to be the reference implementation of the IETF's DualQ Coupled AQM. The qdisc provides two queues called low latency and classic. It classifies packets based on the ECN field in the IP headers. By default it directs non-ECN and ECT(0) into the classic queue and ECT(1) and CE into the low latency queue, as per the IETF spec. Each queue runs its own AQM: * The classic AQM is called PI2, which is similar to the PIE AQM but more responsive and simpler. Classic traffic requires a decent target queue (default 15ms for Internet deployment) to fully utilize the link and to avoid high drop rates. * The low latency AQM is, by default, a very shallow ECN marking threshold (1ms) similar to that used for DCTCP. The DualQ isolates the low queuing delay of the Low Latency queue from the larger delay of the 'Classic' queue. However, from a bandwidth perspective, flows in either queue will share out the link capacity as if there was just a single queue. This bandwidth pooling effect is achieved by coupling together the drop and ECN-marking probabilities of the two AQMs. The PI2 AQM has two main parameters in addition to its target delay. All the defaults are suitable for any Internet setting, but it can be reconfigured for a Data Centre setting. The integral gain factor alpha is used to slowly correct any persistent standing queue error from the target delay, while the proportional gain factor beta is used to quickly compensate for queue changes (growth or shrinkage). Either alpha and beta are given as a parameter, or they can be calculated by tc from alternative typical and maximum RTT parameters. Internally, the output of a linear Proportional Integral (PI) controller is used for both queues. This output is squared to calculate the drop or ECN-marking probability of the classic queue. This counterbalances the square-root rate equation of Reno/Cubic, which is the trick that balances flow rates across the queues. For the ECN-marking probability of the low latency queue, the output of the base AQM is multiplied by a coupling factor. This determines the balance between the flow rates in each queue. The default setting makes the flow rates roughly equal, which should be generally applicable. If DUALPI2 AQM has detected overload (due to excessive non-responsive traffic in either queue), it will switch to signaling congestion solely using drop, irrespective of the ECN field. Alternatively, it can be configured to limit the drop probability and let the queue grow and eventually overflow (like tail-drop). Additional details can be found in the draft: https://datatracker.ietf.org/doc/html/rfc9332 Signed-off-by: Koen De Schepper Co-developed-by: Olga Albisser Signed-off-by: Olga Albisser Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Co-developed-by: Henrik Steen Signed-off-by: Henrik Steen Signed-off-by: Bob Briscoe Signed-off-by: Ilpo Järvinen Co-developed-by: Chia-Yu Chang Signed-off-by: Chia-Yu Chang --- include/linux/netdevice.h | 1 + include/uapi/linux/pkt_sched.h | 34 ++ net/sched/Kconfig | 20 + net/sched/Makefile | 1 + net/sched/sch_dualpi2.c | 1046 ++++++++++++++++++++++++++++++++ 5 files changed, 1102 insertions(+) create mode 100644 net/sched/sch_dualpi2.c diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8feaca12655e..bdd7d6262112 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -30,6 +30,7 @@ #include #include +#include #include #include #include diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index 25a9a47001cd..f2418eabdcb1 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -1210,4 +1210,38 @@ enum { #define TCA_ETS_MAX (__TCA_ETS_MAX - 1) +/* DUALPI2 */ +enum { + TCA_DUALPI2_UNSPEC, + TCA_DUALPI2_LIMIT, /* Packets */ + TCA_DUALPI2_TARGET, /* us */ + TCA_DUALPI2_TUPDATE, /* us */ + TCA_DUALPI2_ALPHA, /* Hz scaled up by 256 */ + TCA_DUALPI2_BETA, /* HZ scaled up by 256 */ + TCA_DUALPI2_STEP_THRESH, /* Packets or us */ + TCA_DUALPI2_STEP_PACKETS, /* Whether STEP_THRESH is in packets */ + TCA_DUALPI2_COUPLING, /* Coupling factor between queues */ + TCA_DUALPI2_DROP_OVERLOAD, /* Whether to drop on overload */ + TCA_DUALPI2_DROP_EARLY, /* Whether to drop on enqueue */ + TCA_DUALPI2_C_PROTECTION, /* Percentage */ + TCA_DUALPI2_ECN_MASK, /* L4S queue classification mask */ + TCA_DUALPI2_SPLIT_GSO, /* Split GSO packets at enqueue */ + TCA_DUALPI2_PAD, + __TCA_DUALPI2_MAX +}; + +#define TCA_DUALPI2_MAX (__TCA_DUALPI2_MAX - 1) + +struct tc_dualpi2_xstats { + __u32 prob; /* current probability */ + __u32 delay_c; /* current delay in C queue */ + __u32 delay_l; /* current delay in L queue */ + __s32 credit; /* current c_protection credit */ + __u32 packets_in_c; /* number of packets enqueued in C queue */ + __u32 packets_in_l; /* number of packets enqueued in L queue */ + __u32 maxq; /* maximum queue size */ + __u32 ecn_mark; /* packets marked with ecn*/ + __u32 step_marks; /* ECN marks due to the step AQM */ +}; + #endif diff --git a/net/sched/Kconfig b/net/sched/Kconfig index 8180d0c12fce..c1421e219040 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig @@ -403,6 +403,26 @@ config NET_SCH_ETS If unsure, say N. +config NET_SCH_DUALPI2 + tristate "Dual Queue Proportional Integral Controller Improved with a Square (DUALPI2) scheduler" + help + Say Y here if you want to use the DualPI2 AQM. + This is a combination of the DUALQ Coupled-AQM with a PI2 base-AQM. + The PI2 AQM is in turn both an extension and a simplification of the + PIE AQM. PI2 makes quite some PIE heuristics unnecessary, while being + able to control scalable congestion controls like DCTCP and + TCP-Prague. With PI2, both Reno/Cubic can be used in parallel with + DCTCP, maintaining window fairness. DUALQ provides latency separation + between low latency DCTCP flows and Reno/Cubic flows that need a + bigger queue. + For more information, please see + https://datatracker.ietf.org/doc/html/rfc9332 + + To compile this code as a module, choose M here: the module + will be called sch_dualpi2. + + If unsure, say N. + menuconfig NET_SCH_DEFAULT bool "Allow override default queue discipline" help diff --git a/net/sched/Makefile b/net/sched/Makefile index 82c3f78ca486..1abb06554057 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile @@ -62,6 +62,7 @@ obj-$(CONFIG_NET_SCH_FQ_PIE) += sch_fq_pie.o obj-$(CONFIG_NET_SCH_CBS) += sch_cbs.o obj-$(CONFIG_NET_SCH_ETF) += sch_etf.o obj-$(CONFIG_NET_SCH_TAPRIO) += sch_taprio.o +obj-$(CONFIG_NET_SCH_DUALPI2) += sch_dualpi2.o obj-$(CONFIG_NET_CLS_U32) += cls_u32.o obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o diff --git a/net/sched/sch_dualpi2.c b/net/sched/sch_dualpi2.c new file mode 100644 index 000000000000..18e8934faa4e --- /dev/null +++ b/net/sched/sch_dualpi2.c @@ -0,0 +1,1046 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2024 Nokia + * + * Author: Koen De Schepper + * Author: Olga Albisser + * Author: Henrik Steen + * Author: Olivier Tilmans + * Author: Chia-Yu Chang + * + * DualPI Improved with a Square (dualpi2): + * - Supports congestion controls that comply with the Prague requirements + * in RFC9331 (e.g. TCP-Prague) + * - Supports coupled dual-queue with PI2 as defined in RFC9332 + * - Supports ECN L4S-identifier (IP.ECN==0b*1) + * + * note: DCTCP is not Prague compliant, so DCTCP & DualPI2 can only be + * used in DC context; BBRv3 (overwrites bbr) stopped Prague support, + * you should use TCP-Prague instead for low latency apps + * + * References: + * - RFC9332: https://datatracker.ietf.org/doc/html/rfc9332 + * - De Schepper, Koen, et al. "PI 2: A linearized AQM for both classic and + * scalable TCP." in proc. ACM CoNEXT'16, 2016. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* 32b enable to support flows with windows up to ~8.6 * 1e9 packets + * i.e., twice the maximal snd_cwnd. + * MAX_PROB must be consistent with the RNG in dualpi2_roll(). + */ +#define MAX_PROB U32_MAX +/* alpha/beta values exchanged over netlink are in units of 256ns */ +#define ALPHA_BETA_SHIFT 8 +/* Scaled values of alpha/beta must fit in 32b to avoid overflow in later + * computations. Consequently (see and dualpi2_scale_alpha_beta()), their + * netlink-provided values can use at most 31b, i.e. be at most (2^23)-1 + * (~4MHz) as those are given in 1/256th. This enable to tune alpha/beta to + * control flows whose maximal RTTs can be in usec up to few secs. + */ +#define ALPHA_BETA_MAX ((1U << 31) - 1) +/* Internal alpha/beta are in units of 64ns. + * This enables to use all alpha/beta values in the allowed range without loss + * of precision due to rounding when scaling them internally, e.g., + * scale_alpha_beta(1) will not round down to 0. + */ +#define ALPHA_BETA_GRANULARITY 6 +#define ALPHA_BETA_SCALING (ALPHA_BETA_SHIFT - ALPHA_BETA_GRANULARITY) +/* We express the weights (wc, wl) in %, i.e., wc + wl = 100 */ +#define MAX_WC 100 + +struct dualpi2_sched_data { + struct Qdisc *l_queue; /* The L4S LL queue */ + struct Qdisc *sch; /* The classic queue (owner of this struct) */ + + /* Registered tc filters */ + struct { + struct tcf_proto __rcu *filters; + struct tcf_block *block; + } tcf; + + struct { /* PI2 parameters */ + u64 target; /* Target delay in nanoseconds */ + u32 tupdate;/* Timer frequency in nanoseconds */ + u32 prob; /* Base PI probability */ + u32 alpha; /* Gain factor for the integral rate response */ + u32 beta; /* Gain factor for the proportional response */ + struct hrtimer timer; /* prob update timer */ + } pi2; + + struct { /* Step AQM (L4S queue only) parameters */ + u32 thresh; /* Step threshold */ + bool in_packets;/* Whether the step is in packets or time */ + } step; + + struct { /* Classic queue starvation protection */ + s32 credit; /* Credit (sign indicates which queue) */ + s32 init; /* Reset value of the credit */ + u8 wc; /* C queue weight (between 0 and MAX_WC) */ + u8 wl; /* L queue weight (MAX_WC - wc) */ + } c_protection; + + /* General dualQ parameters */ + u8 coupling_factor;/* Coupling factor (k) between both queues */ + u8 ecn_mask; /* Mask to match L4S packets */ + bool drop_early; /* Drop at enqueue instead of dequeue if true */ + bool drop_overload; /* Drop (1) on overload, or overflow (0) */ + bool split_gso; /* Split aggregated skb (1) or leave as is */ + + /* Statistics */ + u64 c_head_ts; /* Enqueue timestamp of the classic Q's head */ + u64 l_head_ts; /* Enqueue timestamp of the L Q's head */ + u64 last_qdelay; /* Q delay val at the last probability update */ + u32 packets_in_c; /* Number of packets enqueued in C queue */ + u32 packets_in_l; /* Number of packets enqueued in L queue */ + u32 maxq; /* maximum queue size */ + u32 ecn_mark; /* packets marked with ECN */ + u32 step_marks; /* ECN marks due to the step AQM */ + + struct { /* Deferred drop statistics */ + u32 cnt; /* Packets dropped */ + u32 len; /* Bytes dropped */ + } deferred_drops; +}; + +struct dualpi2_skb_cb { + u64 ts; /* Timestamp at enqueue */ + u8 apply_step:1, /* Can we apply the step threshold */ + classified:2, /* Packet classification results */ + ect:2; /* Packet ECT codepoint */ +}; + +enum dualpi2_classification_results { + DUALPI2_C_CLASSIC = 0, /* C queue */ + DUALPI2_C_L4S = 1, /* L queue (scalable marking/classic drops) */ + DUALPI2_C_LLLL = 2, /* L queue (no drops/marks) */ + __DUALPI2_C_MAX /* Keep last*/ +}; + +static struct dualpi2_skb_cb *dualpi2_skb_cb(struct sk_buff *skb) +{ + qdisc_cb_private_validate(skb, sizeof(struct dualpi2_skb_cb)); + return (struct dualpi2_skb_cb *)qdisc_skb_cb(skb)->data; +} + +static u64 skb_sojourn_time(struct sk_buff *skb, u64 reference) +{ + return reference - dualpi2_skb_cb(skb)->ts; +} + +static u64 head_enqueue_time(struct Qdisc *q) +{ + struct sk_buff *skb = qdisc_peek_head(q); + + return skb ? dualpi2_skb_cb(skb)->ts : 0; +} + +static u32 dualpi2_scale_alpha_beta(u32 param) +{ + u64 tmp = ((u64)param * MAX_PROB >> ALPHA_BETA_SCALING); + + do_div(tmp, NSEC_PER_SEC); + return tmp; +} + +static u32 dualpi2_unscale_alpha_beta(u32 param) +{ + u64 tmp = ((u64)param * NSEC_PER_SEC << ALPHA_BETA_SCALING); + + do_div(tmp, MAX_PROB); + return tmp; +} + +static ktime_t next_pi2_timeout(struct dualpi2_sched_data *q) +{ + return ktime_add_ns(ktime_get_ns(), q->pi2.tupdate); +} + +static bool skb_is_l4s(struct sk_buff *skb) +{ + return dualpi2_skb_cb(skb)->classified == DUALPI2_C_L4S; +} + +static bool skb_in_l_queue(struct sk_buff *skb) +{ + return dualpi2_skb_cb(skb)->classified != DUALPI2_C_CLASSIC; +} + +static bool dualpi2_mark(struct dualpi2_sched_data *q, struct sk_buff *skb) +{ + if (INET_ECN_set_ce(skb)) { + q->ecn_mark++; + return true; + } + return false; +} + +static void dualpi2_reset_c_protection(struct dualpi2_sched_data *q) +{ + q->c_protection.credit = q->c_protection.init; +} + +/* This computes the initial credit value and WRR weight for the L queue (wl) + * from the weight of the C queue (wc). + * If wl > wc, the scheduler will start with the L queue when reset. + */ +static void dualpi2_calculate_c_protection(struct Qdisc *sch, + struct dualpi2_sched_data *q, u32 wc) +{ + q->c_protection.wc = wc; + q->c_protection.wl = MAX_WC - wc; + q->c_protection.init = (s32)psched_mtu(qdisc_dev(sch)) * + ((int)q->c_protection.wc - (int)q->c_protection.wl); + dualpi2_reset_c_protection(q); +} + +static bool dualpi2_roll(u32 prob) +{ + return get_random_u32() <= prob; +} + +/* Packets in the C queue are subject to a marking probability pC, which is the + * square of the internal PI2 probability (i.e., have an overall lower mark/drop + * probability). If the qdisc is overloaded, ignore ECT values and only drop. + * + * Note that this marking scheme is also applied to L4S packets during overload. + * Return true if packet dropping is required in C queue + */ +static bool dualpi2_classic_marking(struct dualpi2_sched_data *q, + struct sk_buff *skb, u32 prob, + bool overload) +{ + if (dualpi2_roll(prob) && dualpi2_roll(prob)) { + if (overload || dualpi2_skb_cb(skb)->ect == INET_ECN_NOT_ECT) + return true; + dualpi2_mark(q, skb); + } + return false; +} + +/* Packets in the L queue are subject to a marking probability pL given by the + * internal PI2 probability scaled by the coupling factor. + * + * On overload (i.e., @local_l_prob is >= 100%): + * - if the qdisc is configured to trade losses to preserve latency (i.e., + * @q->drop_overload), apply classic drops first before marking. + * - otherwise, preserve the "no loss" property of ECN at the cost of queueing + * delay, eventually resulting in taildrop behavior once sch->limit is + * reached. + * Return true if packet dropping is required in L queue + */ +static bool dualpi2_scalable_marking(struct dualpi2_sched_data *q, + struct sk_buff *skb, + u64 local_l_prob, u32 prob, + bool overload) +{ + if (overload) { + /* Apply classic drop */ + if (!q->drop_overload || + !(dualpi2_roll(prob) && dualpi2_roll(prob))) + goto mark; + return true; + } + + /* We can safely cut the upper 32b as overload==false */ + if (dualpi2_roll(local_l_prob)) { + /* Non-ECT packets could have classified as L4S by filters. */ + if (dualpi2_skb_cb(skb)->ect == INET_ECN_NOT_ECT) + return true; +mark: + dualpi2_mark(q, skb); + } + return false; +} + +/* Decide whether a given packet must be dropped (or marked if ECT), according + * to the PI2 probability. + * + * Never mark/drop if we have a standing queue of less than 2 MTUs. + */ +static bool must_drop(struct Qdisc *sch, struct dualpi2_sched_data *q, + struct sk_buff *skb) +{ + u64 local_l_prob; + u32 prob; + bool overload; + + if (sch->qstats.backlog < 2 * psched_mtu(qdisc_dev(sch))) + return false; + + prob = READ_ONCE(q->pi2.prob); + local_l_prob = (u64)prob * q->coupling_factor; + overload = local_l_prob > MAX_PROB; + + switch (dualpi2_skb_cb(skb)->classified) { + case DUALPI2_C_CLASSIC: + return dualpi2_classic_marking(q, skb, prob, overload); + case DUALPI2_C_L4S: + return dualpi2_scalable_marking(q, skb, local_l_prob, prob, + overload); + default: /* DUALPI2_C_LLLL */ + return false; + } +} + +static void dualpi2_read_ect(struct sk_buff *skb) +{ + struct dualpi2_skb_cb *cb = dualpi2_skb_cb(skb); + int wlen = skb_network_offset(skb); + + switch (skb_protocol(skb, true)) { + case htons(ETH_P_IP): + wlen += sizeof(struct iphdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + goto not_ecn; + + cb->ect = ipv4_get_dsfield(ip_hdr(skb)) & INET_ECN_MASK; + break; + case htons(ETH_P_IPV6): + wlen += sizeof(struct ipv6hdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + goto not_ecn; + + cb->ect = ipv6_get_dsfield(ipv6_hdr(skb)) & INET_ECN_MASK; + break; + default: + goto not_ecn; + } + return; + +not_ecn: + /* Non pullable/writable packets can only be dropped hence are + * classified as not ECT. + */ + cb->ect = INET_ECN_NOT_ECT; +} + +static int dualpi2_skb_classify(struct dualpi2_sched_data *q, + struct sk_buff *skb) +{ + struct dualpi2_skb_cb *cb = dualpi2_skb_cb(skb); + struct tcf_result res; + struct tcf_proto *fl; + int result; + + dualpi2_read_ect(skb); + if (cb->ect & q->ecn_mask) { + cb->classified = DUALPI2_C_L4S; + return NET_XMIT_SUCCESS; + } + + if (TC_H_MAJ(skb->priority) == q->sch->handle && + TC_H_MIN(skb->priority) < __DUALPI2_C_MAX) { + cb->classified = TC_H_MIN(skb->priority); + return NET_XMIT_SUCCESS; + } + + fl = rcu_dereference_bh(q->tcf.filters); + if (!fl) { + cb->classified = DUALPI2_C_CLASSIC; + return NET_XMIT_SUCCESS; + } + + result = tcf_classify(skb, NULL, fl, &res, false); + if (result >= 0) { +#ifdef CONFIG_NET_CLS_ACT + switch (result) { + case TC_ACT_STOLEN: + case TC_ACT_QUEUED: + case TC_ACT_TRAP: + return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; + case TC_ACT_SHOT: + return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + } +#endif + cb->classified = TC_H_MIN(res.classid) < __DUALPI2_C_MAX ? + TC_H_MIN(res.classid) : DUALPI2_C_CLASSIC; + } + return NET_XMIT_SUCCESS; +} + +static int dualpi2_enqueue_skb(struct sk_buff *skb, struct Qdisc *sch, + struct sk_buff **to_free) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct dualpi2_skb_cb *cb; + + if (unlikely(qdisc_qlen(sch) >= sch->limit)) { + qdisc_qstats_overlimit(sch); + if (skb_in_l_queue(skb)) + qdisc_qstats_overlimit(q->l_queue); + return qdisc_drop(skb, sch, to_free); + } + + if (q->drop_early && must_drop(sch, q, skb)) { + qdisc_drop(skb, sch, to_free); + return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + } + + cb = dualpi2_skb_cb(skb); + cb->ts = ktime_get_ns(); + + if (qdisc_qlen(sch) > q->maxq) + q->maxq = qdisc_qlen(sch); + + if (skb_in_l_queue(skb)) { + /* Only apply the step if a queue is building up */ + dualpi2_skb_cb(skb)->apply_step = + skb_is_l4s(skb) && qdisc_qlen(q->l_queue) > 1; + /* Keep the overall qdisc stats consistent */ + ++sch->q.qlen; + qdisc_qstats_backlog_inc(sch, skb); + ++q->packets_in_l; + if (!q->l_head_ts) + q->l_head_ts = cb->ts; + return qdisc_enqueue_tail(skb, q->l_queue); + } + ++q->packets_in_c; + if (!q->c_head_ts) + q->c_head_ts = cb->ts; + return qdisc_enqueue_tail(skb, sch); +} + +/* Optionally, dualpi2 will split GSO skbs into independent skbs and enqueue + * each of those individually. This yields the following benefits, at the + * expense of CPU usage: + * - Finer-grained AQM actions as the sub-packets of a burst no longer share the + * same fate (e.g., the random mark/drop probability is applied individually) + * - Improved precision of the starvation protection/WRR scheduler at dequeue, + * as the size of the dequeued packets will be smaller. + */ +static int dualpi2_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, + struct sk_buff **to_free) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + int err; + + err = dualpi2_skb_classify(q, skb); + if (err != NET_XMIT_SUCCESS) { + if (err & __NET_XMIT_BYPASS) + qdisc_qstats_drop(sch); + __qdisc_drop(skb, to_free); + return err; + } + + if (q->split_gso && skb_is_gso(skb)) { + netdev_features_t features; + struct sk_buff *nskb, *next; + int cnt, byte_len, orig_len; + int err; + + features = netif_skb_features(skb); + nskb = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); + if (IS_ERR_OR_NULL(nskb)) + return qdisc_drop(skb, sch, to_free); + + cnt = 1; + byte_len = 0; + orig_len = qdisc_pkt_len(skb); + while (nskb) { + next = nskb->next; + skb_mark_not_on_list(nskb); + qdisc_skb_cb(nskb)->pkt_len = nskb->len; + dualpi2_skb_cb(nskb)->classified = + dualpi2_skb_cb(skb)->classified; + dualpi2_skb_cb(nskb)->ect = dualpi2_skb_cb(skb)->ect; + err = dualpi2_enqueue_skb(nskb, sch, to_free); + if (err == NET_XMIT_SUCCESS) { + /* Compute the backlog adjustement that needs + * to be propagated in the qdisc tree to reflect + * all new skbs successfully enqueued. + */ + ++cnt; + byte_len += nskb->len; + } + nskb = next; + } + if (err == NET_XMIT_SUCCESS) { + /* The caller will add the original skb stats to its + * backlog, compensate this. + */ + --cnt; + byte_len -= orig_len; + } + qdisc_tree_reduce_backlog(sch, -cnt, -byte_len); + consume_skb(skb); + return err; + } + return dualpi2_enqueue_skb(skb, sch, to_free); +} + +/* Select the queue from which the next packet can be dequeued, ensuring that + * neither queue can starve the other with a WRR scheduler. + * + * The sign of the WRR credit determines the next queue, while the size of + * the dequeued packet determines the magnitude of the WRR credit change. If + * either queue is empty, the WRR credit is kept unchanged. + * + * As the dequeued packet can be dropped later, the caller has to perform the + * qdisc_bstats_update() calls. + */ +static struct sk_buff *dequeue_packet(struct Qdisc *sch, + struct dualpi2_sched_data *q, + int *credit_change, + u64 now) +{ + struct sk_buff *skb = NULL; + int c_len; + + *credit_change = 0; + c_len = qdisc_qlen(sch) - qdisc_qlen(q->l_queue); + if (qdisc_qlen(q->l_queue) && (!c_len || q->c_protection.credit <= 0)) { + skb = __qdisc_dequeue_head(&q->l_queue->q); + WRITE_ONCE(q->l_head_ts, head_enqueue_time(q->l_queue)); + if (c_len) + *credit_change = q->c_protection.wc; + qdisc_qstats_backlog_dec(q->l_queue, skb); + /* Keep the global queue size consistent */ + --sch->q.qlen; + } else if (c_len) { + skb = __qdisc_dequeue_head(&sch->q); + WRITE_ONCE(q->c_head_ts, head_enqueue_time(sch)); + if (qdisc_qlen(q->l_queue)) + *credit_change = ~((s32)q->c_protection.wl) + 1; + } else { + dualpi2_reset_c_protection(q); + return NULL; + } + *credit_change *= qdisc_pkt_len(skb); + qdisc_qstats_backlog_dec(sch, skb); + return skb; +} + +static int do_step_aqm(struct dualpi2_sched_data *q, struct sk_buff *skb, + u64 now) +{ + u64 qdelay = 0; + + if (q->step.in_packets) + qdelay = qdisc_qlen(q->l_queue); + else + qdelay = skb_sojourn_time(skb, now); + + if (dualpi2_skb_cb(skb)->apply_step && qdelay > q->step.thresh) { + if (!dualpi2_skb_cb(skb)->ect) + /* Drop this non-ECT packet */ + return 1; + if (dualpi2_mark(q, skb)) + ++q->step_marks; + } + qdisc_bstats_update(q->l_queue, skb); + return 0; +} + +static void drop_and_retry(struct dualpi2_sched_data *q, struct sk_buff *skb, struct Qdisc *sch) +{ + ++q->deferred_drops.cnt; + q->deferred_drops.len += qdisc_pkt_len(skb); + consume_skb(skb); + qdisc_qstats_drop(sch); +} + +static struct sk_buff *dualpi2_qdisc_dequeue(struct Qdisc *sch) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + int credit_change; + u64 now; + + now = ktime_get_ns(); + + while ((skb = dequeue_packet(sch, q, &credit_change, now))) { + if (!q->drop_early && must_drop(sch, q, skb)) { + drop_and_retry(q, skb, sch); + continue; + } + + if (skb_in_l_queue(skb) && do_step_aqm(q, skb, now)) { + qdisc_qstats_drop(q->l_queue); + drop_and_retry(q, skb, sch); + continue; + } + + q->c_protection.credit += credit_change; + qdisc_bstats_update(sch, skb); + break; + } + + /* We cannot call qdisc_tree_reduce_backlog() if our qlen is 0, + * or HTB crashes. + */ + if (q->deferred_drops.cnt && qdisc_qlen(sch)) { + qdisc_tree_reduce_backlog(sch, q->deferred_drops.cnt, + q->deferred_drops.len); + q->deferred_drops.cnt = 0; + q->deferred_drops.len = 0; + } + return skb; +} + +static s64 __scale_delta(u64 diff) +{ + do_div(diff, 1 << ALPHA_BETA_GRANULARITY); + return diff; +} + +static void get_queue_delays(struct dualpi2_sched_data *q, u64 *qdelay_c, + u64 *qdelay_l) +{ + u64 now, qc, ql; + + now = ktime_get_ns(); + qc = READ_ONCE(q->c_head_ts); + ql = READ_ONCE(q->l_head_ts); + + *qdelay_c = qc ? now - qc : 0; + *qdelay_l = ql ? now - ql : 0; +} + +static u32 calculate_probability(struct Qdisc *sch) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + u32 new_prob; + u64 qdelay_c; + u64 qdelay_l; + u64 qdelay; + s64 delta; + + get_queue_delays(q, &qdelay_c, &qdelay_l); + qdelay = max(qdelay_l, qdelay_c); + /* Alpha and beta take at most 32b, i.e, the delay difference would + * overflow for queuing delay differences > ~4.2sec. + */ + delta = ((s64)qdelay - q->pi2.target) * q->pi2.alpha; + delta += ((s64)qdelay - q->last_qdelay) * q->pi2.beta; + if (delta > 0) { + new_prob = __scale_delta(delta) + q->pi2.prob; + if (new_prob < q->pi2.prob) + new_prob = MAX_PROB; + } else { + new_prob = q->pi2.prob - __scale_delta(~delta + 1); + if (new_prob > q->pi2.prob) + new_prob = 0; + } + q->last_qdelay = qdelay; + /* If we do not drop on overload, ensure we cap the L4S probability to + * 100% to keep window fairness when overflowing. + */ + if (!q->drop_overload) + return min_t(u32, new_prob, MAX_PROB / q->coupling_factor); + return new_prob; +} + +static enum hrtimer_restart dualpi2_timer(struct hrtimer *timer) +{ + struct dualpi2_sched_data *q = from_timer(q, timer, pi2.timer); + + WRITE_ONCE(q->pi2.prob, calculate_probability(q->sch)); + + hrtimer_set_expires(&q->pi2.timer, next_pi2_timeout(q)); + return HRTIMER_RESTART; +} + +static const struct nla_policy dualpi2_policy[TCA_DUALPI2_MAX + 1] = { + [TCA_DUALPI2_LIMIT] = {.type = NLA_U32}, + [TCA_DUALPI2_TARGET] = {.type = NLA_U32}, + [TCA_DUALPI2_TUPDATE] = {.type = NLA_U32}, + [TCA_DUALPI2_ALPHA] = {.type = NLA_U32}, + [TCA_DUALPI2_BETA] = {.type = NLA_U32}, + [TCA_DUALPI2_STEP_THRESH] = {.type = NLA_U32}, + [TCA_DUALPI2_STEP_PACKETS] = {.type = NLA_U8}, + [TCA_DUALPI2_COUPLING] = {.type = NLA_U8}, + [TCA_DUALPI2_DROP_OVERLOAD] = {.type = NLA_U8}, + [TCA_DUALPI2_DROP_EARLY] = {.type = NLA_U8}, + [TCA_DUALPI2_C_PROTECTION] = {.type = NLA_U8}, + [TCA_DUALPI2_ECN_MASK] = {.type = NLA_U8}, + [TCA_DUALPI2_SPLIT_GSO] = {.type = NLA_U8}, +}; + +static int dualpi2_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[TCA_DUALPI2_MAX + 1]; + struct dualpi2_sched_data *q; + int old_backlog; + int old_qlen; + int err; + + if (!opt) + return -EINVAL; + err = nla_parse_nested_deprecated(tb, TCA_DUALPI2_MAX, opt, + dualpi2_policy, extack); + if (err < 0) + return err; + + q = qdisc_priv(sch); + sch_tree_lock(sch); + + if (tb[TCA_DUALPI2_LIMIT]) { + u32 limit = nla_get_u32(tb[TCA_DUALPI2_LIMIT]); + + if (!limit) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_DUALPI2_LIMIT], + "limit must be greater than 0."); + sch_tree_unlock(sch); + return -EINVAL; + } + sch->limit = limit; + } + + if (tb[TCA_DUALPI2_TARGET]) + q->pi2.target = (u64)nla_get_u32(tb[TCA_DUALPI2_TARGET]) * + NSEC_PER_USEC; + + if (tb[TCA_DUALPI2_TUPDATE]) { + u64 tupdate = nla_get_u32(tb[TCA_DUALPI2_TUPDATE]); + + if (!tupdate) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_DUALPI2_TUPDATE], + "tupdate cannot be 0us."); + sch_tree_unlock(sch); + return -EINVAL; + } + q->pi2.tupdate = tupdate * NSEC_PER_USEC; + } + + if (tb[TCA_DUALPI2_ALPHA]) { + u32 alpha = nla_get_u32(tb[TCA_DUALPI2_ALPHA]); + + if (alpha > ALPHA_BETA_MAX) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_DUALPI2_ALPHA], + "alpha is too large."); + sch_tree_unlock(sch); + return -EINVAL; + } + q->pi2.alpha = dualpi2_scale_alpha_beta(alpha); + } + + if (tb[TCA_DUALPI2_BETA]) { + u32 beta = nla_get_u32(tb[TCA_DUALPI2_BETA]); + + if (beta > ALPHA_BETA_MAX) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_DUALPI2_BETA], + "beta is too large."); + sch_tree_unlock(sch); + return -EINVAL; + } + q->pi2.beta = dualpi2_scale_alpha_beta(beta); + } + + if (tb[TCA_DUALPI2_STEP_THRESH]) + q->step.thresh = nla_get_u32(tb[TCA_DUALPI2_STEP_THRESH]) * + NSEC_PER_USEC; + + if (tb[TCA_DUALPI2_COUPLING]) { + u8 coupling = nla_get_u8(tb[TCA_DUALPI2_COUPLING]); + + if (!coupling) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_DUALPI2_COUPLING], + "Must use a non-zero coupling."); + sch_tree_unlock(sch); + return -EINVAL; + } + q->coupling_factor = coupling; + } + + if (tb[TCA_DUALPI2_STEP_PACKETS]) + q->step.in_packets = !!nla_get_u8(tb[TCA_DUALPI2_STEP_PACKETS]); + + if (tb[TCA_DUALPI2_DROP_OVERLOAD]) + q->drop_overload = !!nla_get_u8(tb[TCA_DUALPI2_DROP_OVERLOAD]); + + if (tb[TCA_DUALPI2_DROP_EARLY]) + q->drop_early = !!nla_get_u8(tb[TCA_DUALPI2_DROP_EARLY]); + + if (tb[TCA_DUALPI2_C_PROTECTION]) { + u8 wc = nla_get_u8(tb[TCA_DUALPI2_C_PROTECTION]); + + if (wc > MAX_WC) { + NL_SET_ERR_MSG_ATTR(extack, + tb[TCA_DUALPI2_C_PROTECTION], + "c_protection must be <= 100."); + sch_tree_unlock(sch); + return -EINVAL; + } + dualpi2_calculate_c_protection(sch, q, wc); + } + + if (tb[TCA_DUALPI2_ECN_MASK]) + q->ecn_mask = nla_get_u8(tb[TCA_DUALPI2_ECN_MASK]); + + if (tb[TCA_DUALPI2_SPLIT_GSO]) + q->split_gso = !!nla_get_u8(tb[TCA_DUALPI2_SPLIT_GSO]); + + old_qlen = qdisc_qlen(sch); + old_backlog = sch->qstats.backlog; + while (qdisc_qlen(sch) > sch->limit) { + struct sk_buff *skb = __qdisc_dequeue_head(&sch->q); + + qdisc_qstats_backlog_dec(sch, skb); + rtnl_qdisc_drop(skb, sch); + } + qdisc_tree_reduce_backlog(sch, old_qlen - qdisc_qlen(sch), + old_backlog - sch->qstats.backlog); + + sch_tree_unlock(sch); + return 0; +} + +/* Default alpha/beta values give a 10dB stability margin with max_rtt=100ms. */ +static void dualpi2_reset_default(struct dualpi2_sched_data *q) +{ + q->sch->limit = 10000; /* Max 125ms at 1Gbps */ + + q->pi2.target = 15 * NSEC_PER_MSEC; + q->pi2.tupdate = 16 * NSEC_PER_MSEC; + q->pi2.alpha = dualpi2_scale_alpha_beta(41); /* ~0.16 Hz * 256 */ + q->pi2.beta = dualpi2_scale_alpha_beta(819); /* ~3.20 Hz * 256 */ + + q->step.thresh = 1 * NSEC_PER_MSEC; + q->step.in_packets = false; + + dualpi2_calculate_c_protection(q->sch, q, 10); /* wc=10%, wl=90% */ + + q->ecn_mask = INET_ECN_ECT_1; + q->coupling_factor = 2; /* window fairness for equal RTTs */ + q->drop_overload = true; /* Preserve latency by dropping */ + q->drop_early = false; /* PI2 drops on dequeue */ + q->split_gso = true; +} + +static int dualpi2_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + int err; + + q->l_queue = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops, + TC_H_MAKE(sch->handle, 1), extack); + if (!q->l_queue) + return -ENOMEM; + + err = tcf_block_get(&q->tcf.block, &q->tcf.filters, sch, extack); + if (err) + return err; + + q->sch = sch; + dualpi2_reset_default(q); + hrtimer_init(&q->pi2.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED); + q->pi2.timer.function = dualpi2_timer; + + if (opt) { + err = dualpi2_change(sch, opt, extack); + + if (err) + return err; + } + + hrtimer_start(&q->pi2.timer, next_pi2_timeout(q), + HRTIMER_MODE_ABS_PINNED); + return 0; +} + +static u32 convert_ns_to_usec(u64 ns) +{ + do_div(ns, NSEC_PER_USEC); + return ns; +} + +static int dualpi2_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start_noflag(skb, TCA_OPTIONS); + if (!opts) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_DUALPI2_LIMIT, sch->limit) || + nla_put_u32(skb, TCA_DUALPI2_TARGET, + convert_ns_to_usec(q->pi2.target)) || + nla_put_u32(skb, TCA_DUALPI2_TUPDATE, + convert_ns_to_usec(q->pi2.tupdate)) || + nla_put_u32(skb, TCA_DUALPI2_ALPHA, + dualpi2_unscale_alpha_beta(q->pi2.alpha)) || + nla_put_u32(skb, TCA_DUALPI2_BETA, + dualpi2_unscale_alpha_beta(q->pi2.beta)) || + nla_put_u32(skb, TCA_DUALPI2_STEP_THRESH, q->step.in_packets ? + q->step.thresh : convert_ns_to_usec(q->step.thresh)) || + nla_put_u8(skb, TCA_DUALPI2_COUPLING, q->coupling_factor) || + nla_put_u8(skb, TCA_DUALPI2_DROP_OVERLOAD, q->drop_overload) || + nla_put_u8(skb, TCA_DUALPI2_STEP_PACKETS, q->step.in_packets) || + nla_put_u8(skb, TCA_DUALPI2_DROP_EARLY, q->drop_early) || + nla_put_u8(skb, TCA_DUALPI2_C_PROTECTION, q->c_protection.wc) || + nla_put_u8(skb, TCA_DUALPI2_ECN_MASK, q->ecn_mask) || + nla_put_u8(skb, TCA_DUALPI2_SPLIT_GSO, q->split_gso)) + goto nla_put_failure; + + return nla_nest_end(skb, opts); + +nla_put_failure: + nla_nest_cancel(skb, opts); + return -1; +} + +static int dualpi2_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct tc_dualpi2_xstats st = { + .prob = READ_ONCE(q->pi2.prob), + .packets_in_c = q->packets_in_c, + .packets_in_l = q->packets_in_l, + .maxq = q->maxq, + .ecn_mark = q->ecn_mark, + .credit = q->c_protection.credit, + .step_marks = q->step_marks, + }; + u64 qc, ql; + + get_queue_delays(q, &qc, &ql); + st.delay_l = convert_ns_to_usec(ql); + st.delay_c = convert_ns_to_usec(qc); + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + +static void dualpi2_reset(struct Qdisc *sch) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + + qdisc_reset_queue(sch); + qdisc_reset_queue(q->l_queue); + q->c_head_ts = 0; + q->l_head_ts = 0; + q->pi2.prob = 0; + q->packets_in_c = 0; + q->packets_in_l = 0; + q->maxq = 0; + q->ecn_mark = 0; + q->step_marks = 0; + dualpi2_reset_c_protection(q); +} + +static void dualpi2_destroy(struct Qdisc *sch) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + + q->pi2.tupdate = 0; + hrtimer_cancel(&q->pi2.timer); + if (q->l_queue) + qdisc_put(q->l_queue); + tcf_block_put(q->tcf.block); +} + +static struct Qdisc *dualpi2_leaf(struct Qdisc *sch, unsigned long arg) +{ + return NULL; +} + +static unsigned long dualpi2_find(struct Qdisc *sch, u32 classid) +{ + return 0; +} + +static unsigned long dualpi2_bind(struct Qdisc *sch, unsigned long parent, + u32 classid) +{ + return 0; +} + +static void dualpi2_unbind(struct Qdisc *q, unsigned long cl) +{ +} + +static struct tcf_block *dualpi2_tcf_block(struct Qdisc *sch, unsigned long cl, + struct netlink_ext_ack *extack) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + + if (cl) + return NULL; + return q->tcf.block; +} + +static void dualpi2_walk(struct Qdisc *sch, struct qdisc_walker *arg) +{ + unsigned int i; + + if (arg->stop) + return; + + /* We statically define only 2 queues */ + for (i = 0; i < 2; i++) { + if (arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, i + 1, arg) < 0) { + arg->stop = 1; + break; + } + arg->count++; + } +} + +/* Minimal class support to handler tc filters */ +static const struct Qdisc_class_ops dualpi2_class_ops = { + .leaf = dualpi2_leaf, + .find = dualpi2_find, + .tcf_block = dualpi2_tcf_block, + .bind_tcf = dualpi2_bind, + .unbind_tcf = dualpi2_unbind, + .walk = dualpi2_walk, +}; + +static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { + .id = "dualpi2", + .cl_ops = &dualpi2_class_ops, + .priv_size = sizeof(struct dualpi2_sched_data), + .enqueue = dualpi2_qdisc_enqueue, + .dequeue = dualpi2_qdisc_dequeue, + .peek = qdisc_peek_dequeued, + .init = dualpi2_init, + .destroy = dualpi2_destroy, + .reset = dualpi2_reset, + .change = dualpi2_change, + .dump = dualpi2_dump, + .dump_stats = dualpi2_dump_stats, + .owner = THIS_MODULE, +}; + +static int __init dualpi2_module_init(void) +{ + return register_qdisc(&dualpi2_qdisc_ops); +} + +static void __exit dualpi2_module_exit(void) +{ + unregister_qdisc(&dualpi2_qdisc_ops); +} + +module_init(dualpi2_module_init); +module_exit(dualpi2_module_exit); + +MODULE_DESCRIPTION("Dual Queue with Proportional Integral controller Improved with a Square (dualpi2) scheduler"); +MODULE_AUTHOR("Koen De Schepper "); +MODULE_AUTHOR("Olga Albisser "); +MODULE_AUTHOR("Henrik Steen "); +MODULE_AUTHOR("Olivier Tilmans "); +MODULE_AUTHOR("Chia-Yu Chang "); + +MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0"); From patchwork Tue Oct 15 10:28:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836067 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2076.outbound.protection.outlook.com [40.107.249.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD6D2146D6B for ; Tue, 15 Oct 2024 10:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988221; cv=fail; b=H9CJIkCyuz3lBAlH0Lop142XGad4zhmtuJaAaLO7GAjYlkWx/eNZ7a4CfuKSOCdDDxL/xZoS6xczmlFlCir3F1AVKI2bDiCB+45djxHuxXLzi7zw3R9VO4u8B174RpSvWo+jCzoLNffp8eDQymMGraScoZtWByO+xk1H4ObUAcg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988221; c=relaxed/simple; bh=iqP4Lrn2Z/fBm0RWoUJbIosaP4CJmoZQtGIJjWwHjO4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jli2HkAjRI57ZNoPynMvjicRKWnl4tYJ2/8DQ267cS8eVf5pvfm30r+5yGOEwgw+VP/4NwYGDg138Al/i6JWWZf0tuKCGIo7vAl532BcxAIkDZs67bwF+NQcazk1XfAJWNrUIyB14cNhz7OL6zqA/LkLL8t1lPOD1jyBOhXfmAI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=XRUSuX67; arc=fail smtp.client-ip=40.107.249.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="XRUSuX67" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s5Ip3xC6oQiQQeF8XG/uVvjKuxPXWzDNm9r/qoHAcS9LKmAN4a/yWnZN6kOKwvPIQwrv1RO094rwK5jnBXftw01Sq3S9xezkbIUA9OJM8dM3cDQiDZ8dVEoAN8SJUnpV0M4BlNZZTsuowzv5iTJ1o2ikwUreUryoxfHlhDiLLhf1AGjUBfdRqX+qgv2mElBgLpq7boWIjRvAQ3oCcT9/thf/LNSeal7ubQkWZOUCs56Ygyof8TQpHiRrrB+zaa0HJzsaZaJVW7y51fbVxn9r6+X509+1VTnrdjTBc6ngtNMEqVjYncsn0t5WSoxORdmfh7eYw6iRATM/sctZuGN9dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qap5KOTYkSn3sw5d0xLoait3kFngQIXe3o0O4mhxPZA=; b=PT8uEzcoa35eLsY9dtn+qcnZQ3ZgHRHH2/qjd1pxPlkxRpA1nFVWQn7zbmfBM/XkgQavZZILzGn/todQPZKz80uqCR7CZGcxTzfBQgjdBaKsWTMJbil0j1bTFV9ggry0YDjL+RNRUA+t9+y8z2XP8SrhaxzO9GsRQIdF27T3lieF4fHfj3zq2MHqvrj3mpbckxt3qqboSwOPEFzXLZ6DmYOdCmx0SilF3KSr2UGQ6VwdrGfY3Q5AmF0Ehbs8ulRYkwxDWryNhf8g7V0Qyj4AzV6ZBQ7n+eD/lh1biAxZ8kmOMYH5UmokbitnmQ7tYQfBI/hrqZk4FDmliZ2nAiC1kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qap5KOTYkSn3sw5d0xLoait3kFngQIXe3o0O4mhxPZA=; b=XRUSuX67ks6hKyq9Psw40XV4Wbhh8HiwVZOW8t8KS9nTIat7lowe6S4CjtJXbT3mA6oDb28uaw/jeP/Fx+VZMu+OjdV1iKixbivMEz6WjCHS2tf33o3rQu6zeE8iix9TfS91SxXKCkCLAMmo9FrahNsWtOxHBJF9XTf7vMO6BWNMMc18mc+8eLkWEcT0AVhByNvEyz7m1kbcb37mqTlUeMADIuv+LnYWcN6SAaRPfahs/rVKYMUiGhTIsSf71rLJDPcI22fZJp+btbSyHs02DURO6+bSU2sfxPWDIgKQfvAGTzZpJGmxTXd1xG/OYuR5Fb8YBkXzoEg2luxIpTYO7Q== Received: from DUZPR01CA0011.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::19) by VI1PR07MB9406.eurprd07.prod.outlook.com (2603:10a6:800:1c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:14 +0000 Received: from DU2PEPF00028D07.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::fd) by DUZPR01CA0011.outlook.office365.com (2603:10a6:10:3c3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D07.mail.protection.outlook.com (10.167.242.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtn6029578; Tue, 15 Oct 2024 10:30:12 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 02/44] tcp: reorganize tcp_in_ack_event() and tcp_count_delivered() Date: Tue, 15 Oct 2024 12:28:58 +0200 Message-Id: <20241015102940.26157-3-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D07:EE_|VI1PR07MB9406:EE_ X-MS-Office365-Filtering-Correlation-Id: 04bd9a17-2837-4a87-b825-08dced045b01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HdXmKQ1Qma+nCL+q3/u/1nrfaxhYFEN?= =?utf-8?q?UoMjrwHvX38I3IEGXayei4LaWbZaDZ9k34+Z5pW9qaIdqq7A6Mr8oedtYpDF3TOaf?= =?utf-8?q?zh+QBYddBc9UTFZuwAEYlzUMp64qseEBeZzHrTkLwej3L+Tk1nFELiHMNwzdKD7dt?= =?utf-8?q?rutO0CiKyKpAIryisbtVGHEXQGhbWbAbvZ8bdldHyAwt48iDztt2vF9jyfJNZXm4O?= =?utf-8?q?Qj1L+kVwLYftTWd+sgdX91QwQU8KNOT4p2oouVJpNst2Fg4j5QYeNVmyoCe03yRGk?= =?utf-8?q?B+FnWR5ti0L1CZu4rc3CcvP+w+qkVZ1nHnhjSjLQTX7/9rKkkdipDaZjfssHBs1Mc?= =?utf-8?q?7sxJGl6NujNvR7M8as6M0Wf1DGoS56/XZnGOrnuzQDGt/iX0msxTu+sl8pWWP9O3w?= =?utf-8?q?AMhISh7Lc48od1OGsaPzpZAGxehdYQx0UrXgE2d59E5UgQE/iftPMLz6nW9aMgP0f?= =?utf-8?q?fTKixZ/d8u72X434nN2vv96NWnjPflFuwxvYsA/t7PEq/+y1UYQwvIM0x2v1hVOL6?= =?utf-8?q?8XX5voIkohJjjBFMRFC3W6JqNJ+pIev8d2eKLXFo6IwnO5kfBrnUPI/9G54Mp/p4n?= =?utf-8?q?8v0LCcaapm4x1e57kbSbGv9ODiRU8lAarTjO1HySywCxwAMBsjmFpJUTa9UDMvOfd?= =?utf-8?q?GKhf5vtUH3XRV/JGN2EQbmcWGMxBfp8UwLzIMAv1E+PHjCiCldHYiIKgfiproNtsY?= =?utf-8?q?m8eHjR73KM531iO8/ChQ9BjYVedFHwMGnarPS+zVaHYbXXsr2TWFaievuQSB3PKc9?= =?utf-8?q?c4XgeYK1tqrwvE9PbGCG4/HLZ/etFUwOpzkJEXqxDzX5dt4xbEnOmqyiJIzXIQ6/e?= =?utf-8?q?TzCvRPYEqa7PSw+SlXFsVtXGsxgWonIfs9ZBwAmm87i6tpR/2R/yjX17A2Y1hDOYt?= =?utf-8?q?h76haJdCMRe1XHtnIdyMczcslGQQbbKQ3Y8W8z7qcghIJPHmztyGGjUmg4YwCKuNQ?= =?utf-8?q?Bt4C98FJDLlQ6aW0olH1ySd3+joh1ARGRTPHqQt5i9KLBiXYeObU12gzl6p6v+79B?= =?utf-8?q?6IZSWn4OglhcWVJ27x0RyITQsGWO21kM9SI0Q/bTrfqK9LFa6vTauWDLB8Wwyj75a?= =?utf-8?q?PdhxzOh1ZqK5MiKDUiyn0A4RmwT3Jjmu/jouAEYFSeN4ZELFpA6+WCTKe/J1A3zN6?= =?utf-8?q?I4EOo6edfHoLMwGHOLJXRVi+yLUDGQf9an3PxWPAu91TSvQ9BMoVEseUG0laWkF5x?= =?utf-8?q?xBjWgvxGxhA7ELaOiwJDpDyPAnZCSR1zYMWbfMU3ks5TchlFdc4pPnXYhwpwKO8PS?= =?utf-8?q?zJ3G99Y9parK/Nu2Rs2LN6LHPX2SFTmLXCaPFCGvUqqj2NKal//3Vb3UjwtEZszU+?= =?utf-8?q?Tme8XKvhtFMW?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:14.0696 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04bd9a17-2837-4a87-b825-08dced045b01 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D07.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB9406 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen - Move tcp_count_delivered() earlier and split tcp_count_delivered_ce() out of it - Move tcp_in_ack_event() later - While at it, remove the inline from tcp_in_ack_event() and let the compiler to decide Accurate ECN's heuristics does not know if there is going to be ACE field based CE counter increase or not until after rtx queue has been processed. Only then the number of ACKed bytes/pkts is available. As CE or not affects presence of FLAG_ECE, that information for tcp_in_ack_event is not yet available in the old location of the call to tcp_in_ack_event(). Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 56 +++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2d844e1f867f..5a6f93148814 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -413,6 +413,20 @@ static bool tcp_ecn_rcv_ecn_echo(const struct tcp_sock *tp, const struct tcphdr return false; } +static void tcp_count_delivered_ce(struct tcp_sock *tp, u32 ecn_count) +{ + tp->delivered_ce += ecn_count; +} + +/* Updates the delivered and delivered_ce counts */ +static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, + bool ece_ack) +{ + tp->delivered += delivered; + if (ece_ack) + tcp_count_delivered_ce(tp, delivered); +} + /* Buffer size and advertised window tuning. * * 1. Tuning sk->sk_sndbuf, when connection enters established state. @@ -1148,15 +1162,6 @@ void tcp_mark_skb_lost(struct sock *sk, struct sk_buff *skb) } } -/* Updates the delivered and delivered_ce counts */ -static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, - bool ece_ack) -{ - tp->delivered += delivered; - if (ece_ack) - tp->delivered_ce += delivered; -} - /* This procedure tags the retransmission queue when SACKs arrive. * * We have three tag bits: SACKED(S), RETRANS(R) and LOST(L). @@ -3856,12 +3861,23 @@ static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag) } } -static inline void tcp_in_ack_event(struct sock *sk, u32 flags) +static void tcp_in_ack_event(struct sock *sk, int flag) { const struct inet_connection_sock *icsk = inet_csk(sk); - if (icsk->icsk_ca_ops->in_ack_event) - icsk->icsk_ca_ops->in_ack_event(sk, flags); + if (icsk->icsk_ca_ops->in_ack_event) { + u32 ack_ev_flags = 0; + + if (flag & FLAG_WIN_UPDATE) + ack_ev_flags |= CA_ACK_WIN_UPDATE; + if (flag & FLAG_SLOWPATH) { + ack_ev_flags = CA_ACK_SLOWPATH; + if (flag & FLAG_ECE) + ack_ev_flags |= CA_ACK_ECE; + } + + icsk->icsk_ca_ops->in_ack_event(sk, ack_ev_flags); + } } /* Congestion control has updated the cwnd already. So if we're in @@ -3978,12 +3994,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_snd_una_update(tp, ack); flag |= FLAG_WIN_UPDATE; - tcp_in_ack_event(sk, CA_ACK_WIN_UPDATE); - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPHPACKS); } else { - u32 ack_ev_flags = CA_ACK_SLOWPATH; - if (ack_seq != TCP_SKB_CB(skb)->end_seq) flag |= FLAG_DATA; else @@ -3995,19 +4007,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) flag |= tcp_sacktag_write_queue(sk, skb, prior_snd_una, &sack_state); - if (tcp_ecn_rcv_ecn_echo(tp, tcp_hdr(skb))) { + if (tcp_ecn_rcv_ecn_echo(tp, tcp_hdr(skb))) flag |= FLAG_ECE; - ack_ev_flags |= CA_ACK_ECE; - } if (sack_state.sack_delivered) tcp_count_delivered(tp, sack_state.sack_delivered, flag & FLAG_ECE); - - if (flag & FLAG_WIN_UPDATE) - ack_ev_flags |= CA_ACK_WIN_UPDATE; - - tcp_in_ack_event(sk, ack_ev_flags); } /* This is a deviation from RFC3168 since it states that: @@ -4034,6 +4039,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_rack_update_reo_wnd(sk, &rs); + tcp_in_ack_event(sk, flag); + if (tp->tlp_high_seq) tcp_process_tlp_ack(sk, ack, flag); @@ -4065,6 +4072,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) return 1; no_queue: + tcp_in_ack_event(sk, flag); /* If data was DSACKed, see if we can undo a cwnd reduction. */ if (flag & FLAG_DSACKING_ACK) { tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag, From patchwork Tue Oct 15 10:28:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836064 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BAD413AD20 for ; Tue, 15 Oct 2024 10:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988220; cv=fail; b=J2YVUSbk/t6JpkNmv6dexCGDOpJm99DiFtxIFMnidKlQbwTLjpKtbJ5dSV1qMgx2ft5nfaP8PSj6koJWA39LtNgOMUMdUiau3rn3o1ae17nLkSDXHFf+i5cBtsCM1Oxbem6jqEMjcjG0dkWSe1Twtp45ez603jjw3EM0gdc+kFI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988220; c=relaxed/simple; bh=3zGp58t362CmVtDa9QFNHZzzdy0EVtxL7MMUb+yZxbI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZMjq7cX9m1UCVut0EQQtZXl8mWU3UrmFV6K+iNIOPBjoj1fkysj0wbHsAbCJgC87tt7nNr9XXtUEPix4yUA79bjBJ1D9zz/sZ/eKZpJljMuUe163UUOicefu9QORi2xECkjvbZbRU5FM4QfkIUCAkfbuCEeqCR9pMgrnCd6WWXE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=kqv+dRbt; arc=fail smtp.client-ip=40.107.22.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="kqv+dRbt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VOBMIx1kcITEoXHx3Kz6q9FbGTHTOHKyTJnLtkS3Yaz96MWXsL3zZqsGwdBsl7R3JbccivPYBbwXEDwwY74gNrVjVQ2UsrURhVduZeOF8HNBucCC9Y1NCNzcOyrNiqk2n5oiN7hLSoVdHnBB6zRISPzSYDi2V7YoXhNA+JvNWouNMSW50QR31QNa8YpmnXSWCK/pq+JIAnvTUWVysTwAIfJ5uf6nRJew0C4OEXhUBtMCzBL1lMJuZC33j7bYeaaMfTEJm2RpCzpqG8B5Fd/W1yxq22ENSMm2PgotZCN4W3s5SpiJq3Yrt5ZdKpPyhE8AsFxo5xTyhiLJKDgNBi1umg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/Pf9hlyv6o7rclrqAn0mftxD+MbOfoa7s/42MqDOeUQ=; b=hIuL3Mi11260OvcjlBjYH1rTMb1riYEeQ/RcOMzJWcx/W+tlgdmii8rZa+rApHeciV57P0Lp3WUBMaWRzj/n91FVWKc+fglM9gnqo9e8pkQdO8j1tLWCjmTKP6iUnQGhD44CouSDYMMm0js5P9qCHMloVzRVlyrqqU5sxfc5564O/pn37y+ctf6sKFtjfcnBPVD3n5k9mfvZiJae7IVLbn03GvTfUTJH6p1OpvSPjETLQwFUO4voOwfkmGzMuzCicp+Bc9vII/UZFZ5c3e7c1NwhLiDiGCrSMZiv0XhBO84GBfIaeof5MjeRHcBt+c3DEAOqxpsqlt9HlPDLYpajOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Pf9hlyv6o7rclrqAn0mftxD+MbOfoa7s/42MqDOeUQ=; b=kqv+dRbtZ8gqZnfIle6w/euZgClFNTKyFd2RNPU3a9H2ubahKIADBOOXhPwHliv14udMjKt9H1XKtqbh0tHKCtJhWKIy1+sD9fU6llF6KyJYlgX4BgzY3Z7X6PHcvABC5WTf0BXfOIu6Md+akBfpe0RA1DhyTGeE164dPnwJwWWp7XoZdTeMAXj+HAoFFWjaE7jqoWUSo7HYI0C6C1vfnKjrWolH6kDlTL0oYCAiMG1yrzsvvzjDbkhol/zOEVnLGPFt8GIhMGqp14vkrJ6qArza5KMRvuaSEx0NaWLSX4Y4+7H8tFBdGTUNLUViwqaLtqq8IZw4j5QnoU1FVTkSEQ== Received: from DU2PR04CA0199.eurprd04.prod.outlook.com (2603:10a6:10:28d::24) by AS8PR07MB7416.eurprd07.prod.outlook.com (2603:10a6:20b:2a5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:14 +0000 Received: from DU2PEPF00028D04.eurprd03.prod.outlook.com (2603:10a6:10:28d:cafe::c3) by DU2PR04CA0199.outlook.office365.com (2603:10a6:10:28d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D04.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtn7029578; Tue, 15 Oct 2024 10:30:13 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 03/44] tcp: create FLAG_TS_PROGRESS Date: Tue, 15 Oct 2024 12:28:59 +0200 Message-Id: <20241015102940.26157-4-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D04:EE_|AS8PR07MB7416:EE_ X-MS-Office365-Filtering-Correlation-Id: 91cc4fef-39cc-400c-d142-08dced045b3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?YAlE3uh9BVOMD+ZdHkXD5mbrD5qYfHR?= =?utf-8?q?+GQrcc/WcmeELEg/nBquvpVTiXN2hq/FDoKdF++fiM1A955elmiCYkiDRt91WcF+9?= =?utf-8?q?Xzi/O9etoQbHzHXnCQ5+SPt5qG9xXpJoB+7gXx21W860qlK24zp4soivNufyUqjYY?= =?utf-8?q?0fM3UX93Q/iq/QA1LHMraWEFZsgVyGEi5zh9nwLmmjdtKc38O0lY/TBSOYmJiUgXF?= =?utf-8?q?xbY3JmVmKqiPP48yu2ibMtQerAwKeuoUxo9lHBOXmxLrKO8RhJ/Ei9z2cBcwZ2Uwm?= =?utf-8?q?ujdN8zFHPgJVx+yKXfDFXKSTsuC7qbIYfSZ9+kxGN4rAEBaKYSJf8NTzzmtiupiKF?= =?utf-8?q?jNBxOZoB2nTqar5u+wpw0EEi8iYGK9GDWuSPlFhjYJuNSbEZErv5fWagCQ9pPVvid?= =?utf-8?q?UYUl+QwdxznegHGRKq2GTWiS1sjda2EpmAxoaUDuE7cYIVDB0HCVz9UA/d2pg0qgw?= =?utf-8?q?I23ux/lIPFVR8ZbC/wS8IKQ5otLS5iC2VCePQegJ2SHGwSOsUyyOJVrkotelTWBHU?= =?utf-8?q?I+c4pYuHNg1tsDE76CufhPDRIfx7wUIKEthRuQS/LveE09eTbpt5ygsLr6+bqDvaC?= =?utf-8?q?2WrkZubSKrah71sd/o0GZ2w4yqkJApkOf3aFYzIJCICupUZxWbAVesK3d9agvgvo1?= =?utf-8?q?9bjXTUJ25UlTii0jehB+bnlwkjzdZkx+a0o968aOzPc/Zd3Czo/QoSKejZhemuwQj?= =?utf-8?q?K6eYyNpCCx6ztrfuUuF2POcudaaOt/O7QfLpk4aQI+iPhe3z4WDSAogBiOMa28yI/?= =?utf-8?q?q5Sgy89h8vVYCqzo0HRTSAtpcq/cfCfRHOuSoVdu7uJTbJU5VgHCSyiKeLVbTHXK1?= =?utf-8?q?yp/kVfG6vx6jZe0jROB107OcmKRHIfPP/IgR0c1bsE8QjfsKW4Gm0eADjc2MKbqT1?= =?utf-8?q?BP3B0ebiE5CgSw/StTsb/KlSwlFg8C6RbKyAiU3SgA1mg53bqQ70lZYCyFKxtxckq?= =?utf-8?q?RoTWofUueBgNPqjsITDZknhtAJYxck8IrBPSx4p4XwwJ6UUWB34tQd6nZk/nv5G34?= =?utf-8?q?dNerxZyNl0hGsJDQMoax/wYM5PtG4pspuQweJfkj1Ud29F6+DOw+Bm2yuWTqd7247?= =?utf-8?q?JEEAYRFGdO74SHChhsxBVrSm1rRJNgomyu+Ke6pi8YjpANulPrT4gSnuZkRVAOOlj?= =?utf-8?q?5CMx6BTkRiOuyZ9HPA+OHyhaEQ0DVyDMfMPctJs62QBolWn4eKGkyo4M9TxzAXV++?= =?utf-8?q?g96n05wFHby37ghz0hQNoBnYY55MF1PV4K01EKGabM4a4cOd3Hi5wj11n7XHFZn2x?= =?utf-8?q?MdxN0hnEE+TCZ8WAkEgaotQSXwH57D85sywdAL1OKi90GUS+zTXE56IHbQOA7hbPz?= =?utf-8?q?42/PxDlglqJb?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(7416014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:14.4569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91cc4fef-39cc-400c-d142-08dced045b3c X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D04.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7416 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Whenever timestamp advances, it declares progress which can be used by the other parts of the stack to decide that the ACK is the most recent one seen so far. AccECN will use this flag when deciding whether to use the ACK to update AccECN state or not. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5a6f93148814..7b8e69ccbbb0 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -102,6 +102,7 @@ int sysctl_tcp_max_orphans __read_mostly = NR_FILE; #define FLAG_NO_CHALLENGE_ACK 0x8000 /* do not call tcp_send_challenge_ack() */ #define FLAG_ACK_MAYBE_DELAYED 0x10000 /* Likely a delayed ACK */ #define FLAG_DSACK_TLP 0x20000 /* DSACK for tail loss probe */ +#define FLAG_TS_PROGRESS 0x40000 /* Positive timestamp delta */ #define FLAG_ACKED (FLAG_DATA_ACKED|FLAG_SYN_ACKED) #define FLAG_NOT_DUP (FLAG_DATA|FLAG_WIN_UPDATE|FLAG_ACKED) @@ -3813,8 +3814,16 @@ static void tcp_store_ts_recent(struct tcp_sock *tp) tp->rx_opt.ts_recent_stamp = ktime_get_seconds(); } -static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) +static int __tcp_replace_ts_recent(struct tcp_sock *tp, s32 tstamp_delta) { + tcp_store_ts_recent(tp); + return tstamp_delta > 0 ? FLAG_TS_PROGRESS : 0; +} + +static int tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) +{ + s32 delta; + if (tp->rx_opt.saw_tstamp && !after(seq, tp->rcv_wup)) { /* PAWS bug workaround wrt. ACK frames, the PAWS discard * extra check below makes sure this can only happen @@ -3823,9 +3832,13 @@ static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) * Not only, also it occurs for expired timestamps. */ - if (tcp_paws_check(&tp->rx_opt, 0)) - tcp_store_ts_recent(tp); + if (tcp_paws_check(&tp->rx_opt, 0)) { + delta = tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent; + return __tcp_replace_ts_recent(tp, delta); + } } + + return 0; } /* This routine deals with acks during a TLP episode and ends an episode by @@ -3982,7 +3995,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) * is in window. */ if (flag & FLAG_UPDATE_TS_RECENT) - tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq); + flag |= tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq); if ((flag & (FLAG_SLOWPATH | FLAG_SND_UNA_ADVANCED)) == FLAG_SND_UNA_ADVANCED) { @@ -6140,6 +6153,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) TCP_SKB_CB(skb)->seq == tp->rcv_nxt && !after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) { int tcp_header_len = tp->tcp_header_len; + s32 tstamp_delta = 0; + int flag = 0; /* Timestamp header prediction: tcp_header_len * is automatically equal to th->doff*4 due to pred_flags @@ -6152,8 +6167,9 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) if (!tcp_parse_aligned_timestamp(tp, th)) goto slow_path; + tstamp_delta = tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent; /* If PAWS failed, check it more carefully in slow path */ - if ((s32)(tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent) < 0) + if (tstamp_delta < 0) goto slow_path; /* DO NOT update ts_recent here, if checksum fails @@ -6173,12 +6189,12 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) if (tcp_header_len == (sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) && tp->rcv_nxt == tp->rcv_wup) - tcp_store_ts_recent(tp); + flag |= __tcp_replace_ts_recent(tp, tstamp_delta); /* We know that such packets are checksummed * on entry. */ - tcp_ack(sk, skb, 0); + tcp_ack(sk, skb, flag); __kfree_skb(skb); tcp_data_snd_check(sk); /* When receiving pure ack in fast path, update @@ -6209,7 +6225,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) if (tcp_header_len == (sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED) && tp->rcv_nxt == tp->rcv_wup) - tcp_store_ts_recent(tp); + flag |= __tcp_replace_ts_recent(tp, tstamp_delta); tcp_rcv_rtt_measure_ts(sk, skb); @@ -6224,7 +6240,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) if (TCP_SKB_CB(skb)->ack_seq != tp->snd_una) { /* Well, only one small jumplet in fast path... */ - tcp_ack(sk, skb, FLAG_DATA); + tcp_ack(sk, skb, flag | FLAG_DATA); tcp_data_snd_check(sk); if (!inet_csk_ack_scheduled(sk)) goto no_ack; From patchwork Tue Oct 15 10:29:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836065 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2072.outbound.protection.outlook.com [40.107.105.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE57D4683 for ; Tue, 15 Oct 2024 10:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988220; cv=fail; b=cKdNT8bj3iprq48R95eCH3FYqUejxpa9sxsgWcrGJJRA9skcOChrTmTDeKfMVLHAfQtWJRMgr75HNWSMtBH7Dke+yOETCUZ9jAms5vrtS9iroqsm/tyEifiKfAAly7npaFh7JuS9s1YBrNKBd+fXppxTaGEu4dlQCWEsZcKu9og= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988220; c=relaxed/simple; bh=VWfBnNyWjEH3XDaLA3UuMW35easf2rQkez0Pfq+GLhw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=GG1Tm9/2DWtHxkynIMffDxHbE7eWYMh2IT8lcfVapItFdlXkjHc0vjN//J/GqU7ip05Y3VZFZmDCmlfR9iUOlQLqNrCYtJGh3WyqwvfSLfU9c1+SWiXenVK4DWeJBCVugg0A+rQTAvlSadobwhMaAJVVC1oRrlhZF9yaUJigW54= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=H7MqK/eM; arc=fail smtp.client-ip=40.107.105.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="H7MqK/eM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tioMl8G5R8I2BOoZnIR8JZPuOaQnZEgfj9pwLYcjakZICkzVKL4TAg67ZJ2EBqtjoB4/HBiXsi2k1ISLBMv8mVPg+rin6jncMus4gpB00lSs1Jj8s75Ds319m7b/S7CEHB4hOpFGCM1m/U49xJKGUPWT7r0vaDGhvtFB//Ed8eWtCv5PmKYOgWbVyhAHpuvcNzRZFKfoHvavJIWVEnmJlvoaOsGY6Ldi5bdfxx7nkrqNd9kqObYyihwt/S+mkZeYhf/iJI5VuWl3HSdH/n61JFm+50PyDubhSmHZZ7Oq85+cQjf4fTIfOeL2Yc96R1f8XIuvS026MFFCOkh+gupaRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MMx3u4H44x+CVsqgJMWoc4rn9lSzlzPywoG4I9GWyRA=; b=Y7c/Bs6nPks2yyMIvGEI66nga+dE0UvO/2v62O7FPYOXmIACjtD8HYyAIm1oWLyRO5N1GieuUI6ebb9yjpnKgNAb+bnsYdKycNrP4bUVCUaO5bpX+KqxwVXyWbx168hZb7Bw6IW0LG2FnKnD7o/M5gtdD5mGLZbbZrFzOOErFazd/xxvY2D05r+2R5RRCxp5Hi17o5SAPURPw88b/lTHDi9s+84Jt5n/T0hHZF+/TkKnau6z+4bv5ewvWRzSBSI7q1NirbqhVHiIPa+2yNAIh77tKZkrHcCpFFzCqtxi0FK/8jY38bLKh3EzSwgGEKKeNXb6qIbmAueHGmqKPbNy5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=temperror action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MMx3u4H44x+CVsqgJMWoc4rn9lSzlzPywoG4I9GWyRA=; b=H7MqK/eMRuSVCwH04zrbO8PUNka/r2PE1bPEDM9rSHM8keJY5s3/DeoWY62VWYCFB5QMor+4gi2qquSFRGiTBkhkncQpSLZfE+5R3zkkMfAHCYgDzo0bMXSgLPft1kjDWoAQ81q0JJJxzeGRcYPJ+f2S9Z1HPhgwotwvmXUPlKeJgH32nHuhWmXCovt4gfDNCW5MX3gZGE7LgBnH41LEPTP13C2qt3l12bq3KfDmCrLGK2XROBw2y4RFIRHzm2y40MtBKcREu/3ZkBg/wI1XN1KxIQQg/VaRLo6jhVxNOE2PoSfekDYXda7GS9ZGnyM5qYbufHLBz4fucp0OH7pCUQ== Received: from AM6P194CA0080.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::21) by AS8PR07MB8054.eurprd07.prod.outlook.com (2603:10a6:20b:359::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:16 +0000 Received: from AMS0EPF0000019F.eurprd05.prod.outlook.com (2603:10a6:209:8f:cafe::e1) by AM6P194CA0080.outlook.office365.com (2603:10a6:209:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:16 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nokia-bell-labs.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nokia-bell-labs.com: DNS Timeout) Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF0000019F.mail.protection.outlook.com (10.167.16.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:14 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtn8029578; Tue, 15 Oct 2024 10:30:14 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 04/44] tcp: use BIT() macro in include/net/tcp.h Date: Tue, 15 Oct 2024 12:29:00 +0200 Message-Id: <20241015102940.26157-5-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019F:EE_|AS8PR07MB8054:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c649344-a8e7-4aed-7d74-08dced045b81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?etNTthu6ZWHHCkXkmaL8gbGVCB4HzNK?= =?utf-8?q?lgHwl6ALy0cawBobs92Z2qcNOjEdPwg0t2/FpRu/xOqN7Ykcptvqi0SUeslsp7Idj?= =?utf-8?q?u22DZb0J1pqndTOf6dgzPo/qTxPnakP9kTNdRZI3eNSsW16weyR8UUWR9WQDki+ek?= =?utf-8?q?aItkPFZVG7ynbW0dOkt/zSH3IDwAsodum0yfsPxTblsMjiX69TdxDwGbY0cZFdfHJ?= =?utf-8?q?chdqvMD+8Jky4ljaGPjT9+wzcbE7VH52spVtQLhxnrHVZzFwMOaaYCg516hVCHIZ2?= =?utf-8?q?kmik2YWmje013uG1f/L5vf0BmJ8arESJSLf/aBd85Thns7sIwKHn/Xc+OKb6YNF7j?= =?utf-8?q?d0r+oS9PM5MxzM+1MtZs/9AO10qDKuaYF5c2lqrRSPrZkbhh9kzIwcNgS85YW8+AJ?= =?utf-8?q?31DvAJAppXcaT9GggPYdHYSJ7UuR/GutWlAuf+eDQcSA5DwwahYhHXETqGeFA638r?= =?utf-8?q?Ibs/LZvpbVIuqHJZBHwsfc9jzRdfUFoqw9K6MT0h+k9gj5WU7KIUrTHIklVziLNy4?= =?utf-8?q?OCw48yma7/M3xdwyzlLtdYmSN9tYH+DHVML4a9wx/5qXlQW1lk3ny8RZ5i0HvoXn2?= =?utf-8?q?OxaY2g7EDzLF/aWBRLF99OGd8BJDz7n0fi/qMc0fzeS7mFG37db1xfzfswHovo4vS?= =?utf-8?q?mh2QlS2K891dSDpTkE2ew24HiBgsv++0wb96OBCW2w0UU3LLbN+aOMT1tKna2j+Yt?= =?utf-8?q?G2v91m08zgOB6FP13KGAxqpxiZCqv2dO+fhnjNPMX+49rxhKh0qnDmwsimm+fJLVY?= =?utf-8?q?JbvqHVLmi0oLAOojTtyJEnkaZi+TrmK2x6OPV3xRqx15bAwykaauZMmpzC+iIpftu?= =?utf-8?q?mLcHALC9QB4FMtRg1oESSyHpeGL1LEPmA6t8ZqW0yI0RoYXK055lYrmI4QGflxk21?= =?utf-8?q?3iXjvBSk3riahTOI4hPTQzEolT7YP4hbtaY+7Z7HXl/wOKP8gXXSH9lEt2OMCHOcY?= =?utf-8?q?pOofOaARr8ysd0tNwrxpkG6F9Dj9Q1by+aTpU56ByvKlxU1mHGfn6LHw0NHrvcZkT?= =?utf-8?q?afTZDA4bVQRFkOa68F+VeJRzFHDFwXPE++0aSWldp6KiSfJx+TVCm3tniI30kaAbH?= =?utf-8?q?RDV/+cQc7bgTDMBaAoecNs22ymxtwC1iTgp/nts6NEvFsowrjx2suhY5IbdzRA3DC?= =?utf-8?q?/Gw5mHLws51Kd4km8HMtswlxjz3CsN8Pz+pQhqrc2ZHcu5+jrDhp31u0SNapvAKUl?= =?utf-8?q?dB/JxzFqX9a7Nl/y7OUAVw4V+IAF9q1e2G0Zm0033O2jSiEd3P64bTRuJwS1EjC/f?= =?utf-8?q?EhCwiWg8AqTH12rik9Iw4qdaDgsmhkTAr0LrYAohHZY25utTQLkZN1cLlc7CrsWIN?= =?utf-8?q?j5b+33bg3jXp?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:14.9539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c649344-a8e7-4aed-7d74-08dced045b81 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF0000019F.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB8054 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Use BIT() macro for TCP flags field and TCP congestion control flags that will be used by the congestion control algorithm. No functional changes. Signed-off-by: Chia-Yu Chang Reviewed-by: Ilpo Järvinen --- include/net/tcp.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 739a9fb83d0c..bc34b450929c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -911,14 +912,14 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq) #define tcp_flag_byte(th) (((u_int8_t *)th)[13]) -#define TCPHDR_FIN 0x01 -#define TCPHDR_SYN 0x02 -#define TCPHDR_RST 0x04 -#define TCPHDR_PSH 0x08 -#define TCPHDR_ACK 0x10 -#define TCPHDR_URG 0x20 -#define TCPHDR_ECE 0x40 -#define TCPHDR_CWR 0x80 +#define TCPHDR_FIN BIT(0) +#define TCPHDR_SYN BIT(1) +#define TCPHDR_RST BIT(2) +#define TCPHDR_PSH BIT(3) +#define TCPHDR_ACK BIT(4) +#define TCPHDR_URG BIT(5) +#define TCPHDR_ECE BIT(6) +#define TCPHDR_CWR BIT(7) #define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR) @@ -1107,9 +1108,9 @@ enum tcp_ca_ack_event_flags { #define TCP_CA_UNSPEC 0 /* Algorithm can be set on socket without CAP_NET_ADMIN privileges */ -#define TCP_CONG_NON_RESTRICTED 0x1 +#define TCP_CONG_NON_RESTRICTED BIT(0) /* Requires ECN/ECT set on all packets */ -#define TCP_CONG_NEEDS_ECN 0x2 +#define TCP_CONG_NEEDS_ECN BIT(1) #define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN) union tcp_cc_info; From patchwork Tue Oct 15 10:29:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836068 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2082.outbound.protection.outlook.com [40.107.22.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B4E51E3DC1 for ; Tue, 15 Oct 2024 10:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988222; cv=fail; b=jkdV60phUSNJCrsUJJz8MYk4srar6LPiXMgKmp7X/mKX735wy7f2Ks1jfBCZmQgRNUqBakDLg/4XlaUL/eGizvsUThZ+CcmAdIXRRYe80bHWBx1FlIWrjT41Rc6wnx+f5GUU/aOb0ay+ugcnCFqJwqvGAaR+v0hUVdfFTfXp1Nc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988222; c=relaxed/simple; bh=Hmdtr0We50ejAD355SghSxW3LOTq66I4DTi+GKYgG1U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=o+oPchYFMZ4heBBny4YuCqN1SuzjpDievc2G0K/pIx/O14Pb+MveXaO9X2BZDSXmjqMRvw+CcVi4/9L0XIj075VHHhRvs0gBBNRto8iUYZKZKMBj/fU2BuXJyGltg9pauAfmtTz5/Vz4amShpCDX4WoK6P2Vu4WZkrQgElhYjQs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=so6miN1D; arc=fail smtp.client-ip=40.107.22.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="so6miN1D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JGxLq6yowkZG+5MY8XpDMQgKeNqobP01jLLrD7dy25+aRnew+AMRydKcvddOHfoEHrPqXytOkWiyVHWqs9FEZfcX9soeJzN8iVZg9hdRVNBdMuI3Xpen7qPZjrWekkcFBZA0BGf8SZsMzkv9USfk2F0a/VS+ROKdsF17ctNEIMwrjc9F2E9KwFAoc9PmvEqWRuacEltI1k9loolVdX1KfNIGlupjzlSCY22QwtaEUwlXv+S30uZO7ZZ7cFH6Uc/raFJC3rNCe7IwEWB86d7TRJ+wEWh/AMTyCVW6V29Nqnxary7rWV3sHv/e0/MItu8HN+RjqRYoDvysCzoAtcLTsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WJtuM1nTfrSpcdQnGQbMn0HkkJCOFzlul0aCRL1BYBc=; b=yV9i011EaE/B3xMfJBfofLgH/mvgpdYFxW6OwWbrmKGo5GTvJD80n94W5wjcriihRtMaBWpxvQhvbJ3SsdjlX0qBjEJD79Ar249Q9/GyWWIvoNKPn/rrK2DMdjEy+FPqx3iWGR5AhH5FLZcm83xiF/QYuVr+x5+T46BTD/0Q+m6GmbTB7qS532OPbyrKa0+DVaBJbrYlPLkRKlNL9x8EuclDxDUKVBe0FA1v6mCt4gCC64UpMB+xtSnJJFdzJo7/CWVau/Az0+IYYZowilInhFw8SJR4Y6qm6djVBkZRlKT/oxNKs4d22niDAJLJL6/DPuXRVXIigk6Q0elr5Av/9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=temperror action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WJtuM1nTfrSpcdQnGQbMn0HkkJCOFzlul0aCRL1BYBc=; b=so6miN1D2XlSCpUjOCZSyRqnKsP+k0u+CUgZTMxnBgLzdC/S0rJ0P7m4FOatAet1GI5qagketRTNQFNIp/Snj8Qo9/aVF8a/OB23QBvwcfjDkD0Gt49h8f19nmPmmvBzf3LyvKTzLr1ARBmX4h8vSxHj+u22L90TA0Ts9gF9G+PXtWxsHYEYG7PNBk63b31c1HnbbxY4qTcww2Hi/JJAKrDAh4e9BirS9P5Q8p3N1v3T/MjElD5z8+9bQvQGCbQYnIH5NvnAuz5c9Vdfv50inxfKRb+fetMjukeqodhqeCkXK7k+Qpdsvserj+cFEnOCZXL7fH9SE6eotJ+ziaOATg== Received: from DU2PR04CA0209.eurprd04.prod.outlook.com (2603:10a6:10:28d::34) by VI1PR0701MB6815.eurprd07.prod.outlook.com (2603:10a6:800:199::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:17 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:28d:cafe::a9) by DU2PR04CA0209.outlook.office365.com (2603:10a6:10:28d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:17 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nokia-bell-labs.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nokia-bell-labs.com: DNS Timeout) Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:15 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtn9029578; Tue, 15 Oct 2024 10:30:14 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 05/44] tcp: extend TCP flags to allow AE bit/ACE field Date: Tue, 15 Oct 2024 12:29:01 +0200 Message-Id: <20241015102940.26157-6-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|VI1PR0701MB6815:EE_ X-MS-Office365-Filtering-Correlation-Id: 60af88fb-29c4-49c7-0826-08dced045c1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6zj8MUOtSzogcdFFFvkuYc5LiMR8knE?= =?utf-8?q?k9trDPUBMOjRD2JSTHfGROkR3chGysVonzwKvWJM7ny/jrF5rEUMUlxV+K7ggkC70?= =?utf-8?q?QjmTG+46PwyPDmerq0x+47LWz165sEv8gOszS7TyXNa7OpohH/mgRLvz4I286bAnC?= =?utf-8?q?/U2hHSDA9kdGvlsMp4+ODHfV67LCHqxkWx+fTxZ/DFZlH5kt/5kEZZ5NdkR5SZbse?= =?utf-8?q?vFgjiEUb6p1KQqP5IGYSna6Fn2VtCg21Ug1gTOXsHU/eG4jwCSguQ9ybimzMDZ7+s?= =?utf-8?q?d/6MLYKMocUyr0h57c5YC3uNvJMPA96FUZEvpFFM494TpQQGkfKy1/balgGVvzidw?= =?utf-8?q?XC1WrtYN1jIYI/GN3Znpjax1R0W+E8zA1R6bhmfiXsf/c6dl/ubpC6mg09tJLwFoY?= =?utf-8?q?GUOKIE2NxOSrXvyW9Xw17UdBlyBtdvpNNuHekrLrkktqOSmCau5NdHRYByYnWVCl4?= =?utf-8?q?BpPgOysovCoGLc+LjoJmPSVPVldhFn6fKOQ2StdynnhTlqc/JrpfnxAf2/R8q2YDd?= =?utf-8?q?yBndgyXv0EhTGcpAEICjcNYLU1sl6mlTV8xx8tDvtxDwe6HMjxuwUD8dyBD2DYLiG?= =?utf-8?q?6+2SD5Dq/oOq9iT+5p7j/rKJjbFyXkgCjKMEmePA4JBGGN3+1aGeSJuFKhfgUxZd3?= =?utf-8?q?OeW3Ap4PmLhkfg+O/P4sc0IxDVgXgMY8SXUrf/2infSPOA5U5xl7uSP4JA1hvqXrF?= =?utf-8?q?cmUlLjw6vSbrA4gYFvbs84GMf2pz8m6nCTiCALGgJmBNffUik1aPJJ7Z0HmugjJMX?= =?utf-8?q?z6BqY5eTf0isATMteMqu5hinHinWsmPTmvwZW18xLq09RXIdm2gZeThHtD+Xj/oT5?= =?utf-8?q?/vKQa5tEp0LsmbQT0fJGVz4UqBCJhJDXnHE+p2B7qqbSz8VRn6PerLcm+jGHW+wsk?= =?utf-8?q?eOSEqpcMjSAbP2TmGOIrT329I1HRbPl0tcQ1xhIllMQNd+XkdMwQgl1MLDBmp7+7Q?= =?utf-8?q?CD1+etnbdVO8et69c5fSQHvZs6ZFXDoAAKVgCg6ZIpQlwSG7ANkiQDMJNMylBIrg+?= =?utf-8?q?vItScMnOBzNQwEI4JbbEUhHocz4YBI/Hpokw14+uyjx6vEwKcslnHN2hiSZEKrHui?= =?utf-8?q?itr60oOVKf+xcEjI9s4qvLXReBBowIav87eZ2gB8LqrOZXiXrTbrjDe77dr9TRVeI?= =?utf-8?q?BIk3agOBq0nn4IPJ22dInuW5xnxOuW0sW0sfpIvWoYEzThrbE2GhSMPrhSsyO70TH?= =?utf-8?q?TroXy87mr3GEJX8L6DNDRyp/rhPH7lghoxVl46BXO0X1jEudXxHaK569o2uV7WkPm?= =?utf-8?q?+8guBavKK6RYS5aIqTZtFFnHaWjfMxZytVSE9f0e7iHZt4k5MANRPI3WHkxUfXW2K?= =?utf-8?q?g295nQ303xSZ?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:15.6920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60af88fb-29c4-49c7-0826-08dced045c1d X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB6815 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen With AccECN, there's one additional TCP flag to be used (AE) and ACE field that overloads the definition of AE, CWR, and ECE flags. As tcp_flags was previously only 1 byte, the byte-order stuff needs to be added to it's handling. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 7 ++++++- include/uapi/linux/tcp.h | 9 ++++++--- net/ipv4/tcp_ipv4.c | 3 ++- net/ipv4/tcp_output.c | 8 ++++---- net/ipv6/tcp_ipv6.c | 3 ++- net/netfilter/nf_log_syslog.c | 8 +++++--- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index bc34b450929c..549fec6681d0 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -920,7 +920,12 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq) #define TCPHDR_URG BIT(5) #define TCPHDR_ECE BIT(6) #define TCPHDR_CWR BIT(7) +#define TCPHDR_AE BIT(8) +#define TCPHDR_FLAGS_MASK (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \ + TCPHDR_PSH | TCPHDR_ACK | TCPHDR_URG | \ + TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) +#define TCPHDR_ACE (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) #define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR) /* State flags for sacked in struct tcp_skb_cb */ @@ -955,7 +960,7 @@ struct tcp_skb_cb { u16 tcp_gso_size; }; }; - __u8 tcp_flags; /* TCP header flags. (tcp[13]) */ + __u16 tcp_flags; /* TCP header flags. (tcp[12-13]) */ __u8 sacked; /* State flags for SACK. */ __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */ diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index dbf896f3146c..3fe08d7dddaf 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -28,7 +28,8 @@ struct tcphdr { __be32 seq; __be32 ack_seq; #if defined(__LITTLE_ENDIAN_BITFIELD) - __u16 res1:4, + __u16 ae:1, + res1:3, doff:4, fin:1, syn:1, @@ -40,7 +41,8 @@ struct tcphdr { cwr:1; #elif defined(__BIG_ENDIAN_BITFIELD) __u16 doff:4, - res1:4, + res1:3, + ae:1, cwr:1, ece:1, urg:1, @@ -70,6 +72,7 @@ union tcp_word_hdr { #define tcp_flag_word(tp) (((union tcp_word_hdr *)(tp))->words[3]) enum { + TCP_FLAG_AE = __constant_cpu_to_be32(0x01000000), TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), @@ -78,7 +81,7 @@ enum { TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), - TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), + TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0E000000), TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) }; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 9d3dd101ea71..9fe314a59240 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2162,7 +2162,8 @@ static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph, TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + skb->len - th->doff * 4); TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); - TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th); + TCP_SKB_CB(skb)->tcp_flags = ntohs(*(__be16 *)&tcp_flag_word(th)) & + TCPHDR_FLAGS_MASK; TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph); TCP_SKB_CB(skb)->sacked = 0; TCP_SKB_CB(skb)->has_rxtstamp = diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 054244ce5117..45cb67c635be 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -400,7 +400,7 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb, /* Constructs common control bits of non-data skb. If SYN/FIN is present, * auto increment end seqno. */ -static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags) +static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u16 flags) { skb->ip_summed = CHECKSUM_PARTIAL; @@ -1382,7 +1382,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, th->seq = htonl(tcb->seq); th->ack_seq = htonl(rcv_nxt); *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | - tcb->tcp_flags); + (tcb->tcp_flags & TCPHDR_FLAGS_MASK)); th->check = 0; th->urg_ptr = 0; @@ -1604,7 +1604,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, int old_factor; long limit; int nlen; - u8 flags; + u16 flags; if (WARN_ON(len > skb->len)) return -EINVAL; @@ -2159,7 +2159,7 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, { int nlen = skb->len - len; struct sk_buff *buff; - u8 flags; + u16 flags; /* All of a TSO frame must be composed of paged data. */ DEBUG_NET_WARN_ON_ONCE(skb->len != skb->data_len); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 597920061a3a..252d3dac3a09 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1737,7 +1737,8 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr, TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + skb->len - th->doff*4); TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); - TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th); + TCP_SKB_CB(skb)->tcp_flags = ntohs(*(__be16 *)&tcp_flag_word(th)) & + TCPHDR_FLAGS_MASK; TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr); TCP_SKB_CB(skb)->sacked = 0; TCP_SKB_CB(skb)->has_rxtstamp = diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c index 58402226045e..86d5fc5d28e3 100644 --- a/net/netfilter/nf_log_syslog.c +++ b/net/netfilter/nf_log_syslog.c @@ -216,7 +216,9 @@ nf_log_dump_tcp_header(struct nf_log_buf *m, /* Max length: 9 "RES=0x3C " */ nf_log_buf_add(m, "RES=0x%02x ", (u_int8_t)(ntohl(tcp_flag_word(th) & TCP_RESERVED_BITS) >> 22)); - /* Max length: 32 "CWR ECE URG ACK PSH RST SYN FIN " */ + /* Max length: 35 "AE CWR ECE URG ACK PSH RST SYN FIN " */ + if (th->ae) + nf_log_buf_add(m, "AE "); if (th->cwr) nf_log_buf_add(m, "CWR "); if (th->ece) @@ -516,7 +518,7 @@ dump_ipv4_packet(struct net *net, struct nf_log_buf *m, /* Proto Max log string length */ /* IP: 40+46+6+11+127 = 230 */ - /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */ + /* TCP: 10+max(25,20+30+13+9+35+11+127) = 255 */ /* UDP: 10+max(25,20) = 35 */ /* UDPLITE: 14+max(25,20) = 39 */ /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */ @@ -526,7 +528,7 @@ dump_ipv4_packet(struct net *net, struct nf_log_buf *m, /* (ICMP allows recursion one level deep) */ /* maxlen = IP + ICMP + IP + max(TCP,UDP,ICMP,unknown) */ - /* maxlen = 230+ 91 + 230 + 252 = 803 */ + /* maxlen = 230+ 91 + 230 + 255 = 806 */ } static noinline_for_stack void From patchwork Tue Oct 15 10:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836070 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2042.outbound.protection.outlook.com [40.107.20.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C83BB1E5720 for ; Tue, 15 Oct 2024 10:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988223; cv=fail; b=BUaDspgWQX3XHO/h4EaXqarrU5QC9CLSBHHJk18ZPnktB7k1TLFjdSmuCyWLJi+JrN/EvtmDbxiR2LgD8wVYGZimawntevgx7ZQvm0avU+S5rt5keBGEBeFejgrBwS8xDhJb2YX8iBut4vwntILftJANbSUqqi3d3SyIfbefdgM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988223; c=relaxed/simple; bh=/DXiP48JvOyuu2neVkASCL/V6m9Qs0aUxatR2JoMVD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=RM3esYgSD8zJ2kkdlmzi4A1sYago3w0SVUS7Pigu7b2HVfLdpmu1P2x3DG02xLDWow/EHwJKI02dq0Ym82zmjV8cV3P6khhHyGKtL7po10GnKMj3Nt7SSjPeWNRdaQgW5w5wyHgIn2wWcNFu9lAqj9Y1LrShHEPLMTs6WJ31QGQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=QOitL4IG; arc=fail smtp.client-ip=40.107.20.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="QOitL4IG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cr7yYMjoCggfHuKMCeG8G5Ou2fz2Ao3xLZlfaWj2M/o3BbuiLPk061UDMuolAe1H15X85QCD+X9OCpVSV1m0ftsOIt4OLPabcwxR8XdYGEvzo7w3ur+OzeYQBLA1dAi+H0EjFilpqq+KT5xc5MOmebUkFph/VfyhkBt4zu87jlc6hfwWBvU0rKLUxBJiL9Zc5uYrJkSq0r7iKNZq6TvI1HMeARuZlGIRMTdSNUcn1V5T0HEnYLFZizFQ9rbTFWfmisyCu0lpKCmFgtoqfak7EAKQsfIiy8/BImGGdZaXD87VYqZUd+Y7Geagj/8BLuQKoSq786dant6ZVnlQNRdw4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=slhYpgNbfxS31y0O4s9n10+y1xuaFQsDE8kARtPSdOI=; b=gpzyvC8LC2j1GPBSFWUgRcDVvR2KSZa2SCzIrBiH4DRyuR6ZyPs3AtTPY+CNAVIJiq1PqEjx5xhnA6wXoNLV5Iw90rpveSiDI51jUuNdWiB9kRmGRkC8G1cU467GZrm4hcKFaF29Qrl8oXKCAnE0hfI4OhUKIWTsQkPht7J8IL/I0+73cOSocwqtKFCCk0sMAKp8aQaOiWmzfuPsEtX4Im37U502vNoH5po6Gq1Ak5/lkq8GdSx5lSNwKEnZDzxrPlgVTXtjHVy3pDp8RSnMl5P0H2eJKu66amvDMm1d0OnJEgls35S3NiygmRm/9xMp/ssVAEHsEK6fXgRn9pxcTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=slhYpgNbfxS31y0O4s9n10+y1xuaFQsDE8kARtPSdOI=; b=QOitL4IG3MD22SwSdFgIYMXtBvn2EpT8u8Az5ugwGWneqQafcKHOGj9xpdBdfe/HIBeFiod/EvW1/d3FenizwSR9xhj7pTuR7n85fnenGnmroAgKfmRGoHH6HWYKdF2RUYjBRSg6J6M9b9UTXAvJn/+smOwTYC+i1/DZAYPLAY8lPtgTGwIK1jVS6HTU7P8i7qx9LyNz8geqkAtpk9iX4yKf0ASCmDKHaZNHvqLcRfMfREbqmvCWB0GIkGY7MMiPx7eaOvOMXeTiymwQLmTkzbYfuCTA63h/6UHsbaPIKhJfILYmkOoiwWjop2JPNstTpHcIx5xjf6ByeTHH+WkyLg== Received: from DU7PR01CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::10) by PAXPR07MB7726.eurprd07.prod.outlook.com (2603:10a6:102:15f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:18 +0000 Received: from DU2PEPF00028D09.eurprd03.prod.outlook.com (2603:10a6:10:50f:cafe::30) by DU7PR01CA0022.outlook.office365.com (2603:10a6:10:50f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D09.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:16 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnA029578; Tue, 15 Oct 2024 10:30:15 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 06/44] tcp: reorganize SYN ECN code Date: Tue, 15 Oct 2024 12:29:02 +0200 Message-Id: <20241015102940.26157-7-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D09:EE_|PAXPR07MB7726:EE_ X-MS-Office365-Filtering-Correlation-Id: e757c98b-e7f0-499d-0143-08dced045c41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4POOKynKDerRz9N/j+A1j63ctHXk2cL?= =?utf-8?q?dDVaSsxdRmtBBTmbAfzYp3sff8my7gT7YekgCRTFCGP8IfGbKlHmJ4zzZvgmTlGPB?= =?utf-8?q?8gjkSdaU1QsilamTYbwdy9kbIXyek5DSbWcdTy6UMqY/RNPt+pRIjAhNRFZiO0ozC?= =?utf-8?q?cxGuG2vGkdVIc8SUw/WyvgoiG+8+Oc1MHwTwmYfd0tcDrvCRGZV0TQQqHJLCXPGS5?= =?utf-8?q?slV7maId6W60KrHyBVNiIT6PPjeV3mlki4BdwAfUJ1QviKBMpv1fxzE9cGe3Vxp1i?= =?utf-8?q?0EUvO8o1wM3spXPvzIg1fGmsiVtE+pjpBb5Ls7xfjAWb/3GWmc7iDncEM34Q9ueFg?= =?utf-8?q?Wm3sqcXYgo8R59y4LFwuR8hhz27Srik+Td0qHN8PA//YZ+dB46CvMMEGlOVlkqhJs?= =?utf-8?q?lcTNISbS5aCl0ZN5HWr27kGHaVIocDc5l++xGfBoR9kfu7X9qxtssX10ktMT/morz?= =?utf-8?q?R88tAAApFLBGnfFhzwLQRjEk3+GkzXBP1y7oZIQzxMgRIKyFDBqrtPLYVkJczb04d?= =?utf-8?q?VmxYuzMBHEic6oLy6xUWbW7249euBDNdHTTNFyem9vFIXhPtSQM9ySR2Kvb8ifGzx?= =?utf-8?q?DAu1k1jTqoVU+7+iMx6TpuRW6kOPocsuDvQOR1MjwVLS+dcx/fiAzzYtgLyDhPEjU?= =?utf-8?q?k9IzvUiN2LvpdNWyY2YEDfpWsU9Kb8rAcdokC+1s4Nl8uNKlQWot0dGfztFDRYoYp?= =?utf-8?q?mMjAG8QVJmcyoX6m5O3oL2fXIHzEM+C+c140IwlMrvC8/u7gxiCCov2kNLE8fL8uK?= =?utf-8?q?5QknxLgdeqbJrzKMvEvCj7jS4mQzjjXC4V8FRjp39yiZNVx+0GxBn5frPi/Vqno3c?= =?utf-8?q?sESc78/nd9Em+g8KoseJtQppgB9TUSzdrL6IFWrmmHAzCBSkFnRIdllPkCWZ+q0rW?= =?utf-8?q?AImM1TP159CrBgyyr+lUx/zSJr6/GITnt0qkbGAulpla8QyuuyToPRs+Uxlk1lY49?= =?utf-8?q?c0V7i3ubrYgCXgaQbwd/KThZ40n/9L9dYrJEJ1mPSQU1y7lXpJIZQZmzoN5vYNCOS?= =?utf-8?q?frkS2B7KVMb+GywLK8kynUUsGZFbVGJrctXMHj8tmnaHPmVcrssGIYPDC7Pf/3mvC?= =?utf-8?q?uRLxpq1gVqV+VV7LUANVoXtUPHrzbRzC5L1LuSxshkOCWSk8VYy40InuEQqv48jqr?= =?utf-8?q?ZsELg5YtAf/FZm1LL7uLt99Pz9u7LXkWCwMJUt82KPtezWGt3Yg5cajcEQqi4Cl5m?= =?utf-8?q?8Xj/zBwyEaurjQc/yH6kCRRqKOwo0o61T//7VD7rVx5/IJ5zEe9R9lvcsHXg+MtSg?= =?utf-8?q?evagW9pGn/XiRpnv0MsNtuJMJV1fV1WMXV7VSY1CVOYrzMK+LvPEOB3S56Ihz+2DA?= =?utf-8?q?cIn3viSWynPI?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:16.1465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e757c98b-e7f0-499d-0143-08dced045c41 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D09.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR07MB7726 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Prepare for AccECN that needs to have access here on IP ECN field value which is only available after INET_ECN_xmit(). No functional changes. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_output.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 45cb67c635be..64d47c18255f 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -347,10 +347,11 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb) tp->ecn_flags = 0; if (use_ecn) { - TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; - tp->ecn_flags = TCP_ECN_OK; if (tcp_ca_needs_ecn(sk) || bpf_needs_ecn) INET_ECN_xmit(sk); + + TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; + tp->ecn_flags = TCP_ECN_OK; } } From patchwork Tue Oct 15 10:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836066 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2051.outbound.protection.outlook.com [40.107.249.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE79D14A4FB for ; Tue, 15 Oct 2024 10:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988221; cv=fail; b=u4aQ/3lQDv9twZ3Ke2H6K8KVWZjB5vIj63NkUMEYhSS9z7S2dH8Mk1yfHh52SS1Ap6IuIV+x3ohaNM3koF/94Nzs7DvOKi1dk64hqzwiHFvDz6RiC9NGuT0cVdBHAtk+tlMu6UnkYlsZ7An5kPsTrMe0MNNa4mH4l2iDjyAYjFQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988221; c=relaxed/simple; bh=/jUnhM67qhllbqUJmPtYVGiT6TZs/a8KJ6py5OD7NWE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=oNNkPGEZIU9JEgTzZJ/mYXCNNtqXe9nL8hPcZztY12oEvX/asdpc/JalL5AWoWNuhfzgalBaWVbRp8uJWFajJdb6aDx30Q81LIJJ6nA73Csk+pXXByzX9NLixdFGM0P0hliwfvAzb/3nrNoWKczzEcXr+IH7+Yut4sFoT67VvmI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=o465QmFY; arc=fail smtp.client-ip=40.107.249.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="o465QmFY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dTZC/PboojFqKC2cb0fTfMdmXBY4+ZOICCX06GQjXsW6JMW610/mLvZDGe+b3IgolNSYp2k3980mYsPdWo0Utt91M5Xg7KKb+wEL60PAm/ICV6SvDPdXv+VbguxoLHt5ScR2vbxodyDo3WB+7a9+QjwDcXrlUNmgp3Be0QxY6PK3xuRZRpHB6A5nrSpcUvCr4hbfR0sbD9qeQcsy9NjTDhXKkES8WR1XtVMBDwJGG3zbAm0gWqvPaUaVOsHQubyxx/rj9E1vUT55kxyoBtIWvQ5/SQcAlTeP9VUToyic4+1Ul4rrinL8wLpipG9mZSzQ3zstqZQPyjhgJNcnqtw5rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=06rvrvJvhApG7LYRr6bC4vZiKxPmT7OwntdkaM2HTEk=; b=x6hoIsBSdIc/qXEP1kXALTWXVslw8asUW4uWUMmrAkqMiyHeWDC4k0tUh2mGOcj2FgX0k3zQO8aLpF6DRxMvWYo+Y3f/qrKZMXZpbxlcpVeUq6nanu2QEHVvgAj5HEkRZqNSahTLlKpjT/awVdmpYfCXbxwuEzGko+numinlZvEr5r/6I3GK4bqgk1sJYncsCEtMw0CTL5AKoeO6ZCITL1f6+cIEf9ezvrs/N2PU0iwl8UmLkyhVG/tHvLm/Sq2X4b/4Puw59V0FcEEyToNb/gcsnwjQlISph64pFG57JrlwxwZDUhLb3x6hnz67Bx3ODXfhEF7hThEP3CVevqcDvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=06rvrvJvhApG7LYRr6bC4vZiKxPmT7OwntdkaM2HTEk=; b=o465QmFYD/MF0qs90kS8+uBhYCzbzJ5Uf3QD9cqJuNhuRGmZEjfv6UkEIaopca6y6Dsf51wTPiLSL3haTaB5y3hIypCyb98H5C4h+Mn4rANb10T86rL4XrclsQB9ed6ZFYSBphrUIXdsXkKYzQgH1X9bBU4Wk40NvPPONskyv5XkNhfKb5E2Noj1F3kqHhfZY6XNJ4NUwG+XuXjdgKmRiwIGE1mmPuAV35dFePYjNv1HCjiwx4CjyT5PjrVzdOooShvhmXeZg1iG3c9ThoBekrZ1ZVRHNk3GVlYFv6QbBxTfAsbh72WJVOeuo9bFeCjF13Kcab+qNdWIxWuvrCHlJQ== Received: from AS9PR0301CA0008.eurprd03.prod.outlook.com (2603:10a6:20b:468::17) by AS8PR07MB9398.eurprd07.prod.outlook.com (2603:10a6:20b:635::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:17 +0000 Received: from AM2PEPF0001C714.eurprd05.prod.outlook.com (2603:10a6:20b:468:cafe::92) by AS9PR0301CA0008.outlook.office365.com (2603:10a6:20b:468::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AM2PEPF0001C714.mail.protection.outlook.com (10.167.16.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:16 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnB029578; Tue, 15 Oct 2024 10:30:15 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 07/44] tcp: rework {__,}tcp_ecn_check_ce() -> tcp_data_ecn_check() Date: Tue, 15 Oct 2024 12:29:03 +0200 Message-Id: <20241015102940.26157-8-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C714:EE_|AS8PR07MB9398:EE_ X-MS-Office365-Filtering-Correlation-Id: 045b047a-e91d-4a14-0634-08dced045c92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?kL/O2CtmtCidBHxYNpZDLeZTM5EcqsF?= =?utf-8?q?Er3DDm96v7x1g4/ihKX5MMUsdEGBRK7tr7OTAEfNjxLCjHxLAk71a7UYA7j9F6DQz?= =?utf-8?q?RbYldiyayqVBgvUWOj5up1VLc+4GgO3Eys8bXopfPYG4zpGGClMJTjznSbZsj9e7P?= =?utf-8?q?f+pBjJ5o7cAyr9ABh3O5u3paP3GJoP0+KHaaHnIfXgfUauSwiR9f9NJcYfGe+MovR?= =?utf-8?q?wZO9r6hTn822If+h1siWdFLQLy9PyeondzD5uHP231KYOui94CdsSJOTfTpPLS9au?= =?utf-8?q?P9Zx9noZGlM1nSzES4Gm0DD1KKmYlU0ChVa2GmJq31K4G+Bjodi+9xljplr6+1XjR?= =?utf-8?q?fiABIqg7X9qmaEtSPhEAHsn9lzY3+/rN4z7/0HeHSdCEOsitrvFLCMdAjuzMKDHb0?= =?utf-8?q?rCnv66yXtewKkVvw47ykAro4pND8H7TNgXGsgPFatkiL/W4y6H3yoKLK+ASFefiFD?= =?utf-8?q?OLujVk0BqrZXaVD/Eq4IkNGixPfcxMCuZX3ZBxgoAUWp3w7KNk8+lSTCKbYjbPClX?= =?utf-8?q?SgE4NzrxYfUtCnMakjggOaDSX6SJQQq4IFfFi+7SfIYgpiw/CS1Rdi20N5wAS621S?= =?utf-8?q?OvdQCLUapjYfrRX0UxstoO3N/YDnfECJkegsze32KxSeluTIkAW3zkTrTfhECxQHd?= =?utf-8?q?pHk6HNXZpHFYgwWkbbQ8ZWvPgqXO5gkjCbOglwVhsF+zsvYy4fWU77pV/qwNno0Uh?= =?utf-8?q?y5N2eHOm0POFkB/12d7AMVxC/lmqvg2fcpA07/goc4kgcDfMQNvLeh6u8qZ0gZ7eX?= =?utf-8?q?OUFhxN/5vXK6xUAkhSM3YutdG/b8HCFtdNeO8dZ9epBikfwTbuZtEnBLyAxaAq9eX?= =?utf-8?q?8J3etg8HVHSqXUFHEIcM3Zk1bRN03knimcpnzWZDLqIQlCMfcUkD8xO4aHRycYQ17?= =?utf-8?q?AGNRBWysLx1oZg4afWpdqa9Adjn3gyqmee+sPOu626n3BnYuO12pSXUqa//0v2Ke6?= =?utf-8?q?1R58Lzsqg8Cti1XO+fdLDkfKvhfGZQ5Rcv1Z6/z2u/mkQHB4JmyP0XR6uoWXfnB9O?= =?utf-8?q?Gd4BhsEK8xXk5YT0P1ZEu9Bj47Tb3QFnGg29rn4PEakNafbNGRCzZzeuOdpd2HLbx?= =?utf-8?q?Rmzc9vdxq8DPlSbkMi6exkvEGsUJ3W2vOyhIOYR5OxG/qm0ZlkjLZ8oEnMoILSuPp?= =?utf-8?q?WUR5yhMS6sHw1LqAFdFLgS63ynW8RUK2+UhqIqB7TE5RCRHClhIdUaVK4ThPForeQ?= =?utf-8?q?SWjZPUMkqeZ7mZfkARI53I20vfH+OAsrGXWq3HfRYBDyNzjOoDIWKRP7Yc8oaPM6I?= =?utf-8?q?CidVFZAB7f8zkeu9vRGwdvCtD5+xZ5PviuNlgEJlu3ZAqffjZ4ZRy14p1lV8HzquU?= =?utf-8?q?HEFN5gZJu6Gt?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:16.7399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 045b047a-e91d-4a14-0634-08dced045c92 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C714.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB9398 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Rename tcp_ecn_check_ce to tcp_data_ecn_check as it is called only for data segments, not for ACKs (with AccECN, also ACKs may get ECN bits). The extra "layer" in tcp_ecn_check_ce() function just checks for ECN being enabled, that can be moved into tcp_ecn_field_check rather than having the __ variant. No functional changes. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7b8e69ccbbb0..7b4e7ed8cc52 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -357,10 +357,13 @@ static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp) tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; } -static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb) +static void tcp_data_ecn_check(struct sock *sk, const struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); + if (!(tcp_sk(sk)->ecn_flags & TCP_ECN_OK)) + return; + switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) { case INET_ECN_NOT_ECT: /* Funny extension: if ECT is not set on a segment, @@ -389,12 +392,6 @@ static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb) } } -static void tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb) -{ - if (tcp_sk(sk)->ecn_flags & TCP_ECN_OK) - __tcp_ecn_check_ce(sk, skb); -} - static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th) { if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || th->cwr)) @@ -866,7 +863,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb) icsk->icsk_ack.lrcvtime = now; tcp_save_lrcv_flowlabel(sk, skb); - tcp_ecn_check_ce(sk, skb); + tcp_data_ecn_check(sk, skb); if (skb->len >= 128) tcp_grow_window(sk, skb, true); @@ -5028,7 +5025,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) bool fragstolen; tcp_save_lrcv_flowlabel(sk, skb); - tcp_ecn_check_ce(sk, skb); + tcp_data_ecn_check(sk, skb); if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP); From patchwork Tue Oct 15 10:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836072 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2065.outbound.protection.outlook.com [40.107.20.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 318941E766B for ; Tue, 15 Oct 2024 10:30:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988225; cv=fail; b=bPJc2C+vXqyrjLBhc799G59hx+AlucKFptDv/7uVJNqkXIZpiFgcx0UsEH7rG+iM3tFgq5nX//h5TxGSfZ3cMMrUS1L0JJ5jm/Y12RzeRye5R2mYL7COCJPo6rlrNSGN6GyOx5GEGuwHsiVvrXX0VMnADJhchA3xZfO0B9ZnEzM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988225; c=relaxed/simple; bh=jdXed6V/Yh0NaH+TDgmUGtmxQ71q3BvRQy9Z+lTQNLA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=aIDReQx07a4tD4I6RmBudh0/Wg58Agzp5Ox9/KDrFMXCrJE6S1IkOvr9mGN+GTuw+LshcsB2it68uVJbrkh25wMQrW07mYJ9ysjJRFye9HJMnha3tRr4KN7zpc0j+xNEbk0+RVaHLEYqON3Wbtl1aT8pE39M2149g/t3i3NS+Y0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=r29DWLfc; arc=fail smtp.client-ip=40.107.20.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="r29DWLfc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wcPVpn0HKm1wU/rJvkRFv1jKeKHJT7H/rMp2ReEZPLZNtHnWozb5Hz5r/Pe/jWVuIvnGG4OKms1OVaikL7GgR0mxFAn7pp83eb4ae4IaoYJO+Z69uNr1e55hhcuMzAZPfMdwxe4aW+97WkB6MZTktx200H3B9V6SBFdkTqbaQBPqRGjcVufUuiC4yiLePSSfSjCSrveqEAUUJEUm587RPlNOWOHa5Q9ufF6gTxOOQPNC3+LWGokknWed6JY5LwSYZBYlJA4VqxBJ5zcX4CJQviRbH73N2mdOmocgh0EMMWQZeIHQ+NmegrMJx+LtthasMLRV8wE5Qjvf6mmEFPa4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ULMd+A5h7VJxRvwiM7CWeriIZLgKm/nirYpOmNuOV6E=; b=DQvQQEr7GA8tXWshw17+3rAZbGIhLhjeDCz6T39Gj7/gnI6+rrSm6DTb6/fm3BXYFFxazT3PAMujAqQ680uPNQOHph6N1lIP/1Ho4S4L9QGWpJYXP059x9j0YSzKreCz3j2WQlVpNzaDQoGMuwejaIy35+obzGL6KwHOHn4F3IrMlDHo0KVEYXkwoyOegTC8ABGqnCjBqStet1CHZJSB0uz3qrCUieDueoFm+pkwQdZbTeK1yxKrAkuq45BafUnvdOvdGBGMMlFoTpjD2Z4OFdExCxn//yGd9VvGGIpwMQaAnBK9XXflpDLR+MSyk8cv4HjObhQ3J0+SlUDK60lo2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ULMd+A5h7VJxRvwiM7CWeriIZLgKm/nirYpOmNuOV6E=; b=r29DWLfcZvhsO0ORUZ+z6i/Fs48eWHZ7cszsgeZ5MKjcKbYe2Uk2R6uVUfPxmlgdtAmh9o3zrMHK5YmYTWmwG6/3y8xTOTVpIrv0SLuLePxst+vL9AMJLw7/1Op4wdG2HXk8xCOwxgoMb2kIDd+xH1nffjZmbR+gPPnNog25slWinfzZzV/eT2oISA+XzkaLmVeBKPF6Hf1CNrMY6uLCHpHgqF9vC4HBm/JJ9ihFl+R6GUVO5N3+znAUPm6HNyYmTUe3uLkHvbqqi7betRPLL4PuJ8CC6cutS/tGNvpligoIHvBmf6V4I0uh2Dx2qBr86N8lTPVLObR8Ta1pyLFcnQ== Received: from AM5PR0601CA0065.eurprd06.prod.outlook.com (2603:10a6:206::30) by VI1PR0701MB6799.eurprd07.prod.outlook.com (2603:10a6:800:190::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:17 +0000 Received: from AMS0EPF0000019C.eurprd05.prod.outlook.com (2603:10a6:206:0:cafe::19) by AM5PR0601CA0065.outlook.office365.com (2603:10a6:206::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF0000019C.mail.protection.outlook.com (10.167.16.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:17 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnC029578; Tue, 15 Oct 2024 10:30:16 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 08/44] tcp: helpers for ECN mode handling Date: Tue, 15 Oct 2024 12:29:04 +0200 Message-Id: <20241015102940.26157-9-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019C:EE_|VI1PR0701MB6799:EE_ X-MS-Office365-Filtering-Correlation-Id: b7138d3a-f4a2-424f-84f8-08dced045cef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Afo6DbPVWG87/8fTfOAl0jN8zCZQB0I?= =?utf-8?q?E+N4tlVcIuD6k66C7ErqUyLGIuK/BVPFzD2wuOMHFUW6dIemr54QaH6a7QtE289x5?= =?utf-8?q?FGX9QcEV2gUPFInXoHB1UubYYEL/VOtGH2etJhdEHbRcTT5sQkc0WJHZRnxunLv6b?= =?utf-8?q?E5CZbsKmPbWWBh9W4xg7w2rCxLRm/O9s9gnIZhSJxYd9fAPJxk31YvvU3+W8J8392?= =?utf-8?q?NHMauKUJN+3GBSwTLBPUQyZeS5HMayaOD5wlVOUSZFP128CoJjaq6RI9SjOj4MIdl?= =?utf-8?q?k+6RFMIj/5us77NO8A/Uy0M26h8vCYyOqKgtc9lURR1AZxcja1S9WtLBbjvgrWsUK?= =?utf-8?q?W2xbKUn9K3HSjP45uh7bKoAEo3DSWFIXH7Y311bSKob77XG44nSzHKgX79uV2GckI?= =?utf-8?q?w52NoaU1uNZk25ZHCnxp47oBejYWU4PdaGpyhMsF3VGnJehncwHfIYqtzDOwqHQPV?= =?utf-8?q?/Gt6/STBh9fWZLeXhNv/G2vurItI8m7kBHFT3ob6Fpupz/vGfohOLGpdTfTcXIzr2?= =?utf-8?q?7Etf/YI/La+ZGllC9DZEP8XR0we5Tqdfd3yyxbHpATzzrHgsgeKfl3bPGL41HbxeP?= =?utf-8?q?4b7yKf4RHVL4nDcYsJEet5rn3U8ud5DbHjgcp8rhSD0EITTG5hqPq8AsSJ3PY/FJO?= =?utf-8?q?JXmtPtj02u4LE8ultyb9TMxwPHTlj/I9nuPR2plok6c+hWY38ZekG3AhES945ryPj?= =?utf-8?q?kTfViV+1yVecH+bAeF7+Z3WiK+/zkRM3Oe1Ck/7w04zNhnSfXyvmC3XcqjC0RCAUV?= =?utf-8?q?l1mWKeRn4vWcPvpk7zDSdTnW7c0/seYyLURwvw22MXPnllsTrn35/25aWkVJLDo4d?= =?utf-8?q?dPVueqz+lMSceNZ8nnXgBOlcW+fSskOpWjq3J5mQzgj+UE2ugaSsl0YZuhhZ1kdgN?= =?utf-8?q?UCPh9cfotqlxes6dSc5e2jR/mfDmRysCul37gyung2CCO/pM1Dg5htkrVbGFqOkQ0?= =?utf-8?q?P+jiZEAAri/qHSz/0Qt4JyyE67to9QP2t4vAroFjQBLZhVQmSMl46skbUc5fYt5sW?= =?utf-8?q?d9p5SZNihaPETi7hX4VTWSQ6frBsnmLzCMj0UDpLivZ/SQs8QZVNEBSmdmgzx7ah+?= =?utf-8?q?3S0ywAT0QYAuau1fRDqiay1B8RflqPYF6dvN89/AcJIpw58qEm9vkhPUkde93yYED?= =?utf-8?q?HbEusskjRiKjwUGncjqkr1VzfsUqPiWPnKkgbrCrAJ/J28BkVCJsjg1EuVkK7P7L7?= =?utf-8?q?SC/3KMNhADVcV9gzwIlQGFL5iFoH88IYRxPLcRR3p74/Mfwd8zJh3Oeb0ikV0yAKs?= =?utf-8?q?GpnSuBMMQ3jqnERPf1SDl379nCd16ZRqFl+NrFQg/r3nltE/col6xfaJQkhDuE4YG?= =?utf-8?q?3b6M/dgn3x7U?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:17.3370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7138d3a-f4a2-424f-84f8-08dced045cef X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF0000019C.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB6799 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Create helpers for TCP ECN modes. No functional changes. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 44 ++++++++++++++++++++++++++++++++++++---- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_dctcp.c | 2 +- net/ipv4/tcp_input.c | 14 ++++++------- net/ipv4/tcp_minisocks.c | 4 +++- net/ipv4/tcp_output.c | 6 +++--- 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 549fec6681d0..ae3f900f17c1 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -372,10 +372,46 @@ static inline void tcp_dec_quickack_mode(struct sock *sk) } } -#define TCP_ECN_OK 1 -#define TCP_ECN_QUEUE_CWR 2 -#define TCP_ECN_DEMAND_CWR 4 -#define TCP_ECN_SEEN 8 +#define TCP_ECN_MODE_RFC3168 BIT(0) +#define TCP_ECN_QUEUE_CWR BIT(1) +#define TCP_ECN_DEMAND_CWR BIT(2) +#define TCP_ECN_SEEN BIT(3) +#define TCP_ECN_MODE_ACCECN BIT(4) + +#define TCP_ECN_DISABLED 0 +#define TCP_ECN_MODE_PENDING (TCP_ECN_MODE_RFC3168|TCP_ECN_MODE_ACCECN) +#define TCP_ECN_MODE_ANY (TCP_ECN_MODE_RFC3168|TCP_ECN_MODE_ACCECN) + +static inline bool tcp_ecn_mode_any(const struct tcp_sock *tp) +{ + return tp->ecn_flags & TCP_ECN_MODE_ANY; +} + +static inline bool tcp_ecn_mode_rfc3168(const struct tcp_sock *tp) +{ + return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_RFC3168; +} + +static inline bool tcp_ecn_mode_accecn(const struct tcp_sock *tp) +{ + return (tp->ecn_flags & TCP_ECN_MODE_ANY) == TCP_ECN_MODE_ACCECN; +} + +static inline bool tcp_ecn_disabled(const struct tcp_sock *tp) +{ + return !tcp_ecn_mode_any(tp); +} + +static inline bool tcp_ecn_mode_pending(const struct tcp_sock *tp) +{ + return (tp->ecn_flags & TCP_ECN_MODE_PENDING) == TCP_ECN_MODE_PENDING; +} + +static inline void tcp_ecn_mode_set(struct tcp_sock *tp, u8 mode) +{ + tp->ecn_flags &= ~TCP_ECN_MODE_ANY; + tp->ecn_flags |= mode; +} enum tcp_tw_status { TCP_TW_SUCCESS = 0, diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 82cc4a5633ce..94546f55385a 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4107,7 +4107,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) info->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale; } - if (tp->ecn_flags & TCP_ECN_OK) + if (tcp_ecn_mode_any(tp)) info->tcpi_options |= TCPI_OPT_ECN; if (tp->ecn_flags & TCP_ECN_SEEN) info->tcpi_options |= TCPI_OPT_ECN_SEEN; diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c index 8a45a4aea933..03abe0848420 100644 --- a/net/ipv4/tcp_dctcp.c +++ b/net/ipv4/tcp_dctcp.c @@ -90,7 +90,7 @@ __bpf_kfunc static void dctcp_init(struct sock *sk) { const struct tcp_sock *tp = tcp_sk(sk); - if ((tp->ecn_flags & TCP_ECN_OK) || + if (tcp_ecn_mode_any(tp) || (sk->sk_state == TCP_LISTEN || sk->sk_state == TCP_CLOSE)) { struct dctcp *ca = inet_csk_ca(sk); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7b4e7ed8cc52..e8d32a231a9e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -334,7 +334,7 @@ static bool tcp_in_quickack_mode(struct sock *sk) static void tcp_ecn_queue_cwr(struct tcp_sock *tp) { - if (tp->ecn_flags & TCP_ECN_OK) + if (tcp_ecn_mode_rfc3168(tp)) tp->ecn_flags |= TCP_ECN_QUEUE_CWR; } @@ -361,7 +361,7 @@ static void tcp_data_ecn_check(struct sock *sk, const struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); - if (!(tcp_sk(sk)->ecn_flags & TCP_ECN_OK)) + if (tcp_ecn_disabled(tp)) return; switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) { @@ -394,19 +394,19 @@ static void tcp_data_ecn_check(struct sock *sk, const struct sk_buff *skb) static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th) { - if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || th->cwr)) - tp->ecn_flags &= ~TCP_ECN_OK; + if (tcp_ecn_mode_rfc3168(tp) && (!th->ece || th->cwr)) + tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); } static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th) { - if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || !th->cwr)) - tp->ecn_flags &= ~TCP_ECN_OK; + if (tcp_ecn_mode_rfc3168(tp) && (!th->ece || !th->cwr)) + tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); } static bool tcp_ecn_rcv_ecn_echo(const struct tcp_sock *tp, const struct tcphdr *th) { - if (th->ece && !th->syn && (tp->ecn_flags & TCP_ECN_OK)) + if (th->ece && !th->syn && tcp_ecn_mode_rfc3168(tp)) return true; return false; } diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index bb1fe1ba867a..bd6515ab660f 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -453,7 +453,9 @@ EXPORT_SYMBOL(tcp_openreq_init_rwin); static void tcp_ecn_openreq_child(struct tcp_sock *tp, const struct request_sock *req) { - tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0; + tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ? + TCP_ECN_MODE_RFC3168 : + TCP_ECN_DISABLED); } void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 64d47c18255f..bb83ad43a4e2 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -322,7 +322,7 @@ static void tcp_ecn_send_synack(struct sock *sk, struct sk_buff *skb) const struct tcp_sock *tp = tcp_sk(sk); TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_CWR; - if (!(tp->ecn_flags & TCP_ECN_OK)) + if (tcp_ecn_disabled(tp)) TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ECE; else if (tcp_ca_needs_ecn(sk) || tcp_bpf_ca_needs_ecn(sk)) @@ -351,7 +351,7 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb) INET_ECN_xmit(sk); TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; - tp->ecn_flags = TCP_ECN_OK; + tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); } } @@ -379,7 +379,7 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb, { struct tcp_sock *tp = tcp_sk(sk); - if (tp->ecn_flags & TCP_ECN_OK) { + if (tcp_ecn_mode_rfc3168(tp)) { /* Not-retransmitted data segment: set ECT and inject CWR. */ if (skb->len != tcp_header_len && !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { From patchwork Tue Oct 15 10:29:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836074 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2059.outbound.protection.outlook.com [40.107.21.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB4EC1E7669 for ; Tue, 15 Oct 2024 10:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988225; cv=fail; b=OFkj85hqm/i4yGgPZJY/oY0NiE+gZSZ3RVbmMlZqxkh60EQZT5mCeQpWHrUJo1kXorRIkTE/BypTlY1ax8XjA6TFYKe2shL9YklfJfLnXpkYuYZ66JmNr1AKsuZbome/96JZG6bSv0vJA3KZyANQWptSCyK0N+r992JAx4aLMPY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988225; c=relaxed/simple; bh=6Sx9qBTCTxY479UCAsx2LMSyVr7Qe8WzgVDxPDrhidc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=L3PaxsnPDVHorHaBnhS6v6d3s5zR0fu7+Y9n0+GQHA0A1J7Nfd45a0r9dBArsT2L7o0cZZJ9s/sQq30fgHXUnuGOinmG7hQjAvxgj8CgUR5TiGPJcyqqgRnaojjv/2nNI+NubDZYovWW+yO8GdrnN6bXFmZNNyyaWyjH68rTB1Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=dN/jdCtv; arc=fail smtp.client-ip=40.107.21.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="dN/jdCtv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fWLJZaINH/gJwgpRdUgrRsbk8SUHk+iSguMpGZpCBkzhAAlEWcB7hBzxaJW1xPuO2nulolFXyO3g1mht6BH086SVomG0zkS1apN1Z1nwHwf2j8MbkmT3efmeWtdPiLvR+dGnKVgdOz+Xwd0UEQzhUqlkaQHTtvPvG78XbjCGJU3+rW2cNw7tUnUsmh2b7OnGi5lwsuVpVqxGlPCZLbZq0YBt3VndU9rMWp012DzJvUhAqna4Ge/M6J7DcRQqJrgESjQ3qy6qjG6Rqm4H1NmzGBAKdsVHCYkpKA4tm4mQ/I+8bmbnZmpv6N39OAQm+vIAGse6gA8Uxvn5ttB+E9jssg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bv0Ov8Ang6Utb31hNCUR9cNxCKHwSBMvKHA6lzQZylw=; b=gO4b3qwwxskOuTx4Tl10rixKqP05mS62UxFTHS8Ja31eHmW2ztYMsQ5mKBeXa02TXFnXf8YIh6czdb9ZkTBjgHeypPLApTsW6JpgVlgfsu2ad5kcoomjLavgZRoQhdLYBPughpCUeWy8iA/r4OZNFMugiQ68VhmMrX1L4zCQ9DhC953p8I856XPKWr4YiN/T7Y3Gs0GHIEJdkp8Ao7UwMYiJFRvWKX9vVUMtCEHcK+lUYJ0ktz8iO9XsJVpNSbgRC93HVbipI1X1D9fDH1DoHLxOuw4ehPSHQd6addWp/DgXIuw5Vfu0hayaYw4tSh631YrsXu3lio2eVL0jpOwc/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bv0Ov8Ang6Utb31hNCUR9cNxCKHwSBMvKHA6lzQZylw=; b=dN/jdCtvAcDy+2PTIPcv2cThYeFlaPMVlqWkokAsn0+uKEg7rXgKzUDRf9DGTn89QY5fsFfTR5WrLTY5J+XnGJPGHk43YZACVogeTnL2A7DiOJsuE4H65AAunc3uFV8jHexROJjfTO5/OFmlENMRtXxHeIQghxH20fZbSzRaSlVAGrNtyviqTGSiqPhicxAuWDc/1UL5VZ34m/7srbfnKvO8yHOk8Z8xWN3N4vQlVJw9tYNZ7E5PhNp96VrSYlYdVAfPOx9EgLB5NGGyZPIo6YKbGmfo8YqlCTodrh1cm6odfJaaSN3s0B9cFsfQmo44I6F0U+UHAPH6PiZMMpUqdg== Received: from DBBPR09CA0003.eurprd09.prod.outlook.com (2603:10a6:10:c0::15) by PR3PR07MB8067.eurprd07.prod.outlook.com (2603:10a6:102:14e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:18 +0000 Received: from DU2PEPF00028D08.eurprd03.prod.outlook.com (2603:10a6:10:c0:cafe::86) by DBBPR09CA0003.outlook.office365.com (2603:10a6:10:c0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D08.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:17 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnD029578; Tue, 15 Oct 2024 10:30:17 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 09/44] gso: AccECN support Date: Tue, 15 Oct 2024 12:29:05 +0200 Message-Id: <20241015102940.26157-10-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D08:EE_|PR3PR07MB8067:EE_ X-MS-Office365-Filtering-Correlation-Id: 772f627a-c6d3-4c3c-6e83-08dced045d55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4qS2cNAtdCabOXXmhz69HaMsbjXy8Bo?= =?utf-8?q?AjXF4j3Oqk05GIIG9ef4d8TY8JFAt8+M0R4zOJwZGcgjAQrWiWWcxWM5HOTVnjL8f?= =?utf-8?q?Az27Gck3b48VePRy2jY3olLnj0WPoQYh7OpIWIxv/DGcG/3A8a9s9BP1oX/Cd35Vw?= =?utf-8?q?uRd6cVgEHKmOSxHU9oCSTUBeb+n8fEqpv+rCcowQLdJceds+TslDcmsnL7VXJ5GTj?= =?utf-8?q?SOSTW5+0usDuB1UmVSWtPTHEufIhZRdkefJP0IGt7+m9ADTHe5zeI0XI70mjXLb93?= =?utf-8?q?nLkNsOdF202Jvcm0su7OHRLtGf8sm54NDlc7Zs93pTchKx+a42eQqktdDZW1/ZmfU?= =?utf-8?q?OYl5gIaNkiinjpRzzHa75G8VXki/K6R/m0EnelhLNjQkwhykgrnp0JNkSw5abKm+A?= =?utf-8?q?M7UbmkFew2GSJXxLwB1U+VmHJSVjaqTb8yBKAfWCaQJH1zw5jbo09OYSxtDq2Vj3a?= =?utf-8?q?mdRSCTTFzuvHj95LYjt3PEMyauPIQQ3JBQPsvaLYBfnS60U6bbi1fx1nxHoPADub6?= =?utf-8?q?r+pjCmIse3iAK4IDvdT4KmrDGh75b288vIvmO+IGJr7jTqDpgijoUA/vOUX6uG3aQ?= =?utf-8?q?SKHLw00gMsZt4D28bRGRlOdGFfv8JdDjhVM28+hCLkq7YpRDcREvI1EmJbVYMnDia?= =?utf-8?q?13HUKmwzNcq/szamcJxx4qPM1ZfOWM9bjOKLwGeFpoQ47Qquv//OeJzU9dkwWdwm4?= =?utf-8?q?o5KsU6W4PzpCjea4O6YAV/IiKYM61tXNV1OQjXUtU81OWWz1y+V6lgrFZXkSOh5Ua?= =?utf-8?q?EbSZN6SsxHNfEUbNStgY9wQrX4QLrYnl34DR8VXpa/1Qw7dyg8po8GRp8Ikn4l6Rq?= =?utf-8?q?+LwFYtov9v/wNNOzUGUCnKU34Hlycb4TaGwMQNtbFaCPsHgqZdIHgZGLS1m0oH0mt?= =?utf-8?q?GDmjk4YVAkKpycRcz/Vgh22pBUFwGcqUVTwPMXzLm31cGfP2E6Kju+smRSftzV779?= =?utf-8?q?qC2CxkEbDqsPEkWn/zHSznGWe6929lKqi21RvghFg0FMlv1VBK4gKEn59ujlxNia3?= =?utf-8?q?sOhnx2p5nX2ObSSa54MVc5XFfJx2pO/CTSRDu9xnY0zbtdG9RYPToaqVkAwk5rYdz?= =?utf-8?q?vTtMGyioJSxm4F9SRsRhGcSXwFFpq77D6Tj2UTT/Iptn1GJT/itvrjq4D2seb8UTB?= =?utf-8?q?5Ic+F7nmP3rCy5RSck3JnBduv2zHy+ifMSeZ40nIXfjEHUq27R/KOO1ljE1LBOaXO?= =?utf-8?q?Ap9xYvc35/jkU+cwNEmqejwsSJ3HLy7azlUzFxHdL6IuCL2JKPG4nY+AZJ3s3p7cS?= =?utf-8?q?w8CR9z/S6vdQZoNaVOskXZ/xH1MSBm6HTmEL5qmS3+EurtsyWoYwzp/fGkBVrBmNs?= =?utf-8?q?J0AK+ke2BgHp?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:17.9737 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 772f627a-c6d3-4c3c-6e83-08dced045d55 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D08.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB8067 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Handling the CWR flag differs between RFC 3168 ECN and AccECN. With RFC 3168 ECN aware TSO (NETIF_F_TSO_ECN) CWR flag is cleared starting from 2nd segment which is incompatible how AccECN handles the CWR flag. Such super-segments are indicated by SKB_GSO_TCP_ECN. With AccECN, CWR flag (or more accurately, the ACE field that also includes ECE & AE flags) changes only when new packet(s) with CE mark arrives so the flag should not be changed within a super-skb. The new skb/feature flags are necessary to prevent such TSO engines corrupting AccECN ACE counters by clearing the CWR flag (if the CWR handling feature cannot be turned off). If NIC is completely unaware of RFC3168 ECN (doesn't support NETIF_F_TSO_ECN) or its TSO engine can be set to not touch CWR flag despite supporting also NETIF_F_TSO_ECN, TSO could be safely used with AccECN on such NIC. This should be evaluated per NIC basis (not done in this patch series for any NICs). For the cases, where TSO cannot keep its hands off the CWR flag, a GSO fallback is provided by this patch. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/linux/netdev_features.h | 5 ++++- include/linux/netdevice.h | 1 + include/linux/skbuff.h | 2 ++ net/ethtool/common.c | 1 + net/ipv4/tcp_offload.c | 6 +++++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index 66e7d26b70a4..2419045e0ffd 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h @@ -53,6 +53,7 @@ enum { NETIF_F_GSO_UDP_BIT, /* ... UFO, deprecated except tuntap */ NETIF_F_GSO_UDP_L4_BIT, /* ... UDP payload GSO (not UFO) */ NETIF_F_GSO_FRAGLIST_BIT, /* ... Fraglist GSO */ + NETIF_F_GSO_ACCECN_BIT, /* TCP AccECN with TSO (no CWR clearing) */ /**/NETIF_F_GSO_LAST = /* last bit, see GSO_MASK */ NETIF_F_GSO_FRAGLIST_BIT, @@ -128,6 +129,7 @@ enum { #define NETIF_F_SG __NETIF_F(SG) #define NETIF_F_TSO6 __NETIF_F(TSO6) #define NETIF_F_TSO_ECN __NETIF_F(TSO_ECN) +#define NETIF_F_GSO_ACCECN __NETIF_F(GSO_ACCECN) #define NETIF_F_TSO __NETIF_F(TSO) #define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED) #define NETIF_F_RXFCS __NETIF_F(RXFCS) @@ -210,7 +212,8 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start) NETIF_F_TSO_ECN | NETIF_F_TSO_MANGLEID) /* List of features with software fallbacks. */ -#define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | NETIF_F_GSO_SCTP | \ +#define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | \ + NETIF_F_GSO_ACCECN | NETIF_F_GSO_SCTP | \ NETIF_F_GSO_UDP_L4 | NETIF_F_GSO_FRAGLIST) /* diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index bdd7d6262112..92fb65090ee7 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5067,6 +5067,7 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type) BUILD_BUG_ON(SKB_GSO_UDP != (NETIF_F_GSO_UDP >> NETIF_F_GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_UDP_L4 != (NETIF_F_GSO_UDP_L4 >> NETIF_F_GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_FRAGLIST != (NETIF_F_GSO_FRAGLIST >> NETIF_F_GSO_SHIFT)); + BUILD_BUG_ON(SKB_GSO_TCP_ACCECN != (NETIF_F_GSO_ACCECN >> NETIF_F_GSO_SHIFT)); return (features & feature) == feature; } diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 48f1e0fa2a13..530cb325fb86 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -694,6 +694,8 @@ enum { SKB_GSO_UDP_L4 = 1 << 17, SKB_GSO_FRAGLIST = 1 << 18, + + SKB_GSO_TCP_ACCECN = 1 << 19, }; #if BITS_PER_LONG > 32 diff --git a/net/ethtool/common.c b/net/ethtool/common.c index dd345efa114b..75625098df07 100644 --- a/net/ethtool/common.c +++ b/net/ethtool/common.c @@ -32,6 +32,7 @@ const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = { [NETIF_F_TSO_BIT] = "tx-tcp-segmentation", [NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust", [NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation", + [NETIF_F_GSO_ACCECN_BIT] = "tx-tcp-accecn-segmentation", [NETIF_F_TSO_MANGLEID_BIT] = "tx-tcp-mangleid-segmentation", [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation", [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index 2308665b51c5..0b05f30e9e5f 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -139,6 +139,7 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb, struct sk_buff *gso_skb = skb; __sum16 newcheck; bool ooo_okay, copy_destructor; + bool ecn_cwr_mask; __wsum delta; th = tcp_hdr(skb); @@ -198,6 +199,8 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb, newcheck = ~csum_fold(csum_add(csum_unfold(th->check), delta)); + ecn_cwr_mask = !!(skb_shinfo(gso_skb)->gso_type & SKB_GSO_TCP_ACCECN); + while (skb->next) { th->fin = th->psh = 0; th->check = newcheck; @@ -217,7 +220,8 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb, th = tcp_hdr(skb); th->seq = htonl(seq); - th->cwr = 0; + + th->cwr &= ecn_cwr_mask; } /* Following permits TCP Small Queues to work well with GSO : From patchwork Tue Oct 15 10:29:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836069 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2055.outbound.protection.outlook.com [40.107.105.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8145C1E5717 for ; Tue, 15 Oct 2024 10:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988223; cv=fail; b=KQDmgXXvubCa8mLVtAPP6TDtDb+cypM2Xq+EcS2d1JdM+V/TxUoKq0iKnwChDOzggYkhk3fSrkIMJo9m6tZ8TZ0L8s5RoIbnrymJxBIE7JFDuppcZZvFeI+rwIp9zcpqL5advV4aEkKm/opmh9b1835oeyXA2DW9uNSexrl+508= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988223; c=relaxed/simple; bh=4j5SJ5HYuPel2Dv+IBBWRsO/17dTAoza3QBOY2Scc+0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=P79fHl1iIrQZOQ9S5ny5N/rkcM4facFgSrMN0sFNS0C93w9QW4fxUH91WqWXU1sylTWSeOyDNn23Sh5T7jheFYo3VDAgrqaIf3IkKuAYJQ7eY8sg/HNDxlaydtXVnQKL/64p4Byq4R8UYpdnnnZ8Tp7cbbXgIr6Um0f2TTgCHaA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=Qpdu1U03; arc=fail smtp.client-ip=40.107.105.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="Qpdu1U03" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rfH7Pa+9l8wC8c4h0m5BLkc17z9w+XzkspnQUutYbpBS1o519YntzgiOj6J2fup4HRMGuztrvv1pu/rL+F1pypJ+FW9eRQIYpsCbynK6SfW+i0CZNcQr+s3pVwg37SgtSqUmWaSOqOjuxbLmlzUED0f5yh59yex5a0KisbQ5C52QKdGB7LjNycbVemg0whidEeItJ17VQNvAy6wgLmtcs5myXtTwB5jfMmu5k/LDAk1kJacI+td9fb4Pf4p3acjcEKBB3GKVAe8msx9cfy0MvG/jtfw04IplFRaLz2QQIZNnSpkCC1pAV14DW9aiJM9I5DEgK7NEPrqycU8pdEzWIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VSA7eqx5WtqjVvMOGIZmeD65xQRrVJgg0ZR6KM5OeDg=; b=NNI0qboxQCmPv5HLrSlNFwHufy741TCAAFyMv5KpgVHx3nDvcSSAl2VdGFxYsmb0RCOqxIlo2jzCVfyk479FGA8CpL+rHkGZGymGJsFdlgFoXI5ORDVXoduhtLIXjAi38iMHhihcesQGcms+IHwIMNxm56tGFopLD4VrJu3uLwDs23mHj1mtUo4X9eIURiShuPzG6FC9TxienTfBPemhCZ7LuT5nY9yxIo3ylc83MKy/jPOL/47uY+g7iZfHU/vwSm4WORno3zcVZDXDLQGezqsCJSBBIBPQq/8bPjcWdf8y+jDMo7JFxpPCVfuf3hCBfIYnyXYsSOFOTxLpIZ0XQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VSA7eqx5WtqjVvMOGIZmeD65xQRrVJgg0ZR6KM5OeDg=; b=Qpdu1U03EsVukVnVJHlx1wMfm+x62qvMVEhZPdYb2R2pYj4MYmn0H49K8rmSJg8ML6RSyZtmAcK60ooRGGW37JJLk/QdgagfrkXV3R7ftG0k9hA8xItasS8fMLtbiwhKhHu+vY9AkBvTqfq30syEkIaPn+zF8cRGvttGb1UfP/89gMshCWlso3vIljsG07cEU5ABC8z5Ds7gpT2HGadSDmWpdkL3zVyFLvSnGEt/Jtga6tQga+lL+jDKI6PZvsVMiiX47w3TaJjsmqnp3vCzf1MrfFoD0I3icvJyGJBUd+WL4fz9hCLbnsVazOr1VAIrdwKMl9BNDmTNfTIqAj+3cQ== Received: from DU7PR01CA0021.eurprd01.prod.exchangelabs.com (2603:10a6:10:50f::9) by AM8PR07MB7666.eurprd07.prod.outlook.com (2603:10a6:20b:240::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Tue, 15 Oct 2024 10:30:18 +0000 Received: from DU2PEPF00028D09.eurprd03.prod.outlook.com (2603:10a6:10:50f:cafe::97) by DU7PR01CA0021.outlook.office365.com (2603:10a6:10:50f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D09.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:18 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnE029578; Tue, 15 Oct 2024 10:30:17 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 10/44] gro: prevent ACE field corruption & better AccECN handling Date: Tue, 15 Oct 2024 12:29:06 +0200 Message-Id: <20241015102940.26157-11-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D09:EE_|AM8PR07MB7666:EE_ X-MS-Office365-Filtering-Correlation-Id: 46f9ad40-b87f-46a7-05a9-08dced045da9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OBrSoxDbGH5eXgUCqTcSyjqTCKqFx0i?= =?utf-8?q?IAUYrs4LoNHNkr1fY+1jP4uFXw4uySfoUkL3fMDG+0nD8wydqpCNmmSKgJYN9rsH+?= =?utf-8?q?cu8x/JLgV4lT/zmlBIDmexfc5rPfa446lbin6P4utAE16zGT5nzAZH09SJgkjBjQX?= =?utf-8?q?70YfGvFxayPLg0bQRkvCkJa8O6TlenA+9R5C2zsJA1OY/deS++Hsj2CFPG3qRXrwA?= =?utf-8?q?9qPrApjMW6DrehxCx9vggk5+pIXlmBp2Oct7gvm+Mx1kqYdra5ij/9bZHqMmEoHJx?= =?utf-8?q?dy0MCHI+FDNXVGd7L+Y7yFO/erek6P2FxWWM+1y4YV19hkDp4xlLcJi7b2aoNKXzd?= =?utf-8?q?hxJ0Xklz+VyTbVlGPLs3cuDRkl3wTgQn7FzgivIHN96R7YKm8Zf3/lSuqkhduV+Pd?= =?utf-8?q?vTY1vHYoNJhkdSSSvotc9yYO8iVQHI1pvctVIubHdFfYHucMrhdRaJucPv8JPfLYv?= =?utf-8?q?lpkg1iKH5wSjiGaNWTi13iALP/zWCABFcYjt2np6g6ToOyyb3mRdnNG29cBj2cr+t?= =?utf-8?q?tfJEk1PrmZy5F4hFbPQUeyDJjy4ER/2YtupnT1fnzgbTz1PaAvHUUWUjeM4KN3Oqy?= =?utf-8?q?lXdNEfjNYQXBTH5LTuQdEa/Xu0Yti0k2YnrGxqN4YyZ4w4wQoU4Kjev0QW5sqhyDf?= =?utf-8?q?gYEwHjA5D7Ta0Bvjk2dbu7hGDLTutG7eizj/jcMW/EhfTE7XFf+zq181r0ukNNKmt?= =?utf-8?q?rkGNBpS/+Npq5UP7NXgUdf+CV4WDRJsElQzZcTeFT4+E/8dLWz1//ogotKpByvvQ0?= =?utf-8?q?YWbTzQt66kX61PNyjboVhVSOJkLclS7JlDyJ9FeRWEcRiPPqinDpi+k9lJ1cEZxkw?= =?utf-8?q?rsBU7iChVanYGD/u5/A+Wta9jiBQGtPEOcqU5sjNnMMHk3RE3/ndYatz3PIXTz8U1?= =?utf-8?q?fB065ZZgUud5PXQAu+lc4banzw3Afy59IJFbq4oWaJ2Tro/klAaHK+9R62OYr9Wp2?= =?utf-8?q?YGSQ9XcymBZZdPJhKN7CXmvt/prZINETt76+T1dDDIDNQ1g+52E166VGn0AGQjgU3?= =?utf-8?q?5NaqxHa1fSUUUT9XK1rZSopAaHzOduS231VVHv53CTosz17BkvUItbNSFyCstkqOU?= =?utf-8?q?K9k9NisQJZ8a1BpBagAFT5DVdv/VZikhQ8ey73l4gSvym/KsRXEg3i4Z8lABZoEfp?= =?utf-8?q?/gAPRPY0v3lbvK9J+3YO/KitwfmPFFitPefA498QNlNDefRs2ZtUi42Z30wx2P4Aq?= =?utf-8?q?CaCBH7IfnPx+CVyxtxGkfWy6Iw+ook6CKCqbZkQ9T+nCJgM5w4hMlhqs6NYw8PJkC?= =?utf-8?q?e8A2MQRLuzZY4lxYnUYW9D/aKGkjwVqAsxRP50HxfV8AeCNN/xGN9xleygRPDXfJw?= =?utf-8?q?16imJ7nUBbJA?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:18.5059 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46f9ad40-b87f-46a7-05a9-08dced045da9 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D09.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB7666 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen There are important differences in how the CWR field behaves in RFC3168 and AccECN. With AccECN, CWR flag is part of the ACE counter and its changes are important so adjust the flags changed mask accordingly. Also, if CWR is there, set the Accurate ECN GSO flag to avoid corrupting CWR flag somewhere. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_offload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index 0b05f30e9e5f..f59762d88c38 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -329,7 +329,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb, th2 = tcp_hdr(p); flush = (__force int)(flags & TCP_FLAG_CWR); flush |= (__force int)((flags ^ tcp_flag_word(th2)) & - ~(TCP_FLAG_CWR | TCP_FLAG_FIN | TCP_FLAG_PSH)); + ~(TCP_FLAG_FIN | TCP_FLAG_PSH)); flush |= (__force int)(th->ack_seq ^ th2->ack_seq); for (i = sizeof(*th); i < thlen; i += 4) flush |= *(u32 *)((u8 *)th + i) ^ @@ -405,7 +405,7 @@ void tcp_gro_complete(struct sk_buff *skb) shinfo->gso_segs = NAPI_GRO_CB(skb)->count; if (th->cwr) - shinfo->gso_type |= SKB_GSO_TCP_ECN; + shinfo->gso_type |= SKB_GSO_TCP_ACCECN; } EXPORT_SYMBOL(tcp_gro_complete); From patchwork Tue Oct 15 10:29:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836085 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2040.outbound.protection.outlook.com [40.107.241.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 977921EBA13 for ; Tue, 15 Oct 2024 10:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988233; cv=fail; b=ggvaxSMVGT2ODkoYyhKxFEx0fTWhRn2XgKtTABds0opF/4F83ZkSYBWLzAT/cB7h+HRjNhT/uXRhTK0ENJ3vkE4zl1NVroWB6Z9OjsfzSF7mDaoBQ4vSkUkv8Nmk12Yu09bhnB30C+8/gDVr24qamf+Lv/9Im5J2iSdfqKYJD+A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988233; c=relaxed/simple; bh=fKBbeaPVW8DcZ6DYlD8c8/FTqvLtUMcI3CoRxLvDMr4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=U7UHsDZx0DwHK2l5G0y6Mf5Z1SJ98/Bn3hxYGcHQHaFNxAuaB0hMdYIuLBDGqzqYSQBXbrw+rQt17UNHQG304P3xBYA7Me8y/2Ixlv7tzgdYNd1waGMNwNaClGUT4+V+vfWMxBwB7mFC8PdHKcI+1y1W87L0oM86iCxAa9Q+6e4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=n1yMvtCx; arc=fail smtp.client-ip=40.107.241.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="n1yMvtCx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ANPsIfYAUbp5cTeCLub9pATuvLnmRUG/txixFKuhDyDiqXJwE1l+c4vus48mhc3IjZ4uUzjZOum+cjnfRKMFwB1gYlBV7qt0in89vzgPlHiMDn2rJsoUgdk4WsJwzaPKktFfTGE173Urcdf0kSW1PuM+Z1hrXp3OuwkLBcXk7CrYef1EvCkKCF4Feh3wr6vwh1ctD+PCj/Sy7HiUKNvlUPjIkgyYi3LQeP/7Nm9ElZGVL7cHEhkyeQ2mODL525VR5bFzxPTOamhqnKw2Wjxs8aqhhNAfoKKAjXj8JXE9TFGef44v0eeiD/eVWp/URdk0dy4+5VPeK4bCzBrhrg2IOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JS+bjUXzLdWxU/fiVihhJtOmIUpj4scV3/uP4j163Rs=; b=mx5tReg0dH5Cs5+i2DpxHaJsAtIKi/q7cP/TKxAB3Mq0mY1DMWqPcHP8rpUc8iJYilBelo/i1obZ1NKywuHHhu2Buhz5rxtjzduiFcQFETjSQJ912BEPghq9al3+FuCpmvP6dkKEFN94eIhee8lm92Z48QvdFIwMWwkA01oXaJYIrO+rnbM0YnR2kx9JiJnP34tBjg19vFdoK/12LqSN7l1+tB9SyUNDD1u2g73lmyHlM2TTFjK5j9Ay5tjlpOLQKPIXGDHJgx0ZKtQ1ke0PYEe1DSK7jq3xCF8c8kexX/KnqUwJHoO9POKfjD3hOgH0I5INDCOOAbPyxaSu3ZXIJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JS+bjUXzLdWxU/fiVihhJtOmIUpj4scV3/uP4j163Rs=; b=n1yMvtCx/KJDGCFFAFm3hRJkXdJwo6EjH55nWgGIXYZWRg1dGX2+btNvWhWKceauw/1DSiWq/HElsHlCEIxuyI2HS1B3QvXny6ndlDUyCJg9iZPaMfZ9VocckJRLh9oKx/nzeL3ofKZYG1CpZaa9Fw5e+3Y+b55ZsSnway9NLA/5HKYX5i4NO1hC3NWDmVZ153CfXVbYxcUO4oiT5p/NH1EqDbPh/5iX/DwTnAfGBVyAlLqvuN0X6r8wWL9tZD6m9llx/zY676OMhbNOhq4SlWBnecPwueE3vUWHoyEVbf/LMmtCkeG+Xo+WjN69sGYHNS9C4sw7t41ZaSaQsF/2qQ== Received: from AM7PR02CA0030.eurprd02.prod.outlook.com (2603:10a6:20b:100::40) by DBBPR07MB7467.eurprd07.prod.outlook.com (2603:10a6:10:1ea::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:19 +0000 Received: from AM2PEPF0001C711.eurprd05.prod.outlook.com (2603:10a6:20b:100:cafe::a8) by AM7PR02CA0030.outlook.office365.com (2603:10a6:20b:100::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26 via Frontend Transport; Tue, 15 Oct 2024 10:30:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AM2PEPF0001C711.mail.protection.outlook.com (10.167.16.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:19 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnF029578; Tue, 15 Oct 2024 10:30:18 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 11/44] tcp: AccECN support to tcp_add_backlog Date: Tue, 15 Oct 2024 12:29:07 +0200 Message-Id: <20241015102940.26157-12-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C711:EE_|DBBPR07MB7467:EE_ X-MS-Office365-Filtering-Correlation-Id: a02c2fbc-6a9e-4e43-a810-08dced045dfd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?gUxu9xB1F6JgjMTvzzhUuACJ5n0lNdB?= =?utf-8?q?4evDa8yN+lF0KhUB912kNc6HmYbi4EeGbFGhubKHXoptvUZU8HfZfCEWiyqQL1OeU?= =?utf-8?q?Qnz0cPqiQg42X0P0Tacc88eY8xZOA9JNKx444oWpb2HIfFwiZcAZpcu4jiUgxOqBB?= =?utf-8?q?5d+K8XNqbeA8wpOf0DqqEdUydAuJP8fKTGcNVbkcrfc9uTE9hVCQUtO9E0eIevG6c?= =?utf-8?q?cLlOjPAVciCVp2DN2Qcbalj/huYJ3JWEkmHEw5BcLod1y+jwADXXcK2RPqHDuzvtr?= =?utf-8?q?D7OpdqE36frx89JmUProb3zHDer+z93byF7XG2YoUn3vPI8wQfxYS99lDbZKP02Lx?= =?utf-8?q?5ObwDG5PHNNCMxmAuNfzhlVwDA5YQDISJk33EIw9pcUyPnBCTVoEZt4DL+JffLCYC?= =?utf-8?q?ZfNiLyR5h4NB0mvGSd8zhTSyUTzb65+Tl88tzx6Yt0q3l8qf95BUcCh6R+YMjgw76?= =?utf-8?q?IVI2/ucT/9DzZY2D0sjbG3t10ed8MPbMycj/QOO26xhTzQcJJtDKA+D6R9goKa1Wn?= =?utf-8?q?3TKEEBnbuHt3p/G6Df+OMGXqyo8FSZwiDCx2cQQJDc19DD8Q0D23E+qYdaaMamQlU?= =?utf-8?q?gEnO53SUCa2YFBn0LiGlTJh+T1EUYwaaO+aH56oPzsEQGXzaaCGIzUCM1yCiIQTbb?= =?utf-8?q?XucwIcGm5Cgm+kaxAWwTZkQ+DRjQ9qAsDhkt8+hqMmMtPN1zgnNbvvsdm3Iqd2KLE?= =?utf-8?q?LVR7IEJhMWVYY2/3MQGh5h2EcYr+sZnUi3HzG99rr6tePmb/D5brJgAaldYOo8OF2?= =?utf-8?q?Azxk/21FEzJMwCBButQr8IgPlvNV2j6u2JuiM54toyLza2zRVQyWlt4MSjdiVail/?= =?utf-8?q?gFTOQxglSI/hGU3/i3nBq/Jisnu6hpMKsyZSpaMuzzjd/5TIpTfCWzPplWxqGklc1?= =?utf-8?q?s04sV2Zb9q10RkJpAtBWuJWaCUTAF0zGinBQRMNMwnk7+9Su03tjqZy9ExlfwFl/g?= =?utf-8?q?HTiIpiBg9OtdKKO9PPzD0xLq1B0sgOw5cWO2S8ghhuDF1PEwHZ6WvMA6XRWHvq5Rd?= =?utf-8?q?aSUP/hcUj8HgvVWvkEhwRmeklNQeTPQ+NQIcflox8VT4M15MjactV+AjKxywlJNiw?= =?utf-8?q?DG2p06Hw8UGyArbrKx5MQpoER9wjll7WVWc09XgzTK+EIIbrHxmcwT+ybXTyse0mz?= =?utf-8?q?LTN1K5FAWwVighG+7fcZvtCUqtB8ObApIQeCezS9RdGw1tpDj58ZRgovV9gQlRM/j?= =?utf-8?q?UOOaFUE9OEtHWnGd3xtgTooWTcnvGYxZjhuWGhFCAKofwcNRkVDzz54BHa60RNTnd?= =?utf-8?q?h+ekeA9Rb9RjOBNpxR32YRp6ktwnNf0f6cof9V+O/VqC03NWsvV5ovfqjnmdNacJ7?= =?utf-8?q?ZmjOzm0KowQz?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:19.1074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a02c2fbc-6a9e-4e43-a810-08dced045dfd X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C711.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7467 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen AE flag needs to be preserved for AccECN. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_ipv4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 9fe314a59240..d5aa248125f5 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2054,7 +2054,7 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, !((TCP_SKB_CB(tail)->tcp_flags & TCP_SKB_CB(skb)->tcp_flags) & TCPHDR_ACK) || ((TCP_SKB_CB(tail)->tcp_flags ^ - TCP_SKB_CB(skb)->tcp_flags) & (TCPHDR_ECE | TCPHDR_CWR)) || + TCP_SKB_CB(skb)->tcp_flags) & (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE)) || !tcp_skb_can_collapse_rx(tail, skb) || thtail->doff != th->doff || memcmp(thtail + 1, th + 1, hdrlen - sizeof(*th))) From patchwork Tue Oct 15 10:29:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836077 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2088.outbound.protection.outlook.com [40.107.20.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD5971EBA13 for ; Tue, 15 Oct 2024 10:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988229; cv=fail; b=iX9U+GnguIrotxtx27gWBEtsyM5xNLnS9Ut7uYj4rIAmj7tEM6pyISw0qfsyRsAi5oshxnnmClhrhNmfdJqDqGJe3WZVg3LA2jtumSpedxFHHUVlPi7cPfSTOTGGYotxj87qOOiR6wVwAyIGY8JTlyg9aFOb/VMSlQcjmDm12p8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988229; c=relaxed/simple; bh=ZZLBBPsXEl76UOxnvAZ1AxEbusKk9Gb/BZJI0Ei8xMU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZP6yDf8mfigulaXvotuWM2Bw8nJJilgYtKFeBAzfB3c8fOLghRlVI6KXcwb7v+LL+//HuJIHYblZau0cumZsnR62HTZu9x5dkId0bVsX/3hDr4h/DhnXkdfSqeGoN/LL4tiRm0PK4O/wK5ZWo/82LYjvNec9JUz38kYeJgAjDgo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=EhXBg643; arc=fail smtp.client-ip=40.107.20.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="EhXBg643" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ayheyiWbyS8UEBP5krTBGvChFWPpDG7xSU+6beb3ZVDvlHEffc5V43rMUvM2axIAVXobtFe70UQm0vtPHsRkM/s5q+EcbTC94RwLqnJ2i+3Niwr0PpYItO+SqJuCuYTSrx4Mz+np9aypKoENey7fhO6+TRUw6+vVn6/qcgUHJmHiBUfx4qel4pKjR3Na3K+FKnsDD1tZJaOW5okWN4SlKTajxze9C7F2e4MlMvJ7ElHOBYu94cp6/olreoUffSaMfZ15tWKE8o1pAwZWpXl1czTvPemvkBdApmOkflHqKuJy7EpuJzzZFLEA6n8tNMXmRcS5G6PTs5wSk0R+RQKa2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sTd4kCFgA0flO2yxP58SbyTLmsBf6cIegpV9zqGv+Ho=; b=I2ZuS4qDWe8U8IXzh/j05EMDBVXTQiJMdC/IdGqzSxm931pouBRqZNG/1iqSbuGTVzxsSWTIp9atCnzINVmVUP0BdqqzvSK7VRqZySlM8zUizF13J2vhZq63902bfRqDdr9pOJ/vsB6bCF8KsydnDw3wrgk6r+p8K0PfTVg+xN0/pLwUqm1be1Acemh9oqw6CuaEZXTb48J8WuqRkUf9LLFl0E/BSifz2kT3xxIiQpUUxS67HDfaAWRqY5VpFYIa66BoHRoYNwGTBSA3SLlyOXFeUTVB0QTBnhKWdfIYFyVGlj+zT3JRbmyiBJYGhg/wkWvPe6pZaNwFzjXKSuxkNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sTd4kCFgA0flO2yxP58SbyTLmsBf6cIegpV9zqGv+Ho=; b=EhXBg643sQbKPrGfsLu0Est84Nl2wyaZzGZehRGM1EmVEE7YsDPwslpYVRj2LHPZT4ZvnRGSOo7aIQTU8BBEJhZi1QqOoQANrYprlAWkpwtrPUrUn6qcPzijn96Bsce45NiimmOqz7/A1yVV05TPwQVy2WAj5L6Cg6psBsgB+OmSfuVe1BKmykLk1UNrVA0SGj3zXoROZXRPpDR7UQdBfIYw8WlorsmiPC0dKuzDv3RbpE7NetoBlwRHdiHDCpP6MCXWFNvbaXxZ+h08c4/0NCl2WitZYFZbOyeU6alqbocrmZjAmTjtb7Hh4YagrWIT+6f8IoyKVGR0cyKqHY+Rdg== Received: from DU2PR04CA0189.eurprd04.prod.outlook.com (2603:10a6:10:28d::14) by AS1PR07MB8615.eurprd07.prod.outlook.com (2603:10a6:20b:473::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Tue, 15 Oct 2024 10:30:20 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:28d:cafe::6c) by DU2PR04CA0189.outlook.office365.com (2603:10a6:10:28d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:19 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnG029578; Tue, 15 Oct 2024 10:30:18 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 12/44] tcp: allow ECN bits in TOS/traffic class Date: Tue, 15 Oct 2024 12:29:08 +0200 Message-Id: <20241015102940.26157-13-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AS1PR07MB8615:EE_ X-MS-Office365-Filtering-Correlation-Id: 312e2f9d-a114-43fa-8afd-08dced045e67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?EyUhSQfZ+krlozxCYhx3NDNfu1O3m10?= =?utf-8?q?iUKpubkVrougZSX367eU8NgjB/tgDs48jcKjczGzN27t3GjhelM04/LIO6RC56O0j?= =?utf-8?q?KZibjH190hI+GPuksIEFKQF5q1kZvTmqPFkrmjlbUmgOT9z+QlnibhUMJE0LAsCoy?= =?utf-8?q?836GZzr9ZjYg5aqb104MRJbrxiJSCiZ57qYcM4iZrxqEv6HBG3xy53FocG8MZVUiL?= =?utf-8?q?I2pRlV9C6fFRfjyi7WvH1f4jBKQ+GaZBPVSb39C7NVAjf7vuaXnR7inRMIvwHHWYS?= =?utf-8?q?elkrEzTW6Y24MlAa774m4ANGDpWPkeSyYZlOVTajYeABUy+END3JzBSHvpg+hwDRl?= =?utf-8?q?MHaqVnRBEERt9359xm3kEPmbQutgAmDBcacZWp+C8WPUYGV1lmJ8F3FehXYm0Jn3G?= =?utf-8?q?5QR/wVFBump1EJmnnDVzlf2m2AnhZ4nWim7CnoTTkP7Jaxk4XQ+/R0B8RLsH6V1EZ?= =?utf-8?q?TDxRlF1Jz3ROHRVCMdMTiyCsRrsURijia6I84NoZIvYXebQXNPzT6QwreTZJ1iMEp?= =?utf-8?q?ufrGUEUN51I8JZ0k091gNDtJwWId/IBlqADmIR2AdAW23xtZ1PvSQvmJRd5PuC/fl?= =?utf-8?q?kOBDtqQ+1rdu4v5/mDoOIiwJKHr7hP1Ylmn2iMfVYw37PV4wZonlEprXNwwhHvGs4?= =?utf-8?q?ZJHgxevpDndlhU0cX4UVOoTGcITQtY+GxPhI2BBnvCrDknTli9BG4ri0ixAVN8aMn?= =?utf-8?q?KsbE2IpU6C2eUdT+OXfEwN/79oBpJ47TZzWgY/OnHDnK59Y+P4k20SbZQCPUFDS8U?= =?utf-8?q?bVpAJIQ2RAuU9YS5y0BlzNwCNIv86kkbQ6v/BlzwjUGyUpDL0EoclK/CRC6/Be40R?= =?utf-8?q?C4yr8c2PyZNSt3z7V1Hz47xv/x/zgHeuY05Kw1UpTWVJihmfmfemkGKq5j2zkXJgv?= =?utf-8?q?IJNjadqy2bPdYBXm6KtCLkzRlBuWrAjgBG9hxBK6rPd7u9dTYXIEPgEwcIbww8eWt?= =?utf-8?q?kxanFUYZpWCN3Cn7LaW2ej4DKoin06C4fAxjU44eI6wvJTriW6eNBinO4ESkCsvwG?= =?utf-8?q?Sxf0sINpS6CGMlyvtUeDTraaRxiGCjuZEVz/88Fy7UzwYKXoSJ5Vxu0dwCc8QO846?= =?utf-8?q?cvL9LoeZrEWdrknMTmdWGa7oZLk334hiqbkvhjfixT33x/VrXjXs8VEBK9bB9V4QM?= =?utf-8?q?9BGgW0v2PZYHt7jQptDblkk3JYYupCWm3cz1t1RKhQnPm9vzD+oX7W+nGXWf4n5ym?= =?utf-8?q?8dRJEXJyJ9i921/Mi77i/pLUtbExR6ysPf1PBNLn3l3ZoKte6jTAn7/ih7h1AZ/on?= =?utf-8?q?7WKz2w8hxWvVu8UsQOSO1W5nsLm3KQPB7qhrKvcOZh85FXpXn84EErX+ZgVJSwVNZ?= =?utf-8?q?46XuaYyiHlZI?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:19.7232 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 312e2f9d-a114-43fa-8afd-08dced045e67 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR07MB8615 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen AccECN connection's last ACK cannot retain ECT(1) as the bits are always cleared causing the packet to switch into another service queue. This effectively adds a finer-grained filtering for ECN bits so that acceptable TW ACKs can retain the bits. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 3 ++- net/ipv4/ip_output.c | 3 +-- net/ipv4/tcp_ipv4.c | 23 +++++++++++++++++------ net/ipv4/tcp_minisocks.c | 2 +- net/ipv6/tcp_ipv6.c | 23 ++++++++++++++++------- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index ae3f900f17c1..fe8ecaa4f71c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -417,7 +417,8 @@ enum tcp_tw_status { TCP_TW_SUCCESS = 0, TCP_TW_RST = 1, TCP_TW_ACK = 2, - TCP_TW_SYN = 3 + TCP_TW_SYN = 3, + TCP_TW_ACK_OOW = 4 }; diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 0065b1996c94..2fe7b1df3b90 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -75,7 +75,6 @@ #include #include #include -#include #include #include #include @@ -1643,7 +1642,7 @@ void ip_send_unicast_reply(struct sock *sk, const struct sock *orig_sk, if (IS_ERR(rt)) return; - inet_sk(sk)->tos = arg->tos & ~INET_ECN_MASK; + inet_sk(sk)->tos = arg->tos; sk->sk_protocol = ip_hdr(skb)->protocol; sk->sk_bound_dev_if = arg->bound_dev_if; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index d5aa248125f5..9419e7b492fc 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -887,7 +888,7 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb, BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) != offsetof(struct inet_timewait_sock, tw_bound_dev_if)); - arg.tos = ip_hdr(skb)->tos; + arg.tos = ip_hdr(skb)->tos & ~INET_ECN_MASK; arg.uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL); local_bh_disable(); local_lock_nested_bh(&ipv4_tcp_sk.bh_lock); @@ -1033,11 +1034,17 @@ static void tcp_v4_send_ack(const struct sock *sk, local_bh_enable(); } -static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) +static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb, + enum tcp_tw_status tw_status) { struct inet_timewait_sock *tw = inet_twsk(sk); struct tcp_timewait_sock *tcptw = tcp_twsk(sk); struct tcp_key key = {}; + u8 tos = tw->tw_tos; + + if (tw_status == TCP_TW_ACK_OOW) + tos &= ~INET_ECN_MASK; + #ifdef CONFIG_TCP_AO struct tcp_ao_info *ao_info; @@ -1080,7 +1087,7 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) READ_ONCE(tcptw->tw_ts_recent), tw->tw_bound_dev_if, &key, tw->tw_transparent ? IP_REPLY_ARG_NOSRCCHECK : 0, - tw->tw_tos, + tos, tw->tw_txhash); inet_twsk_put(tw); @@ -1157,7 +1164,7 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, READ_ONCE(req->ts_recent), 0, &key, inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, - ip_hdr(skb)->tos, + ip_hdr(skb)->tos & ~INET_ECN_MASK, READ_ONCE(tcp_rsk(req)->txhash)); if (tcp_key_is_ao(&key)) kfree(key.traffic_key); @@ -2177,6 +2184,7 @@ static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph, int tcp_v4_rcv(struct sk_buff *skb) { struct net *net = dev_net(skb->dev); + enum tcp_tw_status tw_status; enum skb_drop_reason drop_reason; int sdif = inet_sdif(skb); int dif = inet_iif(skb); @@ -2404,7 +2412,9 @@ int tcp_v4_rcv(struct sk_buff *skb) inet_twsk_put(inet_twsk(sk)); goto csum_error; } - switch (tcp_timewait_state_process(inet_twsk(sk), skb, th, &isn)) { + + tw_status = tcp_timewait_state_process(inet_twsk(sk), skb, th, &isn); + switch (tw_status) { case TCP_TW_SYN: { struct sock *sk2 = inet_lookup_listener(net, net->ipv4.tcp_death_row.hashinfo, @@ -2425,7 +2435,8 @@ int tcp_v4_rcv(struct sk_buff *skb) /* to ACK */ fallthrough; case TCP_TW_ACK: - tcp_v4_timewait_ack(sk, skb); + case TCP_TW_ACK_OOW: + tcp_v4_timewait_ack(sk, skb, tw_status); break; case TCP_TW_RST: tcp_v4_send_reset(sk, skb, SK_RST_REASON_TCP_TIMEWAIT_SOCKET); diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index bd6515ab660f..8fb9f550fdeb 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -44,7 +44,7 @@ tcp_timewait_check_oow_rate_limit(struct inet_timewait_sock *tw, /* Send ACK. Note, we do not put the bucket, * it will be released by caller. */ - return TCP_TW_ACK; + return TCP_TW_ACK_OOW; } /* We are rate-limiting, so just release the tw sock and drop skb. */ diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 252d3dac3a09..d9551c9cd562 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -997,7 +997,7 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 if (!IS_ERR(dst)) { skb_dst_set(buff, dst); ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, - tclass & ~INET_ECN_MASK, priority); + tclass, priority); TCP_INC_STATS(net, TCP_MIB_OUTSEGS); if (rst) TCP_INC_STATS(net, TCP_MIB_OUTRSTS); @@ -1133,7 +1133,8 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb, trace_tcp_send_reset(sk, skb, reason); tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, 1, - ipv6_get_dsfield(ipv6h), label, priority, txhash, + ipv6_get_dsfield(ipv6h) & ~INET_ECN_MASK, + label, priority, txhash, &key); #if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO) @@ -1153,11 +1154,16 @@ static void tcp_v6_send_ack(const struct sock *sk, struct sk_buff *skb, u32 seq, tclass, label, priority, txhash, key); } -static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) +static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb, + enum tcp_tw_status tw_status) { struct inet_timewait_sock *tw = inet_twsk(sk); struct tcp_timewait_sock *tcptw = tcp_twsk(sk); struct tcp_key key = {}; + u8 tclass = tw->tw_tclass; + + if (tw_status == TCP_TW_ACK_OOW) + tclass &= ~INET_ECN_MASK; #ifdef CONFIG_TCP_AO struct tcp_ao_info *ao_info; @@ -1201,7 +1207,7 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, tcp_tw_tsval(tcptw), READ_ONCE(tcptw->tw_ts_recent), tw->tw_bound_dev_if, - &key, tw->tw_tclass, cpu_to_be32(tw->tw_flowlabel), + &key, tclass, cpu_to_be32(tw->tw_flowlabel), tw->tw_priority, tw->tw_txhash); #ifdef CONFIG_TCP_AO @@ -1278,7 +1284,7 @@ static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, tcp_synack_window(req) >> inet_rsk(req)->rcv_wscale, tcp_rsk_tsval(tcp_rsk(req)), READ_ONCE(req->ts_recent), sk->sk_bound_dev_if, - &key, ipv6_get_dsfield(ipv6_hdr(skb)), 0, + &key, ipv6_get_dsfield(ipv6_hdr(skb)) & ~INET_ECN_MASK, 0, READ_ONCE(sk->sk_priority), READ_ONCE(tcp_rsk(req)->txhash)); if (tcp_key_is_ao(&key)) @@ -1747,6 +1753,7 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr, INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) { + enum tcp_tw_status tw_status; enum skb_drop_reason drop_reason; int sdif = inet6_sdif(skb); int dif = inet6_iif(skb); @@ -1968,7 +1975,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) goto csum_error; } - switch (tcp_timewait_state_process(inet_twsk(sk), skb, th, &isn)) { + tw_status = tcp_timewait_state_process(inet_twsk(sk), skb, th, &isn); + switch (tw_status) { case TCP_TW_SYN: { struct sock *sk2; @@ -1993,7 +2001,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) /* to ACK */ fallthrough; case TCP_TW_ACK: - tcp_v6_timewait_ack(sk, skb); + case TCP_TW_ACK_OOW: + tcp_v6_timewait_ack(sk, skb, tw_status); break; case TCP_TW_RST: tcp_v6_send_reset(sk, skb, SK_RST_REASON_TCP_TIMEWAIT_SOCKET); From patchwork Tue Oct 15 10:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836073 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2048.outbound.protection.outlook.com [40.107.104.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D1321E7674 for ; Tue, 15 Oct 2024 10:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988225; cv=fail; b=h4AGW1c6i6eT8xUM6bG3KxRDTHggg7aj0HEHuAvkkKhax54+ClsDz7E6BR7WHL/H6yghOs0DD0pIM6bkePaHwA621T6bSafuqoDk7HVo7F5MssT9CpTA6WEy+7mePn8xULvtfmjGYP4gYjvD28LkqxcNWePKJFnlNQ0pfb8HHAY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988225; c=relaxed/simple; bh=Hj0kpmxspiVLJX8wpFuphNG9SkyVLpob5NDj2PecjNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Y9WQoq//8bBtngKgCEXnU2yUgxjiEQ6ZkCY2aQFFvsrvxdQ2g+PG/INx5jITwHArgOfaxDNms0t/Yoi8hb+4xc8RV1DN7aQL7Y1tHh7L2WNuYVYxM/AiQbhmJsLHUQXTiEMbf/O2U13m9V/3I66I+5MP3qVzfg3eQhT7yCXsNKA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=D+L0NBTL; arc=fail smtp.client-ip=40.107.104.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="D+L0NBTL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c70vXfmcIObNEnM3wzPWtM2lxa8QnbfgZMCp7bVdlPcoP9Yf5uEAm19/OI0cqHTXQFG34UOawUNKehjmwbKBfedF2Tplbvecxv5bRKR5RF/tQ8LETsrN0RzGv8vSu4ZIbCTLlbsE4jUB4ZXXaNtWbU+Lw7TczdQ9imFBb0WEDwhPOmWAH2EwC4aaqg6QjrBfB6vaEYynqpAyJaAto9ZYYT+nb64S3n1LUl2ENfFL3uxf/0TnjA0CdmEU0SjIJll1OLYhOUuYPI5xMMPLjoh8UOWfp3EBB+X2tUfhQo+F03HvPu1azRKf8wLv2ylgvUJ2lFMRwPmPVimet1FZe7dDYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NXl+jkY6ong5Phsy59TTE3OHZvwQGTrSsZW9TS0xUyw=; b=KtpjN4fykmTO5KW8M2qK/jfn9GoV82M0SloottZCTbzpN+2nlufOMtmKzS7qXzOGKrBwPd21pkvq2IXE5VBk+TIu1p83ai6Jt2eBUOaOmbITJXgoDlqgIifLjb9Z6/KO8l7/pCzfSeQO0w+Y5eVsnH22AkGH0tGpJd+UFMYc/4BFLVvITm2N0xLl77lXi4xBqwmpyqK4fGuIDFlcqZPxG64ja8OgVAOtSHoZ+Jp8DxpwkDEs3DvrOySgqqmqfgGzUXQH/VQxiwTbrb0QkveuqdQr6E6IUmBlvrW6mJ6suviMlYQuJYU7bCnrcsbf9EdlTZ/Fp+60pTWw57z16CaliA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NXl+jkY6ong5Phsy59TTE3OHZvwQGTrSsZW9TS0xUyw=; b=D+L0NBTLL7yJL43ew4bgg6gov/n0rBrtygWzwnnXlXzZsdvP4ZvNNj3S0yjByUfy2roxWgQLcDq6WJnY/5HQ8+VhrkuvXbUQOQ7R118G4SFY21de4TtMbejS88AamxsOh0PEcuTIYuPlYabfqqliT6F0JO4Kgw26V595Nn1D1x6JxrPqtaevMiMCocJ8qZqUP2uNBGgdOf/FSc05OYJWYAyf/gFr/tYN8YuB2AQXDMXgCclBVhfNS9nGAXakOClAspmSBJi+OEzdgzs7OENFW8rt/Ai+k/UIyYYGsVvnP8Zsb39WzwvP48KmaDbLl65UIo6NDrVap/DBXSxXiVm1hA== Received: from AM5PR0101CA0018.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::31) by GVXPR07MB9680.eurprd07.prod.outlook.com (2603:10a6:150:110::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:20 +0000 Received: from AMS0EPF0000019E.eurprd05.prod.outlook.com (2603:10a6:206:16:cafe::97) by AM5PR0101CA0018.outlook.office365.com (2603:10a6:206:16::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF0000019E.mail.protection.outlook.com (10.167.16.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:20 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnH029578; Tue, 15 Oct 2024 10:30:19 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 13/44] tcp: Pass flags to __tcp_send_ack Date: Tue, 15 Oct 2024 12:29:09 +0200 Message-Id: <20241015102940.26157-14-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019E:EE_|GVXPR07MB9680:EE_ X-MS-Office365-Filtering-Correlation-Id: 839b605a-2b3f-4419-97fa-08dced045e9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|1800799024|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xZG9xNimkADOpagRMcrEAHCiQUXmIMZ?= =?utf-8?q?caQmDbJNC4/i3Rd7EV0un3MIt51SO/427hQPITYutbWq7mIQAwFIRMt1Vykstu1wh?= =?utf-8?q?mZHFqZ6gzFQVTnOaaAHBe4f3Mq1HVw3WBMkt+QKBzlKmtgf6lRDYJEjxODfMGVlYS?= =?utf-8?q?vfDreQD3dUZfz9VTwd4AQ18PR9sGLHCm2deAev1QrOfhvcVK+Nytzwa4/v5qAVOn8?= =?utf-8?q?C90oDAIvXb4r/CndTYRFTLegcEguyE20xMJZ1tjo5QfzZA+mpOcvWcYKolQlN+uhs?= =?utf-8?q?5feVCpQgxL56EWmbVZmfiyVaKJt2rCqvRnqMdXDuNYZcRnsbtfTMn3pvislEteTft?= =?utf-8?q?mXIUn0vn3w2dNYYBkgK+qeO4GBl2lpfOWaO3V+FkA4rf9uwhP3l7EQe0iTEOha+KQ?= =?utf-8?q?v5opvbocnNhnqjFEMpIGx273uhRKw+rRt6GmlNrCw10H//NGjift/HedpWQylxobd?= =?utf-8?q?EW7IBTFstlraTj8OcxFucwyGnGRRhLu6dqib0kDvGwGJwTvQowX3iYsfh4SC0WNf5?= =?utf-8?q?mxY+7D8lleabeCWCK16SFK2VClxgulPWIQbROYDo+0I/2z3ecL1p4Qypo9iLoHTDP?= =?utf-8?q?v1c+KDTZ/XKE1xSl3HOD75E/bKiCrJRupIuJBClDl196gMfQX9TmTVBLOVo0ta+4x?= =?utf-8?q?ITmIBUS1V80Dw7ITzlYhM6U3ufeNg4et62yh7Kj5TIY3YMvM/eCQu9m6vDLoaC6bH?= =?utf-8?q?wUpt7MigqOJx/fpO0guLh/eXxRbeHqU5qm1tr9U1lQfVRBZbtgOiJg6/C8hvm8Rsg?= =?utf-8?q?YYmYm48tNByCyTcytDgI25XCcTw+66r2k4N0ckRGBcEPz40R4/S0pLTN4UhGlosGp?= =?utf-8?q?PczRLOyr16sggbtWelgQSb5ZxKKiO0yjkLpYlrw3InjO5lTrBW4AAmwNBgteRGqpD?= =?utf-8?q?jeDeMmr7jNxqxlO/T84MA8MKAZnaGEPUStUBMkJY4gAr3BQ2heb6vOZAdU2UU862J?= =?utf-8?q?f4L0kj7Efls2bPlDGz7KLEk9UvSOKb9omBm5QKu15HsOQgjbJowAso+5NhrKVShAd?= =?utf-8?q?d6k3Ad1IumsB6zQxOrphdgrSvtemsj0pxLOw7tdjxyj/LB+cYNEq3Bhzapu+Iy51Y?= =?utf-8?q?2qQI9luP41ZTWeRW/LaxMQDZgcGHsjkkc5SIJgQ7LzgNLyobhd6sQmLCoRBD4mG3s?= =?utf-8?q?jnU5tDUo9ocxVHQwxdsV7z2iTj34oz7PMki2mxzEmWHsXlnt48B+wbUXfNYrwqDmf?= =?utf-8?q?gdfERjuvkOPk0pmcASzTX0YmutYF3mV8Fm5BYx/f72l4ObVWEl/yZ+lfLRBmVCY2J?= =?utf-8?q?E14Q4LJOIkepkZQDhIPf5F5OlTFJAkjqzDdV6EC32dOgHcoYa4euo2d0AOvGioWTY?= =?utf-8?q?nfw8cXW+C590?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(1800799024)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:20.1712 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 839b605a-2b3f-4419-97fa-08dced045e9d X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF0000019E.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR07MB9680 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Accurate ECN needs to send custom flags to handle IP-ECN field reflection during handshake. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 2 +- net/ipv4/bpf_tcp_ca.c | 2 +- net/ipv4/tcp_dctcp.h | 2 +- net/ipv4/tcp_output.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index fe8ecaa4f71c..4d4fce389b20 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -704,7 +704,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority, enum sk_rst_reason reason); int tcp_send_synack(struct sock *); void tcp_push_one(struct sock *, unsigned int mss_now); -void __tcp_send_ack(struct sock *sk, u32 rcv_nxt); +void __tcp_send_ack(struct sock *sk, u32 rcv_nxt, u16 flags); void tcp_send_ack(struct sock *sk); void tcp_send_delayed_ack(struct sock *sk); void tcp_send_loss_probe(struct sock *sk); diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c index 554804774628..e01492234b0b 100644 --- a/net/ipv4/bpf_tcp_ca.c +++ b/net/ipv4/bpf_tcp_ca.c @@ -121,7 +121,7 @@ static int bpf_tcp_ca_btf_struct_access(struct bpf_verifier_log *log, BPF_CALL_2(bpf_tcp_send_ack, struct tcp_sock *, tp, u32, rcv_nxt) { /* bpf_tcp_ca prog cannot have NULL tp */ - __tcp_send_ack((struct sock *)tp, rcv_nxt); + __tcp_send_ack((struct sock *)tp, rcv_nxt, 0); return 0; } diff --git a/net/ipv4/tcp_dctcp.h b/net/ipv4/tcp_dctcp.h index d69a77cbd0c7..4b0259111d81 100644 --- a/net/ipv4/tcp_dctcp.h +++ b/net/ipv4/tcp_dctcp.h @@ -28,7 +28,7 @@ static inline void dctcp_ece_ack_update(struct sock *sk, enum tcp_ca_event evt, */ if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER) { dctcp_ece_ack_cwr(sk, *ce_state); - __tcp_send_ack(sk, *prior_rcv_nxt); + __tcp_send_ack(sk, *prior_rcv_nxt, 0); } inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_NOW; } diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index bb83ad43a4e2..556c2da2bc77 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -4232,7 +4232,7 @@ void tcp_send_delayed_ack(struct sock *sk) } /* This routine sends an ack and also updates the window. */ -void __tcp_send_ack(struct sock *sk, u32 rcv_nxt) +void __tcp_send_ack(struct sock *sk, u32 rcv_nxt, u16 flags) { struct sk_buff *buff; @@ -4261,7 +4261,7 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt) /* Reserve space for headers and prepare control bits. */ skb_reserve(buff, MAX_TCP_HEADER); - tcp_init_nondata_skb(buff, tcp_acceptable_seq(sk), TCPHDR_ACK); + tcp_init_nondata_skb(buff, tcp_acceptable_seq(sk), TCPHDR_ACK | flags); /* We do not want pure acks influencing TCP Small Queues or fq/pacing * too much. @@ -4276,7 +4276,7 @@ EXPORT_SYMBOL_GPL(__tcp_send_ack); void tcp_send_ack(struct sock *sk) { - __tcp_send_ack(sk, tcp_sk(sk)->rcv_nxt); + __tcp_send_ack(sk, tcp_sk(sk)->rcv_nxt, 0); } /* This routine sends a packet with an out of date sequence From patchwork Tue Oct 15 10:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836075 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2079.outbound.protection.outlook.com [40.107.247.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 351AC1EABD1 for ; Tue, 15 Oct 2024 10:30:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988227; cv=fail; b=G/tzfZVEiH6rni0TA3slrHXFUYH4cYIHa8yrQ36AH/FvlF15/cthQr0d1yN/WbaJ+Ry9P+PHDJa0naNT8sPaa9aHOvvb7dtpOrvZVsT2jAg89x5xXp99SZmrS7RcNNfcNwe/eVR6c9qJT2NdrQhtZjnKVnTKInLndD3dL0L+HxU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988227; c=relaxed/simple; bh=aigVrtFmdlODcoDzUAkTu2EEDAXuRELqVFW7iXHciWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LRmUY8BIZPCOCODUe2E4JsHN3vTfHfunN0aLMCMxoSKalfZMbitx99pcYQ3Wblpi+CkySY/7pYj1TjYg6Q73hEurHrSMBIAn6sbZk8WMuikiGoZzvwkPs2XUUj+P0PvnFaYIBIdzCS1Iu7YOOBi7igdhzGYqE5XDjZcuWKTb9dw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=k2fUprPA; arc=fail smtp.client-ip=40.107.247.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="k2fUprPA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mtiMdb5WVudmHC5DgyTEa1C+w4oxqXOkv9XtAfzGxWE32DwtQ6D/7Nd5tqpxbaN2lp3nilxbtEZ5JdmBhNEsgVEvFWD1earg5SCqDjLxcoQxhd9klrPtfpIC8dNBgxrDj1/W7AfFn97QaNBPnJGoaoV0I6A2SAqf+XYBdZgRvQ8cNa2rLfva+0t5YJGaGOF8wxNfIqZPZqHCOJuhGHGlZHwUNqj3NgwOBKQh/gfAFMJiF2Pfkh4ar6UIoGOk3eE4qlY54tlj6N1e0hfJBK4oQDcTDXSE4lEHQrUx1CgBr4m/6WHQbjl/gGhe8bl8adVMz79oTb0ug93/KyPKMxOxog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AwpGt7LZQgUGaYqfl+JpsnW8PuU1p5tVsq5y1AfhjMw=; b=cSKwGesYZAYk5R+Hj1YfQ1XEIdT4DhtVPfPIwmeU5Rf+5ejEjbjbTNqUSU14HfZpokCDgSYzuZpQzCbBTHoclvvqPAhLMikYjLS4yM+sFLJ45ZAKjwimqyiPvIVW12hFW/lpLIwRLxSgg1frYw42XJAs3voPf2cK9SdwWuonCKAoy08TfHB/qgpYd9k2g+1LY0J5NJA6g95D4fE2O0/top9j6Cfi5hLM3KbBLT5JcDww0o30A3rUbVcZw1qg3YTfFrNwphH7etAPnosPRZmHujy3fiv0ccANqNK6Yfb61TlproH7onUtoqk8qSPV9hVqMdaVTObyGz/FHOXvoUbyBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AwpGt7LZQgUGaYqfl+JpsnW8PuU1p5tVsq5y1AfhjMw=; b=k2fUprPA/XYtT4vliokmAYrvFhZPgTvdb6+TlaMb4p8yLmZvIAi3gG8x6DfjkOMaZw5eLgo/+wocs3Jj1otYJegGMAPZiuQT/0FLJXoW74Ivbj4U0bYMw7MrYCeL2NF5Znc5N9yGBH145n9jx6hA7jR9K9BMyEszZRdEWWAz2HEUK1JdzeFVv/LgJ7N5oiwnVUrO/kE+knA3qQIBCZGzI8C4j2jxlqJSNZnk+Btk39MVm2pZdhARa05ca28Hfl55vi7qomBzXKDaQ86CZMaxwZchgL3ugmM4dPceHcApIRdHOTK4jjyWnVqNGSQHWb8juD7Lt9yBDM6a3J0MvOro0Q== Received: from AS9PR0301CA0002.eurprd03.prod.outlook.com (2603:10a6:20b:468::15) by DB9PR07MB9005.eurprd07.prod.outlook.com (2603:10a6:10:3df::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:20 +0000 Received: from AM2PEPF0001C714.eurprd05.prod.outlook.com (2603:10a6:20b:468:cafe::94) by AS9PR0301CA0002.outlook.office365.com (2603:10a6:20b:468::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AM2PEPF0001C714.mail.protection.outlook.com (10.167.16.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:20 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnI029578; Tue, 15 Oct 2024 10:30:19 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chai-Yu Chang Subject: [PATCH net-next 14/44] tcp: fast path functions later Date: Tue, 15 Oct 2024 12:29:10 +0200 Message-Id: <20241015102940.26157-15-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C714:EE_|DB9PR07MB9005:EE_ X-MS-Office365-Filtering-Correlation-Id: 612fdc85-9e7f-461f-388d-08dced045eed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?glldgaikSXW/MsTJimfT5W8gU4URagE?= =?utf-8?q?eLveKZi3uK7MTt2rk9U3ngu/+fisRkh88VeSMKWHSjLPm/a0xyECePPN7XmLSYg2D?= =?utf-8?q?b+tglfXWW/l5H46xDhRkWqnn77awGnsSUs81X800/Iq2O50HWOnp6FROFlNSsiSmC?= =?utf-8?q?GFB/L6e/fuRc2iacf9H+jxmqVUIKfM9rfm3i//YwooWhvwk4h/vjDJtMeu98yoEV0?= =?utf-8?q?jQAxDG5d8Pp9qtGaElXVtDNnQ841uy4qrJw1ioRr/rMMXFbxSilpGvTyR6+vXt+as?= =?utf-8?q?1g4p8YyRwVRDZ31Ln0GtzKjcHQ12HB5m4rMN/tb3rCacwGHg+nN2SHlXrfIxAxsZH?= =?utf-8?q?TGGbHSVCY4igElnxpkQNwjrUjoS30V/eI1ZMfxIs/gSNtvUPDfqN9XmO8Wl35dyeg?= =?utf-8?q?1KjMZiVq4OWvAh8I057M1EGYLsnGXmxeh3iPC+LBZRXfasWoN+YOd5etnv1TKZPib?= =?utf-8?q?jq3TK+26AuRo99tWDrHzAXLa2Z09VlLqtN02s/g0lcmlhxmY2Emg/AczBFyV4muWu?= =?utf-8?q?Ub36K+FMilIX8aFfTkrlFBqE3EnUR+ZST/LDubNFr1uv/Dygh2CbnQwNuTqHbdapU?= =?utf-8?q?XdSI8xh+bvTxvbjwXOfoPnkF7UekRRY2LenC/9IeYusOzYgE0mJg3cAwy8dFbMA+T?= =?utf-8?q?lle36MpQrapmUEWRs2Vx39iPCfR5DiYvIb0DP6+kvAQi13BpvpaMjxk3wdeOKanbz?= =?utf-8?q?ttJB5WB5Vy56mCE9b6BUtmECujdQ/sPm+IKbCadNACWoch7D5YMa7BrVrle6+XCpN?= =?utf-8?q?FEWWcPgIyNXlBTsPJnZlPOsWDB/hfen3hFWdqtKmnn5r+1TROP4pE7V3bPZL7Msan?= =?utf-8?q?3WrJxH2lz1ORtQqxq+rTAUmjI1+HkANppkmpHPVVkYRwrMWxeMduhy8cYt4DxL+nH?= =?utf-8?q?+Bc4w22z6inozwYyNS9sbqTrxOVtcdtxGQbmJ7MWPSJwsPXrVnZwomliP+JtpdL4q?= =?utf-8?q?O+IlZmkyOHiVKvK0aXzg18CaZ5arfXUI/YREyu6vENU9pKGaHAieYiogbGSwHtUSc?= =?utf-8?q?DBlXiN9ZQQJRpJf9wchIaVrlrmkTLfgXCRD+6QtCv27xmqCnGhbVIHom8NIrldOCl?= =?utf-8?q?vjBRfP5HPVaWf/XOnMWgaJXHB2lrLXOnPTqVnwzxFm1DAIZGlAm/pL4UU6IzgbkaL?= =?utf-8?q?4pKcZXqaStnXsli/n/SYlm5z5iUwn4xfDvjGeacPovcxSKR6GQIbSj5B/i0+mNVO1?= =?utf-8?q?wkxwtarj8tKAZhq4rc9hVIgn7w9vIn4d249Y6FqK5QZ1H7bRX7R1U8f/5XcaAyrGh?= =?utf-8?q?eNjReFbA9lOn5GK0APA3/2+EjHbJ/lRBE796Hrq7kNXJs2wXlnsSego/CmEW/+JJS?= =?utf-8?q?G61A2yUPxjUX?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:20.6774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 612fdc85-9e7f-461f-388d-08dced045eed X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C714.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB9005 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen The following patch will use tcp_ecn_mode_accecn(), TCP_ACCECN_CEP_INIT_OFFSET, TCP_ACCECN_CEP_ACE_MASK in __tcp_fast_path_on() to make new flag for AccECN. No functional changes. Signed-off-by: Ilpo Järvinen Signed-off-by: Chai-Yu Chang --- include/net/tcp.h | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 4d4fce389b20..7ceff62969e0 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -788,33 +788,6 @@ static inline u32 __tcp_set_rto(const struct tcp_sock *tp) return usecs_to_jiffies((tp->srtt_us >> 3) + tp->rttvar_us); } -static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) -{ - /* mptcp hooks are only on the slow path */ - if (sk_is_mptcp((struct sock *)tp)) - return; - - tp->pred_flags = htonl((tp->tcp_header_len << 26) | - ntohl(TCP_FLAG_ACK) | - snd_wnd); -} - -static inline void tcp_fast_path_on(struct tcp_sock *tp) -{ - __tcp_fast_path_on(tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); -} - -static inline void tcp_fast_path_check(struct sock *sk) -{ - struct tcp_sock *tp = tcp_sk(sk); - - if (RB_EMPTY_ROOT(&tp->out_of_order_queue) && - tp->rcv_wnd && - atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf && - !tp->urg_data) - tcp_fast_path_on(tp); -} - u32 tcp_delack_max(const struct sock *sk); /* Compute the actual rto_min value */ @@ -1768,6 +1741,33 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt, return true; } +static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) +{ + /* mptcp hooks are only on the slow path */ + if (sk_is_mptcp((struct sock *)tp)) + return; + + tp->pred_flags = htonl((tp->tcp_header_len << 26) | + ntohl(TCP_FLAG_ACK) | + snd_wnd); +} + +static inline void tcp_fast_path_on(struct tcp_sock *tp) +{ + __tcp_fast_path_on(tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); +} + +static inline void tcp_fast_path_check(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + if (RB_EMPTY_ROOT(&tp->out_of_order_queue) && + tp->rcv_wnd && + atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf && + !tp->urg_data) + tcp_fast_path_on(tp); +} + bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb, int mib_idx, u32 *last_oow_ack_time); From patchwork Tue Oct 15 10:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836076 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2080.outbound.protection.outlook.com [40.107.22.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4F421CF5EE for ; Tue, 15 Oct 2024 10:30:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988228; cv=fail; b=EjDDxJRtsQZWMYJ5Dj0byHTszGOYm0N6oFTa+9QN7aXeNJN0UMFsCYDuFgt/Lf9W/dlLV8cft7hJyg44YL/wraApKXUvOOCgtjCebjdLMqsZshe3VhsbeFSoWwWvTMkMpXkOW3tOM55XcPCdwVHT+Z32UXT18KD4kDBqUil/RZU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988228; c=relaxed/simple; bh=RJZ702L6i+bD3tlTU60URnYp1gcS/0mYSai8LLmYhtI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JWmnRFDvWjKxtzG0GVFZM/oJwNmcvldhv5Vrh3VOKfDcqopXd3OwCjm5MBedDeYbfFAdvYNTYqVaVN8u5Wy5pLU5cDnnTMtow0Fnmh3yPXJH5d8G0MrV3Oj0v8USWocK7E/mW89L8MPrziT6jD4gq4XaFoOlhaD+FNGB2eluoRM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=jLEFbNCH; arc=fail smtp.client-ip=40.107.22.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="jLEFbNCH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dxlL9a90gTdVXt58clNqNh5WCITnjQPNIAJwzNxWBgGMkBiol234QuT9Cfk0VUDu5LR0BcDJhtq6UcE9TYvyY6nNjOd2Bf/shsRyy5FAuSrIFawLge//0asBEhJ1io1o04I+hwT8f3QpOZ7sfWDrCkRa0VGDMoU1aoRQcXmIqhRZ/XFz3ufEKOYXXLCLg2DaQynwLEm8YKEp864UYuUhMCMkhvCKldmhedw2V2Gtnu4mxjhO+tBQiKyMztJ/49vf2YirkZ68gRCQhw9r8ge+cfVLPpxlP/jswlN3Pw7lKxQ1tQTLUUspLLwc69Zq2xoONQ08jWHT7QJEkHssZRbMfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fAf0Zgoec2doKwCuYU6QaDGDuuPu/prOFFECekA2clA=; b=jHR426yVl+Lo6kC9N9I5km5pKC8nIOJXzY83m4WnEHJzxeiKJYRc8OhC8ksWCkrk3RD6u8xdNc63izWya0VwGASHjacLZzTDR7ocyMlkdWjJ1vs6tQSkbVgTJuUsEAqISbf6/o06SK0MTEcCiaTJGgvWT7q53rw5qny2kx1F2aHIQOoKCLMSqqDTTcXt+F6Q7sgQrUErvmjtQq0S2BSRlXIrLUl91G1mE48biNvGDP9VDBcAGHcA9kpIcu76TtQKlg16CzcJKjBZAqeR+7bFDCR5TlwcdVsPvZScdt4pkFTYqqEy3OOXfUHmwds3p0QNgCAh1A0Bae8ErrrE7hpYsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fAf0Zgoec2doKwCuYU6QaDGDuuPu/prOFFECekA2clA=; b=jLEFbNCH+hOzaZCql5S+bnMzGAok49TYYYCsqpT+1EVM57nqM4YEEDixQVebN73zM/zhEhqBZKpG2qGNnR5ItsNmUNoc00Ki3gnPb/uAXPHEYssFJ+ph5acdWyO2QJMiMPbhKWOW54+TE77g5Ngg3V3YFFRzRNdQaGyxdACwTcz/BvRMO0tvngQkrjpPCi4fuQNLYt/XHaoSfpRhXkvKuw0ckGUYJOaftnjTtfwK7T+sAO2q7gYfktegleaB1dfCCpLIa8bBfr6w8at5lqbid2iA4onSa5ZdAQIrHUgrJXqvp58fM6zPVwMuxeoez9vyJGTWRSdsG94jANFsZ0dRCg== Received: from DU2PR04CA0090.eurprd04.prod.outlook.com (2603:10a6:10:232::35) by AS8PR07MB7990.eurprd07.prod.outlook.com (2603:10a6:20b:39d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:22 +0000 Received: from DU2PEPF00028D0C.eurprd03.prod.outlook.com (2603:10a6:10:232:cafe::e3) by DU2PR04CA0090.outlook.office365.com (2603:10a6:10:232::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D0C.mail.protection.outlook.com (10.167.242.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:22 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnJ029578; Tue, 15 Oct 2024 10:30:20 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Olivier Tilmans , Chia-Yu Chang Subject: [PATCH net-next 15/44] tcp: AccECN core Date: Tue, 15 Oct 2024 12:29:11 +0200 Message-Id: <20241015102940.26157-16-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0C:EE_|AS8PR07MB7990:EE_ X-MS-Office365-Filtering-Correlation-Id: cf8956fb-6e97-4740-ab82-08dced045fe3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pZbZdw1VU7GZOM/cv1k5QaE05TKlKnh?= =?utf-8?q?Vv0yv54XJkZ/jWcKbP5viyBrEJZWLQ0K/E/spC4MKOJZRoyumkrhtcwehPWFwKAht?= =?utf-8?q?xAVu63LYJo7feptl/2flRwOZl/OJC1lSCjNbrMhyEuH2dNh6nkJ9X+T3Lneh1adOS?= =?utf-8?q?j2I8hiTwGEeaNk7j5yJqd6RxD7CLA1mjPR0WvgKqCXh0mtoDobwCKA8HBoIAQv6xI?= =?utf-8?q?Uuws3CRwGtR83xIhqzbN8hTCSSvrfv/EsghfWbrXGh2GBAslJAlChBc32entdPkVd?= =?utf-8?q?6ZRYqjumjmiyuu7+JI10S9GV7tiu94Hufx30Hny7+hBcrFDnTqslS7n4TG0Th08JI?= =?utf-8?q?fSRRNs2mReTEHtVjLsRWry4ziPzAHKytjmXgkEcBDyey5NZT+IGjRJl2B3hQVMjhC?= =?utf-8?q?Xh2k1t+QTYrx/DKWlPBB1+Za+xl94yIMBB0HW7Hn5FwaGoMTYeulAJvi/Ge0PiQjq?= =?utf-8?q?Cs/W2a8PHcyUnFGUq+uU4TAOQJoTCUnPoWidbNmjTfwv2zPND/U0Ge6sjlZPL80MJ?= =?utf-8?q?n/cIfAwUy1QFCiN9ULFM1S9CcHz/Vr4uqicyUI931aGmU4I9bBkYUUa6O2L9li8ZM?= =?utf-8?q?S9LO+sL7Z9hNcoELjxN9MgTOmz1MtS9DIatwiSlgLpHnmgmshDcIvRZFWDnDkQ20e?= =?utf-8?q?j1xs+k2xH60qpYtqRhj5Uu5MZYD+7QED8bC5rdHn3fxranUBsHUFnbWAKwvGDdngf?= =?utf-8?q?vqbq0tPCtnM1enN9d2O8T1mkkeHHuKOaSPcXTSgNJLAVMYxJKFyc10BnnIAI9+Hgb?= =?utf-8?q?YqyZn76pZD4d97DNaROILOcGfc7IJfpuvU8gP+Pz0WfKNmVDGxrJCCZmOI6t+o6pj?= =?utf-8?q?t11LaNzOlKpLjyptZyxNAhEnV4v90Wce5o5SfenHV1mdCac5xGiYpNdvL9vQTvk5K?= =?utf-8?q?vNEicYeb0uZz9DL9VJwzN5G32AqubVETTMWEIDRUC/Xp0Ntyf7uMjfUjlmaxTpvgA?= =?utf-8?q?oQ4EUlcC1rmz1rrQZuSUcZOmiMmC45OyV4TTXB7IC1FjsmvyPmwvR08hq2OfINdzO?= =?utf-8?q?2qgXKI9+6aNge5OT/IFwAAqEM8VD6uJlswUysJJE+XGPh1w+8bpz6PGPtQeL2r8Hs?= =?utf-8?q?pcpGcscxKKyOhZQTIvI1b7q9Qimf/C0JV6l3NKthzkUvJcDj8YVqNrVxySwAP33dw?= =?utf-8?q?iSIIQ9v3RWJD6v8aDqORiycaB/8hQBBtkpuSVcdVzjTWH3OCH8CpFYfzjX+3GPAty?= =?utf-8?q?Vw+yYFv7+S0khAUZ66QeqAPLUkqveTlodeVVOHcXD90WOf1fJmesRIHft8RG/Dz48?= =?utf-8?q?A7yWICZvSvg851gSday580N5ZB1Ry62ynVPWyKO0vtu2kYKx7neCnRVBcGfXfJl4R?= =?utf-8?q?m/hXWkTfW7NO?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:22.2457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf8956fb-6e97-4740-ab82-08dced045fe3 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D0C.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7990 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen This change implements Accurate ECN without negotiation and AccECN Option (that will be added by later changes). Based on AccECN specifications: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt Accurate ECN allows feeding back the number of CE (congestion experienced) marks accurately to the sender in contrast to RFC3168 ECN that can only signal one marks-seen-yes/no per RTT. Congestion control algorithms can take advantage of the accurate ECN information to fine-tune their congestion response to avoid drastic rate reduction when only mild congestion is encountered. With Accurate ECN, tp->received_ce (r.cep in AccECN spec) keeps track of how many segments have arrived with a CE mark. Accurate ECN uses ACE field (ECE, CWR, AE) to communicate the value back to the sender which updates tp->delivered_ce (s.cep) based on the feedback. This signalling channel is lossy when ACE field overflow occurs. Conservative strategy is selected here to deal with the ACE overflow, however, some strategies using the AccECN option later in the overall patchset mitigate against false overflows detected. The ACE field values on the wire are offset by TCP_ACCECN_CEP_INIT_OFFSET. Delivered_ce/received_ce count the real CE marks rather than forcing all downstream users to adapt to the wire offset. Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 3 ++ include/net/tcp.h | 26 ++++++++++ net/ipv4/tcp.c | 4 +- net/ipv4/tcp_input.c | 113 +++++++++++++++++++++++++++++++++++++----- net/ipv4/tcp_output.c | 21 +++++++- 5 files changed, 152 insertions(+), 15 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 6a5e08b937b3..c36e519f3985 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -294,6 +294,9 @@ struct tcp_sock { u32 snd_up; /* Urgent pointer */ u32 delivered; /* Total data packets delivered incl. rexmits */ u32 delivered_ce; /* Like the above but only ECE marked packets */ + u32 received_ce; /* Like the above but for received CE marked packets */ + u8 received_ce_pending:4, /* Not yet transmitted cnt of received_ce */ + unused2:4; u32 app_limited; /* limited until "delivered" reaches this val */ u32 rcv_wnd; /* Current receiver window */ /* diff --git a/include/net/tcp.h b/include/net/tcp.h index 7ceff62969e0..5ae0d1f9b083 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -413,6 +413,11 @@ static inline void tcp_ecn_mode_set(struct tcp_sock *tp, u8 mode) tp->ecn_flags |= mode; } +static inline u8 tcp_accecn_ace(const struct tcphdr *th) +{ + return (th->ae << 2) | (th->cwr << 1) | th->ece; +} + enum tcp_tw_status { TCP_TW_SUCCESS = 0, TCP_TW_RST = 1, @@ -938,6 +943,20 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq) #define TCPHDR_ACE (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) #define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR) +#define TCP_ACCECN_CEP_ACE_MASK 0x7 +#define TCP_ACCECN_ACE_MAX_DELTA 6 + +/* To avoid/detect middlebox interference, not all counters start at 0. + * See draft-ietf-tcpm-accurate-ecn for the latest values. + */ +#define TCP_ACCECN_CEP_INIT_OFFSET 5 + +static inline void tcp_accecn_init_counters(struct tcp_sock *tp) +{ + tp->received_ce = 0; + tp->received_ce_pending = 0; +} + /* State flags for sacked in struct tcp_skb_cb */ enum tcp_skb_cb_sacked_flags { TCPCB_SACKED_ACKED = (1 << 0), /* SKB ACK'd by a SACK block */ @@ -1743,11 +1762,18 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt, static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) { + u32 ace; + /* mptcp hooks are only on the slow path */ if (sk_is_mptcp((struct sock *)tp)) return; + ace = tcp_ecn_mode_accecn(tp) ? + ((tp->delivered_ce + TCP_ACCECN_CEP_INIT_OFFSET) & + TCP_ACCECN_CEP_ACE_MASK) : 0; + tp->pred_flags = htonl((tp->tcp_header_len << 26) | + (ace << 22) | ntohl(TCP_FLAG_ACK) | snd_wnd); } diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 94546f55385a..499f2a0be036 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3336,6 +3336,7 @@ int tcp_disconnect(struct sock *sk, int flags) tp->window_clamp = 0; tp->delivered = 0; tp->delivered_ce = 0; + tcp_accecn_init_counters(tp); if (icsk->icsk_ca_ops->release) icsk->icsk_ca_ops->release(sk); memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); @@ -5025,6 +5026,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, snd_up); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ce); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ce); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rx_opt); @@ -5032,7 +5034,7 @@ static void __init tcp_struct_check(void) /* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 92 + 4); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 97 + 7); /* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e8d32a231a9e..fcc6b7a75db8 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -334,14 +334,17 @@ static bool tcp_in_quickack_mode(struct sock *sk) static void tcp_ecn_queue_cwr(struct tcp_sock *tp) { + /* Do not set CWR if in AccECN mode! */ if (tcp_ecn_mode_rfc3168(tp)) tp->ecn_flags |= TCP_ECN_QUEUE_CWR; } static void tcp_ecn_accept_cwr(struct sock *sk, const struct sk_buff *skb) { - if (tcp_hdr(skb)->cwr) { - tcp_sk(sk)->ecn_flags &= ~TCP_ECN_DEMAND_CWR; + struct tcp_sock *tp = tcp_sk(sk); + + if (tcp_ecn_mode_rfc3168(tp) && tcp_hdr(skb)->cwr) { + tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; /* If the sender is telling us it has entered CWR, then its * cwnd may be very low (even just 1 packet), so we should ACK @@ -377,17 +380,16 @@ static void tcp_data_ecn_check(struct sock *sk, const struct sk_buff *skb) if (tcp_ca_needs_ecn(sk)) tcp_ca_event(sk, CA_EVENT_ECN_IS_CE); - if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) { + if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR) && + tcp_ecn_mode_rfc3168(tp)) { /* Better not delay acks, sender can have a very low cwnd */ tcp_enter_quickack_mode(sk, 2); tp->ecn_flags |= TCP_ECN_DEMAND_CWR; } - tp->ecn_flags |= TCP_ECN_SEEN; break; default: if (tcp_ca_needs_ecn(sk)) tcp_ca_event(sk, CA_EVENT_ECN_NO_CE); - tp->ecn_flags |= TCP_ECN_SEEN; break; } } @@ -421,10 +423,62 @@ static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, bool ece_ack) { tp->delivered += delivered; - if (ece_ack) + if (tcp_ecn_mode_rfc3168(tp) && ece_ack) tcp_count_delivered_ce(tp, delivered); } +/* Returns the ECN CE delta */ +static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, + u32 delivered_pkts, int flag) +{ + struct tcp_sock *tp = tcp_sk(sk); + u32 delta, safe_delta; + u32 corrected_ace; + + /* Reordered ACK? (...or uncertain due to lack of data to send and ts) */ + if (!(flag & (FLAG_FORWARD_PROGRESS | FLAG_TS_PROGRESS))) + return 0; + + if (!(flag & FLAG_SLOWPATH)) { + /* AccECN counter might overflow on large ACKs */ + if (delivered_pkts <= TCP_ACCECN_CEP_ACE_MASK) + return 0; + } + + /* ACE field is not available during handshake */ + if (flag & FLAG_SYN_ACKED) + return 0; + + if (tp->received_ce_pending >= TCP_ACCECN_ACE_MAX_DELTA) + inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_NOW; + + corrected_ace = tcp_accecn_ace(tcp_hdr(skb)) - TCP_ACCECN_CEP_INIT_OFFSET; + delta = (corrected_ace - tp->delivered_ce) & TCP_ACCECN_CEP_ACE_MASK; + if (delivered_pkts <= TCP_ACCECN_CEP_ACE_MASK) + return delta; + + safe_delta = delivered_pkts - ((delivered_pkts - delta) & TCP_ACCECN_CEP_ACE_MASK); + + return safe_delta; +} + +static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, + u32 delivered_pkts, int *flag) +{ + u32 delta; + struct tcp_sock *tp = tcp_sk(sk); + + delta = __tcp_accecn_process(sk, skb, delivered_pkts, *flag); + if (delta > 0) { + tcp_count_delivered_ce(tp, delta); + *flag |= FLAG_ECE; + /* Recalculate header predictor */ + if (tp->pred_flags) + tcp_fast_path_on(tp); + } + return delta; +} + /* Buffer size and advertised window tuning. * * 1. Tuning sk->sk_sndbuf, when connection enters established state. @@ -3912,7 +3966,8 @@ static void tcp_xmit_recovery(struct sock *sk, int rexmit) } /* Returns the number of packets newly acked or sacked by the current ACK */ -static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, int flag) +static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, + u32 ecn_count, int flag) { const struct net *net = sock_net(sk); struct tcp_sock *tp = tcp_sk(sk); @@ -3920,8 +3975,12 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, int flag) delivered = tp->delivered - prior_delivered; NET_ADD_STATS(net, LINUX_MIB_TCPDELIVERED, delivered); - if (flag & FLAG_ECE) - NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, delivered); + + if (flag & FLAG_ECE) { + if (tcp_ecn_mode_rfc3168(tp)) + ecn_count = delivered; + NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, ecn_count); + } return delivered; } @@ -3942,6 +4001,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) u32 delivered = tp->delivered; u32 lost = tp->lost; int rexmit = REXMIT_NONE; /* Flag to (re)transmit to recover losses */ + u32 ecn_count = 0; /* Did we receive ECE/an AccECN ACE update? */ u32 prior_fack; sack_state.first_sackt = 0; @@ -4049,6 +4109,9 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_rack_update_reo_wnd(sk, &rs); + if (tcp_ecn_mode_accecn(tp)) + ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, &flag); + tcp_in_ack_event(sk, flag); if (tp->tlp_high_seq) @@ -4073,7 +4136,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP)) sk_dst_confirm(sk); - delivered = tcp_newly_delivered(sk, delivered, flag); + delivered = tcp_newly_delivered(sk, delivered, ecn_count, flag); + lost = tp->lost - lost; /* freshly marked lost */ rs.is_ack_delayed = !!(flag & FLAG_ACK_MAYBE_DELAYED); tcp_rate_gen(sk, delivered, lost, is_sack_reneg, sack_state.rate); @@ -4082,12 +4146,14 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) return 1; no_queue: + if (tcp_ecn_mode_accecn(tp)) + ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, &flag); tcp_in_ack_event(sk, flag); /* If data was DSACKed, see if we can undo a cwnd reduction. */ if (flag & FLAG_DSACKING_ACK) { tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag, &rexmit); - tcp_newly_delivered(sk, delivered, flag); + tcp_newly_delivered(sk, delivered, ecn_count, flag); } /* If this ack opens up a zero window, clear backoff. It was * being used to time the probes, and is probably far higher than @@ -4108,7 +4174,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) &sack_state); tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag, &rexmit); - tcp_newly_delivered(sk, delivered, flag); + tcp_newly_delivered(sk, delivered, ecn_count, flag); tcp_xmit_recovery(sk, rexmit); } @@ -5940,6 +6006,24 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t } } +/* Updates Accurate ECN received counters from the received IP ECN field */ +static void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb) +{ + u8 ecnfield = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; + u8 is_ce = INET_ECN_is_ce(ecnfield); + struct tcp_sock *tp = tcp_sk(sk); + + if (!INET_ECN_is_not_ect(ecnfield)) { + u32 pcount = is_ce * max_t(u16, 1, skb_shinfo(skb)->gso_segs); + + tp->ecn_flags |= TCP_ECN_SEEN; + + /* ACE counter tracks *all* segments including pure ACKs */ + tp->received_ce += pcount; + tp->received_ce_pending = min(tp->received_ce_pending + pcount, 0xfU); + } +} + /* Accept RST for rcv_nxt - 1 after a FIN. * When tcp connections are abruptly terminated from Mac OSX (via ^C), a * FIN is sent followed by a RST packet. The RST is sent with the same @@ -6188,6 +6272,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) tp->rcv_nxt == tp->rcv_wup) flag |= __tcp_replace_ts_recent(tp, tstamp_delta); + tcp_ecn_received_counters(sk, skb); + /* We know that such packets are checksummed * on entry. */ @@ -6231,6 +6317,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) /* Bulk data transfer: receiver */ skb_dst_drop(skb); __skb_pull(skb, tcp_header_len); + tcp_ecn_received_counters(sk, skb); eaten = tcp_queue_rcv(sk, skb, &fragstolen); tcp_event_data_recv(sk, skb); @@ -6271,6 +6358,8 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) return; step5: + tcp_ecn_received_counters(sk, skb); + reason = tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT); if ((int)reason < 0) { reason = -reason; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 556c2da2bc77..42177f464d0c 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -371,6 +371,17 @@ tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th) th->ece = 1; } +static void tcp_accecn_set_ace(struct tcphdr *th, struct tcp_sock *tp) +{ + u32 wire_ace; + + wire_ace = tp->received_ce + TCP_ACCECN_CEP_INIT_OFFSET; + th->ece = !!(wire_ace & 0x1); + th->cwr = !!(wire_ace & 0x2); + th->ae = !!(wire_ace & 0x4); + tp->received_ce_pending = 0; +} + /* Set up ECN state for a packet on a ESTABLISHED socket that is about to * be sent. */ @@ -379,11 +390,17 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb, { struct tcp_sock *tp = tcp_sk(sk); - if (tcp_ecn_mode_rfc3168(tp)) { + if (!tcp_ecn_mode_any(tp)) + return; + + INET_ECN_xmit(sk); + if (tcp_ecn_mode_accecn(tp)) { + tcp_accecn_set_ace(th, tp); + skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ACCECN; + } else { /* Not-retransmitted data segment: set ECT and inject CWR. */ if (skb->len != tcp_header_len && !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { - INET_ECN_xmit(sk); if (tp->ecn_flags & TCP_ECN_QUEUE_CWR) { tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; th->cwr = 1; From patchwork Tue Oct 15 10:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836082 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2077.outbound.protection.outlook.com [40.107.103.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 273811E47DB for ; Tue, 15 Oct 2024 10:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; cv=fail; b=abmrDv6tNS9Te/J+9APxniU4shHbBDrud9q975IkkUzsG5qXt/MJo1esA6CCBWZRXcwaQdZid2yh9fZ850EpHHVUQUPBM0e+Cr96q/Z0uurSHhOCp4G95+ub2GcRHM0k7srNGwjnpqKGYM6jmvZn8Wzf6WdWgFcymPemYbZX1Nk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; c=relaxed/simple; bh=gRq09LiTvCqu77G3UmHFbQ+dx7jyMQRVGfRk6XwUonA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=nbUcVUuwDjI4DeZqYPFwnk9V6t9Y91bhFWHI2X6dQNthG8B6lnaJztJrxp6/QVuHLi6Y4egc9AFV8vIsmxpUo959i+CK7APOl1xIcrHmxhw2YeJoP8alO/J/5vED0OR40yYwHySX/nkKLDHUZWfnB8MLgsWI+FRj3qWOwaknkvg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=WhgbBMSt; arc=fail smtp.client-ip=40.107.103.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="WhgbBMSt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kkGOkDa1tDwohMsKGVvVTF0kPoRvVe0FVqPQZ0bydIS+tSAEI9b6weOJPfgYAFkNyRYzfKZQ2VsrdERaFoYURlAlQSPwBh/LYIp++RxL/EdeS1hhCYodfr1cNn8EZXH+ORXY4LpWbmB/w9vxMFYTTgi6Suo5lGNavg7hKevESI7bAj51daaAEZcIwAPwqWqG0M3IRIJj/jYurlm37STQh01xThDMGKine1irke97lXBOWMnexOSSll0bTrhcfuTsF/HJ3Ff/Fx2qUSs/WWgCJ9iro/euamub87OMMDnaUx/op7q0y2BZ0JXLTzA8afQEI+fIiI4OzDUrOImQUaoXHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=anYE30uqxh8PVEBZAC+XD5FOG2Mh8l8iyfB2oxTXqwk=; b=ftVVmuw0b9vwk2mjXlxykYO8t6OKdqznV0KLFiwOivBItHW6mX5mXzxT32YpmlRCY25gSQB4b36s4/wlKF0Mw711j5bjrMLhfdX+O5Kv8n2AFObz7477x24KV3Nnroued0yzbtBpYSuyXiuH3ocvrS1zcLRco58ulwR79nxn0mP1HA3p/exCsN93TOHKRsLe6kdtKR8YZMfzM0Yswxxp2p8fbrhbr+yGxIeWCWvqIyx9jXRSQNrqeDZCH+jupagU5UFHenQ63htETHhd5uZcJR5N7fAdsmJOS6B0hobqfE8HSkuXch8vTIRofjnTfw5bIIjv0hi1IBgWVAsd0H/3qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=anYE30uqxh8PVEBZAC+XD5FOG2Mh8l8iyfB2oxTXqwk=; b=WhgbBMStipQtBQsaebEu96weGiVsjLsoIfq9OPXaMZ7gzAU9kcVdBiziJ3LG3EQvEYfb0p9mTYuJpH/sBjDU0FXR1XNH3u0ZyiKtyqNi8508PpytG/mcW3rtbEOmR2cj6n7wZ4xX2Zx/NUyk8W8QskUa/Mp9gAcmVgasdIA9W0H3KI7LO44yDHueypAMIyC9Q2Hhq2Z+jXSldi+wC1tnUUHpxHsH/2XAbSDXdu2QNyIgNkRuKT/QsuZMSRj0wc5OfWs+CljyMip4aGZQ11Yu+D0ZTrgH7GEPMXtx4Lr6+FyrjTSjTMTOLVbqYHduSCNJxveUBl/DFUbF3rqCUJbzhw== Received: from DU7P250CA0011.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::26) by AS8PR07MB7944.eurprd07.prod.outlook.com (2603:10a6:20b:393::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:23 +0000 Received: from DB5PEPF00014B95.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::31) by DU7P250CA0011.outlook.office365.com (2603:10a6:10:54f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26 via Frontend Transport; Tue, 15 Oct 2024 10:30:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB5PEPF00014B95.mail.protection.outlook.com (10.167.8.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:21 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnK029578; Tue, 15 Oct 2024 10:30:20 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 16/44] net: sysctl: introduce sysctl SYSCTL_FIVE Date: Tue, 15 Oct 2024 12:29:12 +0200 Message-Id: <20241015102940.26157-17-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B95:EE_|AS8PR07MB7944:EE_ X-MS-Office365-Filtering-Correlation-Id: 905ea862-4789-4f96-1003-08dced045fba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: QWtYJiHEOCfETGkBWLY+R9klQX44TMYzuOxyQ0V42itmWBT6WAIuAvStl9OsZ8Rhp8ctoVCurEimwqdRlgLq04h89Al1qJU8S9IaVu3ml7sgfo7SC+ue68OTfVrdsi430FfakRFqHwuTZHbkUDXnaaEJoVnpvyEm1/3uHiOctbzI42t5msGmmkCfCM7efYSfM85rwrWuHJQU07DbzjxhAVxgXKa9ryzvPczG3fgvmOMp8QXBYHviiWmqCPEs8PjCsHGMav89WbKDT3R37s6P+4plNJdu0bHEbBSetDVCYtW2BlhwRxsNE5jzhnev5BlSm+zmVopxv+cYObJeAffizloBztpRcW7DNFKKPXl92q0gNPgX6QaVJ00YV9pcEtytWg8rM5KQOfrgJdfKCXaB63BY6eHMDgAq7Q5uSqcPMBaJEY/zZ0qGPTU6r8LO87H27SSuDwNKIObwvMm5OidrBGydGEm4TfiejHzFYebNNnSwyfoX4kIMq8KpF6uFS1LWTFdj7U6gG57KMdUMgG7AmNhPBWmz1rORs/GZ+rAdTSpVAHD4ZKUUSuCBk3eEkIaamhWY1Rc3hhigENOiRGzsdUoU6QS0i8/+oUvt8fIoZ5Mtr+y5a3Z1KihZWS30v/EmO4vO8tvpo+vt1H4hLcDW7/pRs81UbgoNqEI/lajY6Dx+WQ/tMrVLmWby5iInYJyO3MiDDj3dQAwEqOeBL2JKJOgHXQ5/xRHETN72gSs0RvP+7h1oSGg4pYyquA9lVq+pwdbPv6V0kfaWRo+Ov/9EbJveiRUuE688zZGZZlckLJtxGEJwIoyZMjlzj0qur42FcQM8+I5n12iPQWXlw+QmW4H5yzb3NlPmytqQBh5aDnPgrkbXevy0tdSLO2Xxaf9LQKhX5Fcz8YrqD99ndEtYSYD/m/coYuXNfPc/VwwT0DC+vhUpFHzLQMIcc1rWmI+wf1BnYnSZ4bV3tJw48yLWG9XRqWGzaSgr3G3GwNR677HuCZgzDIE1d4fxuLXixc02UhQHol2KVENgUynYL+PT2IngS7Tfueqha5HzorZpvQKeJRpy7CkODvU2SctNfbTCGgyl7qfnYNN26F9+LWRrnipPVdAaGd+z7gJKN5h21qcN2YkPBxz6DGR3QLngrkAJPlvmhAiHvnQiv6iULW/kYh0d2+5AtZde5ycow/sL0Q9MEXtofrlcTFec4G7x0osHhvMG6/GNLvnr3OAot/DhMvCbLwlhlCWAQoVCzRZN86iyIKlHkMdjTinLdjJj7Wv8wthYZ518F4a4LJo677Ul3PoL0jjZEyZJgWVRHSS3zX/+fA+KoKnIPdXsbusY/xUeMCfJa3rgBwbe8RDrqldGsEKGn0iyp0+youH58Z9/z1rM7EUzgOfAIUaOwBfyPptT X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:21.9730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 905ea862-4789-4f96-1003-08dced045fba X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B95.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7944 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Add SYSCTL_FIVE for new AccECN feedback modes of net.ipv4.tcp_ecn. Signed-off-by: Chia-Yu Chang --- include/linux/sysctl.h | 17 +++++++++-------- kernel/sysctl.c | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index aa4c6d44aaa0..37c95a70c10e 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -37,21 +37,22 @@ struct ctl_table_root; struct ctl_table_header; struct ctl_dir; -/* Keep the same order as in fs/proc/proc_sysctl.c */ +/* Keep the same order as in kernel/sysctl.c */ #define SYSCTL_ZERO ((void *)&sysctl_vals[0]) #define SYSCTL_ONE ((void *)&sysctl_vals[1]) #define SYSCTL_TWO ((void *)&sysctl_vals[2]) #define SYSCTL_THREE ((void *)&sysctl_vals[3]) #define SYSCTL_FOUR ((void *)&sysctl_vals[4]) -#define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[5]) -#define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[6]) -#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[7]) -#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[8]) -#define SYSCTL_INT_MAX ((void *)&sysctl_vals[9]) +#define SYSCTL_FIVE ((void *)&sysctl_vals[5]) +#define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[6]) +#define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[7]) +#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[8]) +#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[9]) +#define SYSCTL_INT_MAX ((void *)&sysctl_vals[10]) /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ -#define SYSCTL_MAXOLDUID ((void *)&sysctl_vals[10]) -#define SYSCTL_NEG_ONE ((void *)&sysctl_vals[11]) +#define SYSCTL_MAXOLDUID ((void *)&sysctl_vals[11]) +#define SYSCTL_NEG_ONE ((void *)&sysctl_vals[12]) extern const int sysctl_vals[]; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 79e6cb1d5c48..a922b44eaddd 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -82,7 +82,7 @@ #endif /* shared constants to be used in various sysctls */ -const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 }; +const int sysctl_vals[] = { 0, 1, 2, 3, 4, 5, 100, 200, 1000, 3000, INT_MAX, 65535, -1 }; EXPORT_SYMBOL(sysctl_vals); const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX }; From patchwork Tue Oct 15 10:29:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836088 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2083.outbound.protection.outlook.com [40.107.21.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A6481EF097 for ; Tue, 15 Oct 2024 10:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; cv=fail; b=CPO56nLe3Rxun0NMyBf9zfdgSx3Mf/mng/5+6iQX5tcixTjcXkqyRr4RpiABv4VGmu5uFW5Mpnn1BJrvFupnPoTcztU0mAxbfa5AdMsGMRV+b5bxd3rI+gz/rPRSNUsijCiITan4VXGwalox1/ovbpaWaGzuf9Q16qwZCoSaymY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; c=relaxed/simple; bh=oI9YWbmfnn7bHGUF6Jhn8gM4ePyi183LuYShyt2yrrE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jd9ErFM/BzCvwCxKdSRqY8xuINbt6VL70WUle4Qv22jGzxNE1bQ0PLMEID76Zinp45mcCRalLnUTU8Ryprdh4UHUY7kIzhygaQ1Lqyfr5OwNRKZJRjGyoNKGCcAaveHhPclvz+68K2aMa7etE7bxiF87fZIl1cbtPbMMhrncmHo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=MOreTiGv; arc=fail smtp.client-ip=40.107.21.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="MOreTiGv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qu9KjXBCTlsAcCOcQ4UmOrhuFUjE9STwbKhZGdLRsQ0Eq+asnyWnB0YVb/tyf1IYc+6qIkiwXq3KS8qv5Yz7evLL5FzE8B04Ty9j0yaCyHkHfArdUec2Ovdof/vLoPPEhqWvjOVcS2NaqP4o3VW31Nv9OWHVbuQd4eT64yszpUVW+xmW22kK+qxcbFjUZ5CzJH61str2yX3uJgR3e67FrjxjeXdQq2M7/N04AjAFYXE2mEo09RoN1ljDWMFX1BL5YelhSsBnyFQY9jFqSZ3x2wQ+ADVsR2XejRg3r9kufACX3C8PRkeiPIZDr/YjVT8PAccV61j/xTkax1SUm21G/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LuF+xJVS/1BDx9BCzigZZHdooEvb2yKsDDkfBtC63C0=; b=rC6jCHlbuV7aTLB7hr+Dh2mWTU8YfNmzvmqta06gTMm0OVMebWgUTy1Rf1iW6n21zSKkaghjTHH2BWWghcXf5qss5TvG+veSFhyNsRIq21GpDGMjdhzi9ubB1QrBgtrUkXpBqEIByiWdJ/QYoWZglol0KoqyQ9yY0l6p6zdyZPW2WwAf7KBfex/4tXAUp4NjO0K23TmCWN9/PmT2tyfbwsk1ocGROvAHp7CmhgtODVXQQhmYpIx1cJw124GBSIrIsyLu8U2sTltGB70cP8QigZg7NDs5+YQ8/aehKFInMgEmQpTQKcjItfmXFYsGT33+ZK5UxQM4hftUDuArwWAlng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LuF+xJVS/1BDx9BCzigZZHdooEvb2yKsDDkfBtC63C0=; b=MOreTiGvEDZ0BgN89JuvvSdw7UIXNwedSELqkN7dx6+uLuwfsSanK6UBWmRas/70LbuWf8YQFyqKYgjiNFsSHArZiBMfXKZOSQR+FfPaJKugyeDYafN58zZx7i21wkLm6/HfsPgTlgqX1tFKj0knKOIEgRrnQK0G9cpwOBanWeM+xELhFRAbb/JMgFm4kK7WreJOgdbIH0lWL68tp6aJe/s1y70/ncEfH2Y5bGstYzPrpuSN7rHJsjuL71S75DzXE+y3UNaVdKutP6l1S2pSksJWLkv1oZu9KJGPYMmNAuXqv2ASyb8TboX4F6aH3jpsy9reuWEOmJ825U5e5E0Y/A== Received: from DBBPR09CA0005.eurprd09.prod.outlook.com (2603:10a6:10:c0::17) by PR3PR07MB8099.eurprd07.prod.outlook.com (2603:10a6:102:172::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:23 +0000 Received: from DU2PEPF00028D0D.eurprd03.prod.outlook.com (2603:10a6:10:c0:cafe::6c) by DBBPR09CA0005.outlook.office365.com (2603:10a6:10:c0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D0D.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:23 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnL029578; Tue, 15 Oct 2024 10:30:21 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Olivier Tilmans , Chia-Yu Chang Subject: [PATCH net-next 17/44] tcp: accecn: AccECN negotiation Date: Tue, 15 Oct 2024 12:29:13 +0200 Message-Id: <20241015102940.26157-18-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0D:EE_|PR3PR07MB8099:EE_ X-MS-Office365-Filtering-Correlation-Id: d71450eb-2210-4e93-aeb3-08dced0460a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pyboLuaXpO3J3tX9p8Y4okt9ZpL9JQu?= =?utf-8?q?vkiwWGoUV5Bkgyb+rs+kY70hOEOTHeSCO4MY6E/1GHRF0hFTkgdl3JKb/YGO1GXV8?= =?utf-8?q?2EifiK+bq2+8pvNAjeqnlUBBO8keQpq0cuEkCLN2vNHRPpgVTQfKSMOS3LVZbYpEE?= =?utf-8?q?YCtszHBs/03UZYa993XtgSEChmvjtPpCHVTQGVYwTUNkMUm803P7HcbNifQIhXI/z?= =?utf-8?q?XnpdmhLvAw8YqYV4abFOH0v0hEWPGbTQeqyzlR4MTsqIal5hpVRJw3DYJbzl6FxeI?= =?utf-8?q?fHn2W+HaY0eT91nOpSZOA58bAnIxFJcIrxs6odCS8R35PtaI9KJ0hVzAK60t4R9r4?= =?utf-8?q?pjjf/UNQA5Ef1vrc7yQcDTj4QCtnlZKDY6USZZdsnfKnixJCzeCv1bcA3CVJjqvbC?= =?utf-8?q?qxGOnJJ0ggGopcWOo2K84CtLG9XEOwMiGljR1YOsCy+h0tBlYDIpm/wl1pSaeVZMm?= =?utf-8?q?vRhhQMsBV8rVEKTUWkQ6ZAWTOrIj3/5HuofeoLGZ84qfApZ+PB66AgLGddozvqWYz?= =?utf-8?q?ZJQguT1iI9IFnyyjJSpY62PugHCbPpwLjqtN9Ix37RVxrBfb7uXR5xlJfz46iiiu2?= =?utf-8?q?Qe2sH+W9o3Oeb1l0seeAXAO0h8wmNKNtv2T31NjknhUZgZUpXx6/4XDzSGRAA5PBU?= =?utf-8?q?F9VG8HU/SxN9mzzdY5tN9ij1rx9l8o/gVMSUCaFwrb/dqjrUDGaastCPONRBVtx5b?= =?utf-8?q?7b1lPxWiJ9KlpBiPi8c/NLpXvgL8CAS6U6/t73abt9RBP45ZsllazTqHuAizs3zDk?= =?utf-8?q?WhdU+RgF+eOHCGLgVpH+Use+SyFuMhD0p+KjUvhoNiWh6y7DfFvSadLtmplxUHJBE?= =?utf-8?q?TFjchyGceVzMipALaOm29OYh4tD8U0eRYwvA2oXQ6Jv0a5AJS90YnKeKqj8cEmSXP?= =?utf-8?q?mwUPwUOtWikjfslt/xNQvcbHWr3A5/02KoyswNe7FBH+GcYOTWxiejIEDPkreoo/7?= =?utf-8?q?EI0gpv6CN0RTsyZzg9FFsQ5qERUBLp2t5fqnsaOOYQ+3aIDj6jUZK5SYaAWL2Cd3s?= =?utf-8?q?qIkxuvSi722qtLovl5hNoIut1Hij8BWbdhq2yIVm4xUDnY+qxFHF5yeSIzzuhTiAE?= =?utf-8?q?iJwB9A71PmiPOWFsw65Qe3xlM5xIIsy/z4gYddosB/27wBEe5At3IdV3BspNs4R0u?= =?utf-8?q?R2E7Bda1hMDMBdSEoyaByRwT5iNM7ZyZTvkY4Q04qAjAQcejPuoMVJpAir3iYp7sB?= =?utf-8?q?23H8MQrHEzaSWG7J9TBPkj2Zy5iBrb+xcDP083gGsH+zkBjAn5bkDWLONL/PAT2Ey?= =?utf-8?q?zpXWEAr7+m0+D4fRlxpMadP4+nzLyEnBLlPVBl1Fc+aszWojIr0MUMmEuY5yG8byh?= =?utf-8?q?XR5O9sq0BBkMnc6s3iicRdc5Qeb9YQn5UA=3D=3D?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700013)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:23.5524 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d71450eb-2210-4e93-aeb3-08dced0460a8 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D0D.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB8099 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Accurate ECN negotiation parts based on the specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt Accurate ECN is negotiated using ECE, CWR and AE flags in the TCP header. TCP falls back into using RFC3168 ECN if one of the ends supports only RFC3168-style ECN. The AccECN negotiation includes reflecting IP ECN field value seen in SYN and SYNACK back using the same bits as negotiation to allow responding to SYN CE marks and to detect ECN field mangling. CE marks should not occur currently because SYN=1 segments are sent with Non-ECT in IP ECN field (but proposal exists to remove this restriction). Reflecting SYN IP ECN field in SYNACK is relatively simple. Reflecting SYNACK IP ECN field in the final/third ACK of the handshake is more challenging. Linux TCP code is not well prepared for using the final/third ACK a signalling channel which makes things somewhat complicated here. Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Signed-off-by: Ilpo Järvinen Co-developed-by: Chia-Yu Chang Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 9 ++- include/net/tcp.h | 80 +++++++++++++++++++- net/ipv4/syncookies.c | 3 + net/ipv4/sysctl_net_ipv4.c | 2 +- net/ipv4/tcp.c | 2 + net/ipv4/tcp_input.c | 149 +++++++++++++++++++++++++++++++++---- net/ipv4/tcp_ipv4.c | 3 +- net/ipv4/tcp_minisocks.c | 51 +++++++++++-- net/ipv4/tcp_output.c | 77 +++++++++++++++---- net/ipv6/syncookies.c | 1 + net/ipv6/tcp_ipv6.c | 1 + 11 files changed, 336 insertions(+), 42 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index c36e519f3985..4970ce3ee864 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -156,6 +156,10 @@ struct tcp_request_sock { #if IS_ENABLED(CONFIG_MPTCP) bool drop_req; #endif + u8 accecn_ok : 1, + syn_ect_snt: 2, + syn_ect_rcv: 2; + u8 accecn_fail_mode:4; u32 txhash; u32 rcv_isn; u32 snt_isn; @@ -372,7 +376,10 @@ struct tcp_sock { u8 compressed_ack; u8 dup_ack_counter:2, tlp_retrans:1, /* TLP is a retransmission */ - unused:5; + syn_ect_snt:2, /* AccECN ECT memory, only */ + syn_ect_rcv:2, /* ... needed durign 3WHS + first seqno */ + wait_third_ack:1; /* Need 3rd ACK in simultaneous open for AccECN */ + u8 accecn_fail_mode:4; /* AccECN failure handling */ u8 thin_lto : 1,/* Use linear timeouts for thin streams */ fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */ diff --git a/include/net/tcp.h b/include/net/tcp.h index 5ae0d1f9b083..6a387d4b2fa1 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -232,6 +233,37 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX); #define TCPOLEN_MSS_ALIGNED 4 #define TCPOLEN_EXP_SMC_BASE_ALIGNED 8 +/* tp->accecn_fail_mode */ +#define TCP_ACCECN_ACE_FAIL_SEND BIT(0) +#define TCP_ACCECN_ACE_FAIL_RECV BIT(1) +#define TCP_ACCECN_OPT_FAIL_SEND BIT(2) +#define TCP_ACCECN_OPT_FAIL_RECV BIT(3) + +static inline bool tcp_accecn_ace_fail_send(const struct tcp_sock *tp) +{ + return tp->accecn_fail_mode & TCP_ACCECN_ACE_FAIL_SEND; +} + +static inline bool tcp_accecn_ace_fail_recv(const struct tcp_sock *tp) +{ + return tp->accecn_fail_mode & TCP_ACCECN_ACE_FAIL_RECV; +} + +static inline bool tcp_accecn_opt_fail_send(const struct tcp_sock *tp) +{ + return tp->accecn_fail_mode & TCP_ACCECN_OPT_FAIL_SEND; +} + +static inline bool tcp_accecn_opt_fail_recv(const struct tcp_sock *tp) +{ + return tp->accecn_fail_mode & TCP_ACCECN_OPT_FAIL_RECV; +} + +static inline void tcp_accecn_fail_mode_set(struct tcp_sock *tp, u8 mode) +{ + tp->accecn_fail_mode |= mode; +} + /* Flags in tp->nonagle */ #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ #define TCP_NAGLE_CORK 2 /* Socket is corked */ @@ -418,6 +450,23 @@ static inline u8 tcp_accecn_ace(const struct tcphdr *th) return (th->ae << 2) | (th->cwr << 1) | th->ece; } +/* Infer the ECT value our SYN arrived with from the echoed ACE field */ +static inline int tcp_accecn_extract_syn_ect(u8 ace) +{ + if (ace & 0x1) + return INET_ECN_ECT_1; + if (!(ace & 0x2)) + return INET_ECN_ECT_0; + if (ace & 0x4) + return INET_ECN_CE; + return INET_ECN_NOT_ECT; +} + +bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect); +void tcp_accecn_third_ack(struct sock *sk, const struct sk_buff *skb, + u8 syn_ect_snt); +void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb); + enum tcp_tw_status { TCP_TW_SUCCESS = 0, TCP_TW_RST = 1, @@ -653,6 +702,15 @@ static inline bool cookie_ecn_ok(const struct net *net, const struct dst_entry * dst_feature(dst, RTAX_FEATURE_ECN); } +/* AccECN specification, 5.1: [...] a server can determine that it + * negotiated AccECN as [...] if the ACK contains an ACE field with + * the value 0b010 to 0b111 (decimal 2 to 7). + */ +static inline bool cookie_accecn_ok(const struct tcphdr *th) +{ + return tcp_accecn_ace(th) > 0x1; +} + #if IS_ENABLED(CONFIG_BPF) static inline bool cookie_bpf_ok(struct sk_buff *skb) { @@ -942,6 +1000,7 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq) #define TCPHDR_ACE (TCPHDR_ECE | TCPHDR_CWR | TCPHDR_AE) #define TCPHDR_SYN_ECN (TCPHDR_SYN | TCPHDR_ECE | TCPHDR_CWR) +#define TCPHDR_SYNACK_ACCECN (TCPHDR_SYN | TCPHDR_ACK | TCPHDR_CWR) #define TCP_ACCECN_CEP_ACE_MASK 0x7 #define TCP_ACCECN_ACE_MAX_DELTA 6 @@ -1023,6 +1082,15 @@ struct tcp_skb_cb { #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) +static inline u16 tcp_accecn_reflector_flags(u8 ect) +{ + u32 flags = ect + 2; + + if (ect == 3) + flags++; + return FIELD_PREP(TCPHDR_ACE, flags); +} + extern const struct inet_connection_sock_af_ops ipv4_specific; #if IS_ENABLED(CONFIG_IPV6) @@ -1145,7 +1213,10 @@ enum tcp_ca_ack_event_flags { #define TCP_CONG_NON_RESTRICTED BIT(0) /* Requires ECN/ECT set on all packets */ #define TCP_CONG_NEEDS_ECN BIT(1) -#define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN) +/* Require successfully negotiated AccECN capability */ +#define TCP_CONG_NEEDS_ACCECN BIT(2) +#define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN | \ + TCP_CONG_NEEDS_ACCECN) union tcp_cc_info; @@ -1277,6 +1348,13 @@ static inline bool tcp_ca_needs_ecn(const struct sock *sk) return icsk->icsk_ca_ops->flags & TCP_CONG_NEEDS_ECN; } +static inline bool tcp_ca_needs_accecn(const struct sock *sk) +{ + const struct inet_connection_sock *icsk = inet_csk(sk); + + return icsk->icsk_ca_ops->flags & TCP_CONG_NEEDS_ACCECN; +} + static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) { const struct inet_connection_sock *icsk = inet_csk(sk); diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 1948d15f1f28..3bd6274c8bcb 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -401,6 +401,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) const struct tcphdr *th = tcp_hdr(skb); struct tcp_sock *tp = tcp_sk(sk); struct inet_request_sock *ireq; + struct tcp_request_sock *treq; struct net *net = sock_net(sk); struct request_sock *req; struct sock *ret = sk; @@ -427,6 +428,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) } ireq = inet_rsk(req); + treq = tcp_rsk(req); sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr); sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr); @@ -481,6 +483,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) if (!req->syncookie) ireq->rcv_wscale = rcv_wscale; ireq->ecn_ok &= cookie_ecn_ok(net, &rt->dst); + treq->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th); ret = tcp_get_cookie_sock(sk, skb, req, &rt->dst); /* ip_queue_xmit() depends on our flow being setup diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index a79b2a52ce01..01fcc6b2045b 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -726,7 +726,7 @@ static struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dou8vec_minmax, .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_TWO, + .extra2 = SYSCTL_FIVE, }, { .procname = "tcp_ecn_fallback", diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 499f2a0be036..f5ceadb43efb 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3336,6 +3336,8 @@ int tcp_disconnect(struct sock *sk, int flags) tp->window_clamp = 0; tp->delivered = 0; tp->delivered_ce = 0; + tp->wait_third_ack = 0; + tp->accecn_fail_mode = 0; tcp_accecn_init_counters(tp); if (icsk->icsk_ca_ops->release) icsk->icsk_ca_ops->release(sk); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index fcc6b7a75db8..0591c605b57a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -394,14 +394,91 @@ static void tcp_data_ecn_check(struct sock *sk, const struct sk_buff *skb) } } -static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th) +/* AccECN specificaiton, 3.1.2: If a TCP server that implements AccECN + * receives a SYN with the three TCP header flags (AE, CWR and ECE) set + * to any combination other than 000, 011 or 111, it MUST negotiate the + * use of AccECN as if they had been set to 111. + */ +static bool tcp_accecn_syn_requested(const struct tcphdr *th) +{ + u8 ace = tcp_accecn_ace(th); + + return ace && ace != 0x3; +} + +/* Check ECN field transition to detect invalid transitions */ +static bool tcp_ect_transition_valid(u8 snt, u8 rcv) +{ + if (rcv == snt) + return true; + + /* Non-ECT altered to something or something became non-ECT */ + if (snt == INET_ECN_NOT_ECT || rcv == INET_ECN_NOT_ECT) + return false; + /* CE -> ECT(0/1)? */ + if (snt == INET_ECN_CE) + return false; + return true; +} + +bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect) { - if (tcp_ecn_mode_rfc3168(tp) && (!th->ece || th->cwr)) + u8 ect = tcp_accecn_extract_syn_ect(ace); + struct tcp_sock *tp = tcp_sk(sk); + + if (!sock_net(sk)->ipv4.sysctl_tcp_ecn_fallback) + return true; + + if (!tcp_ect_transition_valid(sent_ect, ect)) { + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV); + return false; + } + + return true; +} + +/* See Table 2 of the AccECN draft */ +static void tcp_ecn_rcv_synack(struct sock *sk, const struct tcphdr *th, + u8 ip_dsfield) +{ + struct tcp_sock *tp = tcp_sk(sk); + u8 ace = tcp_accecn_ace(th); + + switch (ace) { + case 0x0: + case 0x7: tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); + break; + case 0x1: + case 0x5: + if (tcp_ecn_mode_pending(tp)) + /* Downgrade from AccECN, or requested initially */ + tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); + break; + default: + tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); + tp->syn_ect_rcv = ip_dsfield & INET_ECN_MASK; + if (tcp_accecn_validate_syn_feedback(sk, ace, tp->syn_ect_snt) && + INET_ECN_is_ce(ip_dsfield)) { + tp->received_ce++; + tp->received_ce_pending++; + } + break; + } } -static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th) +static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th, + const struct sk_buff *skb) { + if (tcp_ecn_mode_pending(tp)) { + if (!tcp_accecn_syn_requested(th)) { + /* Downgrade to classic ECN feedback */ + tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); + } else { + tp->syn_ect_rcv = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; + tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); + } + } if (tcp_ecn_mode_rfc3168(tp) && (!th->ece || !th->cwr)) tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); } @@ -3825,7 +3902,7 @@ bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb, } /* RFC 5961 7 [ACK Throttling] */ -static void tcp_send_challenge_ack(struct sock *sk) +static void tcp_send_challenge_ack(struct sock *sk, bool accecn_reflector) { struct tcp_sock *tp = tcp_sk(sk); struct net *net = sock_net(sk); @@ -3855,7 +3932,8 @@ static void tcp_send_challenge_ack(struct sock *sk) WRITE_ONCE(net->ipv4.tcp_challenge_count, count - 1); send_ack: NET_INC_STATS(net, LINUX_MIB_TCPCHALLENGEACK); - tcp_send_ack(sk); + __tcp_send_ack(sk, tp->rcv_nxt, + !accecn_reflector ? 0 : tcp_accecn_reflector_flags(tp->syn_ect_rcv)); } } @@ -4022,7 +4100,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) /* RFC 5961 5.2 [Blind Data Injection Attack].[Mitigation] */ if (before(ack, prior_snd_una - max_window)) { if (!(flag & FLAG_NO_CHALLENGE_ACK)) - tcp_send_challenge_ack(sk); + tcp_send_challenge_ack(sk, false); return -SKB_DROP_REASON_TCP_TOO_OLD_ACK; } goto old_ack; @@ -6007,7 +6085,7 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t } /* Updates Accurate ECN received counters from the received IP ECN field */ -static void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb) +void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb) { u8 ecnfield = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; u8 is_ce = INET_ECN_is_ce(ecnfield); @@ -6047,6 +6125,7 @@ static bool tcp_reset_check(const struct sock *sk, const struct sk_buff *skb) static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, const struct tcphdr *th, int syn_inerr) { + bool send_accecn_reflector = false; struct tcp_sock *tp = tcp_sk(sk); SKB_DR(reason); @@ -6128,7 +6207,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, if (tp->syn_fastopen && !tp->data_segs_in && sk->sk_state == TCP_ESTABLISHED) tcp_fastopen_active_disable(sk); - tcp_send_challenge_ack(sk); + tcp_send_challenge_ack(sk, false); SKB_DR_SET(reason, TCP_RESET); goto discard; } @@ -6139,16 +6218,25 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, * RFC 5961 4.2 : Send a challenge ack */ if (th->syn) { + if (tcp_ecn_mode_accecn(tp)) + send_accecn_reflector = true; if (sk->sk_state == TCP_SYN_RECV && sk->sk_socket && th->ack && TCP_SKB_CB(skb)->seq + 1 == TCP_SKB_CB(skb)->end_seq && TCP_SKB_CB(skb)->seq + 1 == tp->rcv_nxt && - TCP_SKB_CB(skb)->ack_seq == tp->snd_nxt) + TCP_SKB_CB(skb)->ack_seq == tp->snd_nxt) { + if (!tcp_ecn_disabled(tp)) { + tp->wait_third_ack = true; + __tcp_send_ack(sk, tp->rcv_nxt, + !send_accecn_reflector ? 0 : + tcp_accecn_reflector_flags(tp->syn_ect_rcv)); + } goto pass; + } syn_challenge: if (syn_inerr) TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNCHALLENGE); - tcp_send_challenge_ack(sk); + tcp_send_challenge_ack(sk, send_accecn_reflector); SKB_DR_SET(reason, TCP_INVALID_SYN); goto discard; } @@ -6358,6 +6446,13 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) return; step5: + if (unlikely(tp->wait_third_ack)) { + if (!tcp_ecn_disabled(tp)) + tp->wait_third_ack = 0; + if (tcp_ecn_mode_accecn(tp)) + tcp_accecn_third_ack(sk, skb, tp->syn_ect_snt); + tcp_fast_path_on(tp); + } tcp_ecn_received_counters(sk, skb); reason = tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT); @@ -6611,7 +6706,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, * state to ESTABLISHED..." */ - tcp_ecn_rcv_synack(tp, th); + if (tcp_ecn_mode_any(tp)) + tcp_ecn_rcv_synack(sk, th, TCP_SKB_CB(skb)->ip_dsfield); tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); tcp_try_undo_spurious_syn(sk); @@ -6683,7 +6779,9 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, TCP_DELACK_MAX, TCP_RTO_MAX); goto consume; } - tcp_send_ack(sk); + __tcp_send_ack(sk, tp->rcv_nxt, + !tcp_ecn_mode_accecn(tp) ? 0 : + tcp_accecn_reflector_flags(tp->syn_ect_rcv)); return -1; } @@ -6742,7 +6840,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, tp->snd_wl1 = TCP_SKB_CB(skb)->seq; tp->max_window = tp->snd_wnd; - tcp_ecn_rcv_syn(tp, th); + tcp_ecn_rcv_syn(tp, th, skb); tcp_mtup_init(sk); tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); @@ -6925,7 +7023,7 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) } /* accept old ack during closing */ if ((int)reason < 0) { - tcp_send_challenge_ack(sk); + tcp_send_challenge_ack(sk, false); reason = -reason; goto discard; } @@ -6972,9 +7070,16 @@ tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) tp->lsndtime = tcp_jiffies32; tcp_initialize_rcv_mss(sk); - tcp_fast_path_on(tp); + if (likely(!tp->wait_third_ack)) { + if (tcp_ecn_mode_accecn(tp)) + tcp_accecn_third_ack(sk, skb, tp->syn_ect_snt); + tcp_fast_path_on(tp); + } if (sk->sk_shutdown & SEND_SHUTDOWN) tcp_shutdown(sk, SEND_SHUTDOWN); + + if (sk->sk_socket && tp->wait_third_ack) + goto consume; break; case TCP_FIN_WAIT1: { @@ -7144,6 +7249,14 @@ static void tcp_ecn_create_request(struct request_sock *req, bool ect, ecn_ok; u32 ecn_ok_dst; + if (tcp_accecn_syn_requested(th) && + (net->ipv4.sysctl_tcp_ecn >= 3 || tcp_ca_needs_accecn(listen_sk))) { + inet_rsk(req)->ecn_ok = 1; + tcp_rsk(req)->accecn_ok = 1; + tcp_rsk(req)->syn_ect_rcv = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; + return; + } + if (!th_ecn) return; @@ -7151,7 +7264,8 @@ static void tcp_ecn_create_request(struct request_sock *req, ecn_ok_dst = dst_feature(dst, DST_FEATURE_ECN_MASK); ecn_ok = READ_ONCE(net->ipv4.sysctl_tcp_ecn) || ecn_ok_dst; - if (((!ect || th->res1) && ecn_ok) || tcp_ca_needs_ecn(listen_sk) || + if (((!ect || th->res1 || th->ae) && ecn_ok) || + tcp_ca_needs_ecn(listen_sk) || (ecn_ok_dst & DST_FEATURE_ECN_CA) || tcp_bpf_ca_needs_ecn((struct sock *)req)) inet_rsk(req)->ecn_ok = 1; @@ -7168,6 +7282,9 @@ static void tcp_openreq_init(struct request_sock *req, tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1; tcp_rsk(req)->snt_synack = 0; tcp_rsk(req)->last_oow_ack_time = 0; + tcp_rsk(req)->accecn_ok = 0; + tcp_rsk(req)->syn_ect_rcv = 0; + tcp_rsk(req)->syn_ect_snt = 0; req->mss = rx_opt->mss_clamp; req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; ireq->tstamp_ok = rx_opt->tstamp_ok; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 9419e7b492fc..97df9f36714c 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1182,7 +1182,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst, enum tcp_synack_type synack_type, struct sk_buff *syn_skb) { - const struct inet_request_sock *ireq = inet_rsk(req); + struct inet_request_sock *ireq = inet_rsk(req); struct flowi4 fl4; int err = -1; struct sk_buff *skb; @@ -1195,6 +1195,7 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst, skb = tcp_make_synack(sk, dst, req, foc, synack_type, syn_skb); if (skb) { + tcp_rsk(req)->syn_ect_snt = inet_sk(sk)->tos & INET_ECN_MASK; __tcp_v4_send_check(skb, ireq->ir_loc_addr, ireq->ir_rmt_addr); tos = READ_ONCE(inet_sk(sk)->tos); diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 8fb9f550fdeb..81d42942c335 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -450,12 +450,51 @@ void tcp_openreq_init_rwin(struct request_sock *req, } EXPORT_SYMBOL(tcp_openreq_init_rwin); -static void tcp_ecn_openreq_child(struct tcp_sock *tp, - const struct request_sock *req) +void tcp_accecn_third_ack(struct sock *sk, const struct sk_buff *skb, + u8 syn_ect_snt) { - tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ? - TCP_ECN_MODE_RFC3168 : - TCP_ECN_DISABLED); + u8 ace = tcp_accecn_ace(tcp_hdr(skb)); + struct tcp_sock *tp = tcp_sk(sk); + + switch (ace) { + case 0x0: + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV); + break; + case 0x7: + case 0x5: + case 0x1: + /* Unused but legal values */ + break; + default: + /* Validation only applies to first non-data packet */ + if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq && + !TCP_SKB_CB(skb)->sacked && + tcp_accecn_validate_syn_feedback(sk, ace, syn_ect_snt)) { + if ((tcp_accecn_extract_syn_ect(ace) == INET_ECN_CE) && + !tp->delivered_ce) + tp->delivered_ce++; + } + break; + } +} + +static void tcp_ecn_openreq_child(struct sock *sk, + const struct request_sock *req, + const struct sk_buff *skb) +{ + const struct tcp_request_sock *treq = tcp_rsk(req); + struct tcp_sock *tp = tcp_sk(sk); + + if (treq->accecn_ok) { + tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); + tp->syn_ect_snt = treq->syn_ect_snt; + tcp_accecn_third_ack(sk, skb, treq->syn_ect_snt); + tcp_ecn_received_counters(sk, skb); + } else { + tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ? + TCP_ECN_MODE_RFC3168 : + TCP_ECN_DISABLED); + } } void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst) @@ -621,7 +660,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk, if (skb->len >= TCP_MSS_DEFAULT + newtp->tcp_header_len) newicsk->icsk_ack.last_seg_size = skb->len - newtp->tcp_header_len; newtp->rx_opt.mss_clamp = req->mss; - tcp_ecn_openreq_child(newtp, req); + tcp_ecn_openreq_child(newsk, req, skb); newtp->fastopen_req = NULL; RCU_INIT_POINTER(newtp->fastopen_rsk, NULL); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 42177f464d0c..ebda1b71d489 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -319,7 +319,7 @@ static u16 tcp_select_window(struct sock *sk) /* Packet ECN state for a SYN-ACK */ static void tcp_ecn_send_synack(struct sock *sk, struct sk_buff *skb) { - const struct tcp_sock *tp = tcp_sk(sk); + struct tcp_sock *tp = tcp_sk(sk); TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_CWR; if (tcp_ecn_disabled(tp)) @@ -327,6 +327,12 @@ static void tcp_ecn_send_synack(struct sock *sk, struct sk_buff *skb) else if (tcp_ca_needs_ecn(sk) || tcp_bpf_ca_needs_ecn(sk)) INET_ECN_xmit(sk); + + if (tp->ecn_flags & TCP_ECN_MODE_ACCECN) { + TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ACE; + TCP_SKB_CB(skb)->tcp_flags |= tcp_accecn_reflector_flags(tp->syn_ect_rcv); + tp->syn_ect_snt = inet_sk(sk)->tos & INET_ECN_MASK; + } } /* Packet ECN state for a SYN. */ @@ -334,8 +340,20 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); bool bpf_needs_ecn = tcp_bpf_ca_needs_ecn(sk); - bool use_ecn = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn) == 1 || - tcp_ca_needs_ecn(sk) || bpf_needs_ecn; + bool use_ecn, use_accecn; + u8 tcp_ecn = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn); + + /* ============== ========================== + * tcp_ecn values Outgoing connections + * ============== ========================== + * 0,2,5 Do not request ECN + * 1,4 Request ECN connection + * 3 Request AccECN connection + * ============== ========================== + */ + use_accecn = tcp_ecn == 3 || tcp_ca_needs_accecn(sk); + use_ecn = tcp_ecn == 1 || tcp_ecn == 4 || + tcp_ca_needs_ecn(sk) || bpf_needs_ecn || use_accecn; if (!use_ecn) { const struct dst_entry *dst = __sk_dst_get(sk); @@ -351,35 +369,58 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb) INET_ECN_xmit(sk); TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; - tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); + if (use_accecn) { + TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_AE; + tcp_ecn_mode_set(tp, TCP_ECN_MODE_PENDING); + tp->syn_ect_snt = inet_sk(sk)->tos & INET_ECN_MASK; + } else { + tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); + } } } static void tcp_ecn_clear_syn(struct sock *sk, struct sk_buff *skb) { - if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_fallback)) + if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_ecn_fallback)) { /* tp->ecn_flags are cleared at a later point in time when * SYN ACK is ultimatively being received. */ - TCP_SKB_CB(skb)->tcp_flags &= ~(TCPHDR_ECE | TCPHDR_CWR); + TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ACE; + } +} + +static void tcp_accecn_echo_syn_ect(struct tcphdr *th, u8 ect) +{ + th->ae = !!(ect & INET_ECN_ECT_0); + th->cwr = ect != INET_ECN_ECT_0; + th->ece = ect == INET_ECN_ECT_1; } static void tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th) { - if (inet_rsk(req)->ecn_ok) + if (tcp_rsk(req)->accecn_ok) + tcp_accecn_echo_syn_ect(th, tcp_rsk(req)->syn_ect_rcv); + else if (inet_rsk(req)->ecn_ok) th->ece = 1; } -static void tcp_accecn_set_ace(struct tcphdr *th, struct tcp_sock *tp) +static void tcp_accecn_set_ace(struct tcp_sock *tp, struct sk_buff *skb, + struct tcphdr *th) { u32 wire_ace; - wire_ace = tp->received_ce + TCP_ACCECN_CEP_INIT_OFFSET; - th->ece = !!(wire_ace & 0x1); - th->cwr = !!(wire_ace & 0x2); - th->ae = !!(wire_ace & 0x4); - tp->received_ce_pending = 0; + /* The final packet of the 3WHS or anything like it must reflect + * the SYN/ACK ECT instead of putting CEP into ACE field, such + * case show up in tcp_flags. + */ + if (likely(!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACE))) { + wire_ace = tp->received_ce + TCP_ACCECN_CEP_INIT_OFFSET; + th->ece = !!(wire_ace & 0x1); + th->cwr = !!(wire_ace & 0x2); + th->ae = !!(wire_ace & 0x4); + tp->received_ce_pending = 0; + } } /* Set up ECN state for a packet on a ESTABLISHED socket that is about to @@ -393,9 +434,10 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb, if (!tcp_ecn_mode_any(tp)) return; - INET_ECN_xmit(sk); + if (!tcp_accecn_ace_fail_recv(tp)) + INET_ECN_xmit(sk); if (tcp_ecn_mode_accecn(tp)) { - tcp_accecn_set_ace(th, tp); + tcp_accecn_set_ace(tp, skb, th); skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ACCECN; } else { /* Not-retransmitted data segment: set ECT and inject CWR. */ @@ -3404,7 +3446,10 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) tcp_retrans_try_collapse(sk, skb, avail_wnd); } - /* RFC3168, section 6.1.1.1. ECN fallback */ + /* RFC3168, section 6.1.1.1. ECN fallback + * As AccECN uses the same SYN flags (+ AE), this check covers both + * cases. + */ if ((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN_ECN) == TCPHDR_SYN_ECN) tcp_ecn_clear_syn(sk, skb); diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 9d83eadd308b..50046460ee0b 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c @@ -264,6 +264,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) if (!req->syncookie) ireq->rcv_wscale = rcv_wscale; ireq->ecn_ok &= cookie_ecn_ok(net, dst); + tcp_rsk(req)->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th); ret = tcp_get_cookie_sock(sk, skb, req, dst); if (!ret) { diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index d9551c9cd562..6e49f22ce379 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -542,6 +542,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst, skb = tcp_make_synack(sk, dst, req, foc, synack_type, syn_skb); if (skb) { + tcp_rsk(req)->syn_ect_snt = np->tclass & INET_ECN_MASK; __tcp_v6_send_check(skb, &ireq->ir_v6_loc_addr, &ireq->ir_v6_rmt_addr); From patchwork Tue Oct 15 10:29:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836078 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2076.outbound.protection.outlook.com [40.107.104.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32B051EBA1E for ; Tue, 15 Oct 2024 10:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988229; cv=fail; b=bpYl0i/umkZV1/sjL01j/gUfQUnqeCvR8drt4mWD8EfGyqTS7qmhFZrg2ip9tIzY2Gp2g5iSML/IwPjf5O2e0ipZ7QQ6yDYcbq2cTjmsxvvpmxYXSIxHhAGCmkrD6FRfzngZMtV8tgUZrc/X8jEMJ/tmETTqz46rYsnaoQfvnnI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988229; c=relaxed/simple; bh=wq+YACL4M79rnOB2U9WCUMBS/YrWskt7T1pjReeYWVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=K+bKpO3woLYGWPWi4hV0ta2H5Jx1W6FaMh81Dw+K0pOz9daReeuQhHLryq0qqAmzErHUmjeR9qD3tckgY5wiIgBaEyILPoSkp5LMyb44541I4rnSAJEF73IDR6hNli1qOhdOqDwSdO8bcnzYpBNkmEZrmGg95JLQmo6HKPKDCXE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=XwLwSoWz; arc=fail smtp.client-ip=40.107.104.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="XwLwSoWz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AhDBbrJaOrmImhTxrSaHklycxB8pxFVRTLcELjvl6QZFmKJTtcBD1O1V2+YIZEJNaYEf8PczZ+jNwhVGo4r09n+fVu6kEnEcDNyQjdp9JFrPm8WeGesKGBdVLXprDClueT5mpPGgAjhtXK5QzuVf+gEwgKy/XaZkRQ/bTkOG9lF5oVwBnMLDDogA432pSQwJijtVVbN4MiS8Z5FTGen/PgbhjQtZRbiDzZdsHR6bvPzBauWmoJ0+i1xUEhMC4pmC3i5jOiCd8kZRjihSATuSmCoqR4VPz/XR5XhsUQY0aq37Nkq2UPAGGJqMWh2ifGuC7ZpF1U+PuDGrbLOqwKcOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=54krDeb5Wtqm1Iwnx+98ZHOwIvVbXQwTIw8FVm+uiJk=; b=qmbxH9dMcg4JosQVVhsq4+iKK5KxWshfdQziWwpqm+J6+KyV0BzPdtn9Nz1noHvESI1l7emZNX7dCX7xIeN3qUC5s9QZWTFZJ0APRaVblCtGUiqQu77LBldvLIGu3PnVkiAWsghj32DtgpNgEy4WB/edL/Cgu0iOgMAmcAu7shFbl6Z7uqEY1Rf1wuXVfE9Bevc+bCd1jcX/oq3RefdsMPMWSzeC5gnr3YVzY+IinY7wTQpkpMRVkW6oLxBp+tj6FYaRF4SqbrmnS/4UsdD73zbLaHhGNaMnPp+zsnqOXoXNaxTsBvfxmhtPGq81Ee/BTwXMkJGjM5Wl8gUCjIDJgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=54krDeb5Wtqm1Iwnx+98ZHOwIvVbXQwTIw8FVm+uiJk=; b=XwLwSoWzXjroKlQ+Kn5ys8Vb6eKnTPsdMI9qc5guh6jybVgJ9/wEzihGKf+Tsy8OlYri5xo+ycUz4rQzR4PzHxZW2FQ/xPxhR3SWcZOm7dk7lM5br1e7M/riBaIwDx2HlZojc92Z7ENrBuMKf/grkCmnkKstA7LhEu90vQgqt2vpkCS/KXW7xD3iQZfcrcYwXd9MLyQ9Yd1ahWNpasy2aP2vdRC/zC0/LGqDnGqpdHOlgNp1nQn72IrIKgNimSzY0T9+IxA7PxWZNMXu2sJbZYy9yjnWz9PNjdJTA1PiZR4T6xaNX4aXhU+CJ/BcAncXmmTXq+q4M2hU60s6J51Fyw== Received: from DBBPR09CA0021.eurprd09.prod.outlook.com (2603:10a6:10:c0::33) by AS1PR07MB8710.eurprd07.prod.outlook.com (2603:10a6:20b:479::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:23 +0000 Received: from DU2PEPF00028D0D.eurprd03.prod.outlook.com (2603:10a6:10:c0:cafe::93) by DBBPR09CA0021.outlook.office365.com (2603:10a6:10:c0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D0D.mail.protection.outlook.com (10.167.242.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:23 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnM029578; Tue, 15 Oct 2024 10:30:22 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 18/44] tcp: accecn: add AccECN rx byte counters Date: Tue, 15 Oct 2024 12:29:14 +0200 Message-Id: <20241015102940.26157-19-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0D:EE_|AS1PR07MB8710:EE_ X-MS-Office365-Filtering-Correlation-Id: 9783073e-1fb5-41f6-ff1e-08dced046078 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OfLFvzLy5BPeRYBT2I1rt5OCMR4+wre?= =?utf-8?q?jjufxRtoRIDnk9J9Km7FDhn/SUOUpMWDG4xYwwtCrg96R5QmtYSAt6PC/j4oATLZF?= =?utf-8?q?UQg7VsLD0DbacuM1ja/JB1ws1wuIu0TAXNY44YS4rQf+Id8wOXTkxf+R/YnLgjwjK?= =?utf-8?q?zkP8k/wLwGNtSacTem3TT/8nq9nSx7DleIMmbpFpPveLpmbtyh+n3WUxS+jert2Wm?= =?utf-8?q?t1MtJz1NLJzGYHnGeYOAoIxZ6lEaKO9AIGRIKs4DSzjD1KzvyQ75izj0eRa55TmqM?= =?utf-8?q?R5M9sydM4fQjAoVklLgKzw92ubyHOg8XD3kY1H/1yLhw48Wi88NVfBXKHaOaDTVuI?= =?utf-8?q?Wk+Spl3VAh+PfPJ9ef1XaE6lNSw97zs/4ulZuCrJu785p353I0dOcQIecY7/02Pi1?= =?utf-8?q?HZLDluR5W2booS//yZUDWGTHoMRPU2q4a/POCSaML/6V1jytn7mAdoVQW7Mmpoomc?= =?utf-8?q?T2j0Jx0gr9mrNbffnEYUGadB4bUmSx3PAF3LICWldUrF1U8khM/GxOIwsiP00Z+TY?= =?utf-8?q?tALil0nzx9M6ua0ElVynZYwgfF0dgpYDVYAd5Tx3f7o90aOUyoRYfyXHYNZqcb2uj?= =?utf-8?q?7pKqEoojzuyVjmk3CCN//dUKzIS1yCR4sFxVklqMPQRtQkqVcmW4U044TUL5W1e+B?= =?utf-8?q?cnYGIGHGa2PnE7lxUkqpVGAPGEevDQqiwFPET0iq00PCJsaSqovLvg4nAGDB4p3Xe?= =?utf-8?q?dUq+G72EWz4WnOq4nIXy/wiznlnwZPS9p6D7Ee09+6UGR+LzCv000Hedg2DuAvOe8?= =?utf-8?q?F1O6Mxt/QkZluwqfhcdpZ7J24uKMDEHaPIxa4h3iEkL05HcnmWqnXb6owYhFIcR/D?= =?utf-8?q?+m21f7z18vPMZ5YxqCWkx4Yc0nlBrF1gdoa4wFXoba7y7ai1s52lmUThcx9IkbFYC?= =?utf-8?q?oXfpIDRFZJVKfaZrR9mP1WsyoRlWPPRxKnchvJoAOm7s8qq/6Lbdfcar5zO5WZCwo?= =?utf-8?q?AyUSfnULeGtgsxhoMvbeRM9lo3k3dW18N1e7xW79WfXIbZcMlzk+IFLOk5oOv8rMC?= =?utf-8?q?/gYn2B37tzzqQaDGBlzVERO/fizF2ByELxS8venJwcvSvkLXLvz5FpHqgSx2cKSzH?= =?utf-8?q?BsoyWWFu4Bm7XTDqg8dd71soTjXxz1SjS7BGSxb5qMFaYs90FYK+R3Tu7aoSdVuiK?= =?utf-8?q?pIBHRq8F3VeyTbosWFP/p4RXfciB/4NsqN+WcI0huw//nkWkz49u7pbMqx1WyJB2J?= =?utf-8?q?lXK1rP47FDgoQRFknFNfTAelc6b40nr7etzxeR1zbL2vqk5+KRX3zBXPadASvCufP?= =?utf-8?q?97fQcal9eJUB6fQJpOa/FrZDKVA6cqyaQK9moPiiNyDVMGWOATbyEvoo5ZLvM/YRH?= =?utf-8?q?lW9VcCkzy/cQ?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:23.2399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9783073e-1fb5-41f6-ff1e-08dced046078 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D0D.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR07MB8710 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen These counters track IP ECN field payload byte sums for all arriving (acceptable) packets. The AccECN option (added by a later patch in the series) echoes these counters back to sender side. Signed-off-by: Ilpo Järvinen Signed-off-by: Neal Cardwell Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 1 + include/net/tcp.h | 18 +++++++++++++++++- net/ipv4/tcp.c | 3 ++- net/ipv4/tcp_input.c | 12 ++++++++---- net/ipv4/tcp_minisocks.c | 3 ++- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 4970ce3ee864..aaf84044e127 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -299,6 +299,7 @@ struct tcp_sock { u32 delivered; /* Total data packets delivered incl. rexmits */ u32 delivered_ce; /* Like the above but only ECE marked packets */ u32 received_ce; /* Like the above but for received CE marked packets */ + u32 received_ecn_bytes[3]; u8 received_ce_pending:4, /* Not yet transmitted cnt of received_ce */ unused2:4; u32 app_limited; /* limited until "delivered" reaches this val */ diff --git a/include/net/tcp.h b/include/net/tcp.h index 6a387d4b2fa1..56d009723c91 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -465,7 +465,8 @@ static inline int tcp_accecn_extract_syn_ect(u8 ace) bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect); void tcp_accecn_third_ack(struct sock *sk, const struct sk_buff *skb, u8 syn_ect_snt); -void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb); +void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb, + u32 payload_len); enum tcp_tw_status { TCP_TW_SUCCESS = 0, @@ -1009,11 +1010,26 @@ static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq) * See draft-ietf-tcpm-accurate-ecn for the latest values. */ #define TCP_ACCECN_CEP_INIT_OFFSET 5 +#define TCP_ACCECN_E1B_INIT_OFFSET 1 +#define TCP_ACCECN_E0B_INIT_OFFSET 1 +#define TCP_ACCECN_CEB_INIT_OFFSET 0 + +static inline void __tcp_accecn_init_bytes_counters(int *counter_array) +{ + BUILD_BUG_ON(INET_ECN_ECT_1 != 0x1); + BUILD_BUG_ON(INET_ECN_ECT_0 != 0x2); + BUILD_BUG_ON(INET_ECN_CE != 0x3); + + counter_array[INET_ECN_ECT_1 - 1] = 0; + counter_array[INET_ECN_ECT_0 - 1] = 0; + counter_array[INET_ECN_CE - 1] = 0; +} static inline void tcp_accecn_init_counters(struct tcp_sock *tp) { tp->received_ce = 0; tp->received_ce_pending = 0; + __tcp_accecn_init_bytes_counters(tp->received_ecn_bytes); } /* State flags for sacked in struct tcp_skb_cb */ diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f5ceadb43efb..39b20901ac6f 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -5029,6 +5029,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ce); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ce); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rx_opt); @@ -5036,7 +5037,7 @@ static void __init tcp_struct_check(void) /* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 97 + 7); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 109 + 3); /* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 0591c605b57a..c6b1324caab4 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6085,7 +6085,8 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t } /* Updates Accurate ECN received counters from the received IP ECN field */ -void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb) +void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb, + u32 payload_len) { u8 ecnfield = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; u8 is_ce = INET_ECN_is_ce(ecnfield); @@ -6099,6 +6100,9 @@ void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb) /* ACE counter tracks *all* segments including pure ACKs */ tp->received_ce += pcount; tp->received_ce_pending = min(tp->received_ce_pending + pcount, 0xfU); + + if (payload_len > 0) + tp->received_ecn_bytes[ecnfield - 1] += payload_len; } } @@ -6360,7 +6364,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) tp->rcv_nxt == tp->rcv_wup) flag |= __tcp_replace_ts_recent(tp, tstamp_delta); - tcp_ecn_received_counters(sk, skb); + tcp_ecn_received_counters(sk, skb, 0); /* We know that such packets are checksummed * on entry. @@ -6405,7 +6409,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) /* Bulk data transfer: receiver */ skb_dst_drop(skb); __skb_pull(skb, tcp_header_len); - tcp_ecn_received_counters(sk, skb); + tcp_ecn_received_counters(sk, skb, len - tcp_header_len); eaten = tcp_queue_rcv(sk, skb, &fragstolen); tcp_event_data_recv(sk, skb); @@ -6453,7 +6457,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) tcp_accecn_third_ack(sk, skb, tp->syn_ect_snt); tcp_fast_path_on(tp); } - tcp_ecn_received_counters(sk, skb); + tcp_ecn_received_counters(sk, skb, len - th->doff * 4); reason = tcp_ack(sk, skb, FLAG_SLOWPATH | FLAG_UPDATE_TS_RECENT); if ((int)reason < 0) { diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 81d42942c335..ad9ac8e2bfd4 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -486,10 +486,11 @@ static void tcp_ecn_openreq_child(struct sock *sk, struct tcp_sock *tp = tcp_sk(sk); if (treq->accecn_ok) { + const struct tcphdr *th = (const struct tcphdr *)skb->data; tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); tp->syn_ect_snt = treq->syn_ect_snt; tcp_accecn_third_ack(sk, skb, treq->syn_ect_snt); - tcp_ecn_received_counters(sk, skb); + tcp_ecn_received_counters(sk, skb, skb->len - th->doff * 4); } else { tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ? TCP_ECN_MODE_RFC3168 : From patchwork Tue Oct 15 10:29:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836079 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2066.outbound.protection.outlook.com [40.107.22.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 809511E885A for ; Tue, 15 Oct 2024 10:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988230; cv=fail; b=Ev38wE5ZRAaMv8vUfycdPxPIwYKj7tzYebioDrUTtqkxCcOPfjSTzZMZcmgZ9JRYt1+8VHDMc8tYERk5ut6dUFZ02Oxh2K1906lA9cd4bAl0/2ar5P7QQd6NatP5KvVjWHbmrOw4mG+U0uaqrp7tQcJvstRL6blCBEj+gfeGbvI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988230; c=relaxed/simple; bh=jfp/lpTJreumgN0cdPxbzSLdKDeZv/kwkFPOIwuOVxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=o8dtBW5B/74Ole5n3CSIpECALYJ9zlJCNggE5Y3ibv/Zs4QkhJnpYAxDtKyFa5K9l2OZdufKhev+i08A5fQrZDrqd3v/6NVSIPazpUNsmDyjOxA/ffMDtgI3WpguCJZzgbylOOYRDNtbS49zZgmDWPehjTZD31YpzS38q6gpTwA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=h3wSWF/Z; arc=fail smtp.client-ip=40.107.22.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="h3wSWF/Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=clcm0PfYvhqVbos1tMHN98UJOur1OWAzNKZPWa986slrhjDVkPyXP8pKwqNHPqAx9+fhAPvKWsDs+4Gf2sYWdTO5HcY/yb7Aw6nlLBn58MsTM1twiRalImP7I9SxLpLgz1v9FKNqaGfiI4mvem44JJEKXpVuW+BrgNYn5ANKwJzkEcX+2+s8gcsOxI6q7GrlvbAhxjrWdqVLN4aQXlW1M26QXfMcZzAGDtUUQ/jPkPJSGXIQrPlWg+T1ojA6mFgpnwxWz5LYbDVy3NdwT1+XnlQNQlaWdZefYgMVCruw3+4ozYEek/oc5svzxkhvwU6THY968hyhOEH3BmUsh80dkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pMJCZI5dKZUMAGkrvczb/vE8fOfOk2YoOdm8k1fKtfM=; b=yFBN4CLdglGNsfnd1IALx63iV4RChg8wL9QdXc0E1AS69kxiBweHJCr2pDn7nWRIikXla830sBp+s0Ij0KeQpfoVw8UsZUPKAOFdkCupyJz2m4g+o9nswHr9u0XsiHWynVA58h4LYEWJz55KP+Pnjc7T+TOxzXV5kiawX1FK6R/7wuHnE7bTYhATF+fptYGn+UBIROQVQRz8i+09GxAbsCiqZ+kQ7jymFx6QBnijnBeCvkdO1dZpX+ttuuQIU2BiuQfb/Hfdooa55FRzgtMdHJ2Gxp1zB2XpZadm07EaUk3W0X3bq6zbx/nfg12OHr5OrElJkhxkzM0KhhNK+ToI7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pMJCZI5dKZUMAGkrvczb/vE8fOfOk2YoOdm8k1fKtfM=; b=h3wSWF/Zllz+FSP/4BtCXqXq6fT5MVpzEM3nxgWmG+px/czifl9iQ126NbG9k7iE4qJC1lD4LBNZ8itJYV2JHK2/CyVKhf+T4BG9dga3qot6rYXJrWTicbepzvZa1YDbU6d07X5Q1nASID0T17lsWAqes6HemjbK40SlaOl8ocjbSUHBK75LlQyXEca8RYX0SmcDb/Ccp1GKlUyf2cl6MawhpMKzX30nEkbYYd7jMKR/3a2v6pvMBM4s2fybX8UIDS47YIh23pB8oYpukOlFoFiAljKTbduPzoSHirSz+2S5PIA+i9GrEP72aNrJ2DQoWgTOo9W5O5QoEgvAFGutKA== Received: from DUZPR01CA0306.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::16) by DB9PR07MB8026.eurprd07.prod.outlook.com (2603:10a6:10:2ae::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:24 +0000 Received: from DU2PEPF0001E9C5.eurprd03.prod.outlook.com (2603:10a6:10:4b7:cafe::f2) by DUZPR01CA0306.outlook.office365.com (2603:10a6:10:4b7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF0001E9C5.mail.protection.outlook.com (10.167.8.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:23 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnN029578; Tue, 15 Oct 2024 10:30:22 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 19/44] tcp: allow embedding leftover into option padding Date: Tue, 15 Oct 2024 12:29:15 +0200 Message-Id: <20241015102940.26157-20-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C5:EE_|DB9PR07MB8026:EE_ X-MS-Office365-Filtering-Correlation-Id: de79cb3c-6564-4e80-0771-08dced0460d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024|7416014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?PN+S+atX41l6YSUjByijetbB2bOLbmF?= =?utf-8?q?N3TBYeUqnFKrnULkW4bKW23/jqddoJssEyJP6BFvobrJbFAjmgq+nrJc/5IybXIAy?= =?utf-8?q?+EU1nhl5t9qIZWk3T1LlQlWOU+5+l0f5t7WzkofHjaD/NP3/C1+q3Jn/0wygjUDgy?= =?utf-8?q?jiv5P96/b0k8m+dJjSWwgAkWkq6Cd4P9oB/joQfna+Cz2OrvS/RgmdyQe1QQvH3vT?= =?utf-8?q?O5+Si3AujrZN4KCHaMWq7eL/+e5Vp7UXmac90AtTyiEK+jlB7E40mhyt5eAJxyNKI?= =?utf-8?q?WyQp7DpTz9sxFimvna+S7Vpe492Z/TK08hE0F9iAJcLerliLUg3hfibcYtjHOGmbA?= =?utf-8?q?2TwQthAs/0HFwQwTkb/WUTU7qjo+Hr+p6GZj/KYEKQrfDY4mP80eRotJQ9y71Hzbs?= =?utf-8?q?wMT6qyhmx6cT5dWXD1sJqNOnJMm3LRjlIZp0JyxtL7nxIIOlzPRWmqGGP+5Jzcq7g?= =?utf-8?q?BsteBiMaJYtszMc914ShivQpoMFj0yMbEtfA8uOWTHG/f3jGTX1RWnzIPLC9m/Q09?= =?utf-8?q?bNxQiyB+Cndm/Wba3TJLSnAfTByvxqHJ791swS5CPPwW5iF2GSmqusAIA60NdeA8j?= =?utf-8?q?ALugHHc8Qz5yc5HtBARsEsqI1IDIsAXE8wFCXAtYN25wWLWO6VFB87wPFYtDZ7ETo?= =?utf-8?q?dt7oMjSmF66bHL1KAWJ/imZ2pHZEI2nLrcABnfskcuMnfYBhBMqs6U/GsSXXK+9+U?= =?utf-8?q?oFTj106id2TmKD231h3llPyYCB81TGw70Uvfy+djNEVLcneRl2g/r1e4rmPWRU5K4?= =?utf-8?q?2MU3yLOnW9N3xWnLRQ2aPf5HSlij1Yh4BF6DFzo4SK/a6f/1jkvh0JqiYgegH4UTy?= =?utf-8?q?xZ4JwNfQFYA76CJkT5tYrL8SPJwXtCOTH7C0D2tqcF0MQWpk12wOPJuDdUNgsbiTq?= =?utf-8?q?md914Mhl9Jfh55LrtYPArsZprdIG7zGGt6Vml0xFX9V1Tc0BGi+TdMoryflZJN8DZ?= =?utf-8?q?0t/M5Q2wgR/YRI3tFGQVQ2puRMpJ0rKKt5rzC+gHF4MTKedePmtMCJVze6On1TUBH?= =?utf-8?q?725HWlgetU0jfQtUVN2m5eDAV8LcVtBboiCf2wKpuwfkEPYPlJpnu4p6/TiidAfNd?= =?utf-8?q?9QV0Kv6L5cZWxfvqv/THB9+gXGQb6YBjMlvysNIL1XTAEUWfrp1jJv6VJpCuwdsUQ?= =?utf-8?q?VoR9WCoq8z47mMmkIaYo24VQtzJQdJ0vdM7/eB7w4Uya6Q/7HNLvRFcoQqaFxqPpn?= =?utf-8?q?ESSJCkIbKdIO6d9cvvdbst0GeFSibjsSRdrR3JWM4x3K+Y+j/lKf0e7WCwTw2EzR3?= =?utf-8?q?Gb4bd9bnK3vtD+tTuQtkoD9VIroy/aQjrzg6HphcHLuM7UQr18kNqxR3rJYwTvUXa?= =?utf-8?q?ba16zbTrphjC?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:23.8078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de79cb3c-6564-4e80-0771-08dced0460d2 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB8026 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen There is some waste space in the option usage due to padding of 32-bit fields. AccECN option can take advantage of those few bytes as its tail is often consuming just a few odd bytes. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_output.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index ebda1b71d489..becaf0e2ffce 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -703,6 +703,8 @@ static __be32 *process_tcp_ao_options(struct tcp_sock *tp, return ptr; } +#define NOP_LEFTOVER ((TCPOPT_NOP << 8) | TCPOPT_NOP) + /* Write previously computed TCP options to the packet. * * Beware: Something in the Internet is very sensitive to the ordering of @@ -722,7 +724,9 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, struct tcp_key *key) { __be32 *ptr = (__be32 *)(th + 1); + u16 leftover_bytes = NOP_LEFTOVER; /* replace next NOPs if avail */ u16 options = opts->options; /* mungable copy */ + int leftover_size = 2; if (tcp_key_is_md5(key)) { *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | @@ -757,17 +761,22 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, } if (unlikely(OPTION_SACK_ADVERTISE & options)) { - *ptr++ = htonl((TCPOPT_NOP << 24) | - (TCPOPT_NOP << 16) | + *ptr++ = htonl((leftover_bytes << 16) | (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM); + leftover_bytes = NOP_LEFTOVER; } if (unlikely(OPTION_WSCALE & options)) { - *ptr++ = htonl((TCPOPT_NOP << 24) | + u8 highbyte = TCPOPT_NOP; + + if (unlikely(leftover_size == 1)) + highbyte = leftover_bytes >> 8; + *ptr++ = htonl((highbyte << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | opts->ws); + leftover_bytes = NOP_LEFTOVER; } if (unlikely(opts->num_sack_blocks)) { @@ -775,8 +784,7 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, tp->duplicate_sack : tp->selective_acks; int this_sack; - *ptr++ = htonl((TCPOPT_NOP << 24) | - (TCPOPT_NOP << 16) | + *ptr++ = htonl((leftover_bytes << 16) | (TCPOPT_SACK << 8) | (TCPOLEN_SACK_BASE + (opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK))); @@ -788,6 +796,10 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, } tp->rx_opt.dsack = 0; + } else if (unlikely(leftover_bytes != NOP_LEFTOVER)) { + *ptr++ = htonl((leftover_bytes << 16) | + (TCPOPT_NOP << 8) | + TCPOPT_NOP); } if (unlikely(OPTION_FAST_OPEN_COOKIE & options)) { From patchwork Tue Oct 15 10:29:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836087 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2065.outbound.protection.outlook.com [40.107.20.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 713891EF096 for ; Tue, 15 Oct 2024 10:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; cv=fail; b=JVzGSH5Q3hKSu7QlUsZ+qhvzzsMO8ciZyxPnjr7wzMcdIMZdJJL76AeVkgUBlpltXc/z2Aw/7XApcstx3SHKYeTeYcVxiW8jpeBZe9+dCR7FUxo4i42kEocSyPGYsHwe3eCiBEYECCtVmWyj0Si9DXhe/75jc1eTgrY6q9Y9Jtg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; c=relaxed/simple; bh=oSrZ25P4rMvYCO7G+mJ23xPkNYveZyjFXhIjL8qcYfw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=UGsJBfwXbPkD5nucAs2lp0NuH1plYpfaCtMjYU8pr4fQ+nSyBrH55Dz2yf7Ymn15S5axFLkbzQ5p04soDia4SSKvwsZEvFKsif4JN4sxvTTJ+sB3KBlbGr7E7UQ/bspLzV7+ivWQlQPWVy9r+o9pWokXR0m+dQma2VoFhV7Z8AA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=tH1FquCx; arc=fail smtp.client-ip=40.107.20.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="tH1FquCx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OWMhTJ1dIIzK3rz9CAissBBCUF/EybhxX5UY8zQVVmelzsNBiY/BNGkcFL9FkaYR4XqS3w6LMPd89GCrUy6w+GpWlLVEs7kbhPNBJ3mvf0nTt2l3zMQAHpV4oRaBenmN45qo/cOxJVjeEiVgY86pYF2De1IuGz+t/WHf/NsGvR1pXAvZkOEHKehRp0PMu+ZbVMJnF97TKfTnWfuva90C0nFroao3gz0wfLCJT1iYxZiCRx5p6UjxCTLimY1/Kpx8CpwJ8gVcNRlr44vINJ8Zmril8Ln8uCFmvsxlpFHw9ScpeXI8kh0YljyRs1PvpTF5FTCIz84BxAYUzV2I4Kckbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Lka/rWekSVA05v97HPwWmAH4utvYvC99HyKhOLrMgfk=; b=bLC8pp8G/j0K/vNMfbUg8Gmx7mPbfh8uo86Je3/4NUUfVv3vodc2aPFH69lXAapKyMJ2KA1Nz0dqBGXWYTgMbh+YtzouzxOYqOocR+VUTnIVd+kNaOSueenmKMQsdgCA2FzFNGRFBqfDlSjpM3j/0rRL5/lNHmgMxbMIAiTEHkXOYfSaLFuBBX+xyUZyOfZvOfbihpT7ZqfA26LPR3189pdvfAC/+pO2VWcvQ+sq6fKHg1QcmG4O42v9xFScCXlFxpLWXgMZVE0gQhkBvB7M2vwuGJ/ss4IaRdn0IBGaCpNwVs0mwotR3tWthBD6tjS5CxwT/wwbWGTBpNGZQu91kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=temperror action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Lka/rWekSVA05v97HPwWmAH4utvYvC99HyKhOLrMgfk=; b=tH1FquCxiLBk+AXpDFpNgUJMbOm6ReTG8DxbWpQaZaGI9LF8VEqpljNzMnejjhl9lBRjC5NCehOJmuN9t0r3JB+pfq+7DTDZtyzqXWVQhsxcIXMdivA+XFcES0qW4RsTKmho0JAw3Icqs/0LmQZ3oZe73/mz/BsRBH1EKOhViglun8XPyeceLcoGaHNXFhkhUhAFI7vhsSdYZqeL4ewxpxTdJ9ttptNqblSPMsjSFPnhXV/4UCw9sUyW42IRZg8zlBQ0KoC7oGzXFmhynsly4I4GAVeKrj9qNJ+H8YAEA8cV1mMXNaydK+E0D1yJjrqHx3e4xkK6w5XeqLZtmOjdJQ== Received: from DU6P191CA0016.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:540::10) by AS8PR07MB9473.eurprd07.prod.outlook.com (2603:10a6:20b:631::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:25 +0000 Received: from DU2PEPF0001E9BF.eurprd03.prod.outlook.com (2603:10a6:10:540::4) by DU6P191CA0016.outlook.office365.com (2603:10a6:10:540::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:25 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nokia-bell-labs.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nokia-bell-labs.com: DNS Timeout) Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF0001E9BF.mail.protection.outlook.com (10.167.8.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:24 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnO029578; Tue, 15 Oct 2024 10:30:23 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 20/44] tcp: accecn: AccECN needs to know delivered bytes Date: Tue, 15 Oct 2024 12:29:16 +0200 Message-Id: <20241015102940.26157-21-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9BF:EE_|AS8PR07MB9473:EE_ X-MS-Office365-Filtering-Correlation-Id: 113c7c30-361d-40a5-b400-08dced046119 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|36860700013|376014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?G23geMXquWfbJj2xOEnBOQiC7Ouu+54?= =?utf-8?q?UbKs2Y33FpQHEZ5eZSjiLBnL4Oy10KPE1jN4UqIvK0NeL4up6/NuRNLXIoyIY9POQ?= =?utf-8?q?zidlIryHz12UVwWqqTILcnfQZreZ5z5AFfaa1Jwy+gUtIZXiRfywKp2SjQScGDEfI?= =?utf-8?q?ALVDgbPG6IbLdilvhskCVgrBDgY9aMbgA/sylBDNFR6y33JIr6xdfs6qK83eYzVLk?= =?utf-8?q?KcEkiks9E0mwB408y1XkrHEV+pQ7+pKFiRufwCHkkvfYqWxAU2ohNML1vXjfgINvj?= =?utf-8?q?ZLnumgs2TPULNSNt57cnHKlJrYAhpTv4nPLV+bwvZhm0Nn38fBKMRnvpxfc8Cg1Bt?= =?utf-8?q?gwPkVxddOVBF+SCB0IUnhu60APcfYDRcRDuUN9l9INnX5FW52UAcmbFsMKH1S2AlD?= =?utf-8?q?Emf8JSxYN5O2ud7IcBClTuUUTNK67W68l4xRr3S3CgCZUkHxqb+vdjTCkA5Oz0IUh?= =?utf-8?q?vX9/esXFvVdaMIb7AMAzWiUukfxwqPX+UOgWuyRBSPxNwYwQ03ypNdbjk4tvPfLJ6?= =?utf-8?q?jvrq/fwGLHnLqYJQLqBlpqQFzKOF3DNfdEuscwJDtNcN1AN+/+Z92ZXtv9NXApJJH?= =?utf-8?q?FukCUJtPKODl8vIT+q7zpMab4Mtdx+LQWDc99KviMR47Lql8SbXJTam49Req0DgLG?= =?utf-8?q?YaJcFL+2xxUBqxk2InAH9QQYCuoNyZytBiOOMWG2Ct++siZwpaW1/9RFyOGr4eNI5?= =?utf-8?q?yrx57loHIoyIHdLkr2KZ03fNWFxeNoYuTeh3aAlkGwL1sJL0fmhk2BSFhNeb7xcjg?= =?utf-8?q?RYcrVhebaCAl50cNVXz7Yfey/GM1aNvX3qUSzA39lTfnvLpoSGPA0/EznnaojVE6B?= =?utf-8?q?9I90eOE76Ll7F2bQQnT+bRQRXhZ/vYm+mE5szt4LqObkDRq5+kZ9q5W8apBSg3fY3?= =?utf-8?q?j+o6cFW2MN7/MUCHzaSM3dfJIvTCo1sU47yjg6e8XRtUCDfvQq3Re88PvoSKPXLnX?= =?utf-8?q?sXZ4lx9mY3wYjw3iCG7/IcRnOaZZNFZ572Mm8iXOAVSsPUY+Z/kleneJX9II5/5aX?= =?utf-8?q?+4Kpd8exZeLGbnUj6ReM812H2FZ23v0li+s2E/rgcOe5gyzEphYkGePhQdWrX2jUk?= =?utf-8?q?v7Df61lOMuutIlBVsI+5gKklUh7bn+qH6z3Acig+QLegtNF6MbUqgZjz2vTbXKwwu?= =?utf-8?q?7o2pUihdDYIYIPjay1x8eYH0f5m9BPb4epr72UnS4mx7w3sK6YLGhe4Er1pFZkGKB?= =?utf-8?q?DJz8WxqEXjHhZmaldUApRFA0O8aQd3KBbSf6JFtsBBpgnxRjMUJqFt4N2WqVCvTZ4?= =?utf-8?q?36+QtOUlcYyfRNwsp7n/SYA9VrHW3l0xU+/qRYgaOFnMS3flXALxxLNnUtthHUEER?= =?utf-8?q?MpE29irROCKG?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(36860700013)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:24.2775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 113c7c30-361d-40a5-b400-08dced046119 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9BF.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB9473 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen AccECN byte counter estimation requires delivered bytes which can be calculated while processing SACK blocks and cumulative ACK. The delivered bytes will be used to estimate the byte counters between AccECN option (on ACKs w/o the option). Non-SACK calculation is quite annoying, inaccurate, and likely bogus. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index c6b1324caab4..f70b65034e45 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -1159,6 +1159,7 @@ struct tcp_sacktag_state { u64 last_sackt; u32 reord; u32 sack_delivered; + u32 delivered_bytes; int flag; unsigned int mss_now; struct rate_sample *rate; @@ -1520,7 +1521,7 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, static u8 tcp_sacktag_one(struct sock *sk, struct tcp_sacktag_state *state, u8 sacked, u32 start_seq, u32 end_seq, - int dup_sack, int pcount, + int dup_sack, int pcount, u32 plen, u64 xmit_time) { struct tcp_sock *tp = tcp_sk(sk); @@ -1580,6 +1581,7 @@ static u8 tcp_sacktag_one(struct sock *sk, tp->sacked_out += pcount; /* Out-of-order packets delivered */ state->sack_delivered += pcount; + state->delivered_bytes += plen; /* Lost marker hint past SACKed? Tweak RFC3517 cnt */ if (tp->lost_skb_hint && @@ -1621,7 +1623,7 @@ static bool tcp_shifted_skb(struct sock *sk, struct sk_buff *prev, * tcp_highest_sack_seq() when skb is highest_sack. */ tcp_sacktag_one(sk, state, TCP_SKB_CB(skb)->sacked, - start_seq, end_seq, dup_sack, pcount, + start_seq, end_seq, dup_sack, pcount, skb->len, tcp_skb_timestamp_us(skb)); tcp_rate_skb_delivered(sk, skb, state->rate); @@ -1913,6 +1915,7 @@ static struct sk_buff *tcp_sacktag_walk(struct sk_buff *skb, struct sock *sk, TCP_SKB_CB(skb)->end_seq, dup_sack, tcp_skb_pcount(skb), + skb->len, tcp_skb_timestamp_us(skb)); tcp_rate_skb_delivered(sk, skb, state->rate); if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED) @@ -3529,6 +3532,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, const struct sk_buff *ack_skb, if (sacked & TCPCB_SACKED_ACKED) { tp->sacked_out -= acked_pcount; + /* snd_una delta covers these skbs */ + sack->delivered_bytes -= skb->len; } else if (tcp_is_sack(tp)) { tcp_count_delivered(tp, acked_pcount, ece_ack); if (!tcp_skb_spurious_retrans(tp, skb)) @@ -3632,6 +3637,10 @@ static int tcp_clean_rtx_queue(struct sock *sk, const struct sk_buff *ack_skb, delta = prior_sacked - tp->sacked_out; tp->lost_cnt_hint -= min(tp->lost_cnt_hint, delta); } + + sack->delivered_bytes = (skb ? + TCP_SKB_CB(skb)->seq : tp->snd_una) - + prior_snd_una; } else if (skb && rtt_update && sack_rtt_us >= 0 && sack_rtt_us > tcp_stamp_us_delta(tp->tcp_mstamp, tcp_skb_timestamp_us(skb))) { @@ -4085,6 +4094,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) sack_state.first_sackt = 0; sack_state.rate = &rs; sack_state.sack_delivered = 0; + sack_state.delivered_bytes = 0; /* We very likely will need to access rtx queue. */ prefetch(sk->tcp_rtx_queue.rb_node); From patchwork Tue Oct 15 10:29:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836084 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2066.outbound.protection.outlook.com [40.107.105.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F4CC1EC012 for ; Tue, 15 Oct 2024 10:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988233; cv=fail; b=qgfHn+K3iigKYIqrDPvKvWWbUPYEYKa7rcqnVsOTs8N83kWa6Qe0yp/05O4+rfR1WfjluxIHRZ+TJ/9BPVYaeUe7nijIiqeQvY0QCDWnLkGgEx8rC914CMcXEg0PWD2PKfLcQmFarT6TFdH3t4ccJITQD2K0sLRrIX5K5xkRmwE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988233; c=relaxed/simple; bh=0iqVpC3ix4wcVnQolShz1trtufb10W3igQoHnnx0u84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=dNlZYzi/8R0yCUBoO7NlcqQXxejFF15zY8UhAQ1B/SW2jcIIzm/nfZxnbrnARmTK9zsngOtCS432NXgy5jiWSLGPTXLDeX8djjrYikUPIT7//ezTaIKTfr77YTyc8BiiL0X+JJ6VpHAJu73nK5l3ukMK051nbA6z5oGLJF+Q33E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=D3PAndfs; arc=fail smtp.client-ip=40.107.105.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="D3PAndfs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QGmNcAazK6Z/jkpaREyYFrpTkIGal0C1G1wzmFjOjtAy3wN76SsKPT8B8tR3LnjwT0ao7vPxzW7MXUh2POlsU7rpo+Nxx+0u4if1cszVd96y1t3LiMqnHyuO0mFuIJ3RcfCuLgAEA+vVjILmUWCKwGRsQOcLzsaOqJ/eY0UCgmHLbHrNNZw/0PFGqJCU+Dm8L5dXw774WrDMA+2SKmERErex46pxLrhXFwHAc/5JGyY6RTV4Gwacv0gUkle9uP+SjQeTK9iwAbLwga21/utWbn0dKic5Yg4cDzmhcCoD6Z/tp21kttBqDRNRF/RzLmJy7csz3HOAt6Wx3HpUgAirNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2h+tkf60b8yXMyLY4Z8aLYinxoPsag9gw40RsoQrVdA=; b=EJ9L4pydbkwmyd8WEi2ykOSemJl3htybJPs3cR2AQjnTVc9HSPNnyGZ5bhZVFwthpDTr5LavJTayiTXtWCtta2QTvTk1AH1LYBUMaLCzLMMdq23s5Fp1Tmjf/Nd0+ZsII66Cczu4gKCYvxN4QHUpCNn6VnaEQK9LFy3tM6Pn8XMbkn2iajnrRrM5uaiFiAzFKsEa6SQOggVWyzne1I6K50j1zACMxdV/d2jElYUb4NmxjZ9WM0vPKcE+Vd18u31WZ9LP0aslG58RjK3pNvJWn0sulCx7pAb1LKHsRYY+WIuyvSnNYSDBicUmdPIt4GgKKsF8v2mKtnbypDyvwVTRSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=temperror action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2h+tkf60b8yXMyLY4Z8aLYinxoPsag9gw40RsoQrVdA=; b=D3PAndfsAIE+CvRtsqR1vWikkCJmYmQj0+xKXzfFyR+XUydEFg2SK3O+m3QcbQapviU1jsW8KZJ6Uoli5t6HU+B+RsUm3uA/imVozyUfcdCVPemu3EYoBcKo3ieFERk6DULjTdvsaR6LTrNHchu3v3kAB1eUhYxg2c2QNG4grbkWbqMHgxCvRqkey08Y0mQbqingbhk9HoQaQqVqns1cmiLNMKDVwHpLfRv24z1iZuFCfdBiJQYcyc6B4poWX8s3LTaZ2bYb+YJdFOfRyR79OPhf2+/1i4Clds32IExrO41eog8pWneQe0Pesyknj/MfvvIBBkvXtxR+JVoYY9Izqw== Received: from DU7P250CA0014.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::8) by AS8PR07MB7589.eurprd07.prod.outlook.com (2603:10a6:20b:2af::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:27 +0000 Received: from DB5PEPF00014B94.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::2d) by DU7P250CA0014.outlook.office365.com (2603:10a6:10:54f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26 via Frontend Transport; Tue, 15 Oct 2024 10:30:26 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nokia-bell-labs.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nokia-bell-labs.com: DNS Timeout) Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB5PEPF00014B94.mail.protection.outlook.com (10.167.8.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:25 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnP029578; Tue, 15 Oct 2024 10:30:23 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 21/44] tcp: sack option handling improvements Date: Tue, 15 Oct 2024 12:29:17 +0200 Message-Id: <20241015102940.26157-22-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B94:EE_|AS8PR07MB7589:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ed5a913-8636-4213-3109-08dced046196 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?txlS/UKXQrBZimojZqmVxzcnOe20GTY?= =?utf-8?q?aRUqmHzLUlAQVK/xqzLeloqGp9Hke7bZX8A2hWnS6cKf7E25eeTx1ObvxNuOCP8Sb?= =?utf-8?q?tb3LLkBuxTq7uo28zGRgf7DC5bUrO071/sst3JanxLnNErVyqcFrqQz8ixRO/vk1I?= =?utf-8?q?OQkcCd5adn1RVMAOKhGShUmx2F5zQfdUPr0CKVoVF/M37r4pw0I4yJNVK0nZzeQHB?= =?utf-8?q?kEnu/4it5EWfQp5Jcym6vuH8MTW6I7up5YO/+uQNaKCSqYvVJtxZ1LA2kymCntm3m?= =?utf-8?q?UbyMnxNM3CUSUCKj99vs0yxJ7p0eGeOqU8b1ZUp/Pi/M0hxRdPOj18KU1S7gCdKQs?= =?utf-8?q?ZodIwe//HZD3fvpkvmfL8BgTVj0rZBptBiSvlbVvcQo6LM03Th7eM3qUHREx8T/6I?= =?utf-8?q?GlZJx7AogB31FqPdqaPsWXfRQHkgim1weBMyknnJwEDtJRE7a2kBjHsC9Aziwj2Ik?= =?utf-8?q?RRnJdy4SF7/4ZgMxYesStWubupH2yj1fddepLmcpMVgryNrM/RAVe7viBsdxRpotw?= =?utf-8?q?PJcLLuShSjPuvWfhPLV+x++fLOSzRhVH++KjDPQqCCqOebHNXIBBgSJQRS4+j79DC?= =?utf-8?q?LWgeff4OT+LbhxO7DjPDkYaOLLatUSR+hESvM0UXF4AWqnWoetQc5ML4Vsx8wxGyq?= =?utf-8?q?aUuekayZCJF0ulwCjofcWNwrLoyWMlASpDppi1K125iqi05AaJy5sjpqr+qilUfTz?= =?utf-8?q?3A/MsTwnTnJz2j/C02toY4CXLcWU3QnFwrxr27IU2XiMaZbKLp44Gr+rcldEKv68A?= =?utf-8?q?fPkrxw3uYXA7+K35y1OHMGNltcgG5lz0ymwVmrr4oz5IoYoRXUD/ccnZaby3eRFQX?= =?utf-8?q?7OWCOPZx1IDu5XKp3++BHjC0vEKclnerGT5RaAV90aF6W6lgzd1vcB9ieYKQdEYTM?= =?utf-8?q?sAILz8xYJwTyDNHi9MpYErIlaj90HoJqMLQnA+KA8OhpYcfYHy40zR4bswBlkvuEt?= =?utf-8?q?HTd981wg9vc6OesLfagkFT1tlX2TSDKWxHcX2zTNgJOZ7S6U9Yk7VYr2esAFSvoWJ?= =?utf-8?q?hCV5QJDWzh3UuYqSnT3fz3lfuEOTWP4k5AtCThyvXs10tfDyF1eqQ/tESZ9OxPkHK?= =?utf-8?q?gc58iCVpwVK/nauzeYUqdqePSVPkb+72sTqbbd21qM/2Hlae5u2lGTgcZtkm1HnJC?= =?utf-8?q?sfQTVhD4lSw5okc1Nd3OG+ml9aCO08PwyHz1knCMu4DRuopi6MLqj6/WapknpetKP?= =?utf-8?q?0ogIVq5oUoNSV3+IiZbRbSsbzQgBdOL6ux7g8Jf9CsNgfU/5t+8Xkyvco+/NkfN0D?= =?utf-8?q?M83XaA1mYRXO1fqy26UMiiHoj0eq9rwM8lJvkgBYf8nXF1nQIt2sEyU7pBPwio8ss?= =?utf-8?q?Mb4VqJCmXJ/T?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:25.0934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ed5a913-8636-4213-3109-08dced046196 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B94.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7589 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen 1) Don't early return when sack doesn't fit. AccECN code will be placed after this fragment so no early returns please. 2) Make sure opts->num_sack_blocks is not left undefined. E.g., tcp_current_mss() does not memset its opts struct to zero. AccECN code checks if SACK option is present and may even alter it to make room for AccECN option when many SACK blocks are present. Thus, num_sack_blocks needs to be always valid. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_output.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index becaf0e2ffce..d6f16c82eb1b 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1089,17 +1089,18 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack; if (unlikely(eff_sacks)) { const unsigned int remaining = MAX_TCP_OPTION_SPACE - size; - if (unlikely(remaining < TCPOLEN_SACK_BASE_ALIGNED + - TCPOLEN_SACK_PERBLOCK)) - return size; - - opts->num_sack_blocks = - min_t(unsigned int, eff_sacks, - (remaining - TCPOLEN_SACK_BASE_ALIGNED) / - TCPOLEN_SACK_PERBLOCK); - - size += TCPOLEN_SACK_BASE_ALIGNED + - opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK; + if (likely(remaining >= TCPOLEN_SACK_BASE_ALIGNED + + TCPOLEN_SACK_PERBLOCK)) { + opts->num_sack_blocks = + min_t(unsigned int, eff_sacks, + (remaining - TCPOLEN_SACK_BASE_ALIGNED) / + TCPOLEN_SACK_PERBLOCK); + + size += TCPOLEN_SACK_BASE_ALIGNED + + opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK; + } + } else { + opts->num_sack_blocks = 0; } if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp, From patchwork Tue Oct 15 10:29:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836091 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2081.outbound.protection.outlook.com [40.107.20.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E4F1EF09F for ; Tue, 15 Oct 2024 10:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988235; cv=fail; b=cjKF1ammy4LsS24CggdzTeUDZjYG+2RuxfEgF0qbPwXCpryVnzodVrgNNC4QTXGjZj3ywIB03qd+IWSM1bIhBZjAQdiuVVn3uqcLsPQYXUCuBpxdvbi2CRWuPMMTjYjM3mNCA2djWNieGVk52jCmmSFH+Wel9BCb8Y8MIeL3Kts= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988235; c=relaxed/simple; bh=/E5X7eKpxyZ2u6t5vXDxj0fCZgeRWOkIJKQTxIIqZ4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=E2TluomBrmQyH5+fDGGWSod/OyhFdZT7yR3aeHAqeXTbC79lLBACKDnh6fEc88ihYgXMPw7UCJR10iQLUVUxCyDaLhvNl+JdJksjmySULsNYPNQfKJv86rtHDICZj+D8OWDb6Ut9uzCBcfutmoCP8Q6b8O0hCcb0TraHfqA+CLk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=PwGZpwkI; arc=fail smtp.client-ip=40.107.20.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="PwGZpwkI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AxJmA4e6tmchPmKqDAKSkI+IrVjuhq3pKP8H41ZoqFzDPnU0lBvwHQX8s4DkU4c+gmDHh+coV3UqEaCXBpevWAaXNWFuExrRaVO3fii78wgP1KKToJ+Z4ePR2ZwIRRYs1vecv7a5ESrqnbcA72djBRXtV8etEAnJkQQzAmOonLwmiBE96rG23nqxgJxaOnhQ+5g5CyVUd+xSXlsZaXQ/Y0KbdCK7JMPq+LNG8NNxbYpuo7lhtPaJFSPq0PuedZI81agf3LreMbu/ynCd2Rz8kw/fCcauSq1h2DYptmEC+sV8bOhYV24Q38ErlSj9UmUHVVgjyGBiyU7Ix1aAaiB5ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XbCYkkENBRLWyMQxpaW+oCGGmi3pleFCFalw1IPu0N0=; b=ea8x58eVhlgr17RfvlySHbLXhYQvLy0e9T9HzDOdB8+mpFDCYQ5SVGr4yiYu5Sm5aCf3gTuokUFrcgEeGcAk/e+K0M9FBt4jlWn9wDy7HXi+8+ideDT5Gq/X368RpY1vMbVgYz39u2RFLlVOShi5dSyVaVMe5DTbVZ6vqTm4eU3k6zTbWR0m+fCDvB2IN+Rj5C1gvwY/3AFHyxQD96e2q7RMAWKd5kbHbuKyJC+CsJVZ+T8JoFVfkkRxNHMnMD8wfVrqCTgKXAVmbhfsvMX+nsxwpKUX15zWkLY7i8AlAUfzl2XRRTIWibTC0bDhtzXwM1a9yraUshY7GO2uS5nA8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XbCYkkENBRLWyMQxpaW+oCGGmi3pleFCFalw1IPu0N0=; b=PwGZpwkIxhqzcA9yBUHFiWZKw2bb4LZ/DCZ7oEP1UhPkpneajzaF3ty/v+R1qhUchYNMhwIvWMerNq1Fpn62PlG+EJTjJv38EHi/taFz58gNWA8uxuKFiaWEFb01iVfPuqZ8gU3s34o+LCQCcy64PwmoeufZlNGKxEL+eTSFUmU2hLH69PGeFvQOyHVH1EhoDdGajLptlEIKHxZBUjhLUAAt8Ur+I4DeFZKF75rZfI1BdV7R2p+/gLd3GX2JCoaLD3q/HFW7pKUx+7rALNbFVjfMGUnf/vzBau3jgrbCGSf6OeyB0TnoJuzRjXkCvsREnvmaAeDbH/a+yXVmpD7isQ== Received: from DUZPR01CA0292.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::14) by AM7PR07MB6439.eurprd07.prod.outlook.com (2603:10a6:20b:13d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:25 +0000 Received: from DU2PEPF0001E9C5.eurprd03.prod.outlook.com (2603:10a6:10:4b7:cafe::c) by DUZPR01CA0292.outlook.office365.com (2603:10a6:10:4b7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF0001E9C5.mail.protection.outlook.com (10.167.8.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:25 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnQ029578; Tue, 15 Oct 2024 10:30:24 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 22/44] tcp: accecn: AccECN option Date: Tue, 15 Oct 2024 12:29:18 +0200 Message-Id: <20241015102940.26157-23-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C5:EE_|AM7PR07MB6439:EE_ X-MS-Office365-Filtering-Correlation-Id: c4308f58-52a0-49d0-4a08-08dced0461d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+rR/7wbIGWhHLG3zv7YQOmKMJbg6XUd?= =?utf-8?q?uniSmzWIEx/T5E9ASl0WSY2pIWp3HTuzNBKF12PokDeBDa1//bkpuL19+BIBYKysx?= =?utf-8?q?aa5qbjBIlLRzBVXY0GlbnjaVRM64kxq73zILwDXTID0aVNSZqfX5jt0OxdZNMmZV5?= =?utf-8?q?6xxE2pHJ19rMX21g9gPSJsHV74TJbfinZSZhDyNUJZ6bIChyWwBSx/wbk612mpjq1?= =?utf-8?q?BqVh2ApB0lNU06UsLERGawOXQy9WniwvyedA9uif85W1a+UyL3Dm0XsVj1UmhgCcb?= =?utf-8?q?c9HooIbR5eJZTnJwVSXHf4uVyw9W56ff6iFqCG0pKtKcUjR2BA6pRj3xfQhL8Si9A?= =?utf-8?q?tOQfZX3N4e+RIPWepz8lDUOJB06skANoympefs5NU7hr+/ibmWLrT4zbNztKn0YCc?= =?utf-8?q?YZuYBUOMtaBTzcPYep+0q9kOwEyE6E9V8X8zSUVVEEHR52QMgVmbQrSGNJcx7UHn4?= =?utf-8?q?9qPIrVSFNfo78USbHLdHsBtEcdJgN/Dj3/dwCNpI0mNEuU0kFa4lCwP5NPk5/T4Tc?= =?utf-8?q?AtGe9tJrnFjdYJKqjl6QvIXYBiVLty0hPAxNSug9upq3JP/IVrJh6Xoojdrb9IJwB?= =?utf-8?q?PZewXTjcWaHVYOZdL722Uio6dJEvkCG83LCsBHZ8ek4694tEt0czbWw98PAJJj0Ks?= =?utf-8?q?+FCb1l9nk34yGMRVYu9crV/Ya0vnAj+U4+LjqUJEQYeIcNW/6TCUIVAT3npsWKj0y?= =?utf-8?q?kTeeyrgCW3FNJsrLjDS1UeA6zvf/xj9/Ey5MHECreswwGP1fsxHTRdKcY0XAbvylN?= =?utf-8?q?zUd7A2U7hahqgaz9dPW0TFTlCj6Q92+tH+c9dpD51gY3FqmLeTj89HurxK9SId74l?= =?utf-8?q?SfemysOCPwXxpODiBmMpj1ZwTNdae6ouOaPdOLaL16d7+jraqws7pw2MnIww0rZmn?= =?utf-8?q?O49oh/v6qXXO9bT9OWRRkWP/xYAgTylzGF9m+U07NPvL3+WcUQsSMnCg4mrbP+UWW?= =?utf-8?q?EVWeS+LFu9PswY+ers5orJ8PlB6difIp5HBlB0UqOst9GZFM0jaTq87SUVWYcm6i9?= =?utf-8?q?7yFhEBvjh33nXGOZff2LFz1bSqRdMbqVouFfz+gmSohEqomjKCU6oAFSkRhRJm7BU?= =?utf-8?q?HLrh18tkc/pMCCqdhCVWdMhH/Sdgo/pBvd/HQfE9ls/r0AU3GfUBK6TXeZtuWHADc?= =?utf-8?q?OmuZVqHu5nPOaH0TLS3JLzckznkat8vzFbfaI0rgJ/vxxNrrx9Ifq2jcaAektz6Nm?= =?utf-8?q?8HHx2H0BMWsWAL8j1/pj1sV4jgQO+RBuechv8U3bSMZAzZU7qniqvVY1+FkAIFEga?= =?utf-8?q?dyxiLg/EH+EYoiqF5NBQVgI9Jx3Vp7wqL4GyXL4YWvPPZ5lHUgUS1BooW5uSPbEXn?= =?utf-8?q?9RT5IPt40Si5?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:25.5422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4308f58-52a0-49d0-4a08-08dced0461d8 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR07MB6439 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen The Accurate ECN allows echoing back the sum of bytes for each IP ECN field value in the received packets using AccECN option. This change implements AccECN option tx & rx side processing without option send control related features that are added by a later change. Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt (Some features of the spec will be added in the later changes rather than in this one). A full-length AccECN option is always attempted but if it does not fit, the minimum length is selected based on the counters that have changed since the last update. The AccECN option (with 24-bit fields) often ends in odd sizes so the option write code tries to take advantage of some nop used to pad the other TCP options. The delivered_ecn_bytes pairs with received_ecn_bytes similar to how delivered_ce pairs with received_ce. In contrast to ACE field, however, the option is not always available to update delivered_ecn_bytes. For ACK w/o AccECN option, the delivered bytes calculated based on the cumulative ACK+SACK information are assigned to one of the counters using an estimation heuristic to select the most likely ECN byte counter. Any estimation error is corrected when the next AccECN option arrives. It may occur that the heuristic gets too confused when there are enough different byte counter deltas between ACKs with the AccECN option in which case the heuristic just gives up on updating the counters for a while. tcp_ecn_option sysctl can be used to select option sending mode for AccECN. Signed-off-by: Ilpo Järvinen Signed-off-by: Neal Cardwell Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 8 +- include/net/netns/ipv4.h | 1 + include/net/tcp.h | 13 +++ include/uapi/linux/tcp.h | 7 ++ net/ipv4/sysctl_net_ipv4.c | 9 ++ net/ipv4/tcp.c | 12 ++- net/ipv4/tcp_input.c | 164 +++++++++++++++++++++++++++++++++++-- net/ipv4/tcp_ipv4.c | 1 + net/ipv4/tcp_output.c | 116 ++++++++++++++++++++++++++ 9 files changed, 321 insertions(+), 10 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index aaf84044e127..1d53b184e05e 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -122,8 +122,9 @@ struct tcp_options_received { smc_ok : 1, /* SMC seen on SYN packet */ snd_wscale : 4, /* Window scaling received from sender */ rcv_wscale : 4; /* Window scaling to send to receiver */ - u8 saw_unknown:1, /* Received unknown option */ - unused:7; + u8 accecn:6, /* AccECN index in header, 0=no options */ + saw_unknown:1, /* Received unknown option */ + unused:1; u8 num_sacks; /* Number of SACK blocks */ u16 user_mss; /* mss requested by user in ioctl */ u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ @@ -298,10 +299,13 @@ struct tcp_sock { u32 snd_up; /* Urgent pointer */ u32 delivered; /* Total data packets delivered incl. rexmits */ u32 delivered_ce; /* Like the above but only ECE marked packets */ + u32 delivered_ecn_bytes[3]; u32 received_ce; /* Like the above but for received CE marked packets */ u32 received_ecn_bytes[3]; u8 received_ce_pending:4, /* Not yet transmitted cnt of received_ce */ unused2:4; + u8 accecn_minlen:2,/* Minimum length of AccECN option sent */ + estimate_ecnfield:2;/* ECN field for AccECN delivered estimates */ u32 app_limited; /* limited until "delivered" reaches this val */ u32 rcv_wnd; /* Current receiver window */ /* diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 3c014170e001..8a186e99917b 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -135,6 +135,7 @@ struct netns_ipv4 { struct local_ports ip_local_ports; u8 sysctl_tcp_ecn; + u8 sysctl_tcp_ecn_option; u8 sysctl_tcp_ecn_fallback; u8 sysctl_ip_default_ttl; diff --git a/include/net/tcp.h b/include/net/tcp.h index 56d009723c91..adc520b6eeca 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -202,6 +202,8 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX); #define TCPOPT_AO 29 /* Authentication Option (RFC5925) */ #define TCPOPT_MPTCP 30 /* Multipath TCP (RFC6824) */ #define TCPOPT_FASTOPEN 34 /* Fast open (RFC7413) */ +#define TCPOPT_ACCECN0 172 /* 0xAC: Accurate ECN Order 0 */ +#define TCPOPT_ACCECN1 174 /* 0xAE: Accurate ECN Order 1 */ #define TCPOPT_EXP 254 /* Experimental */ /* Magic number to be after the option value for sharing TCP * experimental options. See draft-ietf-tcpm-experimental-options-00.txt @@ -219,6 +221,7 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX); #define TCPOLEN_TIMESTAMP 10 #define TCPOLEN_MD5SIG 18 #define TCPOLEN_FASTOPEN_BASE 2 +#define TCPOLEN_ACCECN_BASE 2 #define TCPOLEN_EXP_FASTOPEN_BASE 4 #define TCPOLEN_EXP_SMC_BASE 6 @@ -232,6 +235,13 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX); #define TCPOLEN_MD5SIG_ALIGNED 20 #define TCPOLEN_MSS_ALIGNED 4 #define TCPOLEN_EXP_SMC_BASE_ALIGNED 8 +#define TCPOLEN_ACCECN_PERFIELD 3 + +/* Maximum number of byte counters in AccECN option + size */ +#define TCP_ACCECN_NUMFIELDS 3 +#define TCP_ACCECN_MAXSIZE (TCPOLEN_ACCECN_BASE + \ + TCPOLEN_ACCECN_PERFIELD * \ + TCP_ACCECN_NUMFIELDS) /* tp->accecn_fail_mode */ #define TCP_ACCECN_ACE_FAIL_SEND BIT(0) @@ -1030,6 +1040,9 @@ static inline void tcp_accecn_init_counters(struct tcp_sock *tp) tp->received_ce = 0; tp->received_ce_pending = 0; __tcp_accecn_init_bytes_counters(tp->received_ecn_bytes); + __tcp_accecn_init_bytes_counters(tp->delivered_ecn_bytes); + tp->accecn_minlen = 0; + tp->estimate_ecnfield = 0; } /* State flags for sacked in struct tcp_skb_cb */ diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index 3fe08d7dddaf..8c21fa0463e9 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -295,6 +295,13 @@ struct tcp_info { __u32 tcpi_snd_wnd; /* peer's advertised receive window after * scaling (bytes) */ + __u32 tcpi_received_ce; /* # of CE marks received */ + __u32 tcpi_delivered_e1_bytes; /* Accurate ECN byte counters */ + __u32 tcpi_delivered_e0_bytes; + __u32 tcpi_delivered_ce_bytes; + __u32 tcpi_received_e1_bytes; + __u32 tcpi_received_e0_bytes; + __u32 tcpi_received_ce_bytes; __u32 tcpi_rcv_wnd; /* local advertised receive window after * scaling (bytes) */ diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 01fcc6b2045b..0d7c0fea150b 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -728,6 +728,15 @@ static struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_FIVE, }, + { + .procname = "tcp_ecn_option", + .data = &init_net.ipv4.sysctl_tcp_ecn_option, + .maxlen = sizeof(u8), + .mode = 0644, + .proc_handler = proc_dou8vec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_TWO, + }, { .procname = "tcp_ecn_fallback", .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 39b20901ac6f..ea1fbafd4fd9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -270,6 +270,7 @@ #include #include +#include #include #include #include @@ -4178,6 +4179,14 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) info->tcpi_rehash = tp->plb_rehash + tp->timeout_rehash; info->tcpi_fastopen_client_fail = tp->fastopen_client_fail; + info->tcpi_received_ce = tp->received_ce; + info->tcpi_delivered_e1_bytes = tp->delivered_ecn_bytes[INET_ECN_ECT_1 - 1]; + info->tcpi_delivered_e0_bytes = tp->delivered_ecn_bytes[INET_ECN_ECT_0 - 1]; + info->tcpi_delivered_ce_bytes = tp->delivered_ecn_bytes[INET_ECN_CE - 1]; + info->tcpi_received_e1_bytes = tp->received_ecn_bytes[INET_ECN_ECT_1 - 1]; + info->tcpi_received_e0_bytes = tp->received_ecn_bytes[INET_ECN_ECT_0 - 1]; + info->tcpi_received_ce_bytes = tp->received_ecn_bytes[INET_ECN_CE - 1]; + info->tcpi_total_rto = tp->total_rto; info->tcpi_total_rto_recoveries = tp->total_rto_recoveries; info->tcpi_total_rto_time = tp->total_rto_time; @@ -5028,6 +5037,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, snd_up); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ce); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ce); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); @@ -5037,7 +5047,7 @@ static void __init tcp_struct_check(void) /* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 109 + 3); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 122 + 6); /* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index f70b65034e45..6daeced890f7 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -490,6 +491,136 @@ static bool tcp_ecn_rcv_ecn_echo(const struct tcp_sock *tp, const struct tcphdr return false; } +/* Maps IP ECN field ECT/CE code point to AccECN option field number, given + * we are sending fields with Accurate ECN Order 1: ECT(1), CE, ECT(0). + */ +static u8 tcp_ecnfield_to_accecn_optfield(u8 ecnfield) +{ + switch (ecnfield) { + case INET_ECN_NOT_ECT: + return 0; /* AccECN does not send counts of NOT_ECT */ + case INET_ECN_ECT_1: + return 1; + case INET_ECN_CE: + return 2; + case INET_ECN_ECT_0: + return 3; + default: + WARN_ONCE(1, "bad ECN code point: %d\n", ecnfield); + } + return 0; +} + +/* Maps IP ECN field ECT/CE code point to AccECN option field value offset. + * Some fields do not start from zero, to detect zeroing by middleboxes. + */ +static u32 tcp_accecn_field_init_offset(u8 ecnfield) +{ + switch (ecnfield) { + case INET_ECN_NOT_ECT: + return 0; /* AccECN does not send counts of NOT_ECT */ + case INET_ECN_ECT_1: + return TCP_ACCECN_E1B_INIT_OFFSET; + case INET_ECN_CE: + return TCP_ACCECN_CEB_INIT_OFFSET; + case INET_ECN_ECT_0: + return TCP_ACCECN_E0B_INIT_OFFSET; + default: + WARN_ONCE(1, "bad ECN code point: %d\n", ecnfield); + } + return 0; +} + +/* Maps AccECN option field #nr to IP ECN field ECT/CE bits */ +static unsigned int tcp_accecn_optfield_to_ecnfield(unsigned int optfield, bool order) +{ + u8 tmp; + + optfield = order ? 2 - optfield : optfield; + tmp = optfield + 2; + + return (tmp + (tmp >> 2)) & INET_ECN_MASK; +} + +/* Handles AccECN option ECT and CE 24-bit byte counters update into + * the u32 value in tcp_sock. As we're processing TCP options, it is + * safe to access from - 1. + */ +static s32 tcp_update_ecn_bytes(u32 *cnt, const char *from, u32 init_offset) +{ + u32 truncated = (get_unaligned_be32(from - 1) - init_offset) & 0xFFFFFFU; + u32 delta = (truncated - *cnt) & 0xFFFFFFU; + + /* If delta has the highest bit set (24th bit) indicating negative, + * sign extend to correct an estimation using sign_extend32(delta, 24 - 1) + */ + delta = sign_extend32(delta, 23); + *cnt += delta; + return (s32)delta; +} + +/* Returns true if the byte counters can be used */ +static bool tcp_accecn_process_option(struct tcp_sock *tp, + const struct sk_buff *skb, + u32 delivered_bytes, int flag) +{ + u8 estimate_ecnfield = tp->estimate_ecnfield; + bool ambiguous_ecn_bytes_incr = false; + bool first_changed = false; + unsigned int optlen; + unsigned char *ptr; + bool order1, res; + unsigned int i; + + if (!(flag & FLAG_SLOWPATH) || !tp->rx_opt.accecn) { + if (estimate_ecnfield) { + tp->delivered_ecn_bytes[estimate_ecnfield - 1] += delivered_bytes; + return true; + } + return false; + } + + ptr = skb_transport_header(skb) + tp->rx_opt.accecn; + optlen = ptr[1] - 2; + WARN_ON_ONCE(ptr[0] != TCPOPT_ACCECN0 && ptr[0] != TCPOPT_ACCECN1); + order1 = (ptr[0] == TCPOPT_ACCECN1); + ptr += 2; + + res = !!estimate_ecnfield; + for (i = 0; i < 3; i++) { + if (optlen >= TCPOLEN_ACCECN_PERFIELD) { + u8 ecnfield = tcp_accecn_optfield_to_ecnfield(i, order1); + u32 init_offset = tcp_accecn_field_init_offset(ecnfield); + s32 delta; + + delta = tcp_update_ecn_bytes(&tp->delivered_ecn_bytes[ecnfield - 1], + ptr, init_offset); + if (delta) { + if (delta < 0) { + res = false; + ambiguous_ecn_bytes_incr = true; + } + if (ecnfield != estimate_ecnfield) { + if (!first_changed) { + tp->estimate_ecnfield = ecnfield; + first_changed = true; + } else { + res = false; + ambiguous_ecn_bytes_incr = true; + } + } + } + + optlen -= TCPOLEN_ACCECN_PERFIELD; + ptr += TCPOLEN_ACCECN_PERFIELD; + } + } + if (ambiguous_ecn_bytes_incr) + tp->estimate_ecnfield = 0; + + return res; +} + static void tcp_count_delivered_ce(struct tcp_sock *tp, u32 ecn_count) { tp->delivered_ce += ecn_count; @@ -506,7 +637,7 @@ static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, /* Returns the ECN CE delta */ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, - u32 delivered_pkts, int flag) + u32 delivered_pkts, u32 delivered_bytes, int flag) { struct tcp_sock *tp = tcp_sk(sk); u32 delta, safe_delta; @@ -516,6 +647,8 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, if (!(flag & (FLAG_FORWARD_PROGRESS | FLAG_TS_PROGRESS))) return 0; + tcp_accecn_process_option(tp, skb, delivered_bytes, flag); + if (!(flag & FLAG_SLOWPATH)) { /* AccECN counter might overflow on large ACKs */ if (delivered_pkts <= TCP_ACCECN_CEP_ACE_MASK) @@ -540,12 +673,13 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, } static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, - u32 delivered_pkts, int *flag) + u32 delivered_pkts, u32 delivered_bytes, int *flag) { u32 delta; struct tcp_sock *tp = tcp_sk(sk); - delta = __tcp_accecn_process(sk, skb, delivered_pkts, *flag); + delta = __tcp_accecn_process(sk, skb, delivered_pkts, + delivered_bytes, *flag); if (delta > 0) { tcp_count_delivered_ce(tp, delta); *flag |= FLAG_ECE; @@ -4198,7 +4332,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_rack_update_reo_wnd(sk, &rs); if (tcp_ecn_mode_accecn(tp)) - ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, &flag); + ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, + sack_state.delivered_bytes, &flag); tcp_in_ack_event(sk, flag); @@ -4235,7 +4370,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) no_queue: if (tcp_ecn_mode_accecn(tp)) - ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, &flag); + ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, + sack_state.delivered_bytes, &flag); tcp_in_ack_event(sk, flag); /* If data was DSACKed, see if we can undo a cwnd reduction. */ if (flag & FLAG_DSACKING_ACK) { @@ -4363,6 +4499,7 @@ void tcp_parse_options(const struct net *net, ptr = (const unsigned char *)(th + 1); opt_rx->saw_tstamp = 0; + opt_rx->accecn = 0; opt_rx->saw_unknown = 0; while (length > 0) { @@ -4454,6 +4591,12 @@ void tcp_parse_options(const struct net *net, ptr, th->syn, foc, false); break; + case TCPOPT_ACCECN0: + case TCPOPT_ACCECN1: + /* Save offset of AccECN option in TCP header */ + opt_rx->accecn = (ptr - 2) - (__u8 *)th; + break; + case TCPOPT_EXP: /* Fast Open option shares code 254 using a * 16 bits magic number. @@ -4514,11 +4657,14 @@ static bool tcp_fast_parse_options(const struct net *net, */ if (th->doff == (sizeof(*th) / 4)) { tp->rx_opt.saw_tstamp = 0; + tp->rx_opt.accecn = 0; return false; } else if (tp->rx_opt.tstamp_ok && th->doff == ((sizeof(*th) + TCPOLEN_TSTAMP_ALIGNED) / 4)) { - if (tcp_parse_aligned_timestamp(tp, th)) + if (tcp_parse_aligned_timestamp(tp, th)) { + tp->rx_opt.accecn = 0; return true; + } } tcp_parse_options(net, skb, &tp->rx_opt, 1, NULL); @@ -6111,8 +6257,11 @@ void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb, tp->received_ce += pcount; tp->received_ce_pending = min(tp->received_ce_pending + pcount, 0xfU); - if (payload_len > 0) + if (payload_len > 0) { + u8 minlen = tcp_ecnfield_to_accecn_optfield(ecnfield); tp->received_ecn_bytes[ecnfield - 1] += payload_len; + tp->accecn_minlen = max_t(u8, tp->accecn_minlen, minlen); + } } } @@ -6322,6 +6471,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) */ tp->rx_opt.saw_tstamp = 0; + tp->rx_opt.accecn = 0; /* pred_flags is 0xS?10 << 16 + snd_wnd * if header_prediction is to be made diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 97df9f36714c..e632327f19f8 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -3447,6 +3447,7 @@ static void __net_init tcp_set_hashinfo(struct net *net) static int __net_init tcp_sk_init(struct net *net) { net->ipv4.sysctl_tcp_ecn = 2; + net->ipv4.sysctl_tcp_ecn_option = 2; net->ipv4.sysctl_tcp_ecn_fallback = 1; net->ipv4.sysctl_tcp_base_mss = TCP_BASE_MSS; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index d6f16c82eb1b..bddd0b309443 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -487,6 +487,7 @@ static inline bool tcp_urg_mode(const struct tcp_sock *tp) #define OPTION_SMC BIT(9) #define OPTION_MPTCP BIT(10) #define OPTION_AO BIT(11) +#define OPTION_ACCECN BIT(12) static void smc_options_write(__be32 *ptr, u16 *options) { @@ -508,12 +509,14 @@ struct tcp_out_options { u16 mss; /* 0 to disable */ u8 ws; /* window scale, 0 to disable */ u8 num_sack_blocks; /* number of SACK blocks to include */ + u8 num_accecn_fields; /* number of AccECN fields needed */ u8 hash_size; /* bytes in hash_location */ u8 bpf_opt_len; /* length of BPF hdr option */ __u8 *hash_location; /* temporary pointer, overloaded */ __u32 tsval, tsecr; /* need to include OPTION_TS */ struct tcp_fastopen_cookie *fastopen_cookie; /* Fast open cookie */ struct mptcp_out_options mptcp; + u32 *ecn_bytes; /* AccECN ECT/CE byte counters */ }; static void mptcp_options_write(struct tcphdr *th, __be32 *ptr, @@ -760,6 +763,39 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, *ptr++ = htonl(opts->tsecr); } + if (OPTION_ACCECN & options) { + u32 e0b = opts->ecn_bytes[INET_ECN_ECT_0 - 1] + TCP_ACCECN_E0B_INIT_OFFSET; + u32 e1b = opts->ecn_bytes[INET_ECN_ECT_1 - 1] + TCP_ACCECN_E1B_INIT_OFFSET; + u32 ceb = opts->ecn_bytes[INET_ECN_CE - 1] + TCP_ACCECN_CEB_INIT_OFFSET; + u8 len = TCPOLEN_ACCECN_BASE + + opts->num_accecn_fields * TCPOLEN_ACCECN_PERFIELD; + + if (opts->num_accecn_fields == 2) { + *ptr++ = htonl((TCPOPT_ACCECN1 << 24) | (len << 16) | + ((e1b >> 8) & 0xffff)); + *ptr++ = htonl(((e1b & 0xff) << 24) | + (ceb & 0xffffff)); + } else if (opts->num_accecn_fields == 1) { + *ptr++ = htonl((TCPOPT_ACCECN1 << 24) | (len << 16) | + ((e1b >> 8) & 0xffff)); + leftover_bytes = ((e1b & 0xff) << 8) | + TCPOPT_NOP; + leftover_size = 1; + } else if (opts->num_accecn_fields == 0) { + leftover_bytes = (TCPOPT_ACCECN1 << 8) | len; + leftover_size = 2; + } else if (opts->num_accecn_fields == 3) { + *ptr++ = htonl((TCPOPT_ACCECN1 << 24) | (len << 16) | + ((e1b >> 8) & 0xffff)); + *ptr++ = htonl(((e1b & 0xff) << 24) | + (ceb & 0xffffff)); + *ptr++ = htonl(((e0b & 0xffffff) << 8) | + TCPOPT_NOP); + } + if (tp) + tp->accecn_minlen = 0; + } + if (unlikely(OPTION_SACK_ADVERTISE & options)) { *ptr++ = htonl((leftover_bytes << 16) | (TCPOPT_SACK_PERM << 8) | @@ -880,6 +916,60 @@ static void mptcp_set_option_cond(const struct request_sock *req, } } +/* Initial values for AccECN option, ordered is based on ECN field bits + * similar to received_ecn_bytes. Used for SYN/ACK AccECN option. + */ +u32 synack_ecn_bytes[3] = { 0, 0, 0 }; + +static u32 tcp_synack_options_combine_saving(struct tcp_out_options *opts) +{ + /* How much there's room for combining with the alignment padding? */ + if ((opts->options & (OPTION_SACK_ADVERTISE | OPTION_TS)) == + OPTION_SACK_ADVERTISE) + return 2; + else if (opts->options & OPTION_WSCALE) + return 1; + return 0; +} + +/* Calculates how long AccECN option will fit to @remaining option space. + * + * AccECN option can sometimes replace NOPs used for alignment of other + * TCP options (up to @max_combine_saving available). + * + * Only solutions with at least @required AccECN fields are accepted. + * + * Returns: The size of the AccECN option excluding space repurposed from + * the alignment of the other options. + */ +static int tcp_options_fit_accecn(struct tcp_out_options *opts, int required, + int remaining, int max_combine_saving) +{ + int size = TCP_ACCECN_MAXSIZE; + + opts->num_accecn_fields = TCP_ACCECN_NUMFIELDS; + + while (opts->num_accecn_fields >= required) { + int leftover_size = size & 0x3; + /* Pad to dword if cannot combine */ + if (leftover_size > max_combine_saving) + leftover_size = -((4 - leftover_size) & 0x3); + + if (remaining >= size - leftover_size) { + size -= leftover_size; + break; + } + + opts->num_accecn_fields--; + size -= TCPOLEN_ACCECN_PERFIELD; + } + if (opts->num_accecn_fields < required) + return 0; + + opts->options |= OPTION_ACCECN; + return size; +} + /* Compute TCP options for SYN packets. This is not the final * network wire format yet. */ @@ -960,6 +1050,16 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb, } } + /* Simultaneous open SYN/ACK needs AccECN option but not SYN */ + if (unlikely((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) && + tcp_ecn_mode_accecn(tp) && + sock_net(sk)->ipv4.sysctl_tcp_ecn_option && + remaining >= TCPOLEN_ACCECN_BASE)) { + opts->ecn_bytes = synack_ecn_bytes; + remaining -= tcp_options_fit_accecn(opts, 0, remaining, + tcp_synack_options_combine_saving(opts)); + } + bpf_skops_hdr_opt_len(sk, skb, NULL, NULL, 0, opts, &remaining); return MAX_TCP_OPTION_SPACE - remaining; @@ -977,6 +1077,7 @@ static unsigned int tcp_synack_options(const struct sock *sk, { struct inet_request_sock *ireq = inet_rsk(req); unsigned int remaining = MAX_TCP_OPTION_SPACE; + struct tcp_request_sock *treq = tcp_rsk(req); if (tcp_key_is_md5(key)) { opts->options |= OPTION_MD5; @@ -1033,6 +1134,13 @@ static unsigned int tcp_synack_options(const struct sock *sk, smc_set_option_cond(tcp_sk(sk), ireq, opts, &remaining); + if (treq->accecn_ok && sock_net(sk)->ipv4.sysctl_tcp_ecn_option && + remaining >= TCPOLEN_ACCECN_BASE) { + opts->ecn_bytes = synack_ecn_bytes; + remaining -= tcp_options_fit_accecn(opts, 0, remaining, + tcp_synack_options_combine_saving(opts)); + } + bpf_skops_hdr_opt_len((struct sock *)sk, skb, req, syn_skb, synack_type, opts, &remaining); @@ -1103,6 +1211,14 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb opts->num_sack_blocks = 0; } + if (tcp_ecn_mode_accecn(tp) && + sock_net(sk)->ipv4.sysctl_tcp_ecn_option) { + opts->ecn_bytes = tp->received_ecn_bytes; + size += tcp_options_fit_accecn(opts, tp->accecn_minlen, + MAX_TCP_OPTION_SPACE - size, + opts->num_sack_blocks > 0 ? 2 : 0); + } + if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_WRITE_HDR_OPT_CB_FLAG))) { unsigned int remaining = MAX_TCP_OPTION_SPACE - size; From patchwork Tue Oct 15 10:29:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836083 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2053.outbound.protection.outlook.com [40.107.105.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D02661EC01C for ; Tue, 15 Oct 2024 10:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; cv=fail; b=mA2nvHThDGUbIrZcil5/wUxYobjpMLUC0tLe87oS9gG2I9Of2chk/v9RJ+W0I1IiLlBfu9Ag9WsQgW0fXBFbDtN7yx82jkQ0qmMq5GZwpzGfWtxHu3usr1uaBocx4e1vBayEJIQA7LibjEWspgCCZ0iJgXjrH8SjJu3F9Tm0i4w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; c=relaxed/simple; bh=GaRiTRj4vGy7a/ovH+seDj/pbJNwdlHYL9WhlqJpLtg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=T4ENhAGS4JzT/+9GKeW+NdyWIn7ETHkY4IyNND3vi/ttRSydLRmnnGa/gtbljObDheuHC0wvq8oNEsh1DEmXL09VtsrVG8Jqv1WEJU4zJbGeXL+aw4XrhCAktU13R+aWgySnfJfmjVUgaBEHFKtYoRJwgBpj80KuWD/0eJ6M6zo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=aOcHGAHi; arc=fail smtp.client-ip=40.107.105.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="aOcHGAHi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QZ6/4P7Z+NO4JDTlMdvfFWqco7zbj6TMKBtdRLVME0JBp3FzuMwEhH5dbEqhJ5I7u5gDIU9Q/8mg1x7IZZ7nfgHuRqrmoB1MruzC3cGbladKFvCEnzbgyxjgG5SuNaJbpxzRuPBsVtpYhRF5fDIlzWQXXVfhH/01vEeRiPS9PVYCk0E3bzO+5L5OTEI285Q48uEFWpQ1vvHvKMlfwNnExWy5+a+7Vrqdpym6CNzGve1Se3o9UCdZdWkB9yeEBxXbCcHJzF8tcg97LWBeJOKV2+11g3uKwN0KHaV2YEHVpptFjefj8Bd2BHN/2M7dMoR2Ek5gMPDuujjrY0/eeZZBGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2tA8+OFEEaeCTtJ10aJN8mcAISEKN2T4zBYLL84QNoc=; b=E5HYRjrTI8J7D0TE+jFnudNqohlqGQfLEoutax9R81uQahtohotWi7ZAg+UqjtCLh671QHw0oNhqs8EO9FTrbWp9xvUOQWW+/YGDnEXaIexh8Wuqq1tVkecNjRCClQBd8rzaKcIDFfoABe3AES5WvhvpIc0Xb70pIMej4zySuqT5+xJ8RVWF4dqDDuFi7rBRMN1S03jPUs/BoZ5NsHiB8hWn9zBTBdd4t5iW5sVm38sbSPT3Hj3qbAfIE2WJpQYCOaxqkXF+5aBUdXz83Yk+DA+geYuKBK8vh5MJ07kJLe1ePZGw5hKNIQMUOv5x2a4r62uOt5B9RnjsATvcpyz+iA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=temperror action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2tA8+OFEEaeCTtJ10aJN8mcAISEKN2T4zBYLL84QNoc=; b=aOcHGAHiUrPkPhS1H/gJt3IfLSbHPxNEs+FLkrEF7JwegYv5PWo5yBq3/lXmC16+yZcvAqFsaxyE18F2RExJY3mxSxqml7NMgYtewlfJFqutw7noD5rMdGJX7olWjNJPtH6sgJFXhWCi8GJy2CaH6HQnfdk4MrYr7wJe00AvJPM+/SklRA2z+O8OvlTne2sLCJKG8G9EIIefNfTepAoLRQkRezkJDReBqoLRKo84QkMJi59iBUUIhQVx+pj03vyzd6iwBGYSBR4gnnDBxIxOru1AqlbiuaIGRpsjBt0MkYx9/kJe49wotC+y+CGNMX5oTGKvfQci2UFKq2HqB7+AGw== Received: from DUZP191CA0048.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4f8::8) by AS2PR07MB9003.eurprd07.prod.outlook.com (2603:10a6:20b:556::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:27 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:4f8:cafe::b6) by DUZP191CA0048.outlook.office365.com (2603:10a6:10:4f8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:27 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nokia-bell-labs.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nokia-bell-labs.com: DNS Timeout) Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:26 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnR029578; Tue, 15 Oct 2024 10:30:25 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 23/44] tcp: accecn: AccECN option send control Date: Tue, 15 Oct 2024 12:29:19 +0200 Message-Id: <20241015102940.26157-24-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|AS2PR07MB9003:EE_ X-MS-Office365-Filtering-Correlation-Id: 98faa436-6b86-49e0-a879-08dced04622d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?VtIWi0+/eIsimhmaKeg4fcU7+zFKpqP?= =?utf-8?q?Ybou76YvT6D9ahN4MW6E/B9gqb/+yjdi6k6Cd5cvB2UEN6/Nyv9h2b4crK31Y1UeK?= =?utf-8?q?Vv0HtiIvS/DSRdwIYG2B29/YpJEfd3RujLgXuACPtgVSqVe0OBUOHlkG9uxP3H+fV?= =?utf-8?q?+7/q3V/+yeFmEERRLd27F0J8YJs4BfT4ZgRc9/BkLfZWM0IGneQCWgvMWb0xUB6ge?= =?utf-8?q?wWqb6PuOp1nxkSZEBxk4mbHeoFbC2HczaO1T28GZAd1vVG4TA+H9M2VVsLcvOs4Mt?= =?utf-8?q?mjJnAcdpbngTZIsl52QfnzfE9JekZ+oIS3u4uThyrGmOGTctfyS3QONRUbvbCtWdG?= =?utf-8?q?AoGA5jAcpOSesETo5oozP8aAmZGAci8QwfzwKwd8F9Pgrb6gq7jWlpeKD9YbVfD5k?= =?utf-8?q?0Dggim9rDO3j5bxtZbVkzfW8KF6F97oTjbtXFs0M9uIk9y5T5Hxp0Z3MJhF80EIER?= =?utf-8?q?6hY7jaz9E0Dev2Yu1EDH5d5aGo2lkA7/sGCz1BvaeVLpKXrmab0aQrY+Qt/WBsoWl?= =?utf-8?q?AhUvJmOdydncfXgSJ6oR4kAf497808faKqqxjMQw+gk+v9IdkFPzVKjx0n/bCM75P?= =?utf-8?q?C/+64iYCsexg3mP5IKLb3qY52LrLk+/G18MEAt1PtOwTCR22Qy12KavV+EFh5vcOm?= =?utf-8?q?lthfCLP6NGD4XvbFP0nf6Rah037CqE/iop8NiCYdrKdRkUf+PscUlZt1fMiAoFeeS?= =?utf-8?q?igsp2vMloHEQNh2Ud1bi+ZmKSn3EbO2GQtkosw1vMCAJ5IPDR2NEUz070t4zLthrw?= =?utf-8?q?xHVhpq1YfCnbPvO2HRff+Fb7/luPKgGJJCXKI2DFC2Xpxn00hV4PsYv8WfW0AuNym?= =?utf-8?q?vN9madv6vMvrAxG9DZlh/54d+qKqPsNsSld3qhIX+V3fBTt1c0Euufpczaa/GZN8g?= =?utf-8?q?/Sur3p4pU1P1vlmEcEpql4WReqw89LWZlWnYrcsXHpdwEV3Ztx9JvIO/hcZUYyrm/?= =?utf-8?q?eDjVAMPE4Guff5XbstXzTilo0ZmAS9IOh6jwdk4juTd9Ccu4phOys8ztuctsvkTBL?= =?utf-8?q?v026zNnO1y2FcmJe09dlHbVGKTEx/d9ii86Nlcwi8ZIstLWBr07TTdukQ0JTL9C/a?= =?utf-8?q?0v8CCg0oN+OYKVa4Fqjj95Q2c7Y/HL+1HHtoTPwUR/ga/fi0AIG7JPTR7BzdKVHgv?= =?utf-8?q?y+nh/YtA78IRREUdX/fuywa2EC5N59GaHd2P9EDuNNOtKOIFNDce3vMAWJAnCwjYO?= =?utf-8?q?udNLKCdviYa+v+57NcZsaMdU6m2HsDUay5EOe3xV4SqBylT14RvgHOkcnc5n/YCxr?= =?utf-8?q?pzOmBNCrLSHfxgHvaMUzdZHXjtLZOH2p0+7Ix9uyREL3lGlLdV9F94cPJGJgp/uSZ?= =?utf-8?q?0cQOtfuBREBV?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:26.0860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98faa436-6b86-49e0-a879-08dced04622d X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR07MB9003 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Instead of sending the option in every ACK, limit sending to those ACKs where the option is necessary: - Handshake - "Change-triggered ACK" + the ACK following it. The 2nd ACK is necessary to unambiguously indicate which of the ECN byte counters in increasing. The first ACK has two counters increasing due to the ecnfield edge. - ACKs with CE to allow CEP delta validations to take advantage of the option. - Force option to be sent every at least once per 2^22 bytes. The check is done using the bit edges of the byte counters (avoids need for extra variables). - AccECN option beacon to send a few times per RTT even if nothing in the ECN state requires that. The default is 3 times per RTT, and its period can be set via sysctl_tcp_ecn_option_beacon. Signed-off-by: Ilpo Järvinen Co-developed-by: Chia-Yu Chang Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 3 +++ include/net/netns/ipv4.h | 1 + include/net/tcp.h | 1 + net/ipv4/sysctl_net_ipv4.c | 9 +++++++++ net/ipv4/tcp.c | 5 ++++- net/ipv4/tcp_input.c | 31 ++++++++++++++++++++++++++++++- net/ipv4/tcp_ipv4.c | 1 + net/ipv4/tcp_minisocks.c | 2 ++ net/ipv4/tcp_output.c | 36 +++++++++++++++++++++++++++++++----- 9 files changed, 82 insertions(+), 7 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 1d53b184e05e..e4aa10fdc032 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -305,7 +305,10 @@ struct tcp_sock { u8 received_ce_pending:4, /* Not yet transmitted cnt of received_ce */ unused2:4; u8 accecn_minlen:2,/* Minimum length of AccECN option sent */ + prev_ecnfield:2,/* ECN bits from the previous segment */ + accecn_opt_demand:2,/* Demand AccECN option for n next ACKs */ estimate_ecnfield:2;/* ECN field for AccECN delivered estimates */ + u64 accecn_opt_tstamp; /* Last AccECN option sent timestamp */ u32 app_limited; /* limited until "delivered" reaches this val */ u32 rcv_wnd; /* Current receiver window */ /* diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 8a186e99917b..87880307b68c 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -136,6 +136,7 @@ struct netns_ipv4 { u8 sysctl_tcp_ecn; u8 sysctl_tcp_ecn_option; + u8 sysctl_tcp_ecn_option_beacon; u8 sysctl_tcp_ecn_fallback; u8 sysctl_ip_default_ttl; diff --git a/include/net/tcp.h b/include/net/tcp.h index adc520b6eeca..b3cbf9a11dbc 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1042,6 +1042,7 @@ static inline void tcp_accecn_init_counters(struct tcp_sock *tp) __tcp_accecn_init_bytes_counters(tp->received_ecn_bytes); __tcp_accecn_init_bytes_counters(tp->delivered_ecn_bytes); tp->accecn_minlen = 0; + tp->accecn_opt_demand = 0; tp->estimate_ecnfield = 0; } diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 0d7c0fea150b..987e74a41b09 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -737,6 +737,15 @@ static struct ctl_table ipv4_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, + { + .procname = "tcp_ecn_option_beacon", + .data = &init_net.ipv4.sysctl_tcp_ecn_option_beacon, + .maxlen = sizeof(u8), + .mode = 0644, + .proc_handler = proc_dou8vec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_FOUR, + }, { .procname = "tcp_ecn_fallback", .data = &init_net.ipv4.sysctl_tcp_ecn_fallback, diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index ea1fbafd4fd9..e59fd2cabe03 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3340,6 +3340,8 @@ int tcp_disconnect(struct sock *sk, int flags) tp->wait_third_ack = 0; tp->accecn_fail_mode = 0; tcp_accecn_init_counters(tp); + tp->prev_ecnfield = 0; + tp->accecn_opt_tstamp = 0; if (icsk->icsk_ca_ops->release) icsk->icsk_ca_ops->release(sk); memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); @@ -5040,6 +5042,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ce); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ecn_bytes); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, accecn_opt_tstamp); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rx_opt); @@ -5047,7 +5050,7 @@ static void __init tcp_struct_check(void) /* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 122 + 6); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 130 + 6); /* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 6daeced890f7..14b9a5e63687 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -459,6 +459,7 @@ static void tcp_ecn_rcv_synack(struct sock *sk, const struct tcphdr *th, default: tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); tp->syn_ect_rcv = ip_dsfield & INET_ECN_MASK; + tp->accecn_opt_demand = 2; if (tcp_accecn_validate_syn_feedback(sk, ace, tp->syn_ect_snt) && INET_ECN_is_ce(ip_dsfield)) { tp->received_ce++; @@ -477,6 +478,7 @@ static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th, tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); } else { tp->syn_ect_rcv = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; + tp->prev_ecnfield = tp->syn_ect_rcv; tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); } } @@ -6247,6 +6249,7 @@ void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb, u8 ecnfield = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; u8 is_ce = INET_ECN_is_ce(ecnfield); struct tcp_sock *tp = tcp_sk(sk); + bool ecn_edge; if (!INET_ECN_is_not_ect(ecnfield)) { u32 pcount = is_ce * max_t(u16, 1, skb_shinfo(skb)->gso_segs); @@ -6259,8 +6262,32 @@ void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb, if (payload_len > 0) { u8 minlen = tcp_ecnfield_to_accecn_optfield(ecnfield); + u32 oldbytes = tp->received_ecn_bytes[ecnfield - 1]; + tp->received_ecn_bytes[ecnfield - 1] += payload_len; tp->accecn_minlen = max_t(u8, tp->accecn_minlen, minlen); + + /* Demand AccECN option at least every 2^22 bytes to + * avoid overflowing the ECN byte counters. + */ + if ((tp->received_ecn_bytes[ecnfield - 1] ^ oldbytes) & + ~((1 << 22) - 1)) + tp->accecn_opt_demand = max_t(u8, 1, + tp->accecn_opt_demand); + } + } + + ecn_edge = tp->prev_ecnfield != ecnfield; + if (ecn_edge || is_ce) { + tp->prev_ecnfield = ecnfield; + /* Demand Accurate ECN change-triggered ACKs. Two ACK are + * demanded to indicate unambiguously the ecnfield value + * in the latter ACK. + */ + if (tcp_ecn_mode_accecn(tp)) { + if (ecn_edge) + inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_NOW; + tp->accecn_opt_demand = 2; } } } @@ -6381,8 +6408,10 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, * RFC 5961 4.2 : Send a challenge ack */ if (th->syn) { - if (tcp_ecn_mode_accecn(tp)) + if (tcp_ecn_mode_accecn(tp)) { send_accecn_reflector = true; + tp->accecn_opt_demand = max_t(u8, 1, tp->accecn_opt_demand); + } if (sk->sk_state == TCP_SYN_RECV && sk->sk_socket && th->ack && TCP_SKB_CB(skb)->seq + 1 == TCP_SKB_CB(skb)->end_seq && TCP_SKB_CB(skb)->seq + 1 == tp->rcv_nxt && diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index e632327f19f8..21946ac00282 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -3448,6 +3448,7 @@ static int __net_init tcp_sk_init(struct net *net) { net->ipv4.sysctl_tcp_ecn = 2; net->ipv4.sysctl_tcp_ecn_option = 2; + net->ipv4.sysctl_tcp_ecn_option_beacon = 3; net->ipv4.sysctl_tcp_ecn_fallback = 1; net->ipv4.sysctl_tcp_base_mss = TCP_BASE_MSS; diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index ad9ac8e2bfd4..75baa72849fe 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -490,6 +490,8 @@ static void tcp_ecn_openreq_child(struct sock *sk, tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); tp->syn_ect_snt = treq->syn_ect_snt; tcp_accecn_third_ack(sk, skb, treq->syn_ect_snt); + tp->prev_ecnfield = treq->syn_ect_rcv; + tp->accecn_opt_demand = 1; tcp_ecn_received_counters(sk, skb, skb->len - th->doff * 4); } else { tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ? diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index bddd0b309443..22f6cfba5b27 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -792,8 +792,13 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, *ptr++ = htonl(((e0b & 0xffffff) << 8) | TCPOPT_NOP); } - if (tp) + + if (tp) { tp->accecn_minlen = 0; + tp->accecn_opt_tstamp = tp->tcp_mstamp; + if (tp->accecn_opt_demand) + tp->accecn_opt_demand--; + } } if (unlikely(OPTION_SACK_ADVERTISE & options)) { @@ -970,6 +975,17 @@ static int tcp_options_fit_accecn(struct tcp_out_options *opts, int required, return size; } +static bool tcp_accecn_option_beacon_check(const struct sock *sk) +{ + const struct tcp_sock *tp = tcp_sk(sk); + + if (!sock_net(sk)->ipv4.sysctl_tcp_ecn_option_beacon) + return false; + + return tcp_stamp_us_delta(tp->tcp_mstamp, tp->accecn_opt_tstamp) * + sock_net(sk)->ipv4.sysctl_tcp_ecn_option_beacon >= (tp->srtt_us >> 3); +} + /* Compute TCP options for SYN packets. This is not the final * network wire format yet. */ @@ -1213,10 +1229,15 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb if (tcp_ecn_mode_accecn(tp) && sock_net(sk)->ipv4.sysctl_tcp_ecn_option) { - opts->ecn_bytes = tp->received_ecn_bytes; - size += tcp_options_fit_accecn(opts, tp->accecn_minlen, - MAX_TCP_OPTION_SPACE - size, - opts->num_sack_blocks > 0 ? 2 : 0); + if (sock_net(sk)->ipv4.sysctl_tcp_ecn_option >= 2 || + tp->accecn_opt_demand || + tcp_accecn_option_beacon_check(sk)) { + opts->ecn_bytes = tp->received_ecn_bytes; + size += tcp_options_fit_accecn(opts, tp->accecn_minlen, + MAX_TCP_OPTION_SPACE - size, + opts->num_sack_blocks > 0 ? + 2 : 0); + } } if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp, @@ -2933,6 +2954,11 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, sent_pkts = 0; tcp_mstamp_refresh(tp); + + /* AccECN option beacon depends on mstamp, it may change mss */ + if (tcp_ecn_mode_accecn(tp) && tcp_accecn_option_beacon_check(sk)) + mss_now = tcp_current_mss(sk); + if (!push_one) { /* Do MTU probing. */ result = tcp_mtu_probe(sk); From patchwork Tue Oct 15 10:29:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836080 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2057.outbound.protection.outlook.com [40.107.105.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6A2A1EABB3 for ; Tue, 15 Oct 2024 10:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; cv=fail; b=n2Y8xfxf02EzkTojS5myUIlPvzepyyqwPUgckHl4oVs7CzU6yaga0zD6D6UWcEPFE4/fUqVQHNWnD7UHHRn7kU4SfHC2Yaq1tt93O5FkVg4onDSEF45njU/6xX17XvZkfSvTZpRYRe37QUFFp0cFmYycCIB/VuorsrGXT8wfwW4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; c=relaxed/simple; bh=tYgk/DaGzLDOtcx2pOWmTbX1aS4Ow9+jX8sXtmXZjrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=GxTecR8TRgKQDWguheWOUFtSRSMVRQO3x/DS9OIHXdnWOeCIsGtMrP+Pf2pr9ooH3UH+yrH2GxrXtUR9BknsNc0cDfBtSHlKQO+cHbt2tiApc18iDUBmzEOSVhC+2H4aLru0pzBOc+DWzm4t5/HDZ0TMhdITqrrRqaRBfZ/o/04= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=CSD9DNCT; arc=fail smtp.client-ip=40.107.105.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="CSD9DNCT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ofu2CGxABQ2eheTAdtRW/v7R70kD3368wEdZeIagXudpmOGji/UtbU4qsNgwIByshOaYylQITx/SorneIlgRGZk6Hpxm5Ip21r6yZFhDOq174lsOgO9ARCoSXB+iMnfuDg3vESplLrUOSgahaSyI1Mq2LYSb3zX8/HSwqj5Ny22ODWOiqhcxDYHyEBqNdVWmS4j9vpu++itu3C6uiUmxDoCHg+D+rGfHGRROWiNDR/UN6xleJXg6cpEZuVrfY+4qRJ9QQzQ3zU6gMPOLCrbG463nvHzk7/b7ZS9HoKf356JmXU5mLTVIMJeAJruMYPxQOVYQ0KaqW1mi1Njk6QsZLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uc5z1TX6WuXueX2v7fD8Qt8cKLaAykjsfrwwf1TxHnc=; b=f7NlbHBMwRoaVNXAZ+s0D0OYWYCCXmdYSg/Q/pUiCHd+o04i8XsSBPpn4jIiIEGdIF9XpL6RQwvdsDJIrUds9yhmzrEWl2Yu2RaWqh/0LqU3Bv34seyTzlZ88OcsDsPKd272pRjkclIFiWyg238vEpD7mD4LGpzpI8yg+42tozYL6TU5A6Ir37ohkfkpyj/TzehBB2FEsdYgfRvMtzyEB6lW4VX0106bfJvxKZ4RL71Zgw1HgTbSCacVsgjQoYPfQWVaInVqf4py9+LCBABSP6ffvmUyWVlxYyxYeJhhMQX/zxxBv9fmd616LCz1xXq32pYF/oz6RUq7jH5nyVK8HA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uc5z1TX6WuXueX2v7fD8Qt8cKLaAykjsfrwwf1TxHnc=; b=CSD9DNCTcyvPUSdteJ8JF15eRKjRozWNvU2m1vMEB7YTeOOoiJbwHs7C5+NzbAj/aBJUtSeQ6/9YgJJ2tO8e/sLVq6rg7xz7cVcRbRHx4QiOhsJIBgTY2ezA1f0CWUoqvf8Q3+GNRg8QKn6IY4mjbE/xrArnEU6hR+xkUIXsS6FUUrEmDYQxAK023bDWkui9pESajsKSnvWbbFgcEngSdk2LNlKrSIJTw3CNkeMdpIscyZegbO9Zh+kcNy5QCzVVR+NGpL8iSyS6DOP1uHmGMpgjq/6Qa465YVSbDGmV9ySy28INE2y+Z0ZZ+8xPgLrHwNLz0NJUQYzWvh6hxlyLOw== Received: from DU7P250CA0010.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::28) by PAXPR07MB7856.eurprd07.prod.outlook.com (2603:10a6:102:131::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:26 +0000 Received: from DB5PEPF00014B94.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::5a) by DU7P250CA0010.outlook.office365.com (2603:10a6:10:54f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB5PEPF00014B94.mail.protection.outlook.com (10.167.8.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:26 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnS029578; Tue, 15 Oct 2024 10:30:25 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 24/44] tcp: accecn: AccECN option failure handling Date: Tue, 15 Oct 2024 12:29:20 +0200 Message-Id: <20241015102940.26157-25-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B94:EE_|PAXPR07MB7856:EE_ X-MS-Office365-Filtering-Correlation-Id: d5aa1f8b-2ab4-4e66-fe70-08dced046286 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?1B+5SIYD1VNDfEzQvJJF0HnM2saSAHh?= =?utf-8?q?xeX1xMht4HZzGkuUU95thB+M7hFBnQGGSyqAdykcM1bAQYcyNeWQeQKMb45f+pC6C?= =?utf-8?q?mUDJLR8/3u3XLGI5a31geyuTCzhaIW6DCdjN1Ke1ld6cy+w4wycOsvqF9n4lsGEfE?= =?utf-8?q?vkTCYdaCRJ4/r07MWtFvVRJBJZB5lDFzDuRvnEGso8Kz38ui1GkxS2EX99+imN+ra?= =?utf-8?q?gk/HUtQTeNbWHJfqleBt3+M4ZD0qLeZahMoGqK4WZ7JJOb8soz2VQ9p94yltzt2Do?= =?utf-8?q?YFiqtp/rzD2OuvQQz1ICSyx4frGXWleTWhM7DvYczsObJbFqI6/IIyTn375CJjG3N?= =?utf-8?q?1gqDPV3fZx+8feXCwckkngXyR6deZVT8Fw/CJaXGcp1PSYugpEQJp4v6/kInXId7M?= =?utf-8?q?w3dAIe2gjp7JkpML8ERfEVs21FGDMIgp/qElEYD0FWw9S79Rg4BLD1elrPuR20Oy7?= =?utf-8?q?jPc/wQPoQnU2jcnvN7hn7vTPsy8fMTXWkis1jHX0QbWYpY29rwa+XVZG1mE899ItG?= =?utf-8?q?J5fpR0mtif0AsfRQ/bLDaAcHPgxa/houv7QcnULkHQ2LiDNPD5BcgLyl0QenZHA2D?= =?utf-8?q?JJhvb1sHdaLpDBq2IRNrHfCzbINuhslcoXoBFHZTdnhRDsZzv1GsluY6fgiP2MDei?= =?utf-8?q?TUDENLF0otOO1+4+Ao58tqYMcZLXSo1fPeWGtz5uXtycWhqqhNmnir9VBS9XI1Ic9?= =?utf-8?q?+uSGvlte53FUj0qCHrVmDuYGd7GthOM9mPpjWRWTocZbib2L9Og4jrtxWbbfWkath?= =?utf-8?q?2azzrwuGZuT95jBz4ZvwKdBehCvjwCdEwNBTAcm+IBRBqKA2CR6TiSsCRC1Np0cNo?= =?utf-8?q?CY4FbdaFBdN/Fie8zRUX6GdX8baX1hiWKn6Qw3RLnJDRTH0d8kFsfx2jk368L+Yep?= =?utf-8?q?MN3oqoZHHL4tFxCXIqNcZNTvB77m43uzSQdK50/ZjDLD1gPn9GrluwIz4MuARMYFd?= =?utf-8?q?+ZdDvMrhmAHYtaRSdHG9blD3Bi+OZj0ExRNcvZ39tpd1oqoqFRapcRMfmNFxr68bY?= =?utf-8?q?iRX3h0/hZRVAFg2Hw8W40lOoNxzzbjJmgb/GSdAuEuzHAIDp4czPlBML8732IJdV7?= =?utf-8?q?92ij8PzfC48GD4UeguO80QwmGbc1qywLIMsF6JiCOAxEw9DQCUCSO2MKMjqpmbfZy?= =?utf-8?q?E+keSyIq4CP15cLQC7GR+HovIKnsNswe5RkWTsPG9OoCRe1UofSo2+Cqe2ZfM8jAN?= =?utf-8?q?TzLleHPn2xZnPYBUoezqU7uZmqVhfWloyMAuGd33LeekQ1C7Q5IG4yB8hl4VXrAU9?= =?utf-8?q?uObD5s5tc3Xac2OMxs4kxNGy//xBa4DWIhrKq3ReH3j9qMUWZ/kh3XdJE5jejj6f8?= =?utf-8?q?BSZRqwmj/8Nb?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(7416014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:26.6871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5aa1f8b-2ab4-4e66-fe70-08dced046286 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B94.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR07MB7856 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang AccECN option may fail in various way, handle these: - Remove option from SYN/ACK rexmits to handle blackholes - If no option arrives in SYN/ACK, assume Option is not usable - If an option arrives later, re-enabled - If option is zeroed, disable AccECN option processing Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 6 +++-- include/net/tcp.h | 7 ++++++ net/ipv4/tcp.c | 1 + net/ipv4/tcp_input.c | 47 +++++++++++++++++++++++++++++++++++----- net/ipv4/tcp_minisocks.c | 33 ++++++++++++++++++++++++++++ net/ipv4/tcp_output.c | 7 ++++-- 6 files changed, 92 insertions(+), 9 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index e4aa10fdc032..d817a4d1e17c 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -160,7 +160,8 @@ struct tcp_request_sock { u8 accecn_ok : 1, syn_ect_snt: 2, syn_ect_rcv: 2; - u8 accecn_fail_mode:4; + u8 accecn_fail_mode:4, + saw_accecn_opt :2; u32 txhash; u32 rcv_isn; u32 snt_isn; @@ -387,7 +388,8 @@ struct tcp_sock { syn_ect_snt:2, /* AccECN ECT memory, only */ syn_ect_rcv:2, /* ... needed durign 3WHS + first seqno */ wait_third_ack:1; /* Need 3rd ACK in simultaneous open for AccECN */ - u8 accecn_fail_mode:4; /* AccECN failure handling */ + u8 accecn_fail_mode:4, /* AccECN failure handling */ + saw_accecn_opt:2; /* An AccECN option was seen */ u8 thin_lto : 1,/* Use linear timeouts for thin streams */ fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */ fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */ diff --git a/include/net/tcp.h b/include/net/tcp.h index b3cbf9a11dbc..18c6f0ada141 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -274,6 +274,12 @@ static inline void tcp_accecn_fail_mode_set(struct tcp_sock *tp, u8 mode) tp->accecn_fail_mode |= mode; } +/* tp->saw_accecn_opt states */ +#define TCP_ACCECN_OPT_NOT_SEEN 0x0 +#define TCP_ACCECN_OPT_EMPTY_SEEN 0x1 +#define TCP_ACCECN_OPT_COUNTER_SEEN 0x2 +#define TCP_ACCECN_OPT_FAIL_SEEN 0x3 + /* Flags in tp->nonagle */ #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ #define TCP_NAGLE_CORK 2 /* Socket is corked */ @@ -475,6 +481,7 @@ static inline int tcp_accecn_extract_syn_ect(u8 ace) bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect); void tcp_accecn_third_ack(struct sock *sk, const struct sk_buff *skb, u8 syn_ect_snt); +u8 tcp_accecn_option_init(const struct sk_buff *skb, u8 opt_offset); void tcp_ecn_received_counters(struct sock *sk, const struct sk_buff *skb, u32 payload_len); diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index e59fd2cabe03..7ef69b7265eb 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3339,6 +3339,7 @@ int tcp_disconnect(struct sock *sk, int flags) tp->delivered_ce = 0; tp->wait_third_ack = 0; tp->accecn_fail_mode = 0; + tp->saw_accecn_opt = TCP_ACCECN_OPT_NOT_SEEN; tcp_accecn_init_counters(tp); tp->prev_ecnfield = 0; tp->accecn_opt_tstamp = 0; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 14b9a5e63687..a8669c407978 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -439,8 +439,8 @@ bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect) } /* See Table 2 of the AccECN draft */ -static void tcp_ecn_rcv_synack(struct sock *sk, const struct tcphdr *th, - u8 ip_dsfield) +static void tcp_ecn_rcv_synack(struct sock *sk, const struct sk_buff *skb, + const struct tcphdr *th, u8 ip_dsfield) { struct tcp_sock *tp = tcp_sk(sk); u8 ace = tcp_accecn_ace(th); @@ -459,7 +459,14 @@ static void tcp_ecn_rcv_synack(struct sock *sk, const struct tcphdr *th, default: tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); tp->syn_ect_rcv = ip_dsfield & INET_ECN_MASK; - tp->accecn_opt_demand = 2; + if (tp->rx_opt.accecn && + tp->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { + tp->saw_accecn_opt = tcp_accecn_option_init(skb, + tp->rx_opt.accecn); + if (tp->saw_accecn_opt == TCP_ACCECN_OPT_FAIL_SEEN) + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_RECV); + tp->accecn_opt_demand = 2; + } if (tcp_accecn_validate_syn_feedback(sk, ace, tp->syn_ect_snt) && INET_ECN_is_ce(ip_dsfield)) { tp->received_ce++; @@ -574,7 +581,21 @@ static bool tcp_accecn_process_option(struct tcp_sock *tp, bool order1, res; unsigned int i; + if (tcp_accecn_opt_fail_recv(tp)) + return false; + if (!(flag & FLAG_SLOWPATH) || !tp->rx_opt.accecn) { + if (!tp->saw_accecn_opt) { + /* Too late to enable after this point due to + * potential counter wraps + */ + if (tp->bytes_sent >= (1 << 23) - 1) { + tp->saw_accecn_opt = TCP_ACCECN_OPT_FAIL_SEEN; + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_RECV); + } + return false; + } + if (estimate_ecnfield) { tp->delivered_ecn_bytes[estimate_ecnfield - 1] += delivered_bytes; return true; @@ -588,6 +609,13 @@ static bool tcp_accecn_process_option(struct tcp_sock *tp, order1 = (ptr[0] == TCPOPT_ACCECN1); ptr += 2; + if (tp->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { + tp->saw_accecn_opt = tcp_accecn_option_init(skb, + tp->rx_opt.accecn); + if (tp->saw_accecn_opt == TCP_ACCECN_OPT_FAIL_SEEN) + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_RECV); + } + res = !!estimate_ecnfield; for (i = 0; i < 3; i++) { if (optlen >= TCPOLEN_ACCECN_PERFIELD) { @@ -6410,7 +6438,14 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, if (th->syn) { if (tcp_ecn_mode_accecn(tp)) { send_accecn_reflector = true; - tp->accecn_opt_demand = max_t(u8, 1, tp->accecn_opt_demand); + if (tp->rx_opt.accecn && + tp->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { + tp->saw_accecn_opt = tcp_accecn_option_init(skb, + tp->rx_opt.accecn); + if (tp->saw_accecn_opt == TCP_ACCECN_OPT_FAIL_SEEN) + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_RECV); + tp->accecn_opt_demand = max_t(u8, 1, tp->accecn_opt_demand); + } } if (sk->sk_state == TCP_SYN_RECV && sk->sk_socket && th->ack && TCP_SKB_CB(skb)->seq + 1 == TCP_SKB_CB(skb)->end_seq && @@ -6900,7 +6935,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, */ if (tcp_ecn_mode_any(tp)) - tcp_ecn_rcv_synack(sk, th, TCP_SKB_CB(skb)->ip_dsfield); + tcp_ecn_rcv_synack(sk, skb, th, TCP_SKB_CB(skb)->ip_dsfield); tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); tcp_try_undo_spurious_syn(sk); @@ -7476,6 +7511,8 @@ static void tcp_openreq_init(struct request_sock *req, tcp_rsk(req)->snt_synack = 0; tcp_rsk(req)->last_oow_ack_time = 0; tcp_rsk(req)->accecn_ok = 0; + tcp_rsk(req)->saw_accecn_opt = TCP_ACCECN_OPT_NOT_SEEN; + tcp_rsk(req)->accecn_fail_mode = 0; tcp_rsk(req)->syn_ect_rcv = 0; tcp_rsk(req)->syn_ect_snt = 0; req->mss = rx_opt->mss_clamp; diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 75baa72849fe..cce1816e4244 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -490,6 +490,7 @@ static void tcp_ecn_openreq_child(struct sock *sk, tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); tp->syn_ect_snt = treq->syn_ect_snt; tcp_accecn_third_ack(sk, skb, treq->syn_ect_snt); + tp->saw_accecn_opt = treq->saw_accecn_opt; tp->prev_ecnfield = treq->syn_ect_rcv; tp->accecn_opt_demand = 1; tcp_ecn_received_counters(sk, skb, skb->len - th->doff * 4); @@ -544,6 +545,30 @@ static void smc_check_reset_syn_req(const struct tcp_sock *oldtp, #endif } +u8 tcp_accecn_option_init(const struct sk_buff *skb, u8 opt_offset) +{ + unsigned char *ptr = skb_transport_header(skb) + opt_offset; + unsigned int optlen = ptr[1] - 2; + + WARN_ON_ONCE(ptr[0] != TCPOPT_ACCECN0 && ptr[0] != TCPOPT_ACCECN1); + ptr += 2; + + /* Detect option zeroing: an AccECN connection "MAY check that the + * initial value of the EE0B field or the EE1B field is non-zero" + */ + if (optlen < TCPOLEN_ACCECN_PERFIELD) + return TCP_ACCECN_OPT_EMPTY_SEEN; + if (get_unaligned_be24(ptr) == 0) + return TCP_ACCECN_OPT_FAIL_SEEN; + if (optlen < TCPOLEN_ACCECN_PERFIELD * 3) + return TCP_ACCECN_OPT_COUNTER_SEEN; + ptr += TCPOLEN_ACCECN_PERFIELD * 2; + if (get_unaligned_be24(ptr) == 0) + return TCP_ACCECN_OPT_FAIL_SEEN; + + return TCP_ACCECN_OPT_COUNTER_SEEN; +} + /* This is not only more efficient than what we used to do, it eliminates * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM * @@ -704,6 +729,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, bool own_req; tmp_opt.saw_tstamp = 0; + tmp_opt.accecn = 0; if (th->doff > (sizeof(struct tcphdr)>>2)) { tcp_parse_options(sock_net(sk), skb, &tmp_opt, 0, NULL); @@ -879,6 +905,13 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, if (!(flg & TCP_FLAG_ACK)) return NULL; + if (tcp_rsk(req)->accecn_ok && tmp_opt.accecn && + tcp_rsk(req)->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { + tcp_rsk(req)->saw_accecn_opt = tcp_accecn_option_init(skb, tmp_opt.accecn); + if (tcp_rsk(req)->saw_accecn_opt == TCP_ACCECN_OPT_FAIL_SEEN) + tcp_rsk(req)->accecn_fail_mode |= TCP_ACCECN_OPT_FAIL_RECV; + } + /* For Fast Open no more processing is needed (sk is the * child socket). */ diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 22f6cfba5b27..ee23b08bd750 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1069,6 +1069,7 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb, /* Simultaneous open SYN/ACK needs AccECN option but not SYN */ if (unlikely((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) && tcp_ecn_mode_accecn(tp) && + inet_csk(sk)->icsk_retransmits < 2 && sock_net(sk)->ipv4.sysctl_tcp_ecn_option && remaining >= TCPOLEN_ACCECN_BASE)) { opts->ecn_bytes = synack_ecn_bytes; @@ -1151,7 +1152,7 @@ static unsigned int tcp_synack_options(const struct sock *sk, smc_set_option_cond(tcp_sk(sk), ireq, opts, &remaining); if (treq->accecn_ok && sock_net(sk)->ipv4.sysctl_tcp_ecn_option && - remaining >= TCPOLEN_ACCECN_BASE) { + req->num_timeout < 1 && remaining >= TCPOLEN_ACCECN_BASE) { opts->ecn_bytes = synack_ecn_bytes; remaining -= tcp_options_fit_accecn(opts, 0, remaining, tcp_synack_options_combine_saving(opts)); @@ -1228,7 +1229,9 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb } if (tcp_ecn_mode_accecn(tp) && - sock_net(sk)->ipv4.sysctl_tcp_ecn_option) { + sock_net(sk)->ipv4.sysctl_tcp_ecn_option && + tp->saw_accecn_opt && + !tcp_accecn_opt_fail_send(tp)) { if (sock_net(sk)->ipv4.sysctl_tcp_ecn_option >= 2 || tp->accecn_opt_demand || tcp_accecn_option_beacon_check(sk)) { From patchwork Tue Oct 15 10:29:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836090 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2048.outbound.protection.outlook.com [40.107.21.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2361F1EF0B2 for ; Tue, 15 Oct 2024 10:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; cv=fail; b=ND7kwNVqYOgsu81Erk49pWtx95tbkoXVBy3FJEqyMW9FcbeU9tT8bIi52EXI1QBUaGG+CDgN9OyY3QWSJSxzs2goW/9mm4py7gLsi10o3RLkIQYtk4YlJkHNA5OmpH2fWx5O0jOD4EvafjEPmMgXGAj1CrYZGjDiYmYEAsvfBLg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; c=relaxed/simple; bh=l3W49FJ7X3P04GpewYlcqTWRoP8Xre8nK2J7Qt/y5fo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=IwVA9gRFzkFVjadOfwJxwvg3fp1ScSCcqIpYiemUH7fd/HBW7/W9hB1QuIKvSH82nxjMXvfKG3rPXLB512fd8vQ0B5IvP+GynCHLY2D1jbS8rVuA1Usra0vHbpFfYuErYmU4kQJHRwkv0xOA3W8iVexCGWJDRlGop+CBTRQmy18= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=PNiTohpm; arc=fail smtp.client-ip=40.107.21.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="PNiTohpm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M+847yXSFzA2YGsMZfppSULUYv1w4MvDq5U1aY1m/HlilYeT1KRgrI3lw6v1bkgSteAvhjy2GRhXcETliwjb7WUkR0ciuNrfAQa319EIB/E5NueXvcgWzBoELcNIgk8jo2GbKGBOvokKZOktOS4bTO5vY9cyI8kx50uTABdF+MX7ra3Yl0XYxfSvhfmlIc58zmwODXZ2wATXxEdDujqTblHwQlsEtbyZMif3W20CbvOV8oDMoZufKe2Y104QNYS/sy20SAuLT23Aj5QMxyiqNX2wx2PXGZze7iCSWyXStYmULIpAEBJNHaklVdGeWQ6gDQ/tsmxhiAAL8wJEQhPIIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f/jO4hr0m/M8yM9w8vziwXR2crAOIvRN4ZIq5v7IPvM=; b=d7UREbmhnkO+1TFPVPaXfPqgMlTWySegYsf/GDX/BrrOEKnTiOEdRuqTrQLcyAaZn6oF+pJspvW7g50/IqaVfdGp2HwJm0vXTG0zjrHWkad5AfSiCPkRaZxLSVDfruf+oSqYWeO66ppyFtvCV0MuryYGqfMr2R4LS9lriEEkzld5f36gwqVZ92WI9FISbOzqLCdKWJ12fjlCbrUnH3/MytYU9W12WUIeKnUI13GYRXbHwaqqvmjJXvu1Y4AQERzjWeNhZ6lg966AmVcTNNulecHLZTxaM2I54A890VDzJQmF3/5mcUQpd9qgmbPkOXaASIN0zP5lAIXtDPZXPXU0SA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f/jO4hr0m/M8yM9w8vziwXR2crAOIvRN4ZIq5v7IPvM=; b=PNiTohpmJMqrlPC+WBRF6vdcBDTrx7Q9+Rz8Vnd5vir09nRiv2EUs5keY9N2+v14U2DdcXlhQPcENlVv+sMY9W+faVV4negZXcdx45iGhoQHo06IIjarieuXn6Pbn3A64vji6vGiHI6P+AH3R9GYdhSIvPqiwgBW+LNySW7i1ffbt5ZnBWaSG241wcMUeTGHoFglahTjtrcd5rdRc6XXUyJzATstVjdwLDWKwuecrnlHnlmRZQh17wc4eZ/YctbBrMDgEs1KoD5w3DeBAia/oMmWW02nOEiv5ZBYRDjUmt9HqmbYOASUZ1WnnLluVp1Kncl6XPUbT17AQt+MpL2zag== Received: from DB9PR06CA0002.eurprd06.prod.outlook.com (2603:10a6:10:1db::7) by AM9PR07MB7090.eurprd07.prod.outlook.com (2603:10a6:20b:2d0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:28 +0000 Received: from DB1PEPF000509FA.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::42) by DB9PR06CA0002.outlook.office365.com (2603:10a6:10:1db::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB1PEPF000509FA.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:27 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnT029578; Tue, 15 Oct 2024 10:30:26 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 25/44] tcp: accecn: AccECN option ceb/cep heuristic Date: Tue, 15 Oct 2024 12:29:21 +0200 Message-Id: <20241015102940.26157-26-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509FA:EE_|AM9PR07MB7090:EE_ X-MS-Office365-Filtering-Correlation-Id: d4031417-2146-40ef-30b4-08dced0462c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?PzT88987opU6Tz4qyfj5m5EBgbDD2vX?= =?utf-8?q?kf0NDOKkYz4oOeLz1EbDM5QsDzVwordrQnsPJAdfvgwU5dECyz9ZZlk8TcQbUoqGn?= =?utf-8?q?jf+w1Wp91vG3B7QXZgJZAlbeGqoAxGepUvQpYxmw63HYRaqIMtzByCr1Wh7PV/BW6?= =?utf-8?q?5uPwuLAUdDbz70GtYlA2JHDMOu9qyLRS3bOvSuZJTkswqLoEW/6igB5wOTQHK6FZh?= =?utf-8?q?pi2OnLQwKkfAUIubui8wBRrnaP+5UIsCr6WOWp+0gFtDpdha8sbmKCmW/GkrdKkB5?= =?utf-8?q?jm/7/zeTt+o/k1aXIDNrMgCqJtKkFky9w98IZYGTvelM7eh50HyLbU3M62kdZGaX9?= =?utf-8?q?Mxnuw7jZH/XvrD6kulz6B9oL5ZwE8AA+VUh/oaOQQSwpdtXhNszVQUYaCDtfA/9LD?= =?utf-8?q?AnmOkd/ZnhBpAdLUL/rKxIX/rHe9DMPLP3h6wFQOQcelquMXNV5GpvunFYpDm9VvD?= =?utf-8?q?bqZ14ro3dZ0rBhPFPNONJlFVLdpbykbuR1E1jLTtXlNjTzI4GEmJIPBosj9znA99c?= =?utf-8?q?rh4ox6Aj1QkVXIeQa1bMhxbBCFfB/FXrF6uCM7Oq03UAoZUwaujHTwXwwXqXvxxON?= =?utf-8?q?NGB0V1SbYwsYaf4fLBlkJLKpLyOBbqTde20FRY//9/PgcNcGjY1DSbivKM5Wcoqzt?= =?utf-8?q?7wYRNk7AX7rGD/P2P0WOpkXr1WtiOL81yWgLu2DqmeZ/BvGdtle+WfnQmjWg33bow?= =?utf-8?q?LOkqlqSgwxeNNqGRZPSnMjb71pOwgbvsUvQB1Fc2fZS5QC33PoCvn7yRXK5M5SRTC?= =?utf-8?q?eVQx0DsDR4KK2b9ZEKVQyeMkDqaaTYGYuumDDkkRtCAxDPD3I4ekcdrKPXn2YBwIt?= =?utf-8?q?B0odglx+iWbeG1pd88eSe2gxmfIQCdZrZM21pP0TSesDaz3XE563gGU0HLuwgEzWp?= =?utf-8?q?6A+Gb6Eu2tkQXPzJ83eTk3dL66vxEpp4lhAYmNfugdp8CqND/1175Eu5suBAOFvLL?= =?utf-8?q?btxs7oF7TaiZYdaZ/Jb5NGfz+rGIob+IwjR4WiZpaW4DSfN8+NignBcPRuazH3yxu?= =?utf-8?q?rSjoce/ckWNIW4XMSyFT/AQX586UvxaZwdotR5LmPL1s+VAnAcd0f7X6ckiRFeMrT?= =?utf-8?q?IroUjoRRIoiYQqTtlHWcaNX9YgyMnXUfqMrhP/cWYLIqz1V/gJP6PVJAcPAtEZ6XM?= =?utf-8?q?ijCUlgk54f40+qQX5L6IhHh1MxiCQTh8coX38qivUTIE0M4bJ1Ef3n33wthb+0G5f?= =?utf-8?q?XHdjsk1AaeKb3fblQE75ZT+7/EYYT15e0JKfR4SzSlTS9TYBK7IYI7uJ4DBaOYlhw?= =?utf-8?q?h6NYOru6YKsqCFiZB8CitLFuYmxy1VaVa1R0H5G3u5EmaPk7ck/fZBbn3+tJNE8eg?= =?utf-8?q?ERRF7e5eQs8J?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:27.0856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4031417-2146-40ef-30b4-08dced0462c6 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509FA.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR07MB7090 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen The heuristic algorithm from draft-11 Appendix A.2.2 to mitigate against false ACE field overflows. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 1 + net/ipv4/tcp_input.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 18c6f0ada141..a2f6b8781f11 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -242,6 +242,7 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX); #define TCP_ACCECN_MAXSIZE (TCPOLEN_ACCECN_BASE + \ TCPOLEN_ACCECN_PERFIELD * \ TCP_ACCECN_NUMFIELDS) +#define TCP_ACCECN_SAFETY_SHIFT 1 /* SAFETY_FACTOR in accecn draft */ /* tp->accecn_fail_mode */ #define TCP_ACCECN_ACE_FAIL_SEND BIT(0) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index a8669c407978..79e901eb5fcf 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -669,15 +669,17 @@ static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, u32 delivered_pkts, u32 delivered_bytes, int flag) { + u32 old_ceb = tcp_sk(sk)->delivered_ecn_bytes[INET_ECN_CE - 1]; struct tcp_sock *tp = tcp_sk(sk); - u32 delta, safe_delta; + u32 delta, safe_delta, d_ceb; + bool opt_deltas_valid; u32 corrected_ace; /* Reordered ACK? (...or uncertain due to lack of data to send and ts) */ if (!(flag & (FLAG_FORWARD_PROGRESS | FLAG_TS_PROGRESS))) return 0; - tcp_accecn_process_option(tp, skb, delivered_bytes, flag); + opt_deltas_valid = tcp_accecn_process_option(tp, skb, delivered_bytes, flag); if (!(flag & FLAG_SLOWPATH)) { /* AccECN counter might overflow on large ACKs */ @@ -699,6 +701,16 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, safe_delta = delivered_pkts - ((delivered_pkts - delta) & TCP_ACCECN_CEP_ACE_MASK); + if (opt_deltas_valid) { + d_ceb = tp->delivered_ecn_bytes[INET_ECN_CE - 1] - old_ceb; + if (!d_ceb) + return delta; + if (d_ceb > delta * tp->mss_cache) + return safe_delta; + if (d_ceb < safe_delta * tp->mss_cache >> TCP_ACCECN_SAFETY_SHIFT) + return delta; + } + return safe_delta; } From patchwork Tue Oct 15 10:29:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836081 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2070.outbound.protection.outlook.com [40.107.21.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 212611EF087 for ; Tue, 15 Oct 2024 10:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; cv=fail; b=mHhE+DM6XT64XW170o4QWZMPYB/0xtxgA2V5ZC2hKjPas4DxiHbmTMRXfH555lxGID1SAGZt434R44JBrQA9V8Ps0KQ/Q947p3izKAfXA8du9wmM6yRrluNrJ9L/ULShIk375xeL04KKVps5ASsMeBNYP3k+de6xKuio3uIbxoc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988232; c=relaxed/simple; bh=Gn1/UHy4PJ7gn76PcQtxLIFaOwAKdGOwbNQmuf3ct8k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LBUQOpV2RxFIr9o14GOFGBong82d4HJRAlavYx48DOhYI2TIuCZm+0rKft+bbL0Vsgdb0b0oDR2nQu5TRHbBXw0GBUDnYq+/wDodLP2+y2LF2fERcIVu3bD0BGlxAqdouZUcEKl5ySaY52U3svGOHnVpO+6V6+Juefkemthcx/w= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=X37mKPSq; arc=fail smtp.client-ip=40.107.21.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="X37mKPSq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w2f7DYVW5JxChNdSl7zpSdzaKoAk+Lckd124KF1bt8lxNjUO4n0qcvT7zV9+GZfdsBa5IO4MTcy8OayiU949ZmDmh4f2EHML0TZzjbu/+RosgqTglcygimPGIvyxwxX9GIoxn9d2ocaXQi4sk0KUe8xKuaUQVgQVStYlNF6Jj8xy6kH9cGQXlYXANimi/5Y4g37AlyuzSrXaUJKmagq7FFa0wuHHzl1O1Cm1Y3oRGzr9M4WMj5WgdJqv2JPp5ROoEbopQpX1O8b3RfPwsGKxBMQUx86bD5sxs5dHyvlcSLP0mBrB0nGoxyyNq/b+Qq+lh2rb+P/ahY3j4m/ybN4Eyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j9WwR2Xv4FIHJwuPLcvHdHKdLc6GIQYEULQNRRvPIyo=; b=Z6KT5WqeULtzjtiq+RYTK2hYF5BWvw6vEHSZdkGnUnXtJx3oLV8vfw3qLOeOZ6saM6x2WlWWTzDMS60TqNIhyQdhpK7y0KmwY1fNBrC5TFsO3JRqcfHuyj5tYxSSiKJPnc8o8UkpYyua1hF62qNJPyIBmxYNhNKMxlOp4Zoly1SbL9HqMZ9mSUwibwbG/JyyJCY9td4lrrFtKk8OokLS5oUF0zHraqxwSba9kMsu0cekw728YrOclZiN+CSCDNocQS+QH/9d/7q4JQAB0BE7oxab9tIJcdf/eMH+FdgYerlRiIMBQZfyoMqcJTpkE+BSuDqDX3I9xLyI7t+1KY7Ygw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j9WwR2Xv4FIHJwuPLcvHdHKdLc6GIQYEULQNRRvPIyo=; b=X37mKPSq4d5phqIkZXwiE4RTFP06BrLEYfrClqRlKxecupQdt9FYVmbbfuDrEJVPHvra1+F/jjyGuZlkGJqHpJ3McRqRQzfYalgqLrvmmDX6yEWbZOjjw1u+QwbTyIje8YgjuQg8DTDlfPcNLBXzwxtweuOToPME/wtk4651qsxgaHskpw2IZxv0wobyVx0YZJJfDOGrghEW+RnKjODTAf/MZ+qGicpJ0TvuEMDH1Bob4N6vu9vr8As4GrZCsZvb82WOrWmA276CXMICUfeP6mEqV8aY/AmXqVdLfX0aIkQr4NZXSNfnoW5Krl+GIFHWLhEEfhuqVprJCKYS6lDj8w== Received: from DUZPR01CA0066.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c2::14) by AM0PR07MB6273.eurprd07.prod.outlook.com (2603:10a6:20b:144::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:28 +0000 Received: from DB1PEPF000509FD.eurprd03.prod.outlook.com (2603:10a6:10:3c2:cafe::f) by DUZPR01CA0066.outlook.office365.com (2603:10a6:10:3c2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB1PEPF000509FD.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:27 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnU029578; Tue, 15 Oct 2024 10:30:26 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 26/44] tcp: accecn: AccECN ACE field multi-wrap heuristic Date: Tue, 15 Oct 2024 12:29:22 +0200 Message-Id: <20241015102940.26157-27-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509FD:EE_|AM0PR07MB6273:EE_ X-MS-Office365-Filtering-Correlation-Id: 9313b7b3-7caf-438b-5a44-08dced04631e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?f8911/mmppqQ3it9uFgRrMCWQKfGWVD?= =?utf-8?q?zhu3HSz+SW891Y1x9APvjSKukKV8RgI1OONJCViq0jq1sVeC3qq2gy9PQRq+rV8Xs?= =?utf-8?q?UruCudS/Y85PC3xiv6sps0pyHCUZY20B+zrIAjKHQ0kgynWJAF45w8pvtOi0K/WoM?= =?utf-8?q?CSbZlwswEtaTbjc/5Kl3rz8aQSSWWLuM5s/7y1hi6xxaPxDrqIMkcLXYj/buHeWHG?= =?utf-8?q?WyhE2SS9KYJA0MksYINS3ghQWXQePaCedSdiH3CiBTpb7GkAQNmiPDhuRpkZbQnQG?= =?utf-8?q?VfD4cGFCf17E+HyuK0DiGIZnkw1y/Qjdaiod+glxgfZyKC/3zqAaq1Xee/RyjC5tU?= =?utf-8?q?W6xmTeXus9UW1U+nuzITRMM9dXBvaWTm/sP/IW1deMVNAMQUS/Zu2fc8iNQ9sgSGi?= =?utf-8?q?NmOacbqdqtJH4efCHcD6kYReaBjOTgeo8g71vf/avajnAJUt5LM6xk5CMxmFN8t0J?= =?utf-8?q?WZv7bdkGShiZmuV6ijDQi5Pwme700ZjOC7VxV2EA9pJPSsfEnuaIE+/tM0Tflqg3j?= =?utf-8?q?J2Q2tXcv+RwMMQUeg8y/nHAWjXUDqf1nFsQWMmX9EImmzNYiK7yRy9ZnDrrKFmB54?= =?utf-8?q?+r4HD65Ruue9g/sHRhQuxTOCyADoKyVxJS19PnUN+iNzIyb6XImfRPXTIrItFLJPo?= =?utf-8?q?SUE44pSDW1z6qDb6puV38y1cCAqXKApOKmmL7mY7TI/8wFk3Ih9jUH8qFTNYxu5e8?= =?utf-8?q?RTIAlivmRzv/N9rRZXHP5kmJPGtJva1DPgj4WsIQACCc+kTIcJZ9aqAn07EzrYgP2?= =?utf-8?q?13lAAEq2cZb2LdWXJ1BcrwWtfOmJiPrHlFf/JsyWJhIDUVgkDqXUpdaZ4sq6DHAQI?= =?utf-8?q?HpK5FJ/n/E/kn0iXlcgpKhYO5HQiSfxOQbCOKs+fR7azI+Lwf5NgPq+wAL5b1+5HB?= =?utf-8?q?/PSzFKdcFpEAbGbLP/OOi8cQuyruh5EE76xWFddO3nArQNuvUFVbQIrmWsGJFgh7f?= =?utf-8?q?1ztapeGmU8xFRTdpcXGzT8xQVZf0wqDM9G/91nbHkmK0K047+edh/82Jmw0aZCSBr?= =?utf-8?q?da0Z56dW7JOotf+M2hug/KfUQaFR78JeDzgM3PFYjqk1Oc1VrACd/ZvznjzTkJOCo?= =?utf-8?q?rAuNxbqGLPO43zjm4bxMxWjkJYGGFN5pIrjlFDwCnWzf7ErzGjeX6r9rR8a1S0HKI?= =?utf-8?q?ojv/j8M5l99NyqsJSPN1Vw0jAaUX3pbgWCq7W3T7QdV3JzOW2ADma4YH2uoGj9DH7?= =?utf-8?q?BNFqb7b+QOY4AehwAv+G2uQ9ZBoXfeComDXqoUWJYWLFY2TMe5kzRADBxrSwgPAmP?= =?utf-8?q?iceyWWH+F9VNQJtHYMCbce1Z7+KOquSh7Lad1/bbxkPSYYoaRWnjMZrihvkbYSmr4?= =?utf-8?q?AQ6gheiMxTLY?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:27.6790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9313b7b3-7caf-438b-5a44-08dced04631e X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509FD.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR07MB6273 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Armed with ceb delta from option, delivered bytes, and delivered packets it is possible to estimate how many times ACE field wrapped. This calculation is necessary only if more than one wrap is possible. Without SACK, delivered bytes and packets are not always trustworthy in which case TCP falls back to the simpler no-or-all wraps ceb algorithm. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 79e901eb5fcf..ac928359a443 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -705,6 +705,19 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, d_ceb = tp->delivered_ecn_bytes[INET_ECN_CE - 1] - old_ceb; if (!d_ceb) return delta; + + if ((delivered_pkts >= (TCP_ACCECN_CEP_ACE_MASK + 1) * 2) && + (tcp_is_sack(tp) || + ((1 << inet_csk(sk)->icsk_ca_state) & (TCPF_CA_Open | TCPF_CA_CWR)))) { + u32 est_d_cep; + + if (delivered_bytes <= d_ceb) + return safe_delta; + + est_d_cep = DIV_ROUND_UP_ULL((u64)d_ceb * delivered_pkts, delivered_bytes); + return min(safe_delta, delta + (est_d_cep & ~TCP_ACCECN_CEP_ACE_MASK)); + } + if (d_ceb > delta * tp->mss_cache) return safe_delta; if (d_ceb < safe_delta * tp->mss_cache >> TCP_ACCECN_SAFETY_SHIFT) From patchwork Tue Oct 15 10:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836089 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2041.outbound.protection.outlook.com [40.107.22.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBFC41EF0A2 for ; Tue, 15 Oct 2024 10:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; cv=fail; b=KHDwmPOKLWXHZcKa03gZtkJ85KEMEXlwtk8/mpQ1+4cdqBJG+n3wr7Lu4wp0Aw0nr5DBVS65ZgRrMg0o68+thuW0efIjT+jFgwGPcnQDvlQvlL7L5jbt6DTgClyVzO0u6XckDz4zxZUk79JFzvWjQCRpahRx3njUHmkBfIQSgZ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988234; c=relaxed/simple; bh=pUaHhC59Cj4Z0dvaLCB5XW/N+Y4wfCBDFoLnGSC8I1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=fUBrb81TMJRbkMF14YcOkk1x3qvJoQrYO3oGgRcpe/SeGlB4AC6ZFmO7KWQw6toSbNARVTkmaN5WZHhslqU9lJ6CSCpJLqOa4TqOSP/lJdTq0w2xPi3JMdndpVLuCw8ZQx2JeP82gEXKx4mNEdgEKPK2foakDRWq5S+WFWOXLfI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=a55IT0nX; arc=fail smtp.client-ip=40.107.22.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="a55IT0nX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dAMHAu3rcgq5NzHeY8rrhv/GYVJBkeg81yS2nFZ5RhSyG5Z65PE5xkZYfqJLIod0lZPMan2EAx0bi7ZXJhFpwht1DzjbXHuEzd7HZEfXIK5suvKUKVf03yNgvGzXhaKwyROZTZPMQZjiJEEatLOr2B6VLi8OZM4flep7HT6C99T6ptr7PqmG0yUUnmoegFIZUmD5nPKB9mrYRxqE521jGNxkNsepUTxa/3CfroFClTBRh9OXYDVPRMTvgNhR0iuegqYf3mF2ED399pKd1EZRFVMPRCq4j1+Rgh25uN+wFZUz81SFJ2IQEWopgsBa4Fd5JghwdvKJWj8vxrHiF8cTPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zDNh7T6Ap1f/pvurbbNlCmXyYPjaNfCvCL6bLAYthcs=; b=qk2tqRL8gL1V13RhLfXEKuYgA7LZUjoLit9y0+yvEREOxX8TGKla29W1MeVZOMj0JustxBKM+OHVVYioYcg5Yd9vHjImtiy9F0XFEDf6trLSHOjJqMxvM1Y0fqXo9i1zdYN/B/5DDI/ybLx1cIUOsydDSX1abyhl/Hd9Fcwo8s0vzet9rrF4fACmieKIJLn1X+t38QahB03PARK7N7aNuZX1qfsIe9UkH4FfmR6skEPv/XRaeAfakR/F9PuSLe9kYR2Bv/ueAKe5YIZfmnjvc239aCTqhMg+lW2sXKs2T/Jh1guzR5/L6rjhQxD2WBiCApSs/IfR85VT72SQoH3HzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zDNh7T6Ap1f/pvurbbNlCmXyYPjaNfCvCL6bLAYthcs=; b=a55IT0nXVYxRVixe9Lu3gzH1B4xOPr2z/Z+IB1wRUhR6ao+UtBQuC1O2crFscCNEjyEB4FUkSw7+Ci+CCOArO1aQpXi1Ql9TYzqbxRWmRmEBnSk2RwIlj/CdZ6ybAIWut8YXYp9ERYj874aAXxgXGEsH8YD/BkmM0c+3FnLffAsSYF0cU4b00VH/DB08Na1KIH9SRZcIk/Odw9UnIQj+wXiMdhBRa5efT9bjrNkChEwZUw9lXA+GK5MUfPSuW9rtDFlFddGqV+q+79V2+lYbiyTh3p5uuCIYHoiYhwxg8YWWI49ZTnhVJxLVq1v3i7x6gHDn40ST/p484rO7crEGTA== Received: from DU2PR04CA0292.eurprd04.prod.outlook.com (2603:10a6:10:28c::27) by DB9PR07MB9391.eurprd07.prod.outlook.com (2603:10a6:10:461::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:28 +0000 Received: from DB5PEPF00014B92.eurprd02.prod.outlook.com (2603:10a6:10:28c:cafe::3c) by DU2PR04CA0292.outlook.office365.com (2603:10a6:10:28c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB5PEPF00014B92.mail.protection.outlook.com (10.167.8.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:28 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnV029578; Tue, 15 Oct 2024 10:30:27 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 27/44] tcp: accecn: try to fit AccECN option with SACK Date: Tue, 15 Oct 2024 12:29:23 +0200 Message-Id: <20241015102940.26157-28-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B92:EE_|DB9PR07MB9391:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f3738c9-f5f9-4cd7-c429-08dced046379 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?rjbwQP5Kid0uBZ30763roextQOb3cPM?= =?utf-8?q?2gxlyambFwio0Cx8shBIlHpT0MY8zRvJo5+dw2oUnrQ/lxLw5rvabmgDu3P6onjh5?= =?utf-8?q?QXIiBi7rgTZWmFSEV4csS3RsLfe96GwOBpU2dHzZ4c2ENPyFmNmyg1PQSFvZBN4IK?= =?utf-8?q?gL9BDjaSqycOnyj/29sv+BcrIRSUpEZ8utlmDPxvgOqSX65lX9XqW+aijf5jbYpBM?= =?utf-8?q?pAYpyqnwFcwCLiw/lbU/ihAvR23x8A6eXigANYjhjiHLfBiUZ5Gf5zm99YqSJw17v?= =?utf-8?q?QoWglKxg4pDTZORCrQjZ9GuZ0n559gVh8MfM7OAUmaLLPGXPyybPDUMZh+H27HF52?= =?utf-8?q?JsxEBFRt084HtcmJvJsLA27+DuhKgsuBFuqTbTU0s2R6LYaucyTy2Cpl/m5UQeWFI?= =?utf-8?q?0kfTRYPwJ7+7uGUYwK1gfRaOQ4WCSjBW0AkOh7CsBsDMcuFXNnzYstVh2ZvJpzruU?= =?utf-8?q?swcBl46bxyG+V4rRU7flM0KAuQ7k7d19DIKkJiGzdSxmx6jLPRPyK2BpFIqRVevyM?= =?utf-8?q?pw/+6cV9nub4xOqqwUIPcGvEABDmrN0R4onwPsgKkHofKpzLYLiR1dcRJaUEm7fzV?= =?utf-8?q?Gg9nNNT/EJfNdU+mQ4uYVcUQm2Krf2gTEM+4vT/YNBWdGAKQvHliqka5mzgvhxKZa?= =?utf-8?q?5omt5bgz2bYkTBomwafvY3ikiTpnXMy5TIob+NQjjbHHdjpcQSGh6RTIIc+TF3UKv?= =?utf-8?q?MsJ3E+hWIuqtxrgmBMZnCRByPQ1YoRaSNdvpj4aE3+t9yWMhLriR54jwlVAT28dGP?= =?utf-8?q?5DfhN7747on4JqV8hb6CMMC+00qkkv3Y+kk0Wxlw33n30oial2g3AsvZE3ou8Omri?= =?utf-8?q?JkI+7pCSo2lqHvZ0AMuMFz4RuW1LzevSdxSEcRkqD8mfsbWBuuuFMjUSov3WCLWjn?= =?utf-8?q?IOKS2omQkvaW0knNedOVRo24DsCKrXGlGXEaUk+/1TpyMbZgtpc7Trr9CJR/YjK08?= =?utf-8?q?wgCcZZhfKwpVxDB+srRPwqN4xCJUSJi4erkVIJgj1EiJnSyB2dzg9kSXTiD3AOrps?= =?utf-8?q?ZFHGuoApItOwxEtTqk8BL1rY1ECK42gyMk78P9wHYeHJ/BU3KEf3K+VxaBGv/V8FO?= =?utf-8?q?MfB3qFppl3CnMcjrqtpjx23hrMPRcx2i3wrDPq8h3BkwK1w0KlsyDfo+0cmLeV3XX?= =?utf-8?q?cjHIbS68qGfCV17Nv17VnaYLqS6pDxBUIK2/nWbhlob5dctl4SB+hx18N0dkVJQ+Y?= =?utf-8?q?VU2Hst4zrTRL0oa45zedbFtik8MAY5QXnl+Cznh8O85dnTYJK9LunJcuRsL2wHdwT?= =?utf-8?q?u4JxTZHE1Hv9LQ/1cvSmMq156ohweNBCYW4EzCkIMlC2J8YphSjQ9CY65WQTBqqJF?= =?utf-8?q?qlDczyYGKwRT?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:28.2625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f3738c9-f5f9-4cd7-c429-08dced046379 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B92.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB9391 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen As SACK blocks tend to eat all option space when there are many holes, it is useful to compromise on sending many SACK blocks in every ACK and try to fit AccECN option there by reduction the number of SACK blocks. But never go below two SACK blocks because of AccECN option. As AccECN option is often not put to every ACK, the space hijack is usually only temporary. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_output.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index ee23b08bd750..663cdea1b87b 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -968,8 +968,20 @@ static int tcp_options_fit_accecn(struct tcp_out_options *opts, int required, opts->num_accecn_fields--; size -= TCPOLEN_ACCECN_PERFIELD; } - if (opts->num_accecn_fields < required) + if (opts->num_accecn_fields < required) { + if (opts->num_sack_blocks > 2) { + /* Try to fit the option by removing one SACK block */ + opts->num_sack_blocks--; + size = tcp_options_fit_accecn(opts, required, + remaining + TCPOLEN_SACK_PERBLOCK, + max_combine_saving); + if (opts->options & OPTION_ACCECN) + return size - TCPOLEN_SACK_PERBLOCK; + + opts->num_sack_blocks++; + } return 0; + } opts->options |= OPTION_ACCECN; return size; From patchwork Tue Oct 15 10:29:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836093 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2082.outbound.protection.outlook.com [40.107.22.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A7881EF928 for ; Tue, 15 Oct 2024 10:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988237; cv=fail; b=sYmx4wLudoi6Ks7v6xRUspwlhCoMusrP4/tCwtmHBO+9uyXu7hkUJ8rTtw7PGMFjW+Ny48ENUhK+lyc3byrGQ5F/85kkwfiIATC2frlt5ApSNou2iis1Kz0KQfDCUbrupcVeCva2NOsue7bxN8pqpsX/pJruZ6mH475flUVSx5Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988237; c=relaxed/simple; bh=m7ZFbhE+q6Ubo9equZlDNf2HvkGNHhW9Gqn/b1++HCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZV72nfiO6aj7x9jIsA5jgFCdbatV9QBj89yLCR4eYX6i4vOQe37pRo6p3YykolQokxENvXH5ukO83PaIpz22WkENRuNwOWhnb6gQ7C2kHHPTh0kl2MJ1RCxEoAD86ADFGOq0qGPKCZTOncmkx9UJrWfc+9xTXcWJ2IkUPFRo2fA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=o72X9GUO; arc=fail smtp.client-ip=40.107.22.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="o72X9GUO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S1A7rQuy112l8Cc1hFVdab/j+muAgN9nK8wDJhEf84kNlVIU4lPNajGkFwfbqWVY1A8PoK8a3vXRfyV8eKzkozfALbXThN0jOYMfiTKPzGqJ3FqgZ1fO7TssL+3H898MInqa3cDWgTqxcghTxEozgyRPAOD6CLiHjS3HZbSOyD7zlUwnp3AUvGvoNnbNayBDULNYRU5gJlRW0nvfZ9dX0PiieBdArRuA1w6o7UbZF3EFYcpjFQxE+0oz9Z3/HHuSm22/zOWZOe4fLEZo2qBJDUQVncnDdcHwrpLno/eZWmWQaAtDfPAdFHXx1XVt/R+fkBoSaC0YDID0OyGFMVz4Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wZfkgv0GIEaWmXgw+T300VxmuZzovMl/bQtEbA19A1Y=; b=r94PENJLsr8wqfi68cT8Fpa/vmAakRavJCHSG8tHGkEK7tuYwUZuybgV7NiBzp/3IS8WEZDxQnaztag9O6PpwPNmifgPqx/TkjzebFkL793oG8QrAM2j6aTo7KkNb5Zz3QhdumwATurwVyllplALw7gL8KquJ1806ICrL/zpvMW86PNMrc5gbRrh42qDwIe4jFY4h2e4AFzMsbgDLqYoFAYgSVl8uV7+8d/Aj//9cyfoEz4/fdKZ2DAK+p8ay2hAxtc6p1FrXsTxNaBBO7pIx2zX0sha2fJLkXGRsu7EyI4dd1n9yKRmkB5kMjoo5prkDTc6tt9TRHlr+UNVw0s7/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wZfkgv0GIEaWmXgw+T300VxmuZzovMl/bQtEbA19A1Y=; b=o72X9GUOVPRLS2tLv7rMpEzTAU4vm+Y4IKodpu4r3RMts1qCudS0C3yEcqYMprJwYZ6dItRBMJh11Dn0NGX3bt23GXm2w/wPFV1e7wAmPNqLhr3VQvEuCjihJKPmxk4fHP7FjLBvhletrCh6MNU/lpqb2pW5mhNgRJo77oLNnJ0VEK7mun3i33gT2X/rtf9LVpoi5BweTebdT+MERasFjzCrYyEnpCebNbNg/aiD3uRrGzdlMoHDiZhk58PPUk5j0lRHO5F8JJoSgnXxJjWaXxd/djL1eD8gBv8sXCwUFx2cDEdSR8sZweDPDhAOdfZfe7qth+FVr7F8MJICt0kEEw== Received: from DU7P250CA0029.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::18) by DBAPR07MB6680.eurprd07.prod.outlook.com (2603:10a6:10:182::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:29 +0000 Received: from DB5PEPF00014B94.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::db) by DU7P250CA0029.outlook.office365.com (2603:10a6:10:54f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB5PEPF00014B94.mail.protection.outlook.com (10.167.8.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:28 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnW029578; Tue, 15 Oct 2024 10:30:27 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 28/44] tcp: try to avoid safer when ACKs are thinned Date: Tue, 15 Oct 2024 12:29:24 +0200 Message-Id: <20241015102940.26157-29-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B94:EE_|DBAPR07MB6680:EE_ X-MS-Office365-Filtering-Correlation-Id: 838707fa-44c6-47dd-29c4-08dced0463d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/tUispR7RTOYaX563sE1PBKV+Y+wfqK?= =?utf-8?q?S60rBBNZr1XY2sJkT/3FwBdSKKXuWubnzKdlY+PrkHTKCBCvin3/ue5puu+dzi6hb?= =?utf-8?q?9b5RI/6IMEaWsEjpTRS9ZKSC2SjL8sbuaKKt7F3ppuQNv0mYQxBNaPypP04l7d3ed?= =?utf-8?q?jG3OnzXkRWkQthyu3FIwPmKnPw0arPXScoj8YT5gcOuFUQ/JRzvBp+C9642fDlnx+?= =?utf-8?q?GPFzpxLBJxmvnAf4ou0kaD+H3FuSyWQX7WbooSJ+nFD1LNItE8GdIB8BFcfnYgY1S?= =?utf-8?q?zb+DXuvTynPWv+yrmFj9c5+tdBhDtrxZqW6GVU398NhV/jv3Qk1QYkXUNAQjOgByV?= =?utf-8?q?NZY9EBf8UY9/b9iiu//590VE54NgzMCzUuhK/mC/2e8it5bw7vBf4dz6SqOcKDqcZ?= =?utf-8?q?6Ov11zx0YVd4j0EK4ZhjLMJ3shGPqykOm8x9vlv7XjojqPz6qHOyGIX37I67+w9rT?= =?utf-8?q?Ox0AqA4I17n4o027TcouL72mJ2hwCAlP7FhfioqGFKFCnh0NIyMyw2eLPe9Ky5l03?= =?utf-8?q?NjN2qbJQNB6IulBjmHQnMCrSq4CWYqXc772ISuDZLqSP+osQ6iTV995ORYLV+8xCo?= =?utf-8?q?S6W+a9iYorRldZzzE7S5qoYiv2UtOjOZY/L+tw8Bi2nZq2tmShdgkgJmPDiVmO8yW?= =?utf-8?q?0FMZa6sFCGNWssK1+EHdhppwxMC2Q++LUQzUKLWsUnDCUek/xIgbyxtIBZh0UHvII?= =?utf-8?q?3BDkUIjnALSqtGrRLLTzxz+kq6Tb8WUjh0lYMNWQbHIRaPUZcrHXCA5uW8+IO9Cyn?= =?utf-8?q?lvnzlAn6BmkAAxAkEJnlfBP5Smu2k5E8M1KbBdgEU/gjzOn3ZWPkGMkjtRj1Im0Dz?= =?utf-8?q?LOlqrT0EQS6AKUcYZnoqENxFrlGx3RqNa1+IHLtCnxyrVR01BqTlFcH3bNzjqlXm9?= =?utf-8?q?LI7JywpqyM+xCzYUWYEhEVQrT/9SODn/WKosfLttkEwp56vothaM9baE5Ng3ApsMG?= =?utf-8?q?3Wm6ioZatT9BKHDfO7lZ7RAc3aAspX2K8tHi1egEHAqQjHBO2P3GbNftFVLUUdmTL?= =?utf-8?q?E7H0R3X4cW8v4xcjxrHNxpYQYpj329SSRpV4qzhq5OmuDzmdF/my8LCAMiGFg+0jt?= =?utf-8?q?wjVJb0I4LMYjkPUTXQaWbyDOfP6Gqf+l7KMX1lc8rIUone+Q1U8eZbSFDXsYZdKou?= =?utf-8?q?WAPke12zwCYOjw5Zgkefx4FeGDdnDX1rUA6FejHDXREmOVQF8SzetotxkxScL94tb?= =?utf-8?q?LJTp7ZNtCvjhWk93Y7xsHOnD1uEgl5MG35TNcA0KF7MDZLBrfe6bQbh4NfR6tgvvl?= =?utf-8?q?DLztYpxk72AEWXWzUUeWDmZ6wp+dOaDi39eGIOfdy7QOcYCHlNHeqPLtp3hSR++Cg?= =?utf-8?q?XjvQ3pa3uXJJ?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:28.8590 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 838707fa-44c6-47dd-29c4-08dced0463d7 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B94.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR07MB6680 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Add newly acked pkts EWMA. When ACK thinning occurs, select between safer and unsafe cep delta in AccECN processing based on it. If the packets ACKed per ACK tends to be large, don't conservatively assume ACE field overflow. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 1 + net/ipv4/tcp.c | 4 +++- net/ipv4/tcp_input.c | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index d817a4d1e17c..9dbfaa76d721 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -309,6 +309,7 @@ struct tcp_sock { prev_ecnfield:2,/* ECN bits from the previous segment */ accecn_opt_demand:2,/* Demand AccECN option for n next ACKs */ estimate_ecnfield:2;/* ECN field for AccECN delivered estimates */ + u16 pkts_acked_ewma;/* EWMA of packets acked for AccECN cep heuristic */ u64 accecn_opt_tstamp; /* Last AccECN option sent timestamp */ u32 app_limited; /* limited until "delivered" reaches this val */ u32 rcv_wnd; /* Current receiver window */ diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 7ef69b7265eb..16bf550a619b 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3343,6 +3343,7 @@ int tcp_disconnect(struct sock *sk, int flags) tcp_accecn_init_counters(tp); tp->prev_ecnfield = 0; tp->accecn_opt_tstamp = 0; + tp->pkts_acked_ewma = 0; if (icsk->icsk_ca_ops->release) icsk->icsk_ca_ops->release(sk); memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); @@ -5043,6 +5044,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, delivered_ecn_bytes); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ce); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, received_ecn_bytes); + CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, pkts_acked_ewma); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, accecn_opt_tstamp); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, app_limited); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_txrx, rcv_wnd); @@ -5051,7 +5053,7 @@ static void __init tcp_struct_check(void) /* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 130 + 6); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 132 + 4); /* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index ac928359a443..b1b6c55ff6e2 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -665,6 +665,10 @@ static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, tcp_count_delivered_ce(tp, delivered); } +#define PKTS_ACKED_WEIGHT 6 +#define PKTS_ACKED_PREC 6 +#define ACK_COMP_THRESH 4 + /* Returns the ECN CE delta */ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, u32 delivered_pkts, u32 delivered_bytes, int flag) @@ -681,6 +685,19 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, opt_deltas_valid = tcp_accecn_process_option(tp, skb, delivered_bytes, flag); + if (delivered_pkts) { + if (!tp->pkts_acked_ewma) { + tp->pkts_acked_ewma = delivered_pkts << PKTS_ACKED_PREC; + } else { + u32 ewma = tp->pkts_acked_ewma; + + ewma = (((ewma << PKTS_ACKED_WEIGHT) - ewma) + + (delivered_pkts << PKTS_ACKED_PREC)) >> + PKTS_ACKED_WEIGHT; + tp->pkts_acked_ewma = min_t(u32, ewma, 0xFFFFU); + } + } + if (!(flag & FLAG_SLOWPATH)) { /* AccECN counter might overflow on large ACKs */ if (delivered_pkts <= TCP_ACCECN_CEP_ACE_MASK) @@ -722,7 +739,8 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, return safe_delta; if (d_ceb < safe_delta * tp->mss_cache >> TCP_ACCECN_SAFETY_SHIFT) return delta; - } + } else if (tp->pkts_acked_ewma > (ACK_COMP_THRESH << PKTS_ACKED_PREC)) + return delta; return safe_delta; } From patchwork Tue Oct 15 10:29:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836086 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2059.outbound.protection.outlook.com [40.107.20.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DD161EF09D for ; Tue, 15 Oct 2024 10:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988233; cv=fail; b=M6dIMzUio0KdQFcSWctdA03AGtw5t6Fzkp7GKE4p8b+YV+CDi8/HrFcu+oRrtexGaCRGXfSdHhw4F1A1JJlUVPy5IDt5Yu1M+qRQKe3nXckdA6KQkaKQPXWe+GRx0K9Jc9o4E8ho3Wm5XQ456ByL1CAYszmkshTbWEfE61YDXpU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988233; c=relaxed/simple; bh=6W2eeaETfKUS7q+IQoIsmfag1icCOuuYUqd3t0j6JIY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gx3WlKakguDZnaQbzvCCZJ+zIiCjrWzB8xccmFMsTe5uDOvLSzSEBaueOaErYIM/v6frSpsE/rQAdnsVTbvOOrkA6UDAU6i0SnhDSHJQY1mKmAhn9/o6OH1SkNZwrAsWu9ZcM48JBmGpKipjj6eoOL5QufmzLMV7KWjd44yUB5E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=Nhr23cus; arc=fail smtp.client-ip=40.107.20.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="Nhr23cus" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KXNqV/IS25SmUKaE6TQpisQZYjvFEVxYWSp7ydRDNtnYyHPiEqXf8lex1ayxHbS8vihKSR51vW8ECU0gK2+1i/IlIC9PtM/t+Z54c4zOTdM15ORrbIRWIpDapEMpaplx0YySV1RhxoheZBYP2u7AOe8uL1cDbHRhHvy9RWX5p/Tc4ytYUAr5084AobczpFdj/kTr9Lg+rjUmWM4BxlNRdgTLnx8qNHtQpbnUfQwPMQSnG9l08iqv4mnA6bhNNOKLY5qXE9QDDBc0lLVV4PL44uqBOVNzVFlK4PEQyoFeMu+j3cZWgHHx/rXh09KaEFt4AyZGFE/pba8AsNGBgpoiqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dGUSvRQ5nvfxBGuWXThf9+eGeUp3Rb42NawIGNmq/ls=; b=LsP7Vl5FTjabvlEuV5rmBGP2vYbIQyUzmiDgFRuW6KAJuooyZVTsqMi9p+wiRyJOhvrxxjGi5jdkd7ldmT6FD2i/nb15P5GNpvZe6CW8nKRQF5gS1UhzKrko0Aec+KK7WBiAgTJarJioVjyv8jRzgXlZZxeFhwuYqPdaaNg1ESPFjDwLnZf3Yp6JHJYKVTFqSM31vyAzYB8JjRYOMD3rMHrm8+doolMT3OVjMbxrOR2o8AiK+hcIzIS1/yWW3HDoCqVEJYR4Rq+Wd7IcpQdjQT/l/WK/UjfJn+jFe/s1+25dqinX9bqiNGo7KRfYk6aoNxcv4CRwOQz7cWps64WYqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dGUSvRQ5nvfxBGuWXThf9+eGeUp3Rb42NawIGNmq/ls=; b=Nhr23cusfl2oNN+7QTFQfmk57zIG8gdXScIO60xz9vcW01ukt72w3cUV32xcv4wJpCehotSS89I412LqXjoi7klJAxVPDjgvdSWat7N3T49Mrgu0XvnyEWqSRGmBOlba8Z+CKf4MIjJhNvMWUfMme2CbrSvPoN+ZqfJ4nn31V2+VqcSvqzPIJmT8ipKixKpHCbRAhoPiOqmx23Hd60ZYzQV/ZPPNdHdsI1hdGUkIr/fB/grjcyxrgxcgT7jx0L8jHxDWmeX/oIJN8KoV8xSIdKccIG5zpUexJXtByuIDDKVgj9V7IXwGI17KqRu2T+7z4lThiHLNh4vGyiQehhQEuQ== Received: from DUZP191CA0048.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4f8::8) by DBAPR07MB6710.eurprd07.prod.outlook.com (2603:10a6:10:18a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:29 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:4f8:cafe::89) by DUZP191CA0048.outlook.office365.com (2603:10a6:10:4f8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:29 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnX029578; Tue, 15 Oct 2024 10:30:28 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 29/44] gro: flushing when CWR is set negatively affects AccECN Date: Tue, 15 Oct 2024 12:29:25 +0200 Message-Id: <20241015102940.26157-30-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|DBAPR07MB6710:EE_ X-MS-Office365-Filtering-Correlation-Id: e09aa0fc-3bf9-499a-07d6-08dced046433 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?urAT3n2rxL3tCJRQEm6R+J51mRpgxBL?= =?utf-8?q?QSZmDr154fIcq7mlWtgVa0rpTGhboq1CSl33Q+Co0p5H+R9tfh9pmZK6zT4liE/7Y?= =?utf-8?q?2iXRuclTCwTPar0NT5rxs86sIMknHtfOsrKyEIPltAqsZoULqza3TY7JnUQVcdok0?= =?utf-8?q?D7QumS94Ls+av0BWY1ZWwwPc9xgUBGpoMqusfJmuY8L2lP83xe00qH4l/3x71R/LX?= =?utf-8?q?v5h7J8eyrlajShPoeCt5H6pVUjfydcsgwvfOYidilwRKElHCvfxMlrUKGa3d2zzEg?= =?utf-8?q?3Az6iVIXwhiMBOatFbZKd8wJxpBIE8fwj/GCvdYxS9pkMWFuKetSPmzwwkeQnwrrn?= =?utf-8?q?xO8rPXKokcCU9UcpeBJFhblTB37BxaV6vq5Esz9wm5VocedcC5Z3pLGjdpPiKthlG?= =?utf-8?q?DPeHR1TUB1BNIFX7QN0oTohvfCIaSwDfVcWBE32PwgCrFUKRJa0hEVHSPGcyop7jl?= =?utf-8?q?/KrWmuNdWuv3N5IpGfQEiqv4Eqkuh+Nlssc0F2hUL8ZDlKkCoT2k/ipBaY4u9Hskz?= =?utf-8?q?Mph9Ogp3ohUQdVZeNvqon6txaNYm2cOjGiU+C/HtQ/JmF6xEMnUDVMzhCD9drzxYC?= =?utf-8?q?1/facOkt2pbQymVLewijR28VzCsdKF6ljnn6c0gHYqPvpVsY6kYJ5rOweqftwa5Rw?= =?utf-8?q?LJmm0rRZsTKiXAE9ZHDD/Z0mNxQ/eIsUf/SedCy9jbp5iVJeIOxFLLLX1fFx1UyaW?= =?utf-8?q?gG7m8UFujjwyQh0nhHNGBkMxSJh0d/VNwOf8Rcjy+sFm5Y94w9PH2K2mj4lCKrlNu?= =?utf-8?q?7dNgtw+9MY2VDyDSgzlTKFq8MQHsi6ZTgvIlzWmJemM45BfIPHt1nkwwjWFz/Ii3l?= =?utf-8?q?m+gQjxlMjWg2p+KrDz6lXPUkb5wMpf7tjbKEVam4xE5pEYNaI05juAM7EH0RVkhSw?= =?utf-8?q?Ti6wbaKTtRtsPvHx46561s9UoQmRSWL+oyLvRN1H3SuGM3qSjI/KvmiSQCvj0BbgF?= =?utf-8?q?XMudSR+7B9nFtAfYuLGD28EAjyvBdVivGyFFJfI+tnZsy81goWY2cgIy4CnONsykv?= =?utf-8?q?+CX7lnmpBN7zQmtWPmSLUufyd3KezHFkr4G2CeGRcfQGaZVoHBO5+esscTfnB2ZSj?= =?utf-8?q?RXN+9kpG3Bzj/cjigIkJFj25/svrCnevJfXhenm+95yus+lgexxxyPj+WYEg/H/sS?= =?utf-8?q?LqwmWYgtMQ8uwx3N0alhAeMfbxzuKkUN0E2aYCkzuxzyK8ROtUWdD4xXl3zyEKv3F?= =?utf-8?q?Nj9lM2FtLF8VyOq9mxcY/LXAQVaJQ3IsJbrLXhud0386I0vu4zw2ejIMhqmenvHhz?= =?utf-8?q?Qhs1K7SiGh1A4RZSu59qXsdVRXKwQs6d0qRUy6U6qFESlOhurTCt1Ybzbf2dyPjJ2?= =?utf-8?q?FSpPan5ZR2tM?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(7416014)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:29.4923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e09aa0fc-3bf9-499a-07d6-08dced046433 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR07MB6710 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen As AccECN may keep CWR bit asserted due to different interpretation of the bit, flushing with GRO because of CWR may effectively disable GRO until AccECN counter field changes such that CWR-bit becomes 0. There is no harm done from not immediately forwarding the CWR'ed segment with RFC3168 ECN. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index f59762d88c38..6286488abeca 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -327,8 +327,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb, goto out_check_final; th2 = tcp_hdr(p); - flush = (__force int)(flags & TCP_FLAG_CWR); - flush |= (__force int)((flags ^ tcp_flag_word(th2)) & + flush = (__force int)((flags ^ tcp_flag_word(th2)) & ~(TCP_FLAG_FIN | TCP_FLAG_PSH)); flush |= (__force int)(th->ack_seq ^ th2->ack_seq); for (i = sizeof(*th); i < thlen; i += 4) From patchwork Tue Oct 15 10:29:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836096 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2087.outbound.protection.outlook.com [40.107.103.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36AB31F707E for ; Tue, 15 Oct 2024 10:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988238; cv=fail; b=u6IUIfN9uiaTLpKStdSL460c2tvcQSngg4vpqG75NB+Ni1lfuTuoKtDqYSyO9bNdj7DT3ai3U1lCrP5BhH3Zq8bghU16xukzhoSqxODJjK4x6KSR5VkoQf20pEF8Hd1gXmCX/vxz/RR/APVqZKJVU/+fxYGqkNJPZ9K8WgkMSto= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988238; c=relaxed/simple; bh=RWWYSGqdX05mZ0PPV9KYsJLiRdXUd6QGg20gKYgn6ZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lHaOAPkiVq+V6IntWKlYkvtq94NLLUEiAh5cAfXc4gJal+Nmljtk4pshAnwiEWiaYOOwkTEBf4poXU3nct8/jX7HXjQ/ULqL9BGDuE0vMEcfmirUJVHsHtaO/pPVgbaTlfxpA+7RBIRgqKD1uf32RuVSuLi1L/DgZWYVU3MoZSo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=JMYjGj5z; arc=fail smtp.client-ip=40.107.103.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="JMYjGj5z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cq/HDuulrDp4hefLZcCiyV/gwiX6aUW6AUlKgKBu3l5POPwEwQZhYfXzVjH414cgMzX2OoZ3qYykUGjKgFI1CU/I12OqkuLR+YlRp/Sx9lboLMO2KBmzBSa6doGjuG7CYd8EullUP5z8avb1D8NJdut6NSF9xNKRVSQ+AqOWodW91mAQIXMXoCCiPUnD56a573wTErCXaoXeARSB9qmLe9zUZ785PCdIq7sGmwDFxljOW3yJOQ7on71HlNZGLX8Xp/JZKErhl9YaIV56uI+UGdLjTTC/adV468YPO7drdCZmoxeEno0VjIlhCX/Ybz8wwHla9uUC5jekIHKlRvE7uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=31F4KNXY7Ey8MlgKGCRSZiPZxbFCAMjgL5OaQdxUjcM=; b=y7OrTfrfDNxkJvwQIhbmVlZK2Wyt/XGkgWJ7msuvSm4xNOjwytMrJCTfw2w8WZrkPY70IshIewWr8ucKqGYD0WflX+lre52S2+QnrG1W+4RkPJm59+TnaS089WuB0u1cCf2STQpCxHcTQAoQ/PXBmSmvmy0jmvdyeyd+lNc59QjFtv7bNIjpIT4nJTHlukm8iqu70ZHHmxOZE/HZ4sZSIXm7xZAuc64CgETbbouX+PYOD+yAb5/Yg52EnK9M4LhOZ0afHYtKG0IKAP5L1TsZko2bQgWMdeCrKA+m1cbG5L2rZWpL0RqhjcfyPkD1wYGJ488g61mdvvifm15fLRHEbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=31F4KNXY7Ey8MlgKGCRSZiPZxbFCAMjgL5OaQdxUjcM=; b=JMYjGj5zdwRSRhSQik5gLDAxvrBcY0hlbU3M9Taid8F7EuxYwbGqz1QkzMwbzVT4ONUhiUzb8zMcDkxcM/64jLUwhapvTreD5+3xEVqpEhq/1X6fSx0HvX29WsZm16KAYKRdX/t83C9lqHI4lWVIL4+da/ltgsJBHhck1EnkUuEzPvMfgmc80jxm7cWRVCHlPHVZcw8uU5vrlxRRJlhz4KCCVlrafPp4yPtRgOVSLX6OYW1bRKGElfgqOfIJqdnn9KZuYseKsG0JjM5++FTU9baPIUJwOqmbTzVcEsB7gbCZKyUNHZ52Bzk0yntrpc26fpWojfEG5wIU8/YoBb7S/Q== Received: from DU2PR04CA0200.eurprd04.prod.outlook.com (2603:10a6:10:28d::25) by AS8PR07MB9548.eurprd07.prod.outlook.com (2603:10a6:20b:628::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:32 +0000 Received: from DU2PEPF00028D04.eurprd03.prod.outlook.com (2603:10a6:10:28d:cafe::fe) by DU2PR04CA0200.outlook.office365.com (2603:10a6:10:28d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D04.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:32 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnY029578; Tue, 15 Oct 2024 10:30:29 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Olivier Tilmans , Chia-Yu Chang Subject: [PATCH net-next 30/44] tcp: accecn: Add ece_delta to rate_sample Date: Tue, 15 Oct 2024 12:29:26 +0200 Message-Id: <20241015102940.26157-31-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D04:EE_|AS8PR07MB9548:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c1b99f0-75ac-4318-db66-08dced0465ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?YokCr/DlH4fHcFWXKRJiYDyEfaceiUh?= =?utf-8?q?O66MnioO2szw+UL6GR7g9B0uLzyuXar6INkliFxbJkgLSdaiwDXAdhR7Nl34rjeTl?= =?utf-8?q?HF7bhgCP/na5lsIdq2VofavD1XJzfxj6I4uf7LBaplCCo3DT6g//n/Ej37Y2DO91f?= =?utf-8?q?g3WV884Afwaw6zODRK9b7E66mtbJcdQwcAB9cWPk06bYaqxz8uVFbDc3eHZRUi+iU?= =?utf-8?q?wtc4OjhSMfMrnHpxcPS5qkse/bK7S/8ZXv0+BXSGZUS7ccJwczrk66Clwy7/yZkGg?= =?utf-8?q?o5hbli0ns32Oxw3odkuB8ujdzN+cFcf0XbURpC0lsTw91f5fRCPesnzZxHbKPSpDP?= =?utf-8?q?kxhWZRuwYk09hGBJ/kkntw6x1Ter4baDbYuRg6BDblh4ijQoyT0i8pE5lGtWuP4ii?= =?utf-8?q?i1Ivy2aQcRQg7F5KW8b7bHHRtmR++zNcP8fbMXrXcv29cLcQVzJlbjUq2jkK2MmQx?= =?utf-8?q?TKjLyvRxm8ysn5RfU8hhbWZbilo6ApOpYEt5Cmqgks1cKcxb4pytFzulOXW47Fci0?= =?utf-8?q?WG7dFyzF9FXx1lPRHGCFC9jGowKL+FMxSUhH+ZTnDFve4YKulgfgr7wKFISMkMp98?= =?utf-8?q?L6P4ZGb4cNdZ7BGFdyTND0YtxVD4izQxiZLGZIqtZHEgf9JbkqP4IqBy6CfHE7YhR?= =?utf-8?q?7bklICkC3zKpAEd7T/TMol1zguUwhvelgubvYtIF6LCSRz+K+A/MdIgpA4cmcrpDO?= =?utf-8?q?ThmxDqXRduoQTYqI+jcD0btqhSExlBTii2eYD8ZKWF/ay3fc/KB8r3TAOFQXxDeNC?= =?utf-8?q?XO92KxHd5goLCIR5RizxYPruazfBD7joYGbAxtLqlthBd+4uoo75Tw3DNdmQrvgNk?= =?utf-8?q?WMnjzwU5uDxUrh6/zfL/zo6Ib9vU3aC/hX/FwxPHiWtzNnhlEUnFHwU67OB7BYzac?= =?utf-8?q?bTmWUPywkK1cNGIvnFSyYN+UB6QVrDALBqRhjrYVDj8MG5Vu1l0zJhhajNHi/QxdP?= =?utf-8?q?r0NrrC8g2NnwgcJjWHvmRFbuNrJ28JCQXCpogHHgTT+FAByiBFos2t2XTMCotAYyi?= =?utf-8?q?eqhPsRnfHilTGXISxXBUvEJXHgW8E8bpP68nVlvPVaTUqOqt6QBpX1eI+ufIuZkPC?= =?utf-8?q?JWfB2cjRJ05+LPB1VNcq8E7SyOvuygTJqgMieUfjQ1i0D29iv9uQHq3VWTO56wcXb?= =?utf-8?q?l8GYoeH5kHMTxTA01SrktsRkwig8VKg+/w27zz3CJGFlXjzR9wwzw8vbxuk1jTJYd?= =?utf-8?q?aoE2U8Wi/I5j1+80E1I4kinx+aV/N5ub4JMiexk5ldFZkuVylwsblQi4Sr4GB/bdv?= =?utf-8?q?UaCUhcnqYLS/MopCNWizN88fWwxgokaJLtIoc3eVFJMqu1QRePqvoXciHPKP0WAJR?= =?utf-8?q?VGfAMOIbBvHa?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:32.3944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c1b99f0-75ac-4318-db66-08dced0465ed X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D04.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB9548 X-Patchwork-Delegate: kuba@kernel.org From: Ilpo Järvinen Include echoed CE count into rate_sample. Replace local ecn_count variable with it. Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 1 + net/ipv4/tcp_input.c | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index a2f6b8781f11..822ae5ceb235 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1285,6 +1285,7 @@ struct rate_sample { int losses; /* number of packets marked lost upon ACK */ u32 acked_sacked; /* number of packets newly (S)ACKed upon ACK */ u32 prior_in_flight; /* in flight before this ACK */ + u32 ece_delta; /* is this ACK echoing some received CE? */ u32 last_end_seq; /* end_seq of most recently ACKed packet */ bool is_app_limited; /* is sample from packet with bubble in pipe? */ bool is_retrans; /* is sample from retransmission? */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index b1b6c55ff6e2..bd7430a1e595 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -745,8 +745,9 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, return safe_delta; } -static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, - u32 delivered_pkts, u32 delivered_bytes, int *flag) +static void tcp_accecn_process(struct sock *sk, struct rate_sample *rs, + const struct sk_buff *skb, + u32 delivered_pkts, u32 delivered_bytes, int *flag) { u32 delta; struct tcp_sock *tp = tcp_sk(sk); @@ -756,11 +757,11 @@ static u32 tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, if (delta > 0) { tcp_count_delivered_ce(tp, delta); *flag |= FLAG_ECE; + rs->ece_delta = delta; /* Recalculate header predictor */ if (tp->pred_flags) tcp_fast_path_on(tp); } - return delta; } /* Buffer size and advertised window tuning. @@ -4260,8 +4261,8 @@ static void tcp_xmit_recovery(struct sock *sk, int rexmit) } /* Returns the number of packets newly acked or sacked by the current ACK */ -static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, - u32 ecn_count, int flag) +static u32 tcp_newly_delivered(struct sock *sk, struct rate_sample *rs, + u32 prior_delivered, int flag) { const struct net *net = sock_net(sk); struct tcp_sock *tp = tcp_sk(sk); @@ -4272,8 +4273,8 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, if (flag & FLAG_ECE) { if (tcp_ecn_mode_rfc3168(tp)) - ecn_count = delivered; - NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, ecn_count); + rs->ece_delta = delivered; + NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, rs->ece_delta); } return delivered; @@ -4285,7 +4286,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); struct tcp_sacktag_state sack_state; - struct rate_sample rs = { .prior_delivered = 0 }; + struct rate_sample rs = { .prior_delivered = 0, .ece_delta = 0 }; u32 prior_snd_una = tp->snd_una; bool is_sack_reneg = tp->is_sack_reneg; u32 ack_seq = TCP_SKB_CB(skb)->seq; @@ -4295,7 +4296,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) u32 delivered = tp->delivered; u32 lost = tp->lost; int rexmit = REXMIT_NONE; /* Flag to (re)transmit to recover losses */ - u32 ecn_count = 0; /* Did we receive ECE/an AccECN ACE update? */ u32 prior_fack; sack_state.first_sackt = 0; @@ -4405,8 +4405,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_rack_update_reo_wnd(sk, &rs); if (tcp_ecn_mode_accecn(tp)) - ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, - sack_state.delivered_bytes, &flag); + tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered, + sack_state.delivered_bytes, &flag); tcp_in_ack_event(sk, flag); @@ -4432,7 +4432,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP)) sk_dst_confirm(sk); - delivered = tcp_newly_delivered(sk, delivered, ecn_count, flag); + delivered = tcp_newly_delivered(sk, &rs, delivered, flag); lost = tp->lost - lost; /* freshly marked lost */ rs.is_ack_delayed = !!(flag & FLAG_ACK_MAYBE_DELAYED); @@ -4443,14 +4443,14 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) no_queue: if (tcp_ecn_mode_accecn(tp)) - ecn_count = tcp_accecn_process(sk, skb, tp->delivered - delivered, - sack_state.delivered_bytes, &flag); + tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered, + sack_state.delivered_bytes, &flag); tcp_in_ack_event(sk, flag); /* If data was DSACKed, see if we can undo a cwnd reduction. */ if (flag & FLAG_DSACKING_ACK) { tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag, &rexmit); - tcp_newly_delivered(sk, delivered, ecn_count, flag); + tcp_newly_delivered(sk, &rs, delivered, flag); } /* If this ack opens up a zero window, clear backoff. It was * being used to time the probes, and is probably far higher than @@ -4471,7 +4471,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) &sack_state); tcp_fastretrans_alert(sk, prior_snd_una, num_dupack, &flag, &rexmit); - tcp_newly_delivered(sk, delivered, ecn_count, flag); + tcp_newly_delivered(sk, &rs, delivered, flag); tcp_xmit_recovery(sk, rexmit); } From patchwork Tue Oct 15 10:29:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836099 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1800C1F708E for ; Tue, 15 Oct 2024 10:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988239; cv=fail; b=G4iHJXd+Jfqs9tGEBQM2b1KKKKWSL5u6YceE75PU9Qj+PU5+nplvnpf0bOd6DG1tY3UhrTBTTIXyFfUgshFjNs8+4NZAZjiUvDTYaq18y44pO2iw1m0qgIkrMFLBffDCZXxMkP2H7ccP3M4IIak7Fw4gdWBXpfRwA05H7YH8ifM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988239; c=relaxed/simple; bh=It0nLWJ5ERsv2/nBf30x/Bie0ZlrrWrfaTha/tDSkvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=RPm5UZ1CM9206sjvFgrgv06goRvdB+0OiaGUa1ZUAEFhY+Qux9S8T9D7yp+43etAPewBAz3c1SaY5gNZuIDm+ZRWaQX+yukN2tXca9p0gdcHLBRjih7fRnojz2O7qamRxKAuUMy1ODWtHRFOHokymRvNwzu7KsNzYVEz6btbFI8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=YfGkmBRB; arc=fail smtp.client-ip=40.107.22.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="YfGkmBRB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mkjffl+zIL5OKmJrIYJzMUyFnlEJq+elLAyRCWMxsp/mj85grmx/dsjhUaSpxV7GFZ4zDQ8n7d3yQW9c+FIFf3XAmcwi8mTshbLAIyig5M6jGqemRN9iocfMMPSN2ZXPSuHPcvZdQY/3xpf8urZKPEpLkGamQYb75E02wUrGw24PjhLMo/X8vqbpkU4R5aArGkI9dIdU3mMyPeFHMg5m+IFnRGFwDtNV/CDpBuLE9vX7TBInPRZzX/vb3dmtpE3N3QBASWm82CD1SmyKN1gDPnCStNBpQmlN902vJTEClfdAodvE8DkTT2auiY+cs7eCoo0PWO8GH7omeYiicKdrzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m7/tU67ILY1WUosfmpl0JbHoGFvKVAyGKnyOpbsQfBg=; b=AgoqVYPwnBug7enDywIarqEmkVw60qfHz3Pypr/8y/o3lxFEt89UrLhZ/2n47qVQpNl0qgVC/nvHMZ+vzSVjgcGEM3cLsZlQA6HMLow3LacHH1Evb0ZHPy8wBb9Y2v060V4jjD1KDAMQnMA7ZQYpuie5VSfpj/UVIxduVX3S/F+cfqTWPPsL74UETZ9wy/XgNOzbeMU7QK60Uk88QVhWoSBwo67pWRScGghqXPcGd5wBhIwaeQi++U582+x3UWlkvJQSJtcWNj3hcSsaDQK3ddPFXmRxROKtrJR31o2cffGToFjOGrZTvxDoMORIMmJu25q54dwXocOkR1zQbPJL7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m7/tU67ILY1WUosfmpl0JbHoGFvKVAyGKnyOpbsQfBg=; b=YfGkmBRBPQdHYA4N5nKzOe4SRdVJ5xj1IPKysZCwpA0GWgYw4rD2b16Sg56QQABE6Y0/JMOYkN8Yzj5ShCz2ljEMyklawda3sWd2XUN9w+nESNfBwN5qoUxsm6OZ45P50WiPhtCU74u3pbn466Wl6QWB7t9+lZDIbd9aMM6BbH+kbpFe4PPdBRtkZuJmTxYyojY2HKXPcfFWlmg7ulLtcvPmr38rXV8XHY+/eVjdNeIKvvOCBXP8TOFxXCNYZGrHiqJKGN8c502qTpV3wpRXPbnb6DiRu3Vm1IYvxIAHKN5dnKhscoG5u0KIOA6N4LDgMTT1P8l6QelQ1FgzM72Amg== Received: from DUZPR01CA0259.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b9::7) by VI1PR0701MB6765.eurprd07.prod.outlook.com (2603:10a6:800:192::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:33 +0000 Received: from DB1PEPF000509F1.eurprd03.prod.outlook.com (2603:10a6:10:4b9:cafe::33) by DUZPR01CA0259.outlook.office365.com (2603:10a6:10:4b9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB1PEPF000509F1.mail.protection.outlook.com (10.167.242.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:32 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnZ029578; Tue, 15 Oct 2024 10:30:29 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang , Olivier Tilmans Subject: [PATCH net-next 31/44] tcp: L4S ECT(1) identifier for CC modules Date: Tue, 15 Oct 2024 12:29:27 +0200 Message-Id: <20241015102940.26157-32-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509F1:EE_|VI1PR0701MB6765:EE_ X-MS-Office365-Filtering-Correlation-Id: c14ece64-1532-4215-5253-08dced046639 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FG3h1I45x2Rpm+NhjgkCFCDXCJWSMsE?= =?utf-8?q?q3diOYbIqp/pTwHO98XKySA03Q+ltlL0GiDVIfxY+0+Q9ByQqkLE+kc9shGsVTLZ1?= =?utf-8?q?JK1PrzAoDdMm61fzF6zlD2fgNG7m16NXS5b4Q5Ww2l4DgjbDUS5QPhOKKtK8N0dIS?= =?utf-8?q?loK6TeiGhbnFzvf4D+sXaM3LfsoQwTB8u0CTOf9uplGe1NZsU9aavqemMsyTHxkSi?= =?utf-8?q?XSEhRPyh3pesS+NPqurjNcohK5xh0IUC9wgoeXoHzl7xyXe8NddNSkcB6Gt3yh50z?= =?utf-8?q?aVAqQEDQzVV412jVRHsnp1ZTE01Ks1fZqvjNJ8et/tmERwURbo73rXgb4BU8qusaC?= =?utf-8?q?qkyh9bCcEd2irLt9HEDKJd55uQVgXXsCZoVYgvAoLc597QzlzLeMu0jPprQCQ0C1q?= =?utf-8?q?uqMZFvWmmCtTgIzxRQRYFtd7GwR65ptrXdYPACB6nrhLJ2XNB1+ff42KD45h9lLE7?= =?utf-8?q?xwPH9qcEs100BaFz1b5S6oPcgap8hYgSLzgxf6JzExeO95fxEf/VFPt+P/wuw6X0/?= =?utf-8?q?G+ALBJNn4FOMEYGHAcoUot5gJWi8uCb+fqJDKZ4TXHSN+MRKy8gd6XShyrrb7BLnw?= =?utf-8?q?IBV7iJ5lrLnfMvgvhrBcFg02cb0liagyhNMWZT/Z7IXPk7cXuYIlmQ8kuAapj7hVr?= =?utf-8?q?IuNGMDgHDlHp65QqLbAXJkPWdEBLVWbSOIew9OdJWJfpmt2ein9VIM0tsP35NFJJQ?= =?utf-8?q?5hQj9Y3R7ThGD7zv4YOOQwA/I21nTJiTPu4KVncIC+5kuKMJ6wldgfxNj19gQhADM?= =?utf-8?q?KdtGdSuVAKnLmBaaYHzCrHWjO3hPPQnP+TJktgW9PvvplPq63gPo8OjLjpyJ8BfE3?= =?utf-8?q?chcRuWNIEFVclZoqcDXdkM6EwaBsPMd48vWPr5esaI68v4PT1g8wACZLakuc1H7Td?= =?utf-8?q?mE03h0L3IyU+iy3WBn+VvAU4kPfBNSZTqDNMEWVybi17ycrfgAieEwLeWthoDE9pA?= =?utf-8?q?kdQnKlm5Ei/mcyx6l/rA+U2W/+xHpdOqOi+cPOneSCMVYbxLW/U/B9rVcTSkJydp4?= =?utf-8?q?iQX7m2UQO5e4EEIBCmmMeR5YQkKxGwuoiGIouABkPADxhaU0tlc+5wJUlmOWbFxy9?= =?utf-8?q?E+OX4o8QB5I3sSPXtVBxVZDxn+X34oeXBwGScLIG9i21pBoUz7RBv1vgSEzTgvHYT?= =?utf-8?q?0pmYUU9NrBnMVoFZ/KBbTEcixEfol/BT77QmBGxQVFuW4mFWml+nWuB0lOl4OD/ST?= =?utf-8?q?AOJ46mIroE+J5/NLpOJT3fRhiCusVShq4US/ruLbiT2VyXdanzVmswHGsrRwd6Ppu?= =?utf-8?q?ixzRhJZl+McnpcX3b3ZpKPGt6l7gY2SeYEPLkvUitBAk6j1nYqrx3B2HjOuqpncmC?= =?utf-8?q?fZHuNXQzVzwA?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:32.8890 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c14ece64-1532-4215-5253-08dced046639 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509F1.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB6765 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang When ECN is successfully negociated for a TCP flow, it defaults to always use ECT(0) in the IP header. L4S service, however, needs to use ECT(1). This patch enables congestion control algorithms to control whether ECT(0) or ECT(1) should be used on a per-segment basis. A new CA module flag (TCP_CONG_WANTS_ECT_1) defines the behavior expected by the CA when not-yet initialized for the connection. As such, it implicitely assumes that the CA also has the TCP_CONG_NEEDS_ECN set. Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/inet_ecn.h | 20 +++++++++++++++++--- include/net/tcp.h | 8 ++++++++ net/ipv4/tcp_cong.c | 9 ++++++--- net/ipv4/tcp_output.c | 7 ++++--- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index ea32393464a2..3c64d32a32b0 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h @@ -51,11 +51,25 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) return outer; } +/* Apply either ECT(0) or ECT(1) */ +static inline void __INET_ECN_xmit(struct sock *sk, bool use_ect_1) +{ + __u8 ect = use_ect_1 ? INET_ECN_ECT_1 : INET_ECN_ECT_0; + + /* Mask the complete byte in case the connection alternates between + * ECT(0) and ECT(1). + */ + inet_sk(sk)->tos &= ~INET_ECN_MASK; + inet_sk(sk)->tos |= ect; + if (inet6_sk(sk) != NULL) { + inet6_sk(sk)->tclass &= ~INET_ECN_MASK; + inet6_sk(sk)->tclass |= ect; + } +} + static inline void INET_ECN_xmit(struct sock *sk) { - inet_sk(sk)->tos |= INET_ECN_ECT_0; - if (inet6_sk(sk) != NULL) - inet6_sk(sk)->tclass |= INET_ECN_ECT_0; + __INET_ECN_xmit(sk, false); } static inline void INET_ECN_dontxmit(struct sock *sk) diff --git a/include/net/tcp.h b/include/net/tcp.h index 822ae5ceb235..cecbec887508 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -426,6 +426,7 @@ static inline void tcp_dec_quickack_mode(struct sock *sk) #define TCP_ECN_DEMAND_CWR BIT(2) #define TCP_ECN_SEEN BIT(3) #define TCP_ECN_MODE_ACCECN BIT(4) +#define TCP_ECN_ECT_1 BIT(5) #define TCP_ECN_DISABLED 0 #define TCP_ECN_MODE_PENDING (TCP_ECN_MODE_RFC3168|TCP_ECN_MODE_ACCECN) @@ -1253,6 +1254,8 @@ enum tcp_ca_ack_event_flags { #define TCP_CONG_NEEDS_ECN BIT(1) /* Require successfully negotiated AccECN capability */ #define TCP_CONG_NEEDS_ACCECN BIT(2) +/* Use ECT(1) instead of ECT(0) while the CA is uninitialized */ +#define TCP_CONG_WANTS_ECT_1 (TCP_CONG_NEEDS_ECN | TCP_CONG_NEEDS_ACCECN) #define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN | \ TCP_CONG_NEEDS_ACCECN) @@ -1394,6 +1397,11 @@ static inline bool tcp_ca_needs_accecn(const struct sock *sk) return icsk->icsk_ca_ops->flags & TCP_CONG_NEEDS_ACCECN; } +static inline bool tcp_ca_wants_ect_1(const struct sock *sk) +{ + return inet_csk(sk)->icsk_ca_ops->flags & TCP_CONG_WANTS_ECT_1; +} + static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) { const struct inet_connection_sock *icsk = inet_csk(sk); diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index 0306d257fa64..7be5fb14428b 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -227,7 +227,7 @@ void tcp_assign_congestion_control(struct sock *sk) memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); if (ca->flags & TCP_CONG_NEEDS_ECN) - INET_ECN_xmit(sk); + __INET_ECN_xmit(sk, tcp_ca_wants_ect_1(sk)); else INET_ECN_dontxmit(sk); } @@ -240,7 +240,10 @@ void tcp_init_congestion_control(struct sock *sk) if (icsk->icsk_ca_ops->init) icsk->icsk_ca_ops->init(sk); if (tcp_ca_needs_ecn(sk)) - INET_ECN_xmit(sk); + /* The CA is already initialized, expect it to set the + * appropriate flag to select ECT(1). + */ + __INET_ECN_xmit(sk, tcp_sk(sk)->ecn_flags & TCP_ECN_ECT_1); else INET_ECN_dontxmit(sk); icsk->icsk_ca_initialized = 1; @@ -257,7 +260,7 @@ static void tcp_reinit_congestion_control(struct sock *sk, memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); if (ca->flags & TCP_CONG_NEEDS_ECN) - INET_ECN_xmit(sk); + __INET_ECN_xmit(sk, tcp_ca_wants_ect_1(sk)); else INET_ECN_dontxmit(sk); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 663cdea1b87b..ec10785f6d00 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -326,7 +326,7 @@ static void tcp_ecn_send_synack(struct sock *sk, struct sk_buff *skb) TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ECE; else if (tcp_ca_needs_ecn(sk) || tcp_bpf_ca_needs_ecn(sk)) - INET_ECN_xmit(sk); + __INET_ECN_xmit(sk, tcp_ca_wants_ect_1(sk)); if (tp->ecn_flags & TCP_ECN_MODE_ACCECN) { TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ACE; @@ -366,7 +366,7 @@ static void tcp_ecn_send_syn(struct sock *sk, struct sk_buff *skb) if (use_ecn) { if (tcp_ca_needs_ecn(sk) || bpf_needs_ecn) - INET_ECN_xmit(sk); + __INET_ECN_xmit(sk, tcp_ca_wants_ect_1(sk)); TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; if (use_accecn) { @@ -435,7 +435,8 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb, return; if (!tcp_accecn_ace_fail_recv(tp)) - INET_ECN_xmit(sk); + /* The CCA could change the ECT codepoint on the fly, reset it*/ + __INET_ECN_xmit(sk, tp->ecn_flags & TCP_ECN_ECT_1); if (tcp_ecn_mode_accecn(tp)) { tcp_accecn_set_ace(tp, skb, th); skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ACCECN; From patchwork Tue Oct 15 10:29:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836092 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2084.outbound.protection.outlook.com [40.107.247.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB0621E5027 for ; Tue, 15 Oct 2024 10:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988236; cv=fail; b=BQa84I0ni1GNj0GhGidgT5/My/UWKTuSTrRRytBaMiGJffor/OLyg8BtPmisZCcXurKSwwc1QclSyTCA4DmQc8yplcNEPpl9fXx51MUEkqWMPDt7rg3hPcLDHL0shfDCHOUibnRCCOcdl1VXfVjJI2KL2wA277ocCSqGMMPgtKs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988236; c=relaxed/simple; bh=Z3SiM66emkE8FaYnCaNfsDFR6MdGQAuxmAyDcwQ2iVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=rrRPUTukABtDYHNrEEiPLZ/QQuCIA36Dpa2UWt5wz96BWPa6J42T4KEx1QKjFIs7az/5AojXpWOoKfeYt02MGRqiaGcxhJTw1VKlD1gDb5Zkse6spy2EU16xYq0U6rOVz4oOTmO+bgm5qDNQHDpTXw6zlVcmWLx1RsrV6CEd1X0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=dMpJx5Xh; arc=fail smtp.client-ip=40.107.247.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="dMpJx5Xh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WJGhEaCPo0XOZzF1Yco9dIw+ZTleOKsb0+xY5MHvvdCJkmC79gkjvR/o65Jd2KYHnQSGlQpNZPtQYGSbKdJOSIZMJNqgtnyJ2wTd6FsnndOVCcW8J0PByvNZiiswVhUE/Qh0oXciIuaoXVNGoejVZu/Ri9H/Cx+mBNyF9vYOsK3jzgJmKA2h0JEdZVp5JQ9QX1DBRBBJcn+IusRQ6N2rrLwPhurBtlLdsMdSzvwSuEItZ0XT9OFu0Hb6BbIw/M30biZZxXYBxrdY+Mx/CT9bJHtjxgzxBcLcFSdAFqOc/YbS1fMjJW+chsnKJt0+DgdIwiIUuZwnB6bFNtFRJRN1Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=opF8mV1g7DxL2P+/mDr13QTsVSEvtXw4Bb1IHn/sjCk=; b=L/YZi3PdH8m7r4bNjyfVFMt3Zldy+6zvkci+UsxRTsLclA1DpRLpqrXVbrnqIOfxmx8nRlywNhMp24LXDxyfm0OiVf/OPW+XH3t4PvRKkc6YjsEFA/IN5EL3baM8dKRpkaSOaj4tVH7WkcBoL3rs12iWVx0rDYy7YIXp7iRwnchfjxLH/k3Xs0ZMGRGmEnD8l5Q3eiA/r9RF8EqYHNh6lCM1Js34zSAt1buuNhxfBvTfoDtI/q7EuukkcedMlAAM2kE6i0V5SCwCUwywXdf2HfjTOJaLG/5TXvebORi5riRLWckMa89S7ugyAgAhBmw/oqMOWGkDl7fXzmUc/Y8OGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=opF8mV1g7DxL2P+/mDr13QTsVSEvtXw4Bb1IHn/sjCk=; b=dMpJx5XhCtcpoJ3TbO4kBXFXFtbvdGYkUmzePyYziBmx3H0/gk3lwjRfNTnhJqH6AdeM/C88txKzTRikyGIcTL2yFSOm9wBOaUmHxkDn8x0UhDdEW9wL1CEmb29ntD4c941Zvsqy0lYyhXhm3VzsTT2fT5v5euYw4yVVJ34W4U6VRgiaG3UcUFhqSdPyJ3ZGhp8/fC/K+rfmPAtM5mePg8XZQT5zloBxDvuhuHsFeg2H6H+Lr9x9QH9NZQ/8Dgo97daA+Nf0O15Rxeya64/2Bv5DdxlpcJlth8FqecAy+rQL+4+oLh/rZByC+0rlec7tnzt2p6oSNHra5E/5qcAAGQ== Received: from DU7P250CA0017.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:54f::20) by DBBPR07MB7564.eurprd07.prod.outlook.com (2603:10a6:10:1f1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:31 +0000 Received: from DB5PEPF00014B94.eurprd02.prod.outlook.com (2603:10a6:10:54f:cafe::6a) by DU7P250CA0017.outlook.office365.com (2603:10a6:10:54f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB5PEPF00014B94.mail.protection.outlook.com (10.167.8.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:31 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtna029578; Tue, 15 Oct 2024 10:30:30 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 32/44] tcp: disable RFC3168 fallback identifier for CC modules Date: Tue, 15 Oct 2024 12:29:28 +0200 Message-Id: <20241015102940.26157-33-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B94:EE_|DBBPR07MB7564:EE_ X-MS-Office365-Filtering-Correlation-Id: 61163cd3-2a01-468f-7c39-08dced04652e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: gMPHV3IWuhdFtB7Kfk6Sd1sUmOiTBcvoPFs7Yoan9xC9qKvPSzrYjaOZNUi11MDbKUjWhvy5BA5dVE/mX4xP7iwvKoT+mJsKAdb6B9dcGSWYqPQqCvK8vlT4J/yghRjqjwGGVxIZUucrA2ra2iwNAXTuOHFp8oqdZDiMA33vbW52jB2ch+Qeh5mbU0GZgHN7QLNoNma1kHkS6z1Z9cF2RbDilLu+zwNES0ibMCb99KSI7r8/cy5fiMMhdVfLwPGLyJMtazjQ2TTp8ln74mLuXgrpCC5PUhDj1w3kb7Jg9IIiP72roj3d62bYWc5oDp1C9px6dvImN8j30UQo3gg81HOWzU99EpLxa/ma7DmQwkpJgvaK78BwBLlDuZ7yyW4x4Cxc0C26UJ8FNRW/O7MSf0vEo18yk6PVnLRHh3BLbdzlQ21jW9NFEX/f8fClTczP2D9Aycg75na+qtBtAadxVXrm+13ofKokfhIKWcZMqIx+i37IyvDCFTH+TXGuU9sFltlu1zl3LxOpH+mZSaLhZB9a2I8aMYhUsSAM+7qPJHheJaU4r/EwrmJ29p/jqzqwrNzOll1sW5CA4DbruW0WAGbvf25M2AFE35e2Fwf8ubQVehQb5ngPe7aQSrJv5KCpBKUEEt4rkPLeZbbRR+qHmDHI+SK+1MsWLVmoTjUnPkrtZ5HdwAVrQKhMisqVoC8VbOc4zKcqC18kNS6uMX+ioKwRAwknhMJYeGkmBb2R/gLNsrDhn7ZFoEiCiqdSA0wC0WU2zsruTJY/+Cg/WCEJOhLgQssZ7iRO2nxufFTJqk9EueI8rdT6m95l4vh8A+9km8LSkeciyQrtNf3eEcn8Kmh/W7YMXFdl7of1HXPxn5sILDKRd7ml2Li5T4lCLfemasG9qo4gLPyYOpDbOm7LkE/vwWLfGQhMAFwaedAZTqwKwUNSlKJN8Q57FbsPPJtcJWbEqT8zq1bd7M1bR1ABucU7E1p/Q9/BFtNeD85j/CItAbKo65dyjKLlRu8oVf/9hIdbdXHefRb6gAnqHWehQJkhguy7xCkIh/sY2526t6ud+PsbYAOIk7r/SyEsAabWGsrcH5tKzytW7j5UHyzJDqJht4WNuvZyBmprOcFpi5br5IYewp46v7LA0NTTDi234m/emoH/q3/E/RSaap0zdxB0yqQXxADUSDEkXmX1AfJu5ikLGuSGNkcau9zhqYnM3PeO/AFcsVECKFCltpPmWlNCOzAVnDTkut5IH6DqXoWDqVYyzm5c0nPtrYnI6vYz7EuJT8OY+VJCgfXGyg9rVB6DUTX0poMDAAHN/3+wQhf8zLJsLrx+Cl1ztczzT6gdvK757WEZe44brpluIRTkaHlfWY7XxgPqlqZeljZOtjvHBHXgmDHRd3hgUN/P1PuA X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:31.1402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61163cd3-2a01-468f-7c39-08dced04652e X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B94.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR07MB7564 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang When AccECN is not successfully negociated for a TCP flow, it defaults fallback to classic ECN (RFC3168). However, L4S service will fallback to non-ECN. This patch enables congestion control module to control whether it should not fallback to classic ECN after unsuccessful AccECN negotiation. A new CA module flag (TCP_CONG_NO_FALLBACK_RFC3168) identifies this behavior expected by the CA. Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 11 ++++++++++- net/ipv4/tcp_input.c | 11 +++++++---- net/ipv4/tcp_minisocks.c | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index cecbec887508..4d055a54c645 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1254,10 +1254,12 @@ enum tcp_ca_ack_event_flags { #define TCP_CONG_NEEDS_ECN BIT(1) /* Require successfully negotiated AccECN capability */ #define TCP_CONG_NEEDS_ACCECN BIT(2) +/* Cannot fallback to RFC3168 during AccECN negotiation */ +#define TCP_CONG_NO_FALLBACK_RFC3168 BIT(3) /* Use ECT(1) instead of ECT(0) while the CA is uninitialized */ #define TCP_CONG_WANTS_ECT_1 (TCP_CONG_NEEDS_ECN | TCP_CONG_NEEDS_ACCECN) #define TCP_CONG_MASK (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN | \ - TCP_CONG_NEEDS_ACCECN) + TCP_CONG_NEEDS_ACCECN | TCP_CONG_NO_FALLBACK_RFC3168) union tcp_cc_info; @@ -1397,6 +1399,13 @@ static inline bool tcp_ca_needs_accecn(const struct sock *sk) return icsk->icsk_ca_ops->flags & TCP_CONG_NEEDS_ACCECN; } +static inline bool tcp_ca_no_fallback_rfc3168(const struct sock *sk) +{ + const struct inet_connection_sock *icsk = inet_csk(sk); + + return icsk->icsk_ca_ops->flags & TCP_CONG_NO_FALLBACK_RFC3168; +} + static inline bool tcp_ca_wants_ect_1(const struct sock *sk) { return inet_csk(sk)->icsk_ca_ops->flags & TCP_CONG_WANTS_ECT_1; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index bd7430a1e595..fb3c3a3e7c56 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -452,7 +452,9 @@ static void tcp_ecn_rcv_synack(struct sock *sk, const struct sk_buff *skb, break; case 0x1: case 0x5: - if (tcp_ecn_mode_pending(tp)) + if (tcp_ca_no_fallback_rfc3168(sk)) + tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); + else if (tcp_ecn_mode_pending(tp)) /* Downgrade from AccECN, or requested initially */ tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); break; @@ -476,9 +478,10 @@ static void tcp_ecn_rcv_synack(struct sock *sk, const struct sk_buff *skb, } } -static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th, +static void tcp_ecn_rcv_syn(struct sock *sk, const struct tcphdr *th, const struct sk_buff *skb) { + struct tcp_sock *tp = tcp_sk(sk); if (tcp_ecn_mode_pending(tp)) { if (!tcp_accecn_syn_requested(th)) { /* Downgrade to classic ECN feedback */ @@ -489,7 +492,7 @@ static void tcp_ecn_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th, tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); } } - if (tcp_ecn_mode_rfc3168(tp) && (!th->ece || !th->cwr)) + if (tcp_ecn_mode_rfc3168(tp) && (!th->ece || !th->cwr || tcp_ca_no_fallback_rfc3168(sk))) tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); } @@ -7111,7 +7114,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, tp->snd_wl1 = TCP_SKB_CB(skb)->seq; tp->max_window = tp->snd_wnd; - tcp_ecn_rcv_syn(tp, th, skb); + tcp_ecn_rcv_syn(sk, th, skb); tcp_mtup_init(sk); tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index cce1816e4244..4037a94fbe59 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -495,7 +495,7 @@ static void tcp_ecn_openreq_child(struct sock *sk, tp->accecn_opt_demand = 1; tcp_ecn_received_counters(sk, skb, skb->len - th->doff * 4); } else { - tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok ? + tcp_ecn_mode_set(tp, inet_rsk(req)->ecn_ok && !tcp_ca_no_fallback_rfc3168(sk) ? TCP_ECN_MODE_RFC3168 : TCP_ECN_DISABLED); } From patchwork Tue Oct 15 10:29:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836094 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2043.outbound.protection.outlook.com [40.107.249.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 958151F7077 for ; Tue, 15 Oct 2024 10:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988238; cv=fail; b=KzTWO0Oyt+hYeVpfG9rTUTvYN0Q+n13pglmAc11vrBl5JKU+u24/EQral+zy9r37MExLX+IdeZgmS+vUzivWHXUxk8zqV0SCfurPq0oDEUmVdgSxVtnn6KviGXkwQzSHdP40GMJF7rg1d5i7fOy9HzsYsI0M1pyoIA2gzjjDcR4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988238; c=relaxed/simple; bh=PqvjgjMwi3rbXacaP9BTrylFqEXOptDY7ko1sSD4Yok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=CTOEC64hzxbCKPQwPoHKJ5mUASdFG/yYIzT4WVmUlknuH3tDcmSnt/t73IvlG5NGzVhxcxZSJG8vww7ZS+N21wDUdpXK1Wk1HWhOL5DAfTpb3utl3ecV3TtgniH6we1JH9oqc5lDIGj4+rghGB75kYQ6z+GXRJuXe0tVf7vt7Zk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=XU1PcGP8; arc=fail smtp.client-ip=40.107.249.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="XU1PcGP8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=thtutetDSTVcRysv1CDL1n0aBX1QUR7EqHCsH/fZeXhLY2sP1Lxp273/RqOfaCrbPuzohfkHQDBVnPX5pTJspW18Z/AzBQXgiwXtWy6NzlmSTWUy50ZvXZdjjjiZLhv7awmrEHaw4NmGhaBRruO8xPQMg5465otFI0SNE+jYff+APkptGfefi+Lvr8H+65B3/OTAbrsAL3voG9oHt83YycqVnMo5bCjb/uDvsuSXhQgDbGB9YCzF672X3LlpQjXti2DhyDDMF1+NOOoaWRiMN7hmq3llcNkQSQOhFAHGxfuKO/hyd3ZaLjQQwgBp56mJVOhDhK0Jsmvh3iNezNUtPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Je7YDCIDXh+7FWSdBz6KLrHVgPpuU54a9eqWTbRAePE=; b=LRRn5osytBUmBFjcw2UQ8BYLK2K8ubfeXmYS6C/hhboX7+JDERk78GlZ6SkImb54sN1jkvHKZNXDFkAuVyOLOLNTbSr7ELdGZM/RWR9p+tJKEAoySgScqtTHKgbQZJpw2LzpGZbL8yFHzmSauYXbpglJiinc3L+JoAtKwNvziNpsGesL7iVvzllXb1fdfXS7FVsQZUjT/+Lj+2b3tc00bS40CuCMUXujj+DAcGg8ypAhQPd04j+gjjIx7JlMI09be55w1f6spkpIk+Shz7EnRUOLZ1mDB/tf75Xhkm7xFLsVEr5Va5gNIWFBTFwXNNE/A8sSejEzvsZjpCT/czZucw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Je7YDCIDXh+7FWSdBz6KLrHVgPpuU54a9eqWTbRAePE=; b=XU1PcGP8YaYTv2Yq0ePqDpgrKs0zyICm4PUVFtKdmdLq7wn0lfoWkM5cEw8VrtDWh4OGSH+R4SOW6AhxMgHMJIPLa9kFnjel6RFL33Ze8trj79TSgVThMIq/kE66KcMKtK3BpSntP0Yoip7z1OEloXgfakFCAfgtywYrvNPsq4LeBfZ5fZ/IdFkXCdE3kkK5uEbjC5EVnv8m48cwRwk3g38z/Lyj6nbBwIi9pmVbhPQNzIkMJMUmSqq+sePbaRXHcT4EenNg6eXWduBt92hOA0kmyq3qW/SeBdxcVNl/Adew4kPmdBSzVd04H18kBXOq0hFx39G2Eqb9p2ARq4UpjA== Received: from AS4P195CA0040.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::28) by DBAPR07MB6535.eurprd07.prod.outlook.com (2603:10a6:10:187::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:31 +0000 Received: from AMS0EPF00000190.eurprd05.prod.outlook.com (2603:10a6:20b:65a:cafe::9a) by AS4P195CA0040.outlook.office365.com (2603:10a6:20b:65a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000190.mail.protection.outlook.com (10.167.16.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:31 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnb029578; Tue, 15 Oct 2024 10:30:30 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 33/44] tcp: accecn: handle unexpected AccECN negotiation feedback Date: Tue, 15 Oct 2024 12:29:29 +0200 Message-Id: <20241015102940.26157-34-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000190:EE_|DBAPR07MB6535:EE_ X-MS-Office365-Filtering-Correlation-Id: dc5f917a-43c8-4a02-d1cf-08dced046565 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: /03uvcGNjDbUQ7J7LV6jY/ACGl/U7icqNu9QuFPcOu7RtHo6ucTv8jbzQaDBgQE/qMV6AzK/cHmZs9copCBTng2bWFbOuHHMkzqwmoSuLPl9nKv9MUBwi12/jn+BN80w3g3BuFbsNvgT4E6rhNQFus+VnSEbOMgm6lHZiXgwYWlVBuq+YHaTy3jUpFo4rzk869zuWVjH4ys5y2PfOTaP281MbYzS2StminJXPZJtrQK/kESc6/TJEeOIqPGleOQEa4zWdf5ZfRI1vfdUY2S/rmcbGabHU1+pon1XwrYE/FjVCbGGp8QNTFGnlXF2JjdiZRlY5ZvjG2donz7EzoxuOed2vF8vFdpGwweBbAWLB08/4B+RkKuqvqhBm2HXCSoFuDn/QjmU/96tvttDlhV/cP+ShWM2B7DNpemQ74/hzz+P1AXECxtg9MCXx81QSwPTqbv+F/kacf2LRKKWtaZrPE63sFvbilBaCqQoDFdgqlQ63GWh/7o97MIosHntfwwwh9hjc1AP0Tkr8JlWN8jsUMt3s/LOQhmKu5SwSi10grfg2jzZgzGNc3swLu4TN/udf+3KAYY7slf+8ggazG5s4nmZEau0JPecYaFfJoNDfNQt+jumdU62aZ6dq8h8n6Tjc6HLFb43qZ2vxMbXiLh2Thsut69uU9ZD/JiuiNJlU+pdXuDGA/zMs0v4rCTi/lg75UMNPZhFZEDM0nrjuGMXkoaw0iXCHZ0JVGmtS4vOqSiPenT+T82coRi/8WtfZCOyrT+rHGescyYssscrz9A1lwBXgLnFxYSaFobJL5IVdmzbscfJJIrm0EDdK1PRQtYKJ+v6x5ZycEBacoCCAwSojkTJAthSSCW7qGAgmsIAOTcWxHROozyIwoXID6/INkOgjGoC69MC3L1ziKdd5a3xo8FSVCKwLv+NTOJemFbMfPzuxpK7ByhvbQvwH0DyTIWDr3WK7YlYxQeK96jUKSi7irgK4OeR4f2QrOuuLr7rit/An24EXXb0NLCWGBNVxjUcw9RGdiRi7yiVyEbtuWdKefkpX2U2yQYuymhR81gntk+sI9gM+5osnbym4Qti3Q7RK8kyleoCr2zehrwqL8xvI0c32z4++FA24uc4yIqud6DVCWOFF8AR2hIB/oi0A76VQ9T/eZhKlZmp2kH81Doe2pSuaNH3VuqZJTLjT0Wc6CaMdGKPhtu5GvAmna3BV1QoVPUoJi6mI3AhYbLnKK+p4PXbCx+1SJllLMfbfCocDEN40lOhDOIUOJhW/RiXvZyr7049I85N83aiDn8iuRO9oiWbF1a35peA6A6j+zNClOfiDjXJjvwvQoZWu8yexX7i6tyaaWjhp1zgZcxARoAzStHQ4ICVTiRhKk7MiXHp72VHuDfuyzg6yTMuFBa8SNLK0rEFrwoq5sGM4r0DUzIAhg== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:31.5341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc5f917a-43c8-4a02-d1cf-08dced046565 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000190.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR07MB6535 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.1.2. Backward Compatibility - If a TCP Client has sent a SYN requesting AccECN feedback with (AE,CWR,ECE) = (1,1,1) then receives a SYN/ACK with the currently reserved combination (AE,CWR,ECE) = (1,0,1) but it does not have logic specific to such a combination, the Client MUST enable AccECN mode as if the SYN/ACK confirmed that the Server supported AccECN and as if it fed back that the IP-ECN field on the SYN had arrived unchanged. Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index fb3c3a3e7c56..062bb77d886f 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -438,6 +438,21 @@ bool tcp_accecn_validate_syn_feedback(struct sock *sk, u8 ace, u8 sent_ect) return true; } +static void tcp_ecn_rcv_synack_accecn(struct tcp_sock *tp, const struct sk_buff *skb, + u8 ip_dsfield) +{ + tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); + tp->syn_ect_rcv = ip_dsfield & INET_ECN_MASK; + if (tp->rx_opt.accecn && + tp->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { + tp->saw_accecn_opt = tcp_accecn_option_init(skb, + tp->rx_opt.accecn); + if (tp->saw_accecn_opt == TCP_ACCECN_OPT_FAIL_SEEN) + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_RECV); + tp->accecn_opt_demand = 2; + } +} + /* See Table 2 of the AccECN draft */ static void tcp_ecn_rcv_synack(struct sock *sk, const struct sk_buff *skb, const struct tcphdr *th, u8 ip_dsfield) @@ -451,24 +466,22 @@ static void tcp_ecn_rcv_synack(struct sock *sk, const struct sk_buff *skb, tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); break; case 0x1: - case 0x5: if (tcp_ca_no_fallback_rfc3168(sk)) tcp_ecn_mode_set(tp, TCP_ECN_DISABLED); - else if (tcp_ecn_mode_pending(tp)) - /* Downgrade from AccECN, or requested initially */ + else tcp_ecn_mode_set(tp, TCP_ECN_MODE_RFC3168); break; - default: - tcp_ecn_mode_set(tp, TCP_ECN_MODE_ACCECN); - tp->syn_ect_rcv = ip_dsfield & INET_ECN_MASK; - if (tp->rx_opt.accecn && - tp->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { - tp->saw_accecn_opt = tcp_accecn_option_init(skb, - tp->rx_opt.accecn); - if (tp->saw_accecn_opt == TCP_ACCECN_OPT_FAIL_SEEN) - tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_RECV); - tp->accecn_opt_demand = 2; + case 0x5: + if (tcp_ecn_mode_pending(tp)) { + tcp_ecn_rcv_synack_accecn(tp, skb, ip_dsfield); + if (INET_ECN_is_ce(ip_dsfield)) { + tp->received_ce++; + tp->received_ce_pending++; + } } + break; + default: + tcp_ecn_rcv_synack_accecn(tp, skb, ip_dsfield); if (tcp_accecn_validate_syn_feedback(sk, ace, tp->syn_ect_snt) && INET_ECN_is_ce(ip_dsfield)) { tp->received_ce++; From patchwork Tue Oct 15 10:29:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836095 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2047.outbound.protection.outlook.com [40.107.103.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 160DE1F707D for ; Tue, 15 Oct 2024 10:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988238; cv=fail; b=ixqNk6Q03v+oup8khRuN5Ny3kwtGLXKwJkuscKxvUdPiLfxjrURrbXCz63Aii981X3Fn/ljXVWO4czyLV8JtKEz7X92RREsJnf2j1TrvLBJtmQ5vUMg0OQWasCLzjiD0I2OZXeTsHACHtK2fC5o4HrwEQMqkI67KhSHvTrL7mUI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988238; c=relaxed/simple; bh=lKGxXNDZZApDeCLGx8sftBwGSjzuLvwAVEG3hvVt7+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lf+HSxkhfxwpsC12Ny9z/2uEVJnOHXWxMPn4+eXvCH7xz70skK/2ldLAsdsW6YOCa6pFmgGclZ/RVibtaDk7wt/jQwALO26w0szN0UcNjc5Jovrwzae9OWc2qnZxethyIWou+PJAnJbXnZ434Hhe7+0nEXFaECDSXxrXK0shDos= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=DcjXk7qn; arc=fail smtp.client-ip=40.107.103.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="DcjXk7qn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=idDQFqMNeBzJwv0QCxwgWgb6GzcaoqGCXxHAZmrjnEE188xV8eJXobt7ZHsgvmL6OGpJtv7YcYDcncenxiH0nmua4RGi5gYa50DXA6w4sByuPENDkswFI/lMpL85zUVUZYtOouqRqsggBZPi07EwkaEKcNxQo/DqBj/+F6443O9dr97O9P8AiJidMyLOlZRqRETuJdhJDnGw3//CIBqIGvlQmbHW9ZRCEPraJWG5KNUdd6Vet7OYCBlWbhfa0bdsHkzOEJUZiAeXtYoQoy5zHpT5rK3CeJh3WbVpSGT65DzBGOttSrwxcbGKHvTIsZlq3SVwb4HcM8X6YF3lYUTPvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5KEjRTgsIEa0i/sNgB5taJD8oCxxYCsc4PWaEhpGFOo=; b=FMrlpqnKKOcW6UvdryD1n9BpzrKKqwKvKOuvrwMFnOjOGUNk+OJDX/WUQpNVTj+2fwNtYZA4gYn93ZdhJjXJhZYUQLbrcMCA9vRdLke9qMjvaIBnvsOicXp/71urOZb3VEZGr1KRMjtmHIDm7Snbj2s3Nf7UIPyJdZ/5UR9Ad/RufkjSvjnROtu+sIsI51R+YsFVaP5lu8dho1Z6JlS2Y1vWn5NOn2O9DKhiSNoqygYmFzrpgJGwzqu0ZwpOtJxdlz3dMCl6TvmITGvkpu2Yx+B/p8Uga/8FzpTbVhOWcKvAQIZAxp1nE5GfNMJxh56MrJyoiGaBxRQ2OA2FEaphmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5KEjRTgsIEa0i/sNgB5taJD8oCxxYCsc4PWaEhpGFOo=; b=DcjXk7qnDq2Op2Njlb/ie//6qrSet95RjGVixbhuyIzqB3spHYaIwOtKfEj//l2QPSzzYobtriYZSX28qC9J9vzh6A1uVxGjPjBgIbtqpZoJHrHY9FTFEEz91I5YI6kBTvS+Sr2RVW130FSwZRpWiZDIrGfxFJ/q3ZvUYkvFT/LpwcdeybKj6RcjTKMaQZfx/i1p4ghAXFelW6AR8YmSsliuf64uxtIWhlnOWxldh0VzXHbdi00dmLZTa947aRdZz3yZwn8mCLJmYtWsPH6SPbx/1yCI8zJGZ6W8bJDaElujrYnwa2BqRG9PuNYlnj7FS16RdRP+ujhadpn9/odMQg== Received: from DU2PR04CA0019.eurprd04.prod.outlook.com (2603:10a6:10:3b::24) by DU2PR07MB9410.eurprd07.prod.outlook.com (2603:10a6:10:498::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:33 +0000 Received: from DB1PEPF000509EE.eurprd03.prod.outlook.com (2603:10a6:10:3b:cafe::b9) by DU2PR04CA0019.outlook.office365.com (2603:10a6:10:3b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DB1PEPF000509EE.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:32 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnc029578; Tue, 15 Oct 2024 10:30:31 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 34/44] tcp: accecn: retransmit downgraded SYN in AccECN negotiation Date: Tue, 15 Oct 2024 12:29:30 +0200 Message-Id: <20241015102940.26157-35-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509EE:EE_|DU2PR07MB9410:EE_ X-MS-Office365-Filtering-Correlation-Id: b891e334-10b0-49cb-353e-08dced0465dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|7416014|1800799024|921020; X-Microsoft-Antispam-Message-Info: VR/AnmTNsQ+r0dgen6ErJO5p5UfwYrkgXiLVWeoP3uQvl8tjVo8MXl7bokzD3b76Sf3K/zTfnpZtwikpqjGHNjOJRa0ZVBklT/x+TWrSuhxyZmqJlHfKeeDOoScWutTFnu7KB4t7hypwwOKiXk4/U5xhk06JCRXSo9eEvhucxXkchD7xV2OOn7rUnzp5aryIEjCtF9OF88R6jbVHdKi1bY7igeNaWwzxzQb5ewTBhjAoAxE66Mfi3JXOt5v07qkUsgtxCfA/00cGITyEcsM4n195mLF99iIKT0/OdKenRfRxGOmCL+rRmbmD8M09SflTxH1W94/2O7q80aWI2Sk+KJDjRvwDYtFX4rDyp/NtgTlEEil+5TupYf4HoFMZXgxYTHFUFSt/OrTyPLsKiirgzXDUE0cMnOrlHbO7desiVLYiQswboFaZFxaFovLPMIPfxHkZHr9k4aP+Kf790AoBwgBSmuJmsXJIDOOMM8K/MWWQISbeYycTfCuTK2EFgNMB0/yzulluwx7HbhwruFq8vY/L+/dLDXbDpV9Bb2IC218Z6jODERlMGUpjfU4mGw5IZh5CaP/K9gbvfPsb7pU15c7A8DznSJfEZ0zcv/nzHlWHpN0/UzK3m5nu5ZwMjnVcVaeXUhkk4B3MwiETB81B9RpT2/tgP0ii707Dp8YXiSQp3tnNgYzrJcRiJjYyIbl8p1AasSvs52pgBlwrBdG4Jv0f4R8ItbwMP8hFxm1esXgV7+ibnsVd9lAXNhMWn5/zKzODW16AD+mfsSCqEIEn8VZLtYWDvVwhGywp6EWKLRXnnoJdg/NTEObZWBGzqYQKuEeFMGy+/SkQC9FIKgelVOccd1a3Xatear8J5aWUXqoTxoerIGW1RwIQ2dogQt0BJWVT4n6UBsgZzd1Eo6/dqkqeaY+2wFcLZoh2iBWw8KvDbHtfAgaZz34oNPcl58KYfvbYkAjrYiRxLKQPEpy5FOxdUOlmz1nAwNY+uUgNHFnzsh4NaEF6gtydJDl6f5+tKRixiHoRR3f14iFQxq9+UYyUQwjOdj1K9r8ULo5TQv3rm+jOHGyvDAQEVVfOE4Abb66zdhPBvt9wupPgZ3VKGVUl+/MsNdg6SIsFjJqUhZQWwz2Tb+gL1V3lx1klNleHgCJREG42RC2ZsfgF6QgVyqCq4Zsdv1q0CLf2ujQSosf6n/AapKcw2LdEjQ1XqvjrxRUKQ6N8AGQdNeoIaZEdlDi3V4vZzKnD1y87jM9YhJSGtcQOT+iJay90Y/ov2nrczEsJxdBGiu+4Ed/dHex92hwEPxGBp85z8SXBA4UfmnCA9nk41c+KhqNibnHzjz1xPrbJu+/cS//lAaWTojCZFC7u5K0N++a6Itu/rf73uszZDGbcTx81T8xNFbLCIhB5riEJ1VJ8la4t6rvvG1ZJUQ== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(7416014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:32.2787 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b891e334-10b0-49cb-353e-08dced0465dc X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509EE.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR07MB9410 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.1.4.1. Retransmitted SYNs - If the sender of an AccECN SYN (the TCP Client) times out before receiving the SYN/ACK, it SHOULD attempt to negotiate the use of AccECN at least one more time by continuing to set all three TCP ECN flags (AE,CWR,ECE) = (1,1,1) on the first retransmitted SYN (using the usual retransmission time-outs). If this first retransmission also fails to be acknowledged, in deployment scenarios where AccECN path traversal might be problematic, the TCP Client SHOULD send subsequent retransmissions of the SYN with the three TCP-ECN flags cleared (AE,CWR,ECE) = (0,0,0). Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_output.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index ec10785f6d00..ae78ff6784d3 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -3617,12 +3617,14 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) tcp_retrans_try_collapse(sk, skb, avail_wnd); } - /* RFC3168, section 6.1.1.1. ECN fallback - * As AccECN uses the same SYN flags (+ AE), this check covers both - * cases. - */ - if ((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN_ECN) == TCPHDR_SYN_ECN) - tcp_ecn_clear_syn(sk, skb); + if (!tcp_ecn_mode_pending(tp) || icsk->icsk_retransmits > 1) { + /* RFC3168, section 6.1.1.1. ECN fallback + * As AccECN uses the same SYN flags (+ AE), this check covers both + * cases. + */ + if ((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN_ECN) == TCPHDR_SYN_ECN) + tcp_ecn_clear_syn(sk, skb); + } /* Update global and local TCP statistics. */ segs = tcp_skb_pcount(skb); From patchwork Tue Oct 15 10:29:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836098 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21AE11F708F for ; Tue, 15 Oct 2024 10:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988239; cv=fail; b=uCxVAu0WqOhbbhBQUyCaYDRXq1M7ulJHGqTogAKOW4tfvEEDOfafUIPXxFrgAaNeZASjjJFGZQXoFqCDUQ3L4u8qriXIiYjDQtCrzTysGh/iFYPrKw6YBYOniC39uYCFfAdzxPIXEIW7Hd9i87NXiKpxxP+UOQ4DItjjcMDp89c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988239; c=relaxed/simple; bh=QqchbgJKOdLLbysZJkLh71WhIhritRN6xchguCDMavU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=sPefatMjUS3GygFdnVL0RTHmGfIBnRg9v0Q1nKv3ppzEsaVkQs2k5Pm3/3AVuhIMDVyCCG4c5ifahKSOqjvvO0FRchyzTHRVv6+0QRYvhMbNgMNrZ51QNzh//9DEUqmXtVpwEoMreFEBGDZYF0nNe1xDxbw4ZzyVvfinl0MSgk4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=TqIIBV3v; arc=fail smtp.client-ip=40.107.22.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="TqIIBV3v" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lWQsbj01y5a0T9UrNMc6phzgR7DgO6YnSDFYPLfpDum5fBOK3l3tILW/+CoiR5ywHNzlMAYKbwtArLB6g1WRzpY1SpIopcfRpDfxJWeiv/4SEXs+Y+Cw9m5rpvMllZveEtYBWmaRQWY11iexT1LbicmvVJCRYjcH4mTLLkzekLIEyDLW1FfdWIHIz87Iu8g4pKoR8JMJpjg2g8LfDl592VJWFOR+pKruiNCgROlPpSx1dkSSQc3vErvcqfYCgsbZXggg6EBakoV7pOq9nbLB0nrFEFTzdglE5GdAS2HIU6UsRmk5OYOQnLsXS4Es1JRfVNa4zs8W0gRVtXu01MlUlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=10P/xB9g1lfQexhCGa5YSy2I5M8uKzsS1Cekb6A7BVc=; b=Z1VDoRIziC5VbDcNSXrXzCBcx6KzLQmtgbxNz0gPX0wd2k8SdNY1/3qvRwonXezTLxkXCfera1hgUoIRloQ2dBW9uYldCCBLaLqT4HfyOYPVJrWQH/fnHpnldeAU8qJu+aSfWAj2LrOYSo7jZL/qT1cGRyHo4xshqrYeE8r1hqFy8YgD0+sfmUdtaG5378RfX7uG/Co0PrECglOQ34Jo6F4hnOXlW2WVBPw2cFEUA1BQbbx9kl8EXDPumip+8cO1NRJJI+ttXotYXlek5SjHAswjqpkH2lFKxXEoujtOXweC1PQiiml/Ydo4FzviPEwUec6Su4JsQmHo0Nk8YNHRjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=10P/xB9g1lfQexhCGa5YSy2I5M8uKzsS1Cekb6A7BVc=; b=TqIIBV3vgTgY3I9YeqdXKkGcJ6lehIE6AM5UX2X3qEvvON6NU5/bBuPFF9oEfpSo0ffEkqToG9fqJM84X8YScutjrxThIJPhJXQ4vetzPHlTOPWuByTOcStopHnSAGh8KXlmjZBg3NTt2yvhogXyYT/ysscyiWHtj20LbWjOWmsGX2poCr3eb1Y/mcByUF899IeMY6VUXoHCwrJXTKBk4LXDK+tBYJPgZ41JrbOhUdC0YfdBtRsE6IyjQ6Kqv//koxRtNqTXBFqodDYUMCZBBWpdCI/am7HsO+bBuLeROAhGFCKj9N6a+SOLhNizWRXjp42faGOG4clToaL81fGHuw== Received: from AS9PR06CA0092.eurprd06.prod.outlook.com (2603:10a6:20b:465::10) by DU0PR07MB9063.eurprd07.prod.outlook.com (2603:10a6:10:408::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:32 +0000 Received: from AMS0EPF00000191.eurprd05.prod.outlook.com (2603:10a6:20b:465:cafe::cb) by AS9PR06CA0092.outlook.office365.com (2603:10a6:20b:465::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000191.mail.protection.outlook.com (10.167.16.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:32 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnd029578; Tue, 15 Oct 2024 10:30:31 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 35/44] tcp: move increment of num_retrans Date: Tue, 15 Oct 2024 12:29:31 +0200 Message-Id: <20241015102940.26157-36-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000191:EE_|DU0PR07MB9063:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d46a8b4-a22f-432f-c235-08dced04661d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|82310400026|376014|1800799024|921020; X-Microsoft-Antispam-Message-Info: 8oL4O09OTL5rpCelOSvLarBfAHKQLsqHvg5LEczclE7kqGX4Wsd3/fbPOmPWd/+D39r1/dJKTHyDJmuqT8AuASlUtYZMWtAFzq78GZnbRHegWCz7+1T+fJh7L+dO1QXCbjLb7Bb4mUxU0AUt5cZLmpEGzLvYD/gw8UVQP7VgZZJHdx7MqIgBf+LMY0lVNNnmMjNHaUoEM/wRZZnymrYQ0/Wmq8NTDFWlXMg2yIgummVMCh7OS1FbhDGxzZlVhOkVuDbTGqtcMFVX5su1L3AOReC8UoJ76lt/idDbQAb6wkD88oVX/qrOwKGXV2fvaqE/Oa5BXtYqprAfOQbx3zwj3iHbLDjreJsvI9JuZSmKWWIFtCc6NuSnz9nA2wPwLdHKH+w7EcC9rZvSL0xwwTOTjkyg9FdeZP8Aw+I0EZv6Wksw5yY3lZpBRsaZSqrp7X8x6WO9/TSGypdoisBtNY3t6L4e+X4GY5HKhupOGT+ha3vn/ZZeZKGleqQR7E9bVPkn4apGG8YEdbp/0zqSwQgtCtgIMJIm33cp0+/zjnWzAyOE7zjzD3Xt66VRR//MDqAsc99qqPPWj9sDPYExMFy63tICYKF2gDgba7CWVO5609zsFku90wDU2depuGxCqwr7nY2ZfZISXGxvInnawn7JvU8/07Po8Qyq6v4ycYOr8z7T82Ng3IU88Po6El8wnvV5AUwkd84Yw/UwWMbXfnq6sjkEDgUdda1MxIiTjWT73pwKLK1ycZI6zKVF0MOnwEFl3aA6yyIVfP6GMrSY8NDYQVQ85jaLnRTrtRyXo0MpQHT6BPPrsnOVureAqYsMEktzORBGuV1WwVhcVRXqHkH750Qa6Vwip6b/pYcOHm+8NMGQF4GTN/mL/C5g7/xzhpXoDgbAItqqpk0XdgWvPKMionwS2S249HGB1N7cKqZ2+4Y7XenQ2ilzKejdKhCHVtuzMINcwcCm0feUkTqT1jzZIQbO4NDmzpW184ecYcotgJg535VCpiqC6M8NS+tnRLfr8eR3BKBeGCTu7XrdBUb58G4veYGYitj9GdQhAK4Z8JfZmyxdEUIiFRbkYFhR39PBb2AwEhejO6wSDma3HA0PIBUFQde0ana+jJJNpaHjvQYqhvxKsqZyyWs8tAzWCCgkdeQZjb189Tpfc7fsckDmaaEzEhxcRE015PJCKdB28AaUr0bW80SXVRhYn89VTKIlMtDfGkxSEJ16vdLrymwMwRDDPc0FGdKbyYZm30cKNmIKjvH0q5dUK10FfXOk7RtfXm8R3eD4y6sHSI0wMwvkq3shSnimU/Gri7lZ3nDM4WhJXzsmb/Esk7DrObydED65Sh+6RS5cRattfkk24xOW3hvb/G4PN4uDCy040BzQhKGceQhCPoVWIfX+x8tp8Ddi X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(82310400026)(376014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:32.7552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d46a8b4-a22f-432f-c235-08dced04661d X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000191.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB9063 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Before this patch, num_retrans = 0 for the first SYN/ACK and the first retransmitted SYN/ACK; however, an upcoming change will need to differentiate between those two conditions. This patch moves the increment of num_tranns before rtx_syn_ack() so we can distinguish between these two cases when making SYN/ACK. Signed-off-by: Chia-Yu Chang --- net/ipv4/inet_connection_sock.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 12e975ed4910..cf9491253ca3 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -906,10 +906,12 @@ static void syn_ack_recalc(struct request_sock *req, int inet_rtx_syn_ack(const struct sock *parent, struct request_sock *req) { - int err = req->rsk_ops->rtx_syn_ack(parent, req); + int err; - if (!err) - req->num_retrans++; + req->num_retrans++; + err = req->rsk_ops->rtx_syn_ack(parent, req); + if (err) + req->num_retrans--; return err; } EXPORT_SYMBOL(inet_rtx_syn_ack); From patchwork Tue Oct 15 10:29:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836097 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2042.outbound.protection.outlook.com [40.107.105.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D74B31F7086 for ; Tue, 15 Oct 2024 10:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988239; cv=fail; b=Qk9jg1647RLmcFSsV6reM1lJVtEcVd/DOgcgvb83rQst+hYriDvR+AUCerkB+RMNqfbxK8c5Bym3FMQwIChfRbLR6YnBMHaF10CmrjUusQII8utfFPp7GsdMGAAd8NvEpbZAR2kOGHZhuGFSjNvTVot85P0WnoznNove7eg+SKc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988239; c=relaxed/simple; bh=h4AijBRfbvWP2YriG1Dda0W6XmWIL+m53S8c8oqYtyQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=f74LPPjnnt5edtpdctYRbhKSGeiNWoEBnhOAq/BYNGIaQ9Cfk85yMWJnx/Jg/lpTaA334rG74sFsYXltiVuwu07eFs2pLGrsZQ7wpF44afGtoCIEUQcY9KezHiNY9calR3JwQgRPC/vcsyW0AbeF6yyPXb7rxyo+1jnL1bTDMsI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=F+jYNMzZ; arc=fail smtp.client-ip=40.107.105.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="F+jYNMzZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZpPXaeor9yo/A2wGaLwlxZRx7CUqphEjLowNY9FPFRAX5IDqhsz/outLGe5YGzqPKY/ehgYCmBIB0hN/eXjq9IXlZ4U8SdqKRc6HZ1bV0/XcjiImu6d0XD7EeoriY0q2fMyu+UHI6CB5MstT4WBCCG4lMkwewxOwYn/L3HHqNMy7MkeuPljK6609MTW06MBUv2Z3DipA7uHpeE948K+4zkmkY8jzeRaYsOsC7LSQAa9x0sRKc3F8OVljZXHOpe6n+lAAdQlcl9adlU4kS1sR8d0zNPwr3gr9GTEj14SO6hz7kEzwIieI0ZFxD96gDpDQ6HQz66nPHbgj32uQU7LO6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MVOtQzFDCnH+X3DMDc0GT4uh+a544OCpy+2Xxfq7LI4=; b=uvF4Uv5aBG6LXhUB/3ujQvWWRwJjttwLN1Bm/qxFyVU8tBk9hmfVkVA2zYN36HgM9HGdx4jsGFwSTCA3Sc1kHEr/7dlZDSYrLedfoMXSPh+pRbfjTmijJSjoa7PGp2mk0GXZ7gVOuwFUhhxP1Ve/SMe43lISbJblsdKy7Erx4P7xb8/2XM/oewDXd3bU89UWiLufjJmHSqzZ9+DBRYOG4Ptd87lUB7n8tEbGbTkQoWTWrhRQyAUVDYi+sF1lalYrRHW17Fpvpkz41wkWVMn5ap4F5M3NcYQSXwXEpxg4CjOp4Puwctt0BvMmKOzeCwVCfc8AFt7WXHlBgW7bo3A3oA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MVOtQzFDCnH+X3DMDc0GT4uh+a544OCpy+2Xxfq7LI4=; b=F+jYNMzZjw3Ep9gQ/iQxXjo5IgN2YAcC94jRZPHdl7tamocwkVnAJ3GfW7Sx3r9FTLutcngSgPvmy5U7awo/X5zpL9JSOlluWCsdq/AkLXZTINqKcc66+b2CUeWEP/dHCwXBAwEeCF6oFGf+h6PKJrdXpoXIXBnDTaj/VThkaDEGVpiI800M8P4UpcZKZSb8Wp5+LTu0kGhOVRLOKNU+eVjb6vfK9beSgmCZINSSVl9YPYalzQVfI3oU3yvVmN3h2LU+R8tpoliyFgkZ0rkCfJadTD78gPWJ868ca9WT0wcRrAGi1LerD72o5RGQs9S5h5iUIja2AwFMH5w6MvRTcw== Received: from DU6P191CA0041.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53f::21) by AM8PR07MB8121.eurprd07.prod.outlook.com (2603:10a6:20b:36c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:35 +0000 Received: from DU2PEPF00028D0B.eurprd03.prod.outlook.com (2603:10a6:10:53f:cafe::49) by DU6P191CA0041.outlook.office365.com (2603:10a6:10:53f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D0B.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:33 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtne029578; Tue, 15 Oct 2024 10:30:32 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 36/44] tcp: accecn: retransmit SYN/ACK without AccECN option or non-AccECN SYN/ACK Date: Tue, 15 Oct 2024 12:29:32 +0200 Message-Id: <20241015102940.26157-37-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0B:EE_|AM8PR07MB8121:EE_ X-MS-Office365-Filtering-Correlation-Id: 5899cafa-701d-4656-a8e9-08dced046678 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: GksP0r639g7xPuXFPpO9VuSpRdpai871uA5uFCtlSEiddpBBlPCX/O9fmJvV4MmTvNzcwnBXnV15Ai6AODbIGRscUBqm4cBLDsMk2xZIjk4fsTb4k45BMYpqQhs055zkVtqrqduqqbjnG1GqM1dzOhofXKu7pwoLKYY3d1in2Wtczdc80I0EZo86j/vAddJOE/ghWw5GF3kQ7E1FJ2MRbfk3QxI+VQwQsUWxd91MBXKaoSsI+KEajTGI5WdCDZXxbVyhAfxq3HskMp3j/Js3lzqfdDjPRz25xkPE0BylGXdtc7/ZPJ5TXwKC8YNa9yNQEv/X77rxo45PjjifZcjWe9A4bzqaUyjp9RJw89qgzfVqp1JRudTa6Eb6zflyMV2FDxKTAK4lKyEi6yJHptvhXh6EER+15ycwJxq7YXTtUz9B9cSgC6b5CZZNGGYl/P4sXFOVqddT51lKuCt5WQW17yDvoj1r3T8QAfhxqFZ8xlaQAzODCzhZOspL7Lftrnzsb5862plMWKhI9iz9nL7O8sL7NdjiQVgHI7LlTsWSBhbygne9lHzwEeUa9IWgYQRF4K5oTL5taklcWcAfZsCsa2Mj3y4YEvg5R1gE8wX8buH29sItkegfsXw2jTaiHJfldabDdBYpxFH8OruWbjZa4TTTUulDMpZjJiC0dZvxoimwETRlYLRV/Ud0jgFtopjoZq2EbdyHrol3o4oNzwEn3Pk8nBkhdh54115BuF8g/j9K3XtHiT3kApZile+nVcUvs0lNCio0Ap5XN6CsPYJN5s+Bmt6LMaZ0jCRV1rKCoXRnF89bCj1yfdjLKoVzZ25sMyI/zYjTgBHNuhRLbHf/QEI447YO6o9d/Ba3rRXURQbRs02oj4RxZeRwdfFWsJ2eYodqOr8PEBUWSqVOl8exqKTPHtiGbo6RgULWgFzjGs6ZOiA1b3C/TurShu3Af4vfqNe5x8RPrASgpQnSZuApKpGztVmpIKg7lrjFfyydC7s3viX+y4Iu6FrPFue3xJA/xMcDa2ciovF4WZBMe1J8ZuVUUP6V1LWeZADyPNxOohNSkXlXUNKiuVpO7eQCvE/RUSXV3TNkQ0jscJ9BbKQbUFbhft7TY7xsUD/yFX7i8qzx3jx2SuT4yXLHOoTUz5dyFiUGB9/bW3nQFRvJPqpS8+vVQosSzn47wrur485vATXxzS12zP6HWTRmQib5WQB726kCLV+oDW7WyHUwodysWHiZjFAUfyMLaokGiCXJxsfhS+48yXLSyVIL3LztA9i55ZcNR4pEeED5PcSHwyM2ipkg75YjHuqM3fpcZ95krJhpfjnFsN0ky6irRj8yO5wuvS/rRMcMZeAwdq1hKLXQvBN0V/NGHqHNL+eLO5Yw2EMTVatHh8oJhmnzqO+rJEKWKQWFVQHEuBiiCjah9LcHBw== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:33.3040 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5899cafa-701d-4656-a8e9-08dced046678 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D0B.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB8121 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.2.3.2.2. Testing for Loss of Packets Carrying the AccECN Option - If the TCP Server has not received an ACK to acknowledge its SYN/ACK after the normal TCP timeout or it receives a second SYN with a request for AccECN support, then either the SYN/ACK might just have been lost, e.g. due to congestion, or a middlebox might be blocking AccECN Options. To expedite connection setup in deployment scenarios where AccECN path traversal might be problematic, the TCP Server SHOULD retransmit the SYN/ACK, but with no AccECN Option. If this retransmission times out, to expedite connection setup, the TCP Server SHOULD retransmit the SYN/ACK with (AE,CWR,ECE) = (0,0,0) and no AccECN Option, but it remains in AccECN feedback mode Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_output.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index ae78ff6784d3..e5c361788a17 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -399,10 +399,16 @@ static void tcp_accecn_echo_syn_ect(struct tcphdr *th, u8 ect) static void tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th) { - if (tcp_rsk(req)->accecn_ok) - tcp_accecn_echo_syn_ect(th, tcp_rsk(req)->syn_ect_rcv); - else if (inet_rsk(req)->ecn_ok) - th->ece = 1; + if (req->num_retrans < 1 || req->num_timeout < 1) { + if (tcp_rsk(req)->accecn_ok) + tcp_accecn_echo_syn_ect(th, tcp_rsk(req)->syn_ect_rcv); + else if (inet_rsk(req)->ecn_ok) + th->ece = 1; + } else if (tcp_rsk(req)->accecn_ok) { + th->ae = 0; + th->cwr = 0; + th->ece = 0; + } } static void tcp_accecn_set_ace(struct tcp_sock *tp, struct sk_buff *skb, @@ -1165,7 +1171,7 @@ static unsigned int tcp_synack_options(const struct sock *sk, smc_set_option_cond(tcp_sk(sk), ireq, opts, &remaining); if (treq->accecn_ok && sock_net(sk)->ipv4.sysctl_tcp_ecn_option && - req->num_timeout < 1 && remaining >= TCPOLEN_ACCECN_BASE) { + req->num_retrans < 1 && remaining >= TCPOLEN_ACCECN_BASE) { opts->ecn_bytes = synack_ecn_bytes; remaining -= tcp_options_fit_accecn(opts, 0, remaining, tcp_synack_options_combine_saving(opts)); From patchwork Tue Oct 15 10:29:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836102 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2054.outbound.protection.outlook.com [40.107.21.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5217F1F892C for ; Tue, 15 Oct 2024 10:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988242; cv=fail; b=LdQ95edL84TeIuZoYULMJlspVhWyJi3yS+CsVLnv+F+Z+HMBHyPnp2ZFogUMm4TvQg+C/GHlOaqkTCTJ99iCDNugtEavpG2lFJ/KaSxJCpq8vyNZwaq8CfTpRZElLLORGzl8yYeTb6eKGEOeShmjqJedGdqPL+fe0URHZ80V7RA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988242; c=relaxed/simple; bh=m2bjuGZ9973GOriQACD6gE3iiazOgfcxNFe3v9lkr7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=k+nLVbaBOUGUs1q9/QF+fXsf4uawgNIdH7+uJ8brvAL8imr0xlm00LuEynQAcgnewq9xTmxuR+u/RhCxY62PibVfjM4QOC3ii65QbKtysqBgtgPNxo8SR8bz5388sTNv8UMI9iz7rlikfkKu+mWq3Dr6m6ZJevXSvFl5PLD8m5I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=tbJB3STr; arc=fail smtp.client-ip=40.107.21.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="tbJB3STr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EVAkQwlkGppXn2F7FbzxusC5wtlTadYj2SLqCeGyqu2IkVWTbZEZfMtfDMuokKkYx9sKvO0Iriz2BA92nmwKit70WgFDbBPLlqIpaiKMIpSc2ghvzQj4jhmOykC3zpIqN9Ecxm1ZPfxIW0mkATzemYR6zNqBJZ1C7YQkB0hMpmeCve34nyvW8Nc2wF31ximOFUyANAqpvA3WwP+zdQVswiHa4NzXCtY/P8kwHYygnAMSQNuBIQvwCUUui09J9MiZhNym8+aRYIgirk3liyvR6SYLpFgiKMqaiENMqZvkq/uEZ6+KLMQD5bTkqnGySU6UTTV9squdQWrNsnoy4cjjIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Kqz10crZQa689L0IhzGKSopfBC4GqxfMkmPM9aiowZQ=; b=VoIok/FvrApTuXoqpXsaZTuglC2lFWRv+J4/FE9Is0mDNktGW6oEVM7IOUoGQ4vBen3TLfiW1mPiBooj3hAqZTJZZWf/OfQQ2xuoAhY3KW13KzpxQEG+LjtWYJG6i082lbkl32Pc2n94SvX8/i++GxznOakUxMg4zklZ/CMd4PIR/4QpNiZ1mWmoIOBc4F8UuZ6YqJbeccBw+yvqbZJs+sBkHaQozGdzaXAIku8jAEy09HV9CMiOOazpPrVg6OBwiCRrUr5/Cw0IurqB0kAQg4PvrU/CTdytZMLjjPpadzi3/JhDT2XB/MF3KVNx3I5X/CsIwKfdPcE4smwDDX0Z/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kqz10crZQa689L0IhzGKSopfBC4GqxfMkmPM9aiowZQ=; b=tbJB3STrk5Je5tRJpOzNNVAF4X2l1dUp9/mcvQkgTVSqcg0jUr9vho9/xOaKjvW6OacCso28r9ZGhaKkQ7NAEAu+ZE42cuIaIBZstovKrcMzNOEoLalmeYiTfU1ebkznOJAwIqHqIUYnjdep3SFI27lcQIfUcBxVd4f/vHcrxbHNVm5G1c54xvDELb48BoE/BGMWHPjEJoPywdlaY/uDy8wXIiVeExHUEt/l0diM3/sBJr0bMoxkVYUD6xzWg2qKwS2VLno+E90Q1GJ2Sw0N+0zH1RAU/j0Qr6FBoBaBLcQQI0mSwSkspm7qTcaf78pALTbtF3cyyn2MIB3wG5dMlw== Received: from AS9PR05CA0006.eurprd05.prod.outlook.com (2603:10a6:20b:488::32) by PA4PR07MB7582.eurprd07.prod.outlook.com (2603:10a6:102:c3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:35 +0000 Received: from AM4PEPF00025F9A.EURPRD83.prod.outlook.com (2603:10a6:20b:488:cafe::f) by AS9PR05CA0006.outlook.office365.com (2603:10a6:20b:488::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.34 via Frontend Transport; Tue, 15 Oct 2024 10:30:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AM4PEPF00025F9A.mail.protection.outlook.com (10.167.16.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.1 via Frontend Transport; Tue, 15 Oct 2024 10:30:33 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnf029578; Tue, 15 Oct 2024 10:30:32 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 37/44] tcp: accecn: unset ECT if receive or send ACE=0 in AccECN negotiaion Date: Tue, 15 Oct 2024 12:29:33 +0200 Message-Id: <20241015102940.26157-38-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00025F9A:EE_|PA4PR07MB7582:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d77be7f-91d8-4d5b-3b2b-08dced0466bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: boDaUdI5VlE9haR0WmaFdEUO95GxV3AcLCErgggbhv18lREWi62fxlxzR1mZdNBV/3X6eKvaUjNrTiT5adCkHRXsLHARWm/lTi7FBQ7AC/8q0FEUeqNsHm+cuwy/qsp0Vq/4iQTPBsnVzCALa8IB9YHE4fWXF3cLoOnNg8rUaZCRvD4gnbl0WCN9Ln6MSI41Lve3CLpafBzujmDp4E/xngAd7RK89FvW8cl0tXyMAQ0uZ3OhrlpV+yoOiNo0LdcOecsQfnXOqtq7OyB5NTkxSmu+MR1Lksp4XW2gxZJVvuhyygfQbvd/bKyisPERP2Rueo/iJwKfE4FOxbloBpf85zk+NjFh+AeVr6c6rkzmlI/0B2Kqseuf42hxyx9TLX8ENX8eQE1joTiIRxwWFfgTU/auCOzEOfLlueTnFPu5LOr1kBclRb07eeTQzqjPAOgzaMzWou1gE/NlgEvl1a7cmVn7UFdpv5V+6IM+w31rvkPEfwEejzUKNfrFvfMh5xdnrqLljyXBLurpMQfoQUWgR98j4JTyjqyOGRQchMLXJheBW2Q9IgD4jySfdlTj1K64ut5eq3EIf7R0NM5PUIuBhSbKdzJgbhHnA8CFVZuXgECXFdYC/qAidLUDBNz+oSQM53eoJmon97AZ9ttbOHJU1sozOjiuEVyabTZJLB+ogxVnxsnkPrm2gF6ut6yIMRPAPxioQCLkCk4PE0OagLdwPk+ykLTkttchaqKIFJ+RYF0nLbfKeqxU/7cB4zCxZ3B9yTylciO3rj5DSsPZmVUcp61ViT3/YCIHdFarS8AWl09Rcu6dZH5jN+UrKrIbKgz/HKvzX0wfV9CxWuTo55ALytE4WOlqXetoicGwcVtF/+XnSTWvbmfvgUa8/xy1WZ0LqFmVBv3ztHR2QAeg7+1CLDPmj653l972qimJt9499WlmTrE3Y6xH8zO1RcGJHdldKmxlxwycrKReYMAJKJbS2ZpJHr5NLPzxFjbwn4gQevos7R/01wAUGAOCGMp24sHFMuK2bjhZ7WINARd0UlOOvqP6PSy47zZHXLm1n3Ti2X3EuZWRhvufpFbBG1DvvAabv7ZHsLdyLwbv3jWogcssp3lO92IayUh3LlAhSQJ6Q4bvTv9crgVd4PWEYkn0BZ0Q3jgWQuR0lDeHpTk9hr+aTGQDmeMfcVkgZPtljiVbQRJSXRRJkNEATRePwlT4U6sh4H3wrow2BmIMGHUzh++qDiW8c154qfpABh/ryaUU0MJ6jv6m5n3+YTGlv2mEcAiyPtGZUdOvN3sPyu24nB/zNW0Valqu4iZSTQVPmqjkQtDoL1gfNWf4LAs3IzD9P9dZKaA9QZXJa4C1nnudwjQIf1SMHnK6hORX7pB9sPg9Dh2eaF0itccLcZlMVAYC/cW00sV/ygiN3SbDp4FzwNeZxQ== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:33.7847 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d77be7f-91d8-4d5b-3b2b-08dced0466bd X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00025F9A.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB7582 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.1.5. Implications of AccECN Mode - A TCP Server in AccECN mode MUST NOT set ECT on any packet for the rest of the connection, if it has received or sent at least one valid SYN or Acceptable SYN/ACK with (AE,CWR,ECE) = (0,0,0) during the handshake. 3.1.5 Implications of AccECN Mode - A host in AccECN mode that is feeding back the IP-ECN field on a SYN or SYN/ACK: MUST feed back the IP-ECN field on the latest valid SYN or acceptable SYN/ACK to arrive. Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 1 + net/ipv4/tcp_minisocks.c | 27 +++++++++++++++++---------- net/ipv4/tcp_output.c | 7 ++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 062bb77d886f..e88f449e89e1 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6497,6 +6497,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, if (th->syn) { if (tcp_ecn_mode_accecn(tp)) { send_accecn_reflector = true; + tp->syn_ect_rcv = TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK; if (tp->rx_opt.accecn && tp->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) { tp->saw_accecn_opt = tcp_accecn_option_init(skb, diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 4037a94fbe59..301606ff1708 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -775,16 +775,23 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, */ if (!tcp_oow_rate_limited(sock_net(sk), skb, LINUX_MIB_TCPACKSKIPPEDSYNRECV, - &tcp_rsk(req)->last_oow_ack_time) && - - !inet_rtx_syn_ack(sk, req)) { - unsigned long expires = jiffies; - - expires += reqsk_timeout(req, TCP_RTO_MAX); - if (!fastopen) - mod_timer_pending(&req->rsk_timer, expires); - else - req->rsk_timer.expires = expires; + &tcp_rsk(req)->last_oow_ack_time)) { + if (tcp_rsk(req)->accecn_ok) { + tcp_rsk(req)->syn_ect_rcv = TCP_SKB_CB(skb)->ip_dsfield & + INET_ECN_MASK; + if (tcp_accecn_ace(tcp_hdr(skb)) == 0x0) + tcp_accecn_fail_mode_set(tcp_sk(sk), + TCP_ACCECN_ACE_FAIL_RECV); + } + if (!inet_rtx_syn_ack(sk, req)) { + unsigned long expires = jiffies; + + expires += reqsk_timeout(req, TCP_RTO_MAX); + if (!fastopen) + mod_timer_pending(&req->rsk_timer, expires); + else + req->rsk_timer.expires = expires; + } } return NULL; } diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index e5c361788a17..74ba08a33434 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -397,7 +397,7 @@ static void tcp_accecn_echo_syn_ect(struct tcphdr *th, u8 ect) } static void -tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th) +tcp_ecn_make_synack(struct sock *sk, const struct request_sock *req, struct tcphdr *th) { if (req->num_retrans < 1 || req->num_timeout < 1) { if (tcp_rsk(req)->accecn_ok) @@ -408,6 +408,7 @@ tcp_ecn_make_synack(const struct request_sock *req, struct tcphdr *th) th->ae = 0; th->cwr = 0; th->ece = 0; + tcp_accecn_fail_mode_set(tcp_sk(sk), TCP_ACCECN_ACE_FAIL_SEND); } } @@ -440,7 +441,7 @@ static void tcp_ecn_send(struct sock *sk, struct sk_buff *skb, if (!tcp_ecn_mode_any(tp)) return; - if (!tcp_accecn_ace_fail_recv(tp)) + if (!tcp_accecn_ace_fail_send(tp) && !tcp_accecn_ace_fail_recv(tp)) /* The CCA could change the ECT codepoint on the fly, reset it*/ __INET_ECN_xmit(sk, tp->ecn_flags & TCP_ECN_ECT_1); if (tcp_ecn_mode_accecn(tp)) { @@ -4052,7 +4053,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst, memset(th, 0, sizeof(struct tcphdr)); th->syn = 1; th->ack = 1; - tcp_ecn_make_synack(req, th); + tcp_ecn_make_synack((struct sock *)sk, req, th); th->source = htons(ireq->ir_num); th->dest = ireq->ir_rmt_port; skb->mark = ireq->ir_mark; From patchwork Tue Oct 15 10:29:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836100 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A4B51F12E7 for ; Tue, 15 Oct 2024 10:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988240; cv=fail; b=XrFnUWNTZq1JyqiVFuvu0C/gD3XdHrqovKIvpaTIdmGZhPAVyaWGpMCM6v/jqGNUV/qHYJLPNlUx7Cq5LX5YTc3iQo03czh9/RpziHlWEwd9L9rFSWMbr95p6ARnQ4B8osVv/Vn73N8BuHPy8oQ+itNIumZSyltcNn31vdDYJcY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988240; c=relaxed/simple; bh=We7Z9smTSdx1vJcaPNglBQEnEgR7dNLn6tuVy1PV6B8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=iivsJmBUsEuSCKRNamQJAy92+r+LykyI2ZWi38ELVgaUC4yJE8v7kS19W1fReewEiLvTegUqcY3fLyPxWc9GaUHsjrc6jhzpjUDwS0x+YEpBFYACN3ZKaV0pg3Vixt9nLd8PBYwkJXmjHofnMZWym1P1AxF7MlfGejsd5lt+pZQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=huShFYTF; arc=fail smtp.client-ip=40.107.104.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="huShFYTF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DDX7FqWxdQFq4kDDxsbsYpOcKXaEhdxcfZgL6aVx7rtLlAkkd2KYbthwjVXMqmWHjr0KIepTsdHO8dGVUBAw5LH2gpj34JQE3X9pPj9/LQEeWFqh2kBmt6b7wyyRC8IrqoX4aKr4PvE67LtmUdJm5Vd3ov/1QFMCBkQDb+YrZN2+BlG4bITXVu4+tYZtNoGYknIBhF4W44IVfOGmbg6ZzmXriST/TphMC4A8ZPnGjVL84Pv6lEKl1XN/iKoXO6BR9vceVH9Scp8OhsZycoujkmlPsd9c4n+CXOEvC2mt0At0efFSRU45/T/7TnCr5kLFSwt9Dz87HfihqSfFyD3pwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GWeaYAHRG+xoj26YH3Qs6BpOVG4jj2hs6/dEnRbnAwY=; b=gDs9Tgyhwdx7G3BQdRSVX6uRHqut0QnJpeWlbKpTIaC0a1FR3V3mUapqVrJuTOSNcVq+FZeG3sN1/ojO2tfEUMZ3eBRpfW4xrXK3NLKMgddyJW5WFli8s+aEAFl8IbmDYg6kMje6wMwN7tDEW5mOnY8hWlOOv8kSL9qS9cyHRtIik/V1WC4iSrrG+W+qlhWG7ZJWqiM69NHV7V1PEgEOEbRi4UGGA6Yzar1kqBcvNNrEnckaomqZw9AhrltaJK7xFgX032QatV8lbAfHv6+eBF7vT+AGksg2re8neMSCWheqyuzRszswZ2vMZqBSstUYhlLoX6RWO66/RmEguUtTSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GWeaYAHRG+xoj26YH3Qs6BpOVG4jj2hs6/dEnRbnAwY=; b=huShFYTFnc+TXwMhf01YvZcw2TilOtMEMuVy3L5QNLAAriX8FMqTDlPS6uXKsiZ4mdrQrp0i/ZftXOaS6joPKVaGhYhpbxR/OrD8zjWfe1pIoVc5Q6YHvkbcgCgWRIVJ5kkYo80mSgnq2rsWGgi1dUMrz3Q1/94M+9Q8iSvDxlLAbozdlUppSmnNI3+hIwKvMpwjHU+sHL40nW3hIxNzgCecSuugWVkv1lM35NAWi5AJq6uCdShH3yTcokSR/x0koFY79OOeCKmJafYb+S3As29fBJVwOKJT1DU/n8OiEp7I7QHOxB/3PP1rIpE/HgmvQQlna16bJCMfXtRcXLQ1Lg== Received: from AS4P195CA0047.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:65a::24) by AM7PR07MB6801.eurprd07.prod.outlook.com (2603:10a6:20b:1b8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 10:30:34 +0000 Received: from AMS0EPF00000190.eurprd05.prod.outlook.com (2603:10a6:20b:65a:cafe::29) by AS4P195CA0047.outlook.office365.com (2603:10a6:20b:65a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000190.mail.protection.outlook.com (10.167.16.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:34 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtng029578; Tue, 15 Oct 2024 10:30:33 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 38/44] tcp: accecn: fallback outgoing half link to non-AccECN Date: Tue, 15 Oct 2024 12:29:34 +0200 Message-Id: <20241015102940.26157-39-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000190:EE_|AM7PR07MB6801:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d251bae-4db9-4147-f9b1-08dced046712 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: Lpa5LQ/QSzRmYkapxigNSmkCg+Ned3ikfTIXeX6vxEBd+6QiY56oR74D6++5xX1CERivqJTLk7DOmaySSrPe+PwgYkOtFtEiVn0fyQBtkr5i3w77SJQEvxnS931Xv/+HOdpKXgaB5WBTMeqv1yIi0EXbO07YY5RNzEm3qmDBpK1bVaZTN8QeV7++mng7edF/bpiLj9LcK16KNjbSWatsq5S7HIBRBXAd9dEB2zEaoqr7PcdboIT7ReWr9OnsbmYroqyPDRJ4lWuCcLNItRZWMttIZ1S1Uye4rW3ouHe401qGCPmKj/8H8xDroSHybdV8PolWARmYBxUfAX2/qfy4F9yBwabNdUKPw4jJRqiOOSf9RJSs1hDHgy7cELZS5qCe4tewZ5cpD5+k0czb1gmPdsOWR1vkrGw/tCkrsTQxEmmIn8vhydwJAKT/CJMB6l4B4BaBZRg+6GVURrL6ZxO2n8GMhOTfWPMzCZNpJ7r6kk0YhInAB8b2YN6kM/JgbwcPpMI6Woq9BGt0g74M9mZhVbvvUrCE3Qx8CNMcRmailf+MPgxRAODxy99X/Kcmu7l2JQUZZK6nPQ9znktwD/eMGjHhvZoFtNuv2leCwErCiyOLxbpo4QtErBhcM0p4Y0rjZ30+C25FdbTpRBvG5TruwywRk9AXc1bTKuLDJkdHdu5wIYBOOFUVO1PqmkSzNJVilovVVec9ENdDupJ9xmLGufvtXlblc6MTq7+Jy02bk212zNnE69hPZr3u1jq5qeV26gQpbuUTSYfVnVZlCdMkSkh2jfuzWQH6UMxOEa3eNxvkC5dosBCoPNhrQcXm1he0gLsp4TNVTKZT2S4xE9NyJcNxpq9L0Gxi2dXCiw/nKVxXYfIIozkoePbTVCCOqjKQBfASmoooJMdbz2OUTOphFR+wxKRw/a8FOlaaj168VoZfv+TNvVq9FxlU0auDV9bqSmWATAukl+WPxcPJjBMbpQNx7fLJcAoBZ14awyT8S1mlzjiZZ9voTfp/cCFVJFqLUTnzbXd1N4sItYmvxgHhCDjROdZk+sspNdwUMi5zpBoi5iOLIYYPqwA000AjrZDp808MYg6fMu67FdMAVudqS2XbkKRQGiWq+25wOsnbe0eD0oqvwHjVrkNqBR6PlFShTTP6M7ufzD1MK7Eve2svnxhgUCCQBGeTdwIwAu5y2u/CzIENug2RwPbYN2YvAEzsDtk1GC9DXDOLn0R5dnusfL1EefBXj53hmMexfAKN8RGz1epKehNhfJYuI0uEOtPXOyeTE5TCOLGVjOygDGr66edpZsZWlMFKYUnJK2G3nJNL6UxA605DcveJL8qkUWhCJJcHef8V/cIbjADqFstLUthE88q4ggUBALENZtyU8Yz0kmI9RmhlzL9KwK2KfRsqTu27APl43mM99KQLf0vOSg== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:34.3622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d251bae-4db9-4147-f9b1-08dced046712 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000190.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR07MB6801 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.2.2.1. ACE Field on the ACK of the SYN/ACK - If the Server is in AccECN mode and in SYN-RCVD state, and if it receives a value of zero on a pure ACK with SYN=0 and no SACK blocks, for the rest of the connection the Server MUST NOT set ECT on outgoing packets and MUST NOT respond to AccECN feedback. Nonetheless, as a Data Receiver it MUST NOT disable AccECN feedback. Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_minisocks.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 301606ff1708..ba7a3300ab9e 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -458,7 +458,10 @@ void tcp_accecn_third_ack(struct sock *sk, const struct sk_buff *skb, switch (ace) { case 0x0: - tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV); + if (!TCP_SKB_CB(skb)->sacked) { + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV | + TCP_ACCECN_OPT_FAIL_RECV); + } break; case 0x7: case 0x5: From patchwork Tue Oct 15 10:29:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836101 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FD3E1F890E for ; Tue, 15 Oct 2024 10:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988241; cv=fail; b=TQ+Rld4bhXEffbsx8gByedSgvCja//atOBeAsM1jBdHAkOJEU0Z/H24mPTGtuiXklZCPZGsrf65Zpy/oeM2NgTWX5tay48VK/cZk4gmNOkdJlg1eQCPgYJtCVCDPCxhmsr1LTxS9rbV8P203A1S9WQ64WE9C3bYDmwyAm1+cF4k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988241; c=relaxed/simple; bh=n0ht4NonO0gPeu25Nz9iKgSiyMTjU9RGDiU/LtcuWGo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=eDJHlz7g0xM9Wnnf4MFmdUXgiFXH8a6w+bSMnNBnNZsAmXVnhi34j9U1YbpbyjbkoUJHU7oY25xNJuV4JEXIlOktVWAKzF1XI7m/vsBIgpQ9BWk0uoZEMwZ0jUW1Q9+i3pBFMzxdQ+OT+e0CBNiz+J5vgtJemQsUoTY40Gpno74= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=qHGHbKbl; arc=fail smtp.client-ip=40.107.22.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="qHGHbKbl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EmqK5YPlGt++aENgoXDlUoPYln3BOd8AyswMQKwk1t2lA3ACL9GxsQvi+T7L2U45uBS7/ub3sVcLi2jI0iai0TDvZyBRWC0x0YXhzalKX8zs+1Blf8Qu548LJcLz+ZJsELjKMeIHCqszP//VZARx+m4+S20CmS4FT0VmxxQYJO7fYwokun5a+O+w6s3dEpssLgFxsM34vecruY2CnJyf6etMPtIb04VFK3grwG1xxv6tb/xwLlFHeAybsvMya3wyQrF5SDoZxXAuwc1QQU1QXEZwl0xQaxfOXJ37erA6ckF/pCMtTXEMPZbCnr72R/kKsiVOwZzvFwPBdKqmD43OLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WqrfXx3oGh/3+d/rGqS0pjom0F/F2FRvhC7XT6xhw1E=; b=LA2yp/D0ics74RXChmIGqsRoHWZ5wi8zM6eIcVSI2Q94IajkjqrOyp/KfXPpRsrSMRahiF1ps3ADbwnC9FJwHtJxaHVuURdYBpX3uIXlLcL5SCUwbzaS19B0kG4LBaBLsMqlJj6PoRWCGkAIS4Aet21bHIugavcVGpA82DgNmMxr0E54y3pMv/GwEAi/8q55alRRml5gZTFVkQVGs/PwebfbzeTnpnF4GZD/Ze8nXgFliBZZbD0HA15gmYbvo5mAwy5Tvfnjt9QXkBL7qCtCiEqU111sxtGTDrLLovWHgwxhf08BaOQjEZFq0e2vlKjZKV0CAnhYP0UocYCFbPiisQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WqrfXx3oGh/3+d/rGqS0pjom0F/F2FRvhC7XT6xhw1E=; b=qHGHbKbleLMK+vtFVTA6jYmUjXRdxGqAr5Gb2xNjQbAwav0z2qU6RDW0vijvyscYb0bt/u2LBRLaA4Uwe9gL2aQOD+oh13f+rIJBIUB2hdcs9k6IFWh32U2BGpDESHO+IhTCw4cdTN4ghr4HEkJYOcPvVO1ZuofchCyYLhcs04fFQedYgj3SL41nkxkx/P0Hm+AxfB366qj/y9gM6oXiy1tp2xxBT1Tvfqynu3Q7aV1reQuN3fK3pdEEjUCL88I9U3cocU5/e3y1DNKg27lgvI2LSw7V4nFvQJj+La+AQkqfEelYxKFd1/xelL+L6wifKxcKdpkx/wK8A2pxxLI6Dw== Received: from AS9PR05CA0288.eurprd05.prod.outlook.com (2603:10a6:20b:492::12) by PR3PR07MB8051.eurprd07.prod.outlook.com (2603:10a6:102:14e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:35 +0000 Received: from AMS0EPF00000193.eurprd05.prod.outlook.com (2603:10a6:20b:492:cafe::d0) by AS9PR05CA0288.outlook.office365.com (2603:10a6:20b:492::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.34 via Frontend Transport; Tue, 15 Oct 2024 10:30:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000193.mail.protection.outlook.com (10.167.16.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:35 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnh029578; Tue, 15 Oct 2024 10:30:34 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 39/44] tcp: accecn: verify ACE counter in 1st ACK after AccECN negotiation Date: Tue, 15 Oct 2024 12:29:35 +0200 Message-Id: <20241015102940.26157-40-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000193:EE_|PR3PR07MB8051:EE_ X-MS-Office365-Filtering-Correlation-Id: 644b3fd8-4995-49b7-4362-08dced04677a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026|921020; X-Microsoft-Antispam-Message-Info: sHJK7+afs+aq26m2Ff1F/NG4Na6L2YTb+0fRiERLRnkxRiyeKj8DBZH0ToJBbQwJAQUr5AW5Ga/I1rxTp5JV1opfShtPmDha+Nxm/eQFWA8VNVfCEcb6E71vPTnwCsmoF/RaB2sjBAjT/jbG1igZTS2Pp5HbZeRcPDKkBFzES0BnXi5Sm0LjwGpDI39CIS6KcdysavzLfTY2LUGGbDqs3k6EJor4XDihzSU6Aga//EcldQCTBURVlygTbs7qf/peusp51YppLAXhtmVVZRFEffYtxWLSmj9ju5rKk0S9N0XyPsN83lw+zrfAX1gQwC1iSfd3LvDSd7LW/stg5FOfbGU/skpkcOtnYfxCT8z4jPpYmwtL5E7+y3tngrsF8/JJEBVJrc8KhQ2j0welXorHBTgNqsPgQScuBDCkzAw6iDF6c+RRG3xlzswuvmPqjAm7i7/5TghsWWWtoukVsV5RE47ZtmXiTtaYybnnHBlqeBSEcXftr4AoHfh7Xu0yxe+nljgTbnXf7+Qhs4h9Zne5Pro69Ls2L+mzUE2hx4HrzU9pf4hDcVTOvpae1HnFoEsM0mtVqoLYWayAUo+toZJK053l2Cgt361vNp2BL+iUGEy2LdYF5C7X1TK9cKOSdptv6ivqjXW5jdkmvUWEQUXXOuIX3M8xC9i+tq1ypGL2Qp0rlmxmriERQde/bRDHPzP+jSPrP+UvFpkhc9MSywCy+cD8RIhHud2fEu/LRkbTHXvayKEYWLVoGzym9SITbkaVmw964ZGfzr7awG92peKGo5ZwwlucnPM3DuPJGJWX5ccJfiK4Ec6XsaYeRQ3AijJURs4Kjyz4KuCIIQXPUG44yg3kZ1J1wc+PkMEKltwdNyRrcrDC3lk5O9jn6jtDbFhy+vbu9KHm8eyO8FJBHEhmTqbMmSiEY8JOOiDUwi3OlX+f32U7/f+sNEyLws9vcxwLIIKSvx45wlVQIEeZS8c8oiujPVkl81yeipQzfRZWxiU/nYgdOyZQBPJknOQOc0npZrNKEUcfD7pC08hVnK7w09teVtmlJUEGfE/N5ZXLWyML085tZ0AEkHkNGJReHgp5z9vABld/5MWuZgeuPqHYX0tCYz3kLtMjXH80/bQdY5oxBwvAymXTNfiNB52zZL0jvHOSR8EYck6Ix5JTC1vy+zOk91MZ84FRUSy1yqgZeUq/wRTbCAm65fMnAfj7rZyGOFW1u68musjspe0OyUJLyLrMDBfRTiLFFMa9aXzwPsR9AsmyQA+ONcPrareNrRxedyNNRdpzwl7Tk2qd78jsgzZt4JzpeSq9uN11Bh+yARJubcBCqjxxy8uu45BS4wx+3zJA99KU2ArenYgzCD3oJZJMRmtKqEH306/28o7llHxsCMDyGQmge23gUu9/L6Qpm/ZmW0Uv3Al5oYg4j+4zmw== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:35.0235 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 644b3fd8-4995-49b7-4362-08dced04677a X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000193.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB8051 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang After successfully negotiating AccECN mode in the handshake, check the ACE field of the first dta ACK. If zero, non-ECT packets are sent and any response to CE marking feedback is disabled. Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.2.2.4. Testing for Zeroing of the ACE Field - If AccECN has been successfully negotiated, the Data Sender MAY check the value of the ACE counter in the first feedback packet (with or without data) that arrives after the 3-way handshake. If the value of this ACE field is found to be zero (0b000), for the remainder of the half-connection the Data Sender ought to send non-ECN-capable packets and it is advised not to respond to any feedback of CE markings. Signed-off-by: Chia-Yu Chang --- net/ipv4/tcp_input.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e88f449e89e1..0786e7127064 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -687,7 +687,8 @@ static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered, /* Returns the ECN CE delta */ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, - u32 delivered_pkts, u32 delivered_bytes, int flag) + u32 delivered_pkts, u32 delivered_bytes, + u64 prior_bytes_acked, int flag) { u32 old_ceb = tcp_sk(sk)->delivered_ecn_bytes[INET_ECN_CE - 1]; struct tcp_sock *tp = tcp_sk(sk); @@ -724,6 +725,16 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, if (flag & FLAG_SYN_ACKED) return 0; + /* Verify ACE!=0 in the 1st data ACK after AccECN negotiation */ + if ((flag & FLAG_DATA_ACKED) && prior_bytes_acked <= tp->mss_cache) { + if (tcp_accecn_ace(tcp_hdr(skb)) == 0x0) { + INET_ECN_dontxmit(sk); + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV | + TCP_ACCECN_OPT_FAIL_RECV); + return 0; + } + } + if (tp->received_ce_pending >= TCP_ACCECN_ACE_MAX_DELTA) inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_NOW; @@ -763,13 +774,14 @@ static u32 __tcp_accecn_process(struct sock *sk, const struct sk_buff *skb, static void tcp_accecn_process(struct sock *sk, struct rate_sample *rs, const struct sk_buff *skb, - u32 delivered_pkts, u32 delivered_bytes, int *flag) + u32 delivered_pkts, u32 delivered_bytes, + u64 prior_bytes_acked, int *flag) { u32 delta; struct tcp_sock *tp = tcp_sk(sk); delta = __tcp_accecn_process(sk, skb, delivered_pkts, - delivered_bytes, *flag); + delivered_bytes, prior_bytes_acked, *flag); if (delta > 0) { tcp_count_delivered_ce(tp, delta); *flag |= FLAG_ECE; @@ -4303,6 +4315,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) struct tcp_sock *tp = tcp_sk(sk); struct tcp_sacktag_state sack_state; struct rate_sample rs = { .prior_delivered = 0, .ece_delta = 0 }; + u64 prior_bytes_acked = tp->bytes_acked; u32 prior_snd_una = tp->snd_una; bool is_sack_reneg = tp->is_sack_reneg; u32 ack_seq = TCP_SKB_CB(skb)->seq; @@ -4422,7 +4435,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) if (tcp_ecn_mode_accecn(tp)) tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered, - sack_state.delivered_bytes, &flag); + sack_state.delivered_bytes, + prior_bytes_acked, &flag); tcp_in_ack_event(sk, flag); @@ -4460,7 +4474,8 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) no_queue: if (tcp_ecn_mode_accecn(tp)) tcp_accecn_process(sk, &rs, skb, tp->delivered - delivered, - sack_state.delivered_bytes, &flag); + sack_state.delivered_bytes, + prior_bytes_acked, &flag); tcp_in_ack_event(sk, flag); /* If data was DSACKed, see if we can undo a cwnd reduction. */ if (flag & FLAG_DSACKING_ACK) { From patchwork Tue Oct 15 10:29:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836103 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2050.outbound.protection.outlook.com [40.107.20.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70D8C1F707D for ; Tue, 15 Oct 2024 10:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988242; cv=fail; b=DjKWidfrOyz+cG0o0M8G6NxEANhQxplPUSaWXm8gtVo0h7aG35gk7ssnEF0OwBCK1/rDn5wUNrdhBWr54fsmsFTqd4llq3aKdDkBJQhm8xLtqbs8MrHoLz5NSEomdEfaQGuYOhnkCrQsCIiFDX8gJI5T4YlOeXwl2Toc+V9TSoY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988242; c=relaxed/simple; bh=RZpNN8DBSjinfwIeSkm5oZif5X4XNLxtHtjeqhBfMvA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=p6s+8ezzXFnluLXswtMwYEKBmVeEynEiweEsrljZPCg4Gf2Q2eIOws341SG1ijBeMUjswFtyhnZMRCRFNeuEaTslD/zCXhzuXgP7hM7lJ7CZno7NnbIy7tvU0lTWw1MvxCax6j7ZEagSmWT/susZ2As0DTl8wuAJa0vjgEuiMig= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=hRbVzjH/; arc=fail smtp.client-ip=40.107.20.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="hRbVzjH/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bPT9i36tg1nWlTgN54GsB/SrKfHzTU6A6hxDgXG2VfO83msC0obIIAn62l7aQgzILoDYQt5yl59cfZVCP5T7QNARB1zH3oCjG80weDEr0rs5mz0zVfNBr63p4F6gcIVbFl8SGARYx3pj5goPd7fb5Ia9hoEvea9i3IAFY0/WLjOUe8Tu51TuKHir/TA5gsjUZc+Xn1IR+aMdAF+WqaAif5cRte5VgY1WkwdG/E7dGMsoKvoOVQh4wPaCuUkTdShYRA7V/l+amCHGc47zqa57o4NyoqXml/t13IwGW3x9ZG4kAbTSE/SnP+g2vn+H631LywAc/ezUbFfOa0ADr7dkXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Wt9xrQ3xg5TWde0/7aKHc8cXo5/mm6Vw3u410rgTe2w=; b=dahJmaBKdUScxOczbGYJjcO6HqJrisuIPHDszvPTp6+rjerdUTApJYdc6rnU2JMQ6rSjSUf3xyqBKuDbosoytWzf7STLJvpz7s1JJLLv+ZRRTFygDSPRvzZsHRXrF2ig/jzSBviDshz8lvUamSFtmaym9oV+6xukf79dM335XbN3XaqbjKIXjW6sX4P91R9K3lo/6/0yOyE13SwT15FRCG6E4ean6dKL2t8E/R/xSjUZ1gSTqTuT0PKHXwx+3yhwQZn0x/lFiwGgqarQYiMdD8P7M9kWfqrtqDxPPeEO6ZswaNSLt1QRZ+QjjRDaCRMfFnf0CrjYMFpU6txEA+Xi/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wt9xrQ3xg5TWde0/7aKHc8cXo5/mm6Vw3u410rgTe2w=; b=hRbVzjH/DMQ3K+Q5IvVE0CerGESPmWrzptFkj3gV/VKXUn+vhpKlDDFKJ8PP2RL5jcRYoZZQd15q62p1XVwlwE+9x5stU7QcMSLNQNiWzHSP0Ga1GJmCeFiP1kLJHPX7HfddeAkXjfGIle4TgeIm29iieDaw0kFJyAb8c0XqmiZCEBgmkKw5QzD+qMDQNH0e4MMf8gQEuOx31zbQwE7iUk9EAbR+4W4gk6/Kvrwn6WUhAdE01qicmzKoNrTwNxXCB4873vETlHX9/Zolf51WtfpJ8W0MwcEXwDNtdgVM9Tx3CzAuAMx4/uKzeUXhuprOvtRmuPndLYc60HT9RUYZZA== Received: from PR1P264CA0002.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:19e::7) by GV2PR07MB9009.eurprd07.prod.outlook.com (2603:10a6:150:b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:36 +0000 Received: from AM4PEPF00025F95.EURPRD83.prod.outlook.com (2603:10a6:102:19e:cafe::5e) by PR1P264CA0002.outlook.office365.com (2603:10a6:102:19e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AM4PEPF00025F95.mail.protection.outlook.com (10.167.16.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.1 via Frontend Transport; Tue, 15 Oct 2024 10:30:35 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtni029578; Tue, 15 Oct 2024 10:30:34 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 40/44] tcp: accecn: stop sending AccECN option when loss ACK with AccECN option Date: Tue, 15 Oct 2024 12:29:36 +0200 Message-Id: <20241015102940.26157-41-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00025F95:EE_|GV2PR07MB9009:EE_ X-MS-Office365-Filtering-Correlation-Id: d2f51834-5904-4657-264f-08dced0467cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024|921020; X-Microsoft-Antispam-Message-Info: iUFr+E7COKk6kEt/NtwEtXgtG1h0uXHclGy33ZUSeiQ9X2NxUS5GFRbeyef4y/OahKfRbbfVhBG0T8OkA3+P1Ps/S4TRK+8EPtayijMoE+EFLJ574dFdZesbXJBoMt5V00HlYVUc6F8Itis5aS9ziGwUmbyJdgSVdK+b0OJW3cAfUsEwFaM5NlCAAaogu+U59vmPAXTFekCZRKPti/Akf00iiHgR39UU7SUI/QPV/9W/08fbTS2NaJWB21N51a/O9sxcrieEdo4MXvg2snRgw4Y7SY51Q0JbKr9otROflAVAXLYmkHdzxq9dT118OoC3WbWRbHIl1KdDcRXHRuFzObhQ432x/akIywl/3zqw200lfx5NoVdroOyWSxB8MQB+kG+U59KoCCBhcHWbFSrt8fnqYSWo0T/rjtmy9UpH7yhZe9enBO3+NqG84LCFCNyAJduUgsMeSIq7zXXDBKVjz0iQ+ttNJ3f3y6546uAYfxjiSYZYHVKNuf9JG22OQtKwpwfTsScP8dcrC452668vAAOFhMRF8X+f5iRrzNnHNRxLWN4pBsdwhjvm8dOwwKvp8ySFTY2ebYkbDtL1EAgUKKdBIKeXHA6WlrWhjR4/j88L4tkHSfKVH8pn6JAO99h3CLPRh92qR0y1H9QaP1eJR8UCq2NHdqhBqbvxo6V+OcZPkUHvG/QgXqdW/auDqrQxxV2TOdDKKINDTKyp6HzBS9PGTnpnPwF9N7eI4+iePWGO/vwRvi98yNn/EntZ9CAomiNJa4iPC1HKj9NlfsxY39LwYnYnzIUoYynKDbMtSJ+B9SGRUCjw4V/1CdTAAt0NS+D3hd2jyrvnN8MDpNNlQiQLpv2A4wg0QUhhmJehRRic6jS/sLosjGuL26c3xSkebcXcWGL/l8mXUqUvXXTlhTZy99dvgZIxV4ohWkFyv7HMznvFXnWoWetdCP81FDIru0vUqKefgVqTcZ+X/DEPYuTNfBywRmi0SxIN+wA1qIQQ7KZFwYI3PzpB0G3tSo4riR3fOe0rwxHfYGJN01lX244c7d3ppEsl5nCzXJWoRBjxNbpAKNd79hZjNLMDhj0VYldKwC5d+YClJNlMvgLOPax0MHZw0ii/isgfWR4Nx/ycSgDwMFBjfTyuRoTrNh3pGx1B7gjSUUj6sipzDALsagaLYN/5at1+Y807YpdaIVQdeQJ8/kVtQFbOCLVS0RYAm7iLG4Bu5+Z7vrQBO+m6pGOJFv/GfzobGr3nsB6wgCgUvbtjYR+7DDf2RnMWJvzJzPN5UGzhk3r2mIBcpqDQneqIz8IdmEFdiNHQwktB/h5ybjoOH5y6t4R/k/bnEPDmIwtcRvxTtHUr9mYkLOo/enR8Y1EtzSgFVUzKmOzt+3SV3ix4w0Pe64GY1AJYF+C6FLL7+RLfK8enJzM5YgKq5Q== X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:35.5758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2f51834-5904-4657-264f-08dced0467cc X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00025F95.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR07MB9009 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Detect spurious retransmission of a previously sent ACK carrying the AccECN option after the second retransmission. Since this might be caused by the middlebox dropping ACK with options it does not recognize, disable the sending of the AccECN option in all subsequent ACKs. Based on specification: https://tools.ietf.org/id/draft-ietf-tcpm-accurate-ecn-28.txt 3.2.3.2.2. Testing for Loss of Packets Carrying the AccECN Option - If a middlebox is dropping packets with options it does not recognize, a host that is sending little or no data but mostly pure ACKs will not inherently detect such losses. Such a host MAY detect loss of ACKs carrying the AccECN Option by detecting whether the acknowledged data always reappears as a retransmission. In such cases, the host SHOULD disable the sending of the AccECN Option for this half-connection. Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 3 ++- include/net/tcp.h | 1 + net/ipv4/tcp_input.c | 9 +++++++++ net/ipv4/tcp_output.c | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 9dbfaa76d721..ecc9cfa7210f 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -304,7 +304,8 @@ struct tcp_sock { u32 received_ce; /* Like the above but for received CE marked packets */ u32 received_ecn_bytes[3]; u8 received_ce_pending:4, /* Not yet transmitted cnt of received_ce */ - unused2:4; + accecn_opt_sent:1,/* Sent AccECN option in previous ACK */ + unused2:3; u8 accecn_minlen:2,/* Minimum length of AccECN option sent */ prev_ecnfield:2,/* ECN bits from the previous segment */ accecn_opt_demand:2,/* Demand AccECN option for n next ACKs */ diff --git a/include/net/tcp.h b/include/net/tcp.h index 4d055a54c645..ffb3971105b1 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1050,6 +1050,7 @@ static inline void tcp_accecn_init_counters(struct tcp_sock *tp) tp->received_ce_pending = 0; __tcp_accecn_init_bytes_counters(tp->received_ecn_bytes); __tcp_accecn_init_bytes_counters(tp->delivered_ecn_bytes); + tp->accecn_opt_sent = 0; tp->accecn_minlen = 0; tp->accecn_opt_demand = 0; tp->estimate_ecnfield = 0; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 0786e7127064..74d66c075d6e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5098,6 +5098,7 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq) static void tcp_rcv_spurious_retrans(struct sock *sk, const struct sk_buff *skb) { + struct tcp_sock *tp = tcp_sk(sk); /* When the ACK path fails or drops most ACKs, the sender would * timeout and spuriously retransmit the same segment repeatedly. * If it seems our ACKs are not reaching the other side, @@ -5117,6 +5118,14 @@ static void tcp_rcv_spurious_retrans(struct sock *sk, const struct sk_buff *skb) /* Save last flowlabel after a spurious retrans. */ tcp_save_lrcv_flowlabel(sk, skb); #endif + /* Check DSACK info to detect that the previous ACK carrying the + * AccECN option was lost after the second retransmision, and then + * stop sending AccECN option in all subsequent ACKs. + */ + if (tcp_ecn_mode_accecn(tp) && + TCP_SKB_CB(skb)->seq == tp->duplicate_sack[0].start_seq && + tp->accecn_opt_sent) + tcp_accecn_fail_mode_set(tp, TCP_ACCECN_OPT_FAIL_SEND); } static void tcp_send_dupack(struct sock *sk, const struct sk_buff *skb) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 74ba08a33434..4e00ebf6bd42 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -804,9 +804,12 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, if (tp) { tp->accecn_minlen = 0; tp->accecn_opt_tstamp = tp->tcp_mstamp; + tp->accecn_opt_sent = 1; if (tp->accecn_opt_demand) tp->accecn_opt_demand--; } + } else if (tp) { + tp->accecn_opt_sent = 0; } if (unlikely(OPTION_SACK_ADVERTISE & options)) { From patchwork Tue Oct 15 10:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836105 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DED501F8F0E for ; Tue, 15 Oct 2024 10:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988244; cv=fail; b=fjN3nCd2CRMR6If+zhoF8REvlc2tl1umjqQaZIdOpNgTw27+9+v/yhgXwQdhsK7VVaiLqmnKGV2LCkr/0Q3Q4QyY04T+GGIr/Ofs03t7zVzOkCOG9QqMg7J6IXy8iEGi/+v0qgHohxcnfJuDZh8Ip5IdqHn90uHAKacKUNkmlac= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988244; c=relaxed/simple; bh=PuNMmrXmWS8IZSFobeVZ7VQeDzMTU0QXq8GydOUGo54=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=G6+Ku30UnUIzPOtoAuWVuBbEBJrlksU7LwsBNRyzTIOOSsrIFCIed5bOH9Dg8RnW4Wgn4zp2Q7bsyfEgADlXjua+C0TVZpauJi1hbWz7sxa1a3BaK9CykK4Ul2EwUiU+a8Pj9aS2EOidLAJ4urXXvdkLhafmolGD1VgyI9pd85c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=H+GN/X5P; arc=fail smtp.client-ip=40.107.20.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="H+GN/X5P" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I9KgrQlqGsDAw2WMMSQWZ+IkCDYVLr+jGQ8OStMlCKyHx3IotR5a+GSFmuNn+UH0BGQ10Ivn1f91dW7Cyu3HaOz8uCxFhauzo6o0HnQqWd86wUMYjcD5aTADB8H99kTC7XxDxSWU/bdDX0DCWd5gUYV793hdI6IFqLfSmsGU72YosBb9EnV4/30DIVS6PLtieolxpe9beIIcs73IyrigZYFJLN8Rp+IaNtL5EgimCzJSvL8jlYkZD+cbniQDFcDg+oxGvo5IlKLYUJWosqBHTHujhIcUwJdAJE+2ykUjFB8XrZdjHWTSzqUkfBQ6cXzPg4fh3UHdPn4lQVps9UWRTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MgOiQFUlQFKL1CKgxJh89B2VNzur7Ac2KNfLdkxozq0=; b=RabFvbY6YmUMThXfeB7rr19KOdz7a9BYns0MAcLczWNS2pPKLUkAqAdcY4nFMtCNCxM5CoESgl9X/55hOYhaZZ0AIx5ikQeoDFkJjT9fL1MUpBLsl4T+fO3PdD39jOxyz0ZWKi1M6KcNKDmnyhImnIZQUj6+SkAQ9jtQz8yvjLNoOe9OhIG6KLrDj9fVnDd3H7tn1AIM8Ss7Gtl8L0jWnBTDUviKkFwkmZtgIbyOMjUbqV2wtj37CvvF8aIxQWzaXtVExqndfJKu+8jJ9Du+1pFla0Fjp0oXCp55zeRvBlSd/nhbO2QSJoaL05U4abLintIFm/2KS1qbeIBkSeGkXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=bobbriscoe.net smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MgOiQFUlQFKL1CKgxJh89B2VNzur7Ac2KNfLdkxozq0=; b=H+GN/X5PrhG0hlVRdrEHqM3lMzXpW9Wcga20NxU+PJFnvi9cMmlgObEaczCIRIo1B5lh+Kk5txxrwZZ7Rd45wVhSvha2dAvDJXqEChcOhPgZCzDDZD8bvTQRmpH4gCHffyA74Dv190EXBxp86cfu0nKbC41WwrUQOD8b5hAMuztLTuKtDDRWUQG42U+j4vb8GZIKwLEQCm4fFrg8PXQF456OT1cd8XfMW6LBerLK4T/PUQic7KVjJXGO0R6wRgv93YXaWz/AvhmKpBm1FmbWnT/AALPNnu9LV9/E6tyarFqQCbO2gojBLi2AJ3I3oUehbUVBZww86nHbxZE1rfJmlA== Received: from AM6PR0502CA0072.eurprd05.prod.outlook.com (2603:10a6:20b:56::49) by DB9PR07MB7179.eurprd07.prod.outlook.com (2603:10a6:10:21f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 10:30:37 +0000 Received: from AMS0EPF00000197.eurprd05.prod.outlook.com (2603:10a6:20b:56:cafe::ad) by AM6PR0502CA0072.outlook.office365.com (2603:10a6:20b:56::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.34 via Frontend Transport; Tue, 15 Oct 2024 10:30:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000197.mail.protection.outlook.com (10.167.16.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:36 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnj029578; Tue, 15 Oct 2024 10:30:35 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang , Bob Briscoe Subject: [PATCH net-next 41/44] Documentation: networking: Update ECN related sysctls Date: Tue, 15 Oct 2024 12:29:37 +0200 Message-Id: <20241015102940.26157-42-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000197:EE_|DB9PR07MB7179:EE_ X-MS-Office365-Filtering-Correlation-Id: 5cf2625f-94ca-4c20-d934-08dced04681f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?MtmWMiGOuFkkNCUzER7rRg7rX+yX8LC?= =?utf-8?q?8eb+CNYcbJo6rJrA8c+TifBfenYzXIRRK00fFDhFCOw7YRc+iD5jRkh+K+vN1ToyX?= =?utf-8?q?S/2SjYBbqmO3kH2oM1QSgcgNPu7/fvD5WHIvAiz1me4r7jqVGKRYAmbztIhRZHuts?= =?utf-8?q?7K2xsn+HL/14uV0lUED8kjPjjh43n6KcK265YgOiAqOiNu6bWyXF86sQWG1cysHJ8?= =?utf-8?q?73ueJi+p/es893St5Nxta90D2YI1/ji3cu4EZwZt1b+6ZR8xoVEkJMIpMuDGIgS+w?= =?utf-8?q?TqdeyPfoqVhmz2LtEG+y9uxum+1Y+ZWg7K2+C3CxjSzAM00VUyM/GBjfGGIS/DCxd?= =?utf-8?q?ajHccRyhGiBekqvmCQX9Knc8abfsjntGIYDdb326yXi3B/gU8DD9maIQCM3hp2v+e?= =?utf-8?q?rpy6rlNm8w5sQLTe2CX5fWCHl0OfphNt+65eTYCLuQZzArUrBHsQLBRrfwX0YV5Mt?= =?utf-8?q?mQ3bOprALxawCDDaaPeYXhFuSXs/WVIWLkwuZ16/SGSxyMlQKJSUGs7eQwb5dHEsR?= =?utf-8?q?jDgYJfBs/8aMciXRpQl79YA8iX9S2JmXqgx0N6YcF6cpH5G2Ij61iUzAJ4hZqooh2?= =?utf-8?q?bSBepdKm396b2BV8msKmNDIpRJdNlRn5wfmYcBKUNjS4hgP50Azs955VnhJWG/tlv?= =?utf-8?q?lbnIazmoqaf2leNImt6uqOv0cFOSfjgmCunr5kQI70n9NbTj+q8/zwUst4w3o6/2j?= =?utf-8?q?9S3RTyx7fcqOdxyf2VjAw+DsiXydQPOn+NMT5oosYuetTCzajNlbrQNM7XmmgdsDB?= =?utf-8?q?PuL4uqP9IdC3ha5/HfDtKyuJjymcHceT8MPCGXn3nbDLIER+b/yPiwHHs3NxPGfc6?= =?utf-8?q?B5jTZGOqMV/qAHI6EeiEotzazqaFwSrv5F6uTyCxwp3JIIWHETNUq2feEMp+9BBcz?= =?utf-8?q?sWjO1BGw/DUdtTlUSAvhvHWeR6vVpgv5TU8EsyKsCan2yn1gVmEhYdLrIgjIXX3mh?= =?utf-8?q?KDcBO2wcMoh6GUee+cOkDAWUb69SJAn6idtB3aZOO7/gElKTWfKHoF/dnNM64V0Nr?= =?utf-8?q?JqUk3YVSiiV0IzU24czKBsjuKNSZm+tFDSD+YkeZUyVgtlRXDdSJTqunMnJkD8Vp7?= =?utf-8?q?tx8JfBeo+whN9pjLv61e4QT5ZZB5c1YFFyCqVGgNsbaEhX8TTsyN/aUs+aWTTMBVb?= =?utf-8?q?5S+JtsDAWODr+F1JZcu0GXmqxCcAn9BX/vj2kt9B7umXI+PlWefCupM56rQycS0s0?= =?utf-8?q?jcudJXfPp2zq4hdaa2MGhifjzkjLb3Ga/uXwNXvNoP5nTKOiwlaq6XU6dC0S1UsTL?= =?utf-8?q?8nZXrbtOFcjer/sg4DSWvwJmtkoDAttVGKg8ArVHqZEU+L22zFhj4v9vy5+3nyfZE?= =?utf-8?q?epDAht6Hqxbg?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:36.1087 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5cf2625f-94ca-4c20-d934-08dced04681f X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000197.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR07MB7179 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Clarified that tcp_ecn enables ECN at IP and TCP layers, explained IP and TCP layers differently, and fixed table (table headings don't seem to render unless there's text in the first heading column). Add tcp_ecn_option and tcp_ecn_option_beacon explantions. Signed-off-by: Ilpo Järvinen Co-developed-by: Bob Briscoe Signed-off-by: Bob Briscoe Signed-off-by: Chia-Yu Chang --- Documentation/networking/ip-sysctl.rst | 55 ++++++++++++++++++++------ 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index eacf8983e230..de6b57775140 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -422,23 +422,56 @@ tcp_early_retrans - INTEGER tcp_ecn - INTEGER Control use of Explicit Congestion Notification (ECN) by TCP. - ECN is used only when both ends of the TCP connection indicate - support for it. This feature is useful in avoiding losses due - to congestion by allowing supporting routers to signal - congestion before having to drop packets. + ECN is used only when both ends of the TCP connection indicate support + for it. This feature is useful in avoiding losses due to congestion by + allowing supporting routers to signal congestion before having to drop + packets. A host that supports ECN both sends ECN at the IP layer and + feeds back ECN at the TCP layer. The highest variant of ECN feedback + that both peers support is chosen by the ECN negotiation (Accurate ECN, + ECN, or no ECN). + + The highest negotiated variant for incoming connection requests + and the highest variant requested by outgoing connection + attempts: + + ===== ==================== ==================== + Value Incoming connections Outgoing connections + ===== ==================== ==================== + 0 No ECN No ECN + 1 ECN ECN + 2 ECN No ECN + 3 AccECN AccECN + 4 AccECN ECN + 5 AccECN No ECN + ===== ==================== ==================== + + Default: 2 + +tcp_ecn_option - INTEGER + Control Accurate ECN (AccECN) option sending when AccECN has been + successfully negotiated during handshake. Send logic inhibits + sending AccECN options regarless of this setting when no AccECN + option has been seen for the reverse direction. Possible values are: - = ===================================================== - 0 Disable ECN. Neither initiate nor accept ECN. - 1 Enable ECN when requested by incoming connections and - also request ECN on outgoing connection attempts. - 2 Enable ECN when requested by incoming connections - but do not request ECN on outgoing connections. - = ===================================================== + = ============================================================ + 0 Never send AccECN option. This also disables sending AccECN + option in SYN/ACK during handshake. + 1 Send AccECN option sparingly according to the minimum option + rules outlined in draft-ietf-tcpm-accurate-ecn. + 2 Send AccECN option on every packet whenever it fits into TCP + option space. + = ============================================================ Default: 2 +tcp_ecn_option_beacon - INTEGER + Control Accurate ECN (AccECN) option sending frequency per RTT and it + takes effect only when tcp_ecn_option is set to 2. + + Default: 3 (AccECN will be send at least 3 times per RTT) + tcp_ecn_fallback - BOOLEAN If the kernel detects that ECN connection misbehaves, enable fall back to non-ECN. Currently, this knob implements the fallback From patchwork Tue Oct 15 10:29:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836106 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2082.outbound.protection.outlook.com [40.107.20.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EA431F9400 for ; Tue, 15 Oct 2024 10:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988244; cv=fail; b=pCfsDbnqJiej9RoVjaCd8hk2c4Szp776tyNnoFffYPXDxhAUGmmp6Zna4t+zQN2bqxqddHDhjSBQXnVAx6fZ2qIrs7YnbOwJSMVL/dwC47Y0p6qcHwEjrKNSdHEuEdEZhmFomTVlLab7IszkH+J4Ryy/ieXnbTS4ZKa5oHsYDk0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988244; c=relaxed/simple; bh=4T4GdhUGoEUokZ3OIxzB+EWrizYn5VJAiiF0JPCBDxA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=COEhUAmUEIfL0kskp6NjxkT1qiq03l+iN9/8L3X+jyMVN9AvzBxxuBBtZvVyxWHEPSrOTnkPk/m6pjGJ4xiVau4V4ZHlwAH9nS5t6y3CWDiuPvwSVk70YHnM9EOpt4zMssxot7JGVFsRjnNlgwpGZUS/XQFZn40XeOgy6l7ETak= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=MWh67FpT; arc=fail smtp.client-ip=40.107.20.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="MWh67FpT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BULrhGf5dZT12smCjf33cE7mT5C5bhbDFqVT4aN/boziyxbdUC4/rLFbgPzpkviqDr7j6fuRE0QgGG8u7+o+Y3E+AlFXODpTwvlbRyOiurTk8jeC7ZybrgZi/e6dZR6/edyGx8FluOqqVAUa/4gAhX/lti6L+44+8KrMwELFpsBWUv5foOmN9gsNktEPN7Em6m7lWwHXdVJW/su3hGj7IxN8tnLqYcQbhDTTInu0qT+3LsiOxUZEkZzDGWkKGPbhoPHFvt9hZmx8n3E3vbCBGP33A03H2eMhN3+vyOYMv4fJjiXwSxUKFMuTjgnQdIb5xNRMfyVyMLwb69nLflhV2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1zrYTIT0yK/vPyDCJOaOT2DYRh8LoTEQCWCtfNVV+UE=; b=VL5J+gl27wyCumiGjVzwkfIl5NCxgLwMS02deyyX8yQfEx1T/Hyc72IAXyuFzXedi/792sI4GF7oRHjHnYXn8fcb6ZxWLxLDAqpwLs7Ktu0spHnKGjkfRISfMqTYwVEmhtQTCh4R5bFm4JuQhRPdSaP2/ySnw5UVDNmx6NU36/+ThtG4fUFS6oCE6PW4kJXFeY/ly8k39faOssN7SttF2dDbYF4wqJPYTKj1rR05y4Vnjmc9LvdSxmQhPnWP8u5tfTI+40wcPDW6isj+kkeyGsqHyybk7clsMhXGCMbWm40rNsUsU3fG9tWA+8bXgeUUgpyxAufvsDZ4RXqNNzf/eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1zrYTIT0yK/vPyDCJOaOT2DYRh8LoTEQCWCtfNVV+UE=; b=MWh67FpTp3CCpVpviAcmWc4qVSQRYeGMSye22wlWY62OqXGTV3RMUakoUgBhfwm/G5AMfZvlmVkP0EU3QrMcMdI7oDMvygmpzoHbrGaIAHBpww4mLpLv8COJ5XTJxM46hV6psxttrKx64X7uXoBpPMT4htkNA+TNNHWqO7BwQiyNTBLOPKzZ0Ub+HCFjRnrZgaq63+zsjXFZE6909L2x4DFj0PaBIaJU+sX3//tkFmtU0bUHj7L+G6sWTRmVQiakkbwgzzANrUEjDgX0XeNPi1SBVADm7Bq3/CgztbaIpeh2EkRdo5rpvzdMAxe+arMuvMmfECt1vcVKo3eLPb1nmw== Received: from DB7PR02CA0036.eurprd02.prod.outlook.com (2603:10a6:10:52::49) by AM8PR07MB7346.eurprd07.prod.outlook.com (2603:10a6:20b:24d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Tue, 15 Oct 2024 10:30:38 +0000 Received: from DU2PEPF00028D09.eurprd03.prod.outlook.com (2603:10a6:10:52:cafe::9b) by DB7PR02CA0036.outlook.office365.com (2603:10a6:10:52::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Tue, 15 Oct 2024 10:30:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by DU2PEPF00028D09.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:36 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnk029578; Tue, 15 Oct 2024 10:30:35 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 42/44] tcp: Add tso_segs() CC callback for TCP Prague Date: Tue, 15 Oct 2024 12:29:38 +0200 Message-Id: <20241015102940.26157-43-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D09:EE_|AM8PR07MB7346:EE_ X-MS-Office365-Filtering-Correlation-Id: 43c54c00-bbb9-4f4c-67b5-08dced046887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|82310400026|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8baLhmIrGmXmM0lgvJ7gqjHaEeDnb72?= =?utf-8?q?jAJFCchG6KbVx4nwR145+/tFtQiNIbuB56e6IO676w1JgFOUA2nXR4efOqQuNBmE9?= =?utf-8?q?hNpxlJUZ8hKAFqgerFAKChigk/3rkqOWRKj9/I4mXiclQBmE9lt6jICTiwoXigUtI?= =?utf-8?q?mPtCFKR5Z+yxVL5ui7yVdZY3IpEx4RiZnggdhtBwIVHLooNqi3s1+aH9IZNzewoR9?= =?utf-8?q?Umi1nVAGsLTrJ1rgTJVfOqVBc9RPne2jZK40Pe2SiuwuRKvpF5XS2AfbyAk919cpL?= =?utf-8?q?2M4kR4HRlxS+madWf/rT9j+9qkp995Yz0sxR+IceDuJV29wOQmQ7t7KQMB9Uza4jy?= =?utf-8?q?HLiO+e+bY8R8lOgnk5OrOldY98WL2CjmgUAaj+p9a0eY4HBicaVTv2iq2eiTMOGrF?= =?utf-8?q?LDC+76uBQLbZYKdo6eQwJ7hYPzSn5SufNdApnMbqNTD5sTGtIEbvMb5TgvaWOlkXQ?= =?utf-8?q?7FDA2tM8Owf/PrJ9lWk+c3LnEXDlvIoOlYr9M2XGynp4gG97MkyEKrLNfQv6l1acy?= =?utf-8?q?HyYj+nheyiiosWlyj2UBU/0LW/6AGQ0IW6C8xwW6huaH0uR7g0OedgbcddU5Ozc2D?= =?utf-8?q?/QtBRFG++Jiw7ylJpFYGzvsBTJskmbJc8HrRDQ5UlUf2bCD1Tm34cndzbkDXoWioz?= =?utf-8?q?DljOhsVkLmW8W9pYGTR5wOwUSRSuCPZXGxI1006Vg5nU9Q+vzjir3zTI64I63AL9f?= =?utf-8?q?QpJ2pXZWx1IjT5Y2L3Ap7lqPs0kAXsQBBi77GG857Yu9DemypE/aci0wJ4d9iViGD?= =?utf-8?q?LzW3fDIK+5K3qqR34CxZWWs7U4uzHhslUf3xZwo+vi25jbqM3G2HDUhKkp5lCEY6L?= =?utf-8?q?SPCVWnvnm4va+YxftjGzaTj5Aezs/r1BH9XZl++5ngljg9Fcm45m09R29J3ogFwW9?= =?utf-8?q?CVw6XzmwO2pQ+KnvB567tXbWynFXDeGY4BpMxFvmWubdaozsbNSR9KRYMZSPUWULT?= =?utf-8?q?BUu7RlgdZoiu2cc0d1iQr4M59/XAvAYOlFnlTnihGvehCeaipKu2F8YlFkGgKZH4K?= =?utf-8?q?I+cJfz71rH+31/pwtVqNT1MJErwoVIRfgyzqeMK4kXfgEthceGjaA6pq2DE04pAoQ?= =?utf-8?q?G7cdyOzipo/K3hErExtdxAVlGeAjGIXNNYAZfw5QHLXwWlfHXyvtnFduaw870J9Dw?= =?utf-8?q?tnJ96T8GIRwBHu+hV5hhvyJFU7gRLBvbrPuYBbCHGcdkduDyjQfJ1SDD+065wwZfU?= =?utf-8?q?/AhgHeX7F9lOom9uL3Bq+IKgy+bZdRD165HhazPx8rxrJvBhmGjLQN2IsJFo537H5?= =?utf-8?q?yRBHhjgLrmVaBMRxDe7T368DmfRAtRg6rJToYJpPPt3KCKhMhyxE7T5bf1JMtsvrR?= =?utf-8?q?p6ohhwsCVYA6?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(82310400026)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:36.7405 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43c54c00-bbb9-4f4c-67b5-08dced046887 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D09.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR07MB7346 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang This patch adds tso_segs() CC callbak for CC algorithm to provides explicit tso segment number of each data burst and overrides tcp_tso_autosize(). No functional change. Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/net/tcp.h | 3 +++ net/ipv4/tcp_output.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index ffb3971105b1..ce7230c1ba5f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1322,6 +1322,9 @@ struct tcp_congestion_ops { /* override sysctl_tcp_min_tso_segs */ u32 (*min_tso_segs)(struct sock *sk); + /* override tcp_tso_autosize */ + u32 (*tso_segs)(struct sock *sk, u32 mss_now); + /* call when packets are delivered to update cwnd and pacing rate, * after all the ca_state processing. (optional) */ diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 4e00ebf6bd42..0f0e79b42941 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2275,7 +2275,9 @@ static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now) ca_ops->min_tso_segs(sk) : READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs); - tso_segs = tcp_tso_autosize(sk, mss_now, min_tso); + tso_segs = ca_ops->tso_segs ? + ca_ops->tso_segs(sk, mss_now) : + tcp_tso_autosize(sk, mss_now, min_tso); return min_t(u32, tso_segs, sk->sk_gso_max_segs); } From patchwork Tue Oct 15 10:29:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836104 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2068.outbound.protection.outlook.com [40.107.20.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BF4C1F8EFE for ; Tue, 15 Oct 2024 10:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988243; cv=fail; b=qHZVwKE0NfxysiG/SCpZdc9siob+RDVItG1OXbTvRUeLKBAq2dNQASqyRtqLEnDhikD1AR6pje6rxVlxkOxXC4oGX9JEEY8sntX2Wz/7MfYzFbEeFdKtlqC4I5xkV3F9oDczoM3kfFZfzAl8r+g51gn4XGXgDLgWRYhLw/CpLew= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988243; c=relaxed/simple; bh=buziG2E0HjaEak+PtwFVhEJGklX0FQ65JKrQxi/7SPA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=H8+WLyv3qtYNpvPY6s9WWDKoUl4SI8xCOj6nW9MLDv+dE08nubSKynd0D3oJdcG89TeqvSDw7cVzgxoFysHMFVBLgLMxq1u3j1fAuovFBWTraA6b9MgmWqLra9+hhQZh7+AP9JIGukTdzQy14BB7JjAkx9HH9GU0eJJO7Kcgpf4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=fxN5Fh/n; arc=fail smtp.client-ip=40.107.20.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="fxN5Fh/n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uCWySYgDdzDwOTz6uwsugKly+PHTeFN4/cuYhX4AE9rU3dOfbBm1qn9nKUtJqRRdgYGvhVNCnCutbXccyAP+0/+sOkshribVjAS8Y375EPO6xpPzkZIo0wEtKnu9TMSulVy58Qkgrn/cturW18bAHUXHk4iq4/t+92GVakbqj7K4s31T20PFwN4Bo+V6klnY1k3Nuld9cm+DJ23N0Y92qVyezxnvJ1lOksZbMsSCXHykhY0YcpQh0nU1Eu56VgGtPKyj6nr29VdEk7rvzoS4i0QCUAMCZLX2rOSXL8HPHVcQmH8357l3GTIuON2brcWwMs419zi+zf2BJ8o046qJRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rg6Tyz4T9SA9zigKqHYAXbwNGLtzApIb5Xyf5Mbx9zc=; b=F2sWGPIzmjjvulKQSKVNfusn8YvnzyGzThRZMDtZosywgyqjdJl3P23deTf3UtxQ6Z0D54HZoUM2LTFRYiG2orLDPQamywKSTo3gHQV6gg/TwHwvNFVnzCZ7Osna72sPeYl7fW5waYPFos0oDJbIidBN/T5jofxklYyTVv/3FmRjzWdhoT4PnkcgedKYnehh1FTa0H1BGGnBltaoPx1IRY3zeanr51A4elDlUjUk/ICI6cU6+khD8jIsc2ys/DjEXrq/38je9MsAs5UDw8AIXlb6g3fzzD4eUrmt93ZePUR/Hg3A/kdwzD04z4RYYqzGl5AnCHHqQRI44rv/T5Bbtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rg6Tyz4T9SA9zigKqHYAXbwNGLtzApIb5Xyf5Mbx9zc=; b=fxN5Fh/n7b1Ubolf3+sQVJ+9JjIy5W9ZNhDXGmaVrw51lQ/CO8rgc4/cGfT1NMTn6Ap00aK7knLDPxl7z0Tpmnni3qAmOA1kTduudzNQFv3ZF3GMCae6J6zMkm++2FkclSdDSLTmeMQcZrEJByC/mhDuCH/E/so0Uf8z9UNpJWcD5DaYFTnczTHn648DFwuTjIevVUM9sxW6K1Zy0wKm9kGQr2jOSgnzaW25WKCIrOumX73TssdFuB/tRwnuiDGwL6vXrsXRKBtG19+ej5KwRxCcaQdffHShg47zoJvegDBZU9WsJK48kqsxOSm3fdlRruzhG9hNTWct65KLmIn3tg== Received: from AS4P191CA0001.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d5::14) by GVXPR07MB10134.eurprd07.prod.outlook.com (2603:10a6:150:11f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Tue, 15 Oct 2024 10:30:37 +0000 Received: from AMS0EPF00000195.eurprd05.prod.outlook.com (2603:10a6:20b:5d5:cafe::e4) by AS4P191CA0001.outlook.office365.com (2603:10a6:20b:5d5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 10:30:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000195.mail.protection.outlook.com (10.167.16.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:37 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnl029578; Tue, 15 Oct 2024 10:30:36 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH net-next 43/44] tcp: Add mss_cache_set_by_ca for CC algorithm to set MSS Date: Tue, 15 Oct 2024 12:29:39 +0200 Message-Id: <20241015102940.26157-44-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000195:EE_|GVXPR07MB10134:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dcae411-490b-45ba-818f-08dced0468d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|82310400026|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: A2skQ4lD2G72+z74UUcjMo5T4YpV73MyBqblZNE+U9DhRuHFfPf9QYi5qwdePxW+2utQZBEybREeSvaysAMM2PDVqeJiF8TZWsCUMgkBcT50194zVlKUC5VvSvWIaCnxoYG4aDuY9aXTRwB+dOJQif+loGg1ZBJe6ed7ArHgCU6L8yiCgYyt3P829AcTy6LiHNR1PZHawHxjHnhJ0yxbum3012nK4fjGk+yIpt84fDIkzs7FjPj+nv8T+I4kUzowkoppXtL8DgvzKthphX1ZyWxHI6smSI0oGz2MR5/F8oV4dWz2LZZEAGxvtlDVvSFRWBYglRQBxcCv6pgveBLGiIB2lAYg4sQ7NqFMGxkLFGIDkvhMBUXonn0dZQ/BqMS7Q/Hj5WxH2/zXwCs1EsodMSzzX/phu2oeMpFn8k6FucZCnBv9Yhj3AHIUYSd2nY0GXGfHMGesKRQ2s5CDgpTTdgyunq7+BRX9r3zqQOoymbLM294Wn+ATqkIrUw8txMh92InPRm4e0I6UuTlusbK3xt4TkNYFyoBNwyTRow1EBQM4HqQhdkz3EQfaqAlZoobOe7zxSZ0USaxr9z0eNUrWqudYjzaecXsbuxfMOXZENfwmOdP9bPFej6XXzgOUx657YOF+bXS338NpGRElFH2smjm8ltK0VzPQpS8WIbYRbtDWyzye3LRPE49ROdBoeE8H0GzTtEWUar4Tgfe14rgXWmCjxFwtfR93ZRktygzyt0VswH4jxlI/s3ATzsMBdP1MCv/lTBI6Ye2FUwzODpe/8yyckdlMYIS1G7M0NjQD2PwiQAHjf8ctWRr6mEyHbS1PFfFwFAsgRGSgBMMClkMslhxS5LoveL9M3xVKsScuZe0v75gjgVq5zsCFc19EX2lAY5uPTDq1IInRGHAwGEHDW9U44++GE0g1k2BNgbs6DAfoDHxZd4qC8y88JEp6YZ5ptS7BzXkVeVERhvVhpgAk2d+wiqLAF3FXtOyOjWm9dl4DWy6TbeKX1a4S+0jboWBtzvZTvUjXjrgQhlaMKQw6TlnnnZDfaXY4LgKAd5i4eIwTB9Vz2BgAqzef5L/OM2bQM1NvomVMBPB8vXcMU1GsXQOcl7IuwZVyNxm5WfjhpIqv6m8OJ/xuySyulMkPwYgMtC3CHzBue8Xqngnyq9hVMsYMvDScd/YUVeGmb/z3Zf5a+3XBLo+4uzcb8SI8XrCxNtL4K6YYdnrZ8vfMssRQvvCSscPyhq2JkRfIjOaKEVpOG79qco7Nu2eN2AfVaZ/l0qt9A37rkzM7242N1l+j2uCzxiAh+WcAgf6HiOLhmj7tCc4WohxRWSbqitB//p+tOQGmm/AXBTNfycTpLL9knaZ7ArbsdDYak3X2VEFuOGorA5Y7E6cbLk+JjXBeV6+M X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(82310400026)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:37.2952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9dcae411-490b-45ba-818f-08dced0468d2 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000195.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR07MB10134 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang Make the CC module set the mss_cache smaller than path mtu. This is useful for a CC module that maintains an internal fractional cwnd less than 2 at very low speed (<100kbps) and very low RTT (<1ms). In this case, the minimum snd_cwnd for the stack remains at 2, but the CC module will limit the pacing rate to ensure that its internal fractional cwnd takes effect. Therefore, the CC algorithm can enable fine-grained control without causing big rate saw-tooth and delay jitter. Signed-off-by: Chia-Yu Chang --- include/linux/tcp.h | 3 ++- net/ipv4/tcp.c | 1 + net/ipv4/tcp_output.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index ecc9cfa7210f..add0da4dbedc 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -232,7 +232,8 @@ struct tcp_sock { repair : 1, tcp_usec_ts : 1, /* TSval values in usec */ is_sack_reneg:1, /* in recovery from loss with SACK reneg? */ - is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */ + is_cwnd_limited:1,/* forward progress limited by snd_cwnd? */ + mss_cache_set_by_ca:1;/* mss_cache set by CA */ __cacheline_group_end(tcp_sock_read_txrx); /* RX read-mostly hotpath cache lines */ diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 16bf550a619b..13db4db1be55 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -456,6 +456,7 @@ void tcp_init_sock(struct sock *sk) tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; tp->snd_cwnd_clamp = ~0; tp->mss_cache = TCP_MSS_DEFAULT; + tp->mss_cache_set_by_ca = false; tp->reordering = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reordering); tcp_assign_congestion_control(sk); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 0f0e79b42941..d84c3897e932 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2074,7 +2074,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) struct inet_connection_sock *icsk = inet_csk(sk); int mss_now; - if (icsk->icsk_mtup.search_high > pmtu) + if (icsk->icsk_mtup.search_high > pmtu && !tp->mss_cache_set_by_ca) icsk->icsk_mtup.search_high = pmtu; mss_now = tcp_mtu_to_mss(sk, pmtu); @@ -2104,7 +2104,7 @@ unsigned int tcp_current_mss(struct sock *sk) mss_now = tp->mss_cache; - if (dst) { + if (dst && !tp->mss_cache_set_by_ca) { u32 mtu = dst_mtu(dst); if (mtu != inet_csk(sk)->icsk_pmtu_cookie) mss_now = tcp_sync_mss(sk, mtu); From patchwork Tue Oct 15 10:29:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang (Nokia)" X-Patchwork-Id: 13836107 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2063.outbound.protection.outlook.com [40.107.22.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC0651F9409 for ; Tue, 15 Oct 2024 10:30:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988246; cv=fail; b=ejizAJ4xGBFf3iwhrKc0A0bupxfLdxcbDgGDVrzATKMB8KjmiiglwmgZ+GoKsYaiCCviPKs0C50brhiLLtHzSwOQg2MLJcJTm2kcDCY2gWTQqsiqg4Y43tBKqFOB0w6ytnS6zcMQRM9uI1VTthsbFx2T3JtJTmTc/+YArouN0+0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728988246; c=relaxed/simple; bh=yfUTNItIo4Pe3L3s+Qr6v8JwqHZKo+BecWRWqapFkP4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=hQemusK+oFU8oJNf24sRHuUlybrDMasIL3Ml33sFsky92MpAbT/rws6Ul2LWF0/zmFlYKZWHkZKCOImJ8IGB3BixhxKL+09CHtgUUJhFeUj93FdBKm52aXPPEsc78Q1fF95MCYAWoLMU9bdvDGNbiN/WGsWR6ZecscinayPZJHE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=lEoQzdvw; arc=fail smtp.client-ip=40.107.22.63 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="lEoQzdvw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=afDNcVB8KgpwuCJOS7S4fPDinoKQ/479sHJdEww3sDOpxrGsmh8TFRnWhIHeEtDu+GxlXl/MKt9DV7CDOkQhSR1kcjpwi4+mbCKvsHO+91Wmn44bZ1PppyUkdM5L0U24Iqsp3bNuV/vauvaqATf/LAopwdTvouBeSt/8V6FzNI9p5CEFCHz1tv8LcGIs1h+yOaNzQwjJiPrGxgydiddxgMPJGLLk4T9iOyTa/LxGDwUSS0WuVMuPIyOKFQQkZAyXN802GmmCaX77h6r2dB6P9lpEUJgR4mjwG3qcuxg8zpmJ8HORNJm6ykKYqqODKcp9P6Kq7v6QQGZrAWmP+mv2vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aCKvQc+wQVzwtIAgtT9u6pacSckr8C6sIgT+3wVZ6W4=; b=P2MKyTsFm2zthYjUyKiG+FAVQi+N17r9w3eqWiNfORXPIGTjtYSCumDV7hsaxcDzfnTxt93+eiZZEYuuz9+Ehe6nYlrqPE6MR4Y+ddhcLUn982G0Q0ulBEEF/HwMze7oofUEZAz5A1U3t6uk943BGURrdLCZAZnmHGwWnswEr/6jumj8WmwaPv81XytR0QLmI3TaISg/e4dNWD8b8PGml4n4jTmkc9Yf9E7AnfFxh0FnP5BH9iKEJoKtikmViZs4DBdIFeImiNVjhxpUjVud3Pz2nh8FPXjPqeAt+m9Zr3DbDf+BTaRPxeeR6qMf3v9kjOjWh33QM6Mh7VobLyXC1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.101) smtp.rcpttodomain=bobbriscoe.net smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aCKvQc+wQVzwtIAgtT9u6pacSckr8C6sIgT+3wVZ6W4=; b=lEoQzdvwrB0ZUUDRY603Gsr8im1MnXPy84YolLIfBKfCbqpR5Gh/t+jmZJkH5ntncbS4fVw1XcMJ08w7MTZ2IGHVqwjqjHFzuefKw38tYV4CJEl/d/mxxTxbYjmzNk9JKz8yFew9IRrKCQzADGvNFEKu7w35mmcXMfNfWIqirtlZFjkswYy9GeBqB5PJDvQwb99a2SI20Mc8COBbp2iQF5HJmwf1hQlPFZGqh2uVXsqHbqAMKXrgCVZR5XqnoK42MLFh64N+YBJLJ5mgGrhuMsQ2gYtWAvrAyJdpm42dop23WfPyXv9dtaWU13x5B/T1PxuaQWIiCHWU5FhEao3xgw== Received: from AM6P191CA0051.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:7f::28) by PAXPR07MB7983.eurprd07.prod.outlook.com (2603:10a6:102:13f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 10:30:38 +0000 Received: from AMS0EPF00000192.eurprd05.prod.outlook.com (2603:10a6:209:7f:cafe::9) by AM6P191CA0051.outlook.office365.com (2603:10a6:209:7f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 10:30:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.101) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.101 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.101; helo=fr712usmtp1.zeu.alcatel-lucent.com; pr=C Received: from fr712usmtp1.zeu.alcatel-lucent.com (131.228.6.101) by AMS0EPF00000192.mail.protection.outlook.com (10.167.16.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Tue, 15 Oct 2024 10:30:38 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr712usmtp1.zeu.alcatel-lucent.com (GMO) with ESMTP id 49FATtnm029578; Tue, 15 Oct 2024 10:30:36 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@CableLabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang , Olivier Tilmans , Bob Briscoe Subject: [PATCH net-next 44/44] tcp: Add the TCP Prague congestion control module Date: Tue, 15 Oct 2024 12:29:40 +0200 Message-Id: <20241015102940.26157-45-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> References: <20241015102940.26157-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF00000192:EE_|PAXPR07MB7983:EE_ X-MS-Office365-Filtering-Correlation-Id: a776f52a-1fab-44a7-549a-08dced0469a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?isufWWijqPaY8MLrw+WU7K5BncBE5Kk?= =?utf-8?q?4KmKowl7SCjZG5hHtWrtqDln9aHlD9QVE7zOW/3J29YO1U/r+D1qtFFPgR+uAwv15?= =?utf-8?q?VzKjXQSjwrVoFGQHlA12qgKUb3/6C+Ig+ib6+VZ887H4hOIRP59k2e61KAHXpW0id?= =?utf-8?q?3a9KbTPJTxQpwojNl76EERs/HJ2E0/DnFAMyXmHp/lDP8Bgb3ADc4OYeLpKJLiZff?= =?utf-8?q?Z2W7uVal5QbH94xCx7dZBu3er1PE+m8yiYBN+O1sc1JENWZKJPREiSyGch8ivX8so?= =?utf-8?q?jHigZa+dqzonYlYXuVhw0qprDIGoxZLi/pkwBNoBASdl0aQtQdiz3VakX3xuC2ns3?= =?utf-8?q?VQT0AtnBuwrVvQehf9ZQ3yl2VbhB6c2mblMgyHtpGM0+k7Jexbb/k74rN4ExgPz68?= =?utf-8?q?zjxhze1RLFIsscxXM5eKaVfSPIdUcLkcmEUTRigM7dTuj9OZ6EO/AlzBggv1OY+aT?= =?utf-8?q?f5YyTKgJHcS8O9Zu/x9OtH+x8VWDg5AbXkIzkhyrmA/qpZoUstQibNV+DoO01kM6q?= =?utf-8?q?Qz5J9D7iiniEKJzDQn/BnHbicLrqAFC58zjLBBLg1X39SxyuLcNp/u5JSYv1j9XV3?= =?utf-8?q?SvRhD5yzfXhBp+c0JyLCPNpeULCEMXFPuuk0V/wOd8DeGUpynrCGsdDQUOtd18Pty?= =?utf-8?q?1vWE9KcQjkKl2XgUSjisdAHsgWzji38jijEWq8PxjhKC/uRaGYqPsfT7b06msgQPE?= =?utf-8?q?twabLnyibyYggxb598jKcd37G99nQA5uitpK3GiBQDbkvwgBTc4rKxy84eajj94po?= =?utf-8?q?Qonjdvx9t1DDydYkepIrqsoNdDlotGNu1yQvB8WDpO2tVK2bP3hqWwpxLTQiOU6vS?= =?utf-8?q?i2V1JyHueln2sW8/QvIttSabMNIeIwdU0Ccxaz2bYcsRvFSRpwyKWBxcvximLnu75?= =?utf-8?q?0l200crPSupNZ2TToHoo172UeOUBsBO6y5Fyyv6z5HR9ETW+UQHUnvbMDnMPGhWU7?= =?utf-8?q?Eg6rchRx+8vqf6Lk/A8o56bNY61SKlZ3gytFHDPeLJYzSBIZPkMfQShxOSAUlXWVM?= =?utf-8?q?gRRXaLqrdzbb91K3u/i9Wgglyekt47eTvQJJvqRlIhdg9SExQesbPnzh4qRNYYavQ?= =?utf-8?q?tD1f6aX0azrGegs1oV80tRWJFFnE0SjtIeQ6zR7kMHiX9u6VnneGwhMigp3YTAMle?= =?utf-8?q?D71mY23bQTIT8ROWG7djWMe/irye419bV6HiSDW/SETYyDQ3x1J6pmuKiNCaOfLrX?= =?utf-8?q?j3LJnVezLB5FqbJriAgx6Cn7PJv6L7EMaHerYJsfK1B9SyzbsIMnDltsZ/kkB1c+F?= =?utf-8?q?AZXdg+xQ3sD3fpKRIAg6cUY6PAyF/vg6QmHdCQlrbMCth869tpcxoLpZ4Su1eUDpL?= =?utf-8?q?iEGEMFlRoEdYqmyWhcrEtOZq2Gi4fqTEHw=3D=3D?= X-Forefront-Antispam-Report: CIP:131.228.6.101;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr712usmtp1.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 10:30:38.6547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a776f52a-1fab-44a7-549a-08dced0469a4 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.6.101];Helo=[fr712usmtp1.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF00000192.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR07MB7983 X-Patchwork-Delegate: kuba@kernel.org From: Chia-Yu Chang TCP-Prague evolved from DCTCP, adapted for the use over the public internet and removing all reasons why the NW would need to build a queue in a bottleneck link to control the rate of this congestion- control. As such, it needs to implement the performance and safety requirements listed in Appendix A of IETF RFC9331: https://datatracker.ietf.org/doc/html/rfc9331 This version enhances DCTCP by: * RTT independence * Fractional window and increased alpha resolution * Updated integer arithmetics and fixed-point scaling * Only Additive Increase for ACK of non-marked packets * Pacing/tso sizing * Pacing below minimum congestion window of 2 * +/- 3% pacing variations per RTT * Enforce the use of ECT_1, Accurate ECN and ECN++ All above improvements make Prague behave under 25ms very rate fair and RTT independent, assures full or close to full link utilization on a stable network link and allows the NW to control the rate down to 100kbps without the need to drop packets or built a queue. For RTTs from 0us till 25ms and link rates higher than 100kbps, the resulting rate equation is very close to: r [Mbps] = 1/p - 1 Above 25ms, a correction factor of 25ms/RTT needs to be applied (reducing the rate proportional to the higher RTT). Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Co-developed-by: Koen De Schepper Signed-off-by: Koen De Schepper Signed-off-by: Bob Briscoe Signed-off-by: Ilpo Järvinen Signed-off-by: Chia-Yu Chang --- include/uapi/linux/inet_diag.h | 13 + net/ipv4/Kconfig | 37 ++ net/ipv4/Makefile | 1 + net/ipv4/tcp_prague.c | 866 +++++++++++++++++++++++++++++++++ 4 files changed, 917 insertions(+) create mode 100644 net/ipv4/tcp_prague.c diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h index 86bb2e8b17c9..69d144ba3627 100644 --- a/include/uapi/linux/inet_diag.h +++ b/include/uapi/linux/inet_diag.h @@ -161,6 +161,7 @@ enum { INET_DIAG_SK_BPF_STORAGES, INET_DIAG_CGROUP_ID, INET_DIAG_SOCKOPT, + INET_DIAG_PRAGUEINFO, __INET_DIAG_MAX, }; @@ -231,9 +232,21 @@ struct tcp_bbr_info { __u32 bbr_cwnd_gain; /* cwnd gain shifted left 8 bits */ }; +/* INET_DIAG_PRAGUEINFO */ + +struct tcp_prague_info { + __u64 prague_alpha; + __u64 prague_frac_cwnd; + __u64 prague_rate_bytes; + __u32 prague_max_burst; + __u32 prague_round; + __u32 prague_rtt_target; +}; + union tcp_cc_info { struct tcpvegas_info vegas; struct tcp_dctcp_info dctcp; + struct tcp_prague_info prague; struct tcp_bbr_info bbr; }; #endif /* _UAPI_INET_DIAG_H_ */ diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 6d2c97f8e9ef..f55438c70579 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -679,6 +679,39 @@ config TCP_CONG_BBR AQM schemes that do not provide a delay signal. It requires the fq ("Fair Queue") pacing packet scheduler. +config TCP_CONG_PRAGUE + tristate "TCP Prague" + default n + help + TCP Prague is an enhancement for DCTCP to make DCTCP congestion + control deployable into general Internet. + TCP-Prague evolved from DCTCP, adapted for the use over the public + internet and removing all reasons why the NW would need to build a + queue in a bottleneck link to control the rate of this congestion- + control. As such, it needs to implement the performance and safety + requirements listed in Appendix A of IETF RFC9331: + https://datatracker.ietf.org/doc/html/rfc9331 + + This version enhances DCTCP by: + * RTT independence + * Fractional window and increased alpha resolution + * Updated integer arithmetics and fixed-point scaling + * Only Additive Increase for ACK of non-marked packets + * Pacing/tso sizing + * Pacing below minimum congestion window of 2 + * +/- 3% pacing variations per RTT + * Enforce the use of ECT_1, Accurate ECN and ECN++ + + All above improvements make Prague behave under 25ms very rate fair + and RTT independent, assures full or close to full link utilization + on a stable network link and allows the NW to control the rate down + to 100kbps without the need to drop packets or built a queue. + For RTTs from 0us till 25ms and link rates higher than 100kbps, the + resulting rate equation is very close to: + r [Mbps] = 1/p - 1 + Above 25ms, a correction factor of 25ms/RTT needs to be applied + (reducing the rate proportional to the higher RTT). + choice prompt "Default TCP congestion control" default DEFAULT_CUBIC @@ -716,6 +749,9 @@ choice config DEFAULT_BBR bool "BBR" if TCP_CONG_BBR=y + config DEFAULT_PRAGUE + bool "Prague" if TCP_CONG_PRAGUE=y + config DEFAULT_RENO bool "Reno" endchoice @@ -740,6 +776,7 @@ config DEFAULT_TCP_CONG default "dctcp" if DEFAULT_DCTCP default "cdg" if DEFAULT_CDG default "bbr" if DEFAULT_BBR + default "prague" if DEFAULT_PRAGUE default "cubic" config TCP_SIGPOOL diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile index ec36d2ec059e..47b1304ffa09 100644 --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.o obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o +obj-$(CONFIG_TCP_CONG_PRAGUE) += tcp_prague.o obj-$(CONFIG_TCP_SIGPOOL) += tcp_sigpool.o obj-$(CONFIG_NET_SOCK_MSG) += tcp_bpf.o obj-$(CONFIG_BPF_SYSCALL) += udp_bpf.o diff --git a/net/ipv4/tcp_prague.c b/net/ipv4/tcp_prague.c new file mode 100644 index 000000000000..6db9386b13af --- /dev/null +++ b/net/ipv4/tcp_prague.c @@ -0,0 +1,866 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2024 Nokia + * + * Author: Chia-Yu Chang + * Author: Olivier Tilmans + * Author: Koen De Schepper + * Author: Bob Briscoe + * + * TCP Prague congestion control. + * + * This congestion-control, part of the L4S architecture, achieves low loss, + * low latency and scalable throughput when used in combination with AQMs such + * as DualPI2, CurvyRED, or even fq_codel with a low ce_threshold for the + * L4S flows. + * + * TCP-Prague evolved from DCTCP, adapted for the use over the public + * internet and removing all reasons why the network would need to build a + * queue in a bottleneck link to control the rate of this congestion-control. + * As such, it needs to implement the performance and safety requirements + * listed in Appendix A of IETF RFC9331: + * https://datatracker.ietf.org/doc/html/rfc9331 + * + * Notable changes from DCTCP: + * + * 1/ RTT independence: + * Below a minimum target RTT, Prague will operate as if it was experiencing + * that target RTT (default=25ms). This enable short RTT flows to co-exist + * with long RTT ones (e.g., Edge-DC flows competing vs intercontinental + * internet traffic) without causing starvation or saturating the ECN signal, + * without the need for Diffserv or bandwdith reservation. It also makes the + * lower RTT flows more resilient to the inertia of higher RTT flows. + * + * This is achieved by scaling cwnd growth during Additive Increase, thus + * leaving room for higher RTT flows to grab a larger bandwidth share while at + * the same time relieving the pressure on bottleneck link hence lowering the + * overall marking probability. + * + * Given that this slows short RTT flows, this behavior only makes sense for + * long-running flows that actually need to share the link--as opposed to, + * e.g., RPC traffic. To that end, flows become RTT independent after + * DEFAULT_RTT_TRANSITION number of RTTs after slowstart (default = 4). + * + * 2/ Fractional window and increased alpha resolution: + * To support slower and more gradual increase of the window, a fractional + * window is kept and manipulated from which the socket congestion window is + * derived (rounded up to the next integer and capped to at least 2). + * + * The resolution of alpha has been increased to ensure that a low amount of + * marks over high-BDP paths can be accurately taken into account in the + * computation. + * + * Orthogonally, the value of alpha that is kept in the connection state is + * stored upscaled, in order to preserve its remainder over the course of its + * updates (similarly to how tp->srtt_us is maintained, as opposed to + * dctcp->alpha). + * + * 3/ Updated integer arithmetics and fixed point scaling + * In order to operate with a permanent, (very) low marking probability and + * much larger RTT range, the arithmetics have been updated to track decimal + * precision with unbiased rounding, alongside avoiding capping the integer + * parts. This improves the precision, avoiding avalanche effects as + * remainders are carried over next operations, as well as responsiveness as + * the AQM at the bottleneck can effectively control the operation of the flow + * without drastic marking probability increase. + * + * 4/ Only Additive Increase for ACK of non-marked packets + * DCTCP disabled increase for a full RTT when marks were received. Given that + * L4S AQM may induce CE marks applied every ACK (e.g., from the PI2 + * part of dualpi2), instead of full RTTs of marks once in a while that a step + * AQM would cause, Prague will increase every RTT, but proportional to the + * non-marked packets. So the total increase over an RTT is proportional to + * (1-p)/p. The cwnd is updated for every ACK that reports non-marked + * data on the receiver, regardless of the congestion status of the connection + * (i.e., it is expected to spent most of its time in TCP_CA_CWR when used + * over dualpi2). Note that this is only valid for CE marks. For loss (so + * being in TCP_CA_LOSS state) the increase is still disabled for one RTT. + * + * See https://arxiv.org/abs/1904.07605 for more details around saturation. + * + * 5/ Pacing/TSO sizing + * Prague aims to keep queuing delay as low as possible. To that end, it is in + * its best interest to pace outgoing segments (i.e., to smooth its traffic), + * as well as impose a maximal GSO burst size to avoid instantaneous queue + * buildups in the bottleneck link. The current GSO burst size is limited to + * create up to 250us latency assuming the current transmission rate is the + * bottleneck rate. For this functionality to be active, the "fq" qdisc needs + * to be active on the network interfaces that need to carry Prague flows. + * Note this is the "fq" qdisc, not the default "fq_codel" qdisc. + * + * 6/ Pacing below minimum congestion window of 2 + * Prague will further reduce the pacing rate based on the fractional window + * below 2 MTUs. This is needed for very low RTT networks to be able to + * control flows to low rates without the need for the network to buffer the + * 2 packets in flight per active flow. The rate can go down to 100kbps on + * any RTT. Below 1Mbps, the packet size will be reduced to make sure we + * still can send 2 packets per 25ms, down to 150 bytes at 100kbps. + * The real blocking congestion window will still be 2, but as long as ACKs + * come in, the pacing rate will block the sending. The fractional window + * is also always rounded up to the next integer when assigned to the + * blocking congestion window. This makes the pacing rate most of the time + * the blocking mechanism. As the fractional window is updated every ACK, + * the pacing rate is smoothly increased guaranteeing a non-stepwise rate + * increase when the congestion window has a low integer value. + * + * 7/ +/- 3% pacing variations per RTT + * The first half of every RTT (or 25ms if it is less) the pacing rate is + * increased by 3%, the second half it is decreased by 3%. This triggers + * a stable amount of marks every RTT on a STEP marking AQM when the link + * is very stable. It avoids the undesired on/off marking scheme of DCTCP + * (one RTT of 100% marks and several RTTs no marks), which leads to larger + * rate variations and unfairness of rate and RTT due to its different rate + * to marking probability proportionality: + * r ~ 1/p^2 + * + * 8/ Enforce the use of ECT_1, Accurate ECN and ECN++ + * As per RFC 9331, Prague needs to use ECT_1, Accurate ECN and ECN++ + * (also ECT_1 on non-data packets like SYN, pure ACKs, ...). Independent + * of the other sysctl configs of the kernel, setting the Prague CC on a + * socket will cause the system-wide configuration being overruled. This + * also means that using Prague selectively on a system does not require + * any system-wide changes (except using the FQ qdisc on the NICs). + * + * All above improvements make Prague behave under 25ms very rate fair and + * RTT independent, and assures full or close to full link utilization on + * a stable network link. It allows the network to control the rate down to + * 100kbps without the need to drop packets or built a queue. For RTTs + * from 0us till 25ms and link rates higher than 100kbps, the resulting + * rate equation is very close to: + * r [Mbps] = 1/p - 1 + * or typically the other way around that a flow needs p marking probability + * to get squeezed down to r Mbps: + * p = 1 / (r + 1) + * So 50% (p = 0.5) will result in a rate of 1Mbps or typically the other + * way around: 1Mbps needs 50% marks, 99Mbps needs 1% marks, 100kbps needs + * 91% marks, etc... + * For RTTs above 25ms, a correction factor should be taken into account: + * r [Mbps] = (1/p - 1) * 25ms / RTT + * with RTT and 25ms expressed in the same unit. + */ + +#define pr_fmt(fmt) "TCP-Prague " fmt + +#include +#include +#include +#include +#include +#include +#include + +#define MIN_CWND_RTT 2U +#define MIN_CWND_VIRT 2U +#define MIN_MSS 150U +#define MINIMUM_RATE 12500ULL /* Minimum rate: 100kbps */ +#define PRAGUE_ALPHA_BITS 24U +#define PRAGUE_MAX_ALPHA BIT_ULL(PRAGUE_ALPHA_BITS) +#define CWND_UNIT 20U +#define ONE_CWND BIT_ULL(CWND_UNIT) +#define PRAGUE_SHIFT_G 4 /* EWMA gain g = 1/2^4 */ +#define DEFAULT_RTT_TRANSITION 4 +#define MAX_SCALED_RTT (100 * USEC_PER_MSEC) +#define MTU_SYS 1500UL +#define RATE_OFFSET 4 +#define OFFSET_UNIT 7 +#define HSRTT_SHIFT 7 +#define RTT2SEC_SHIFT 23 + +static u32 prague_burst_shift __read_mostly = 12; /* 1/2^12 sec ~=.25ms */ +MODULE_PARM_DESC(prague_burst_shift, + "maximal GSO burst duration as a base-2 negative exponent"); +module_param(prague_burst_shift, uint, 0644); + +static u32 prague_max_tso_segs __read_mostly; /* Default value for static is 0 */ +MODULE_PARM_DESC(prague_max_tso_segs, "Maximum TSO/GSO segments"); +module_param(prague_max_tso_segs, uint, 0644); + +static u32 prague_rtt_target __read_mostly = 25 * USEC_PER_MSEC; +MODULE_PARM_DESC(prague_rtt_target, "RTT scaling target"); +module_param(prague_rtt_target, uint, 0644); + +static int prague_rtt_transition __read_mostly = DEFAULT_RTT_TRANSITION; +MODULE_PARM_DESC(prague_rtt_transition, + "Amount of post-SS rounds to transition to be RTT independent."); +module_param(prague_rtt_transition, uint, 0644); + +static int prague_rate_offset __read_mostly = 4; /* 4/128 ~= 3% */ +MODULE_PARM_DESC(prague_rate_offset, + "Pacing rate offset in 1/128 units at each half of RTT_virt"); +module_param(prague_rate_offset, uint, 0644); + +static int prague_alpha_mode __read_mostly; /* Default value for static is 0 */ +MODULE_PARM_DESC(prague_alpha_mode, + "TCP Prague SS mode (0: Half cwnd at 1st mark; 1: Init alpha 1)"); +module_param(prague_alpha_mode, uint, 0644); + +static int prague_cwnd_mode __read_mostly; /* Default value for static is 0 */ +MODULE_PARM_DESC(prague_cwnd_mode, + "TCP Prague mode (0: FracWin-base; 1: Rate-base; 2: Switch)"); +module_param(prague_cwnd_mode, uint, 0644); + +static int prague_cwnd_transit __read_mostly = 4; +MODULE_PARM_DESC(prague_cwnd_transit, + "CWND mode switching point in term of # of MTU_SYS"); +module_param(prague_cwnd_transit, uint, 0644); + +struct prague { + u64 cwr_stamp; + u64 alpha_stamp; /* EWMA update timestamp */ + u64 upscaled_alpha; /* Congestion-estimate EWMA */ + u64 ai_ack_increase; /* AI increase per non-CE ACKed MSS */ + u32 mtu_cache; + u64 hsrtt_us; + u64 frac_cwnd; /* internal fractional cwnd */ + u64 rate_bytes; /* internal pacing rate in bytes */ + u64 loss_rate_bytes; + u32 loss_cwnd; + u32 max_tso_burst; + u32 old_delivered; /* tp->delivered at round start */ + u32 old_delivered_ce; /* tp->delivered_ce at round start */ + u32 next_seq; /* tp->snd_nxt at round start */ + u32 round; /* Round count since last slow-start exit */ + u8 saw_ce:1, /* Is there an AQM on the path? */ + cwnd_mode:1, /* CWND operating mode */ + in_loss:1; /* In cwnd reduction caused by loss */ +}; + +/* Fallback struct ops if we fail to negotiate AccECN */ +static struct tcp_congestion_ops prague_reno; + +static void __prague_connection_id(struct sock *sk, char *str, size_t len) +{ + u16 dport = ntohs(inet_sk(sk)->inet_dport); + u16 sport = ntohs(inet_sk(sk)->inet_sport); + + if (sk->sk_family == AF_INET) + snprintf(str, len, "%pI4:%u-%pI4:%u", &sk->sk_rcv_saddr, sport, + &sk->sk_daddr, dport); + else if (sk->sk_family == AF_INET6) + snprintf(str, len, "[%pI6c]:%u-[%pI6c]:%u", + &sk->sk_v6_rcv_saddr, sport, &sk->sk_v6_daddr, dport); +} + +#define LOG(sk, fmt, ...) do { \ + char __tmp[2 * (INET6_ADDRSTRLEN + 9) + 1] = {0}; \ + __prague_connection_id(sk, __tmp, sizeof(__tmp)); \ + /* pr_fmt expects the connection ID*/ \ + pr_info("(%s) : " fmt "\n", __tmp, ##__VA_ARGS__); \ +} while (0) + +static struct prague *prague_ca(struct sock *sk) +{ + return (struct prague *)inet_csk_ca(sk); +} + +static bool prague_is_rtt_indep(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + return !tcp_in_slow_start(tp) && + ca->round >= prague_rtt_transition; +} + +static bool prague_e2e_rtt_elapsed(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + return !before(tp->snd_una, ca->next_seq); +} + +static u32 prague_target_rtt(struct sock *sk) +{ + return prague_rtt_target << 3; +} + +static u32 prague_elapsed_since_alpha_update(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + return tcp_stamp_us_delta(tp->tcp_mstamp, ca->alpha_stamp); +} + +static bool prague_target_rtt_elapsed(struct sock *sk) +{ + return (prague_target_rtt(sk) >> 3) <= + prague_elapsed_since_alpha_update(sk); +} + +/* RTT independence on a step AQM requires the competing flows to converge to the + * same alpha, i.e., the EWMA update frequency might no longer be "once every RTT" + */ +static bool prague_should_update_ewma(struct sock *sk) +{ + return prague_e2e_rtt_elapsed(sk) && + (!prague_is_rtt_indep(sk) || prague_target_rtt_elapsed(sk)); +} + +static u64 prague_unscaled_ai_ack_increase(struct sock *sk) +{ + return 1 << CWND_UNIT; +} + +static u64 prague_rate_scaled_ai_ack_increase(struct sock *sk, u32 rtt) +{ + u64 increase; + u64 divisor; + u64 target; + + target = prague_target_rtt(sk); + if (rtt >= target) + return prague_unscaled_ai_ack_increase(sk); + /* Scale increase to: + * - Grow by 1MSS/target RTT + * - Take into account the rate ratio of doing cwnd += 1MSS + * + * Overflows if e2e RTT is > 100ms, hence the cap + */ + increase = (u64)rtt << CWND_UNIT; + increase *= rtt; + divisor = target * target; + increase = DIV64_U64_ROUND_CLOSEST(increase, divisor); + return increase; +} + +static u32 prague_frac_cwnd_to_snd_cwnd(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + return min_t(u32, max_t(u32, MIN_CWND_RTT, + (ca->frac_cwnd + (ONE_CWND - 1)) >> CWND_UNIT), tp->snd_cwnd_clamp); +} + +static u64 prague_virtual_rtt(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + return max_t(u32, prague_target_rtt(sk), tp->srtt_us); +} + +static u64 prague_pacing_rate_to_max_mtu(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 cwnd_bytes; + + if (prague_is_rtt_indep(sk) && ca->cwnd_mode == 1) { + cwnd_bytes = mul_u64_u64_shr(ca->rate_bytes, prague_virtual_rtt(sk), + RTT2SEC_SHIFT); + } else { + u64 target = prague_target_rtt(sk); + u64 scaled_cwnd = ca->frac_cwnd; + u64 rtt = tp->srtt_us; + + if (rtt < target) + scaled_cwnd = div64_u64(scaled_cwnd * target, rtt); + cwnd_bytes = mul_u64_u64_shr(scaled_cwnd, tcp_mss_to_mtu(sk, tp->mss_cache), + CWND_UNIT); + } + return DIV_U64_ROUND_UP(cwnd_bytes, MIN_CWND_VIRT); +} + +static bool prague_half_virtual_rtt_elapsed(struct sock *sk) +{ + return (prague_virtual_rtt(sk) >> (3 + 1)) <= + prague_elapsed_since_alpha_update(sk); +} + +static u64 prague_pacing_rate_to_frac_cwnd(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 rtt; + u64 mtu; + + mtu = tcp_mss_to_mtu(sk, tp->mss_cache); + rtt = (ca->hsrtt_us >> HSRTT_SHIFT) ?: tp->srtt_us; + + return DIV_U64_ROUND_UP(mul_u64_u64_shr(ca->rate_bytes, rtt, + RTT2SEC_SHIFT - CWND_UNIT), mtu); +} + +static u64 prague_frac_cwnd_to_pacing_rate(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 rate; + + rate = (u64)((u64)USEC_PER_SEC << 3) * tcp_mss_to_mtu(sk, tp->mss_cache); + if (tp->srtt_us) + rate = div64_u64(rate, tp->srtt_us); + return max_t(u64, mul_u64_u64_shr(rate, ca->frac_cwnd, CWND_UNIT), + MINIMUM_RATE); +} + +static u32 prague_valid_mtu(struct sock *sk, u32 mtu) +{ + struct prague *ca = prague_ca(sk); + + return max_t(u32, min_t(u32, ca->mtu_cache, mtu), tcp_mss_to_mtu(sk, MIN_MSS)); +} + +/* RTT independence will scale the classical 1/W per ACK increase. */ +static void prague_ai_ack_increase(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 increase; + u32 rtt; + + rtt = tp->srtt_us; + if (ca->round < prague_rtt_transition || + !rtt || rtt > (MAX_SCALED_RTT << 3)) { + increase = prague_unscaled_ai_ack_increase(sk); + goto exit; + } + + increase = prague_rate_scaled_ai_ack_increase(sk, rtt); + +exit: + WRITE_ONCE(ca->ai_ack_increase, increase); +} + +static void prague_update_pacing_rate(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u32 rate_offset = RATE_OFFSET; + u64 rate, burst, offset; + + if (prague_rate_offset && prague_rate_offset < ((1 << OFFSET_UNIT) - 1)) + rate_offset = prague_rate_offset; + + if (tcp_snd_cwnd(tp) < tp->snd_ssthresh / 2) { + rate = ca->rate_bytes << 1; + } else { + offset = mul_u64_u64_shr(rate_offset, ca->rate_bytes, OFFSET_UNIT); + if (prague_half_virtual_rtt_elapsed(sk)) + rate = ca->rate_bytes - offset; + else + rate = ca->rate_bytes + offset; + } + + rate = min_t(u64, rate, sk->sk_max_pacing_rate); + burst = div_u64(rate, tcp_mss_to_mtu(sk, tp->mss_cache)); + + WRITE_ONCE(prague_ca(sk)->max_tso_burst, + max_t(u32, 1, burst >> prague_burst_shift)); + WRITE_ONCE(sk->sk_pacing_rate, rate); +} + +static void prague_new_round(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + ca->next_seq = tp->snd_nxt; + ca->old_delivered_ce = tp->delivered_ce; + ca->old_delivered = tp->delivered; + if (!tcp_in_slow_start(tp)) { + ++ca->round; + if (!ca->round) + ca->round = prague_rtt_transition; + } + prague_ai_ack_increase(sk); +} + +static void prague_cwnd_changed(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + tp->snd_cwnd_stamp = tcp_jiffies32; + prague_ai_ack_increase(sk); +} + +static void prague_update_alpha(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 ecn_segs, alpha, mtu, mtu_used; + + /* Do not update alpha before we have proof that there's an AQM on + * the path. + */ + if (unlikely(!ca->saw_ce)) + goto skip; + + alpha = ca->upscaled_alpha; + ecn_segs = tp->delivered_ce - ca->old_delivered_ce; + /* We diverge from the original EWMA, i.e., + * alpha = (1 - g) * alpha + g * F + * by working with (and storing) + * upscaled_alpha = alpha * (1/g) [recall that 0delivered - ca->old_delivered; + + ecn_segs <<= PRAGUE_ALPHA_BITS; + ecn_segs = div_u64(ecn_segs, max(1U, acked_segs)); + } + alpha = alpha - (alpha >> PRAGUE_SHIFT_G) + ecn_segs; + ca->alpha_stamp = tp->tcp_mstamp; + + WRITE_ONCE(ca->upscaled_alpha, + min(PRAGUE_MAX_ALPHA << PRAGUE_SHIFT_G, alpha)); + + if (prague_is_rtt_indep(sk) && !ca->in_loss) { + mtu_used = tcp_mss_to_mtu(sk, tp->mss_cache); + mtu = prague_valid_mtu(sk, prague_pacing_rate_to_max_mtu(sk)); + if (mtu_used != mtu) { + ca->frac_cwnd = div_u64(ca->frac_cwnd * mtu_used, mtu); + tp->mss_cache_set_by_ca = true; + tcp_sync_mss(sk, mtu); + + u64 new_cwnd = prague_frac_cwnd_to_snd_cwnd(sk); + + if (tcp_snd_cwnd(tp) != new_cwnd) { + tcp_snd_cwnd_set(tp, new_cwnd); + tp->snd_ssthresh = div_u64(tp->snd_ssthresh * mtu_used, mtu); + prague_cwnd_changed(sk); + } + } + } +skip: + ca->hsrtt_us = ca->hsrtt_us + tp->srtt_us - (ca->hsrtt_us >> HSRTT_SHIFT); + prague_new_round(sk); +} + +static void prague_update_cwnd(struct sock *sk, const struct rate_sample *rs) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 increase; + u64 new_cwnd; + u64 mtu_used; + u64 divisor; + s64 acked; + + acked = rs->acked_sacked; + if (rs->ece_delta) { + if (rs->ece_delta > acked) + LOG(sk, "Received %u marks for %lld acks at %u", + rs->ece_delta, acked, tp->snd_una); + if (unlikely(!ca->saw_ce) && !prague_alpha_mode) + ca->frac_cwnd = (ca->frac_cwnd + 1U) >> 1; + ca->saw_ce = 1; + acked -= rs->ece_delta; + } + + if (acked <= 0 || ca->in_loss || tp->app_limited) + goto adjust; + + if (tcp_in_slow_start(tp)) { + acked = tcp_slow_start(tp, acked); + ca->frac_cwnd = (u64)tcp_snd_cwnd(tp) << CWND_UNIT; + if (!acked) { + prague_cwnd_changed(sk); + return; + } + } + + if (prague_is_rtt_indep(sk) && ca->cwnd_mode == 1) { + mtu_used = tcp_mss_to_mtu(sk, tp->mss_cache); + increase = div_u64(((u64)(acked * MTU_SYS)) << RTT2SEC_SHIFT, + prague_virtual_rtt(sk)); + divisor = mtu_used << RTT2SEC_SHIFT; + new_cwnd = DIV64_U64_ROUND_UP(ca->rate_bytes * prague_virtual_rtt(sk), divisor); + if (likely(new_cwnd)) + ca->rate_bytes += DIV_U64_ROUND_CLOSEST(increase, new_cwnd); + ca->frac_cwnd = max_t(u64, ca->frac_cwnd + acked, + prague_pacing_rate_to_frac_cwnd(sk)); + } else { + increase = acked * ca->ai_ack_increase; + new_cwnd = ca->frac_cwnd; + if (likely(new_cwnd)) + increase = DIV64_U64_ROUND_CLOSEST((increase << CWND_UNIT), new_cwnd); + increase = div_u64(increase * MTU_SYS, tcp_mss_to_mtu(sk, tp->mss_cache)); + ca->frac_cwnd += max_t(u64, acked, increase); + + u64 rate = prague_frac_cwnd_to_pacing_rate(sk); + + ca->rate_bytes = max_t(u64, ca->rate_bytes + acked, rate); + } + +adjust: + new_cwnd = prague_frac_cwnd_to_snd_cwnd(sk); + if (tcp_snd_cwnd(tp) > new_cwnd) { + /* Step-wise cwnd decrement */ + tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) - 1); + tp->snd_ssthresh = tcp_snd_cwnd(tp); + prague_cwnd_changed(sk); + } else if (tcp_snd_cwnd(tp) < new_cwnd) { + /* Step-wise cwnd increment */ + tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) + 1); + prague_cwnd_changed(sk); + } +} + +static void prague_ca_open(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + + ca->in_loss = 0; +} + +static void prague_enter_loss(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + ca->loss_cwnd = tcp_snd_cwnd(tp); + ca->loss_rate_bytes = ca->rate_bytes; + if (prague_is_rtt_indep(sk) && ca->cwnd_mode == 1) { + ca->rate_bytes -= (ca->rate_bytes >> 1); + ca->frac_cwnd = prague_pacing_rate_to_frac_cwnd(sk); + } else { + ca->frac_cwnd -= (ca->frac_cwnd >> 1); + ca->rate_bytes = prague_frac_cwnd_to_pacing_rate(sk); + } + ca->in_loss = 1; +} + +static void prague_enter_cwr(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + u64 reduction; + u64 alpha; + + if (prague_is_rtt_indep(sk) && + (prague_target_rtt(sk) >> 3) > tcp_stamp_us_delta(tp->tcp_mstamp, ca->cwr_stamp)) + return; + ca->cwr_stamp = tp->tcp_mstamp; + alpha = ca->upscaled_alpha >> PRAGUE_SHIFT_G; + + if (prague_is_rtt_indep(sk) && ca->cwnd_mode == 1) { + reduction = mul_u64_u64_shr(ca->rate_bytes, alpha, PRAGUE_ALPHA_BITS + 1); + ca->rate_bytes = max_t(u64, ca->rate_bytes - reduction, MINIMUM_RATE); + ca->frac_cwnd = prague_pacing_rate_to_frac_cwnd(sk); + } else { + reduction = (alpha * (ca->frac_cwnd) + + /* Unbias the rounding by adding 1/2 */ + PRAGUE_MAX_ALPHA) >> + (PRAGUE_ALPHA_BITS + 1U); + ca->frac_cwnd -= reduction; + ca->rate_bytes = prague_frac_cwnd_to_pacing_rate(sk); + } +} + +static void prague_state(struct sock *sk, u8 new_state) +{ + if (new_state == inet_csk(sk)->icsk_ca_state) + return; + + switch (new_state) { + case TCP_CA_Recovery: + prague_enter_loss(sk); + break; + case TCP_CA_CWR: + prague_enter_cwr(sk); + break; + case TCP_CA_Open: + prague_ca_open(sk); + break; + } +} + +static void prague_cwnd_event(struct sock *sk, enum tcp_ca_event ev) +{ + if (ev == CA_EVENT_LOSS) + prague_enter_loss(sk); +} + +static u32 prague_cwnd_undo(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + /* We may have made some progress since then, account for it. */ + ca->in_loss = 0; + ca->rate_bytes = max(ca->rate_bytes, ca->loss_rate_bytes); + ca->frac_cwnd = prague_pacing_rate_to_frac_cwnd(sk); + return max(ca->loss_cwnd, tp->snd_cwnd); +} + +static void prague_cong_control(struct sock *sk, u32 ack, int flag, const struct rate_sample *rs) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + prague_update_cwnd(sk, rs); + if (prague_should_update_ewma(sk)) + prague_update_alpha(sk); + prague_update_pacing_rate(sk); + if (prague_cwnd_mode > 1) { + u64 cwnd_bytes = tcp_snd_cwnd(tp) * tcp_mss_to_mtu(sk, tp->mss_cache); + u64 cwnd_bytes_transit = prague_cwnd_transit * MTU_SYS; + + if (likely(ca->saw_ce) && cwnd_bytes <= cwnd_bytes_transit) + ca->cwnd_mode = 1; + else if (unlikely(!ca->saw_ce) || cwnd_bytes > cwnd_bytes_transit) + ca->cwnd_mode = 0; + } +} + +static u32 prague_ssthresh(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + return tp->snd_ssthresh; +} + +static u32 prague_tso_segs(struct sock *sk, unsigned int mss_now) +{ + u32 tso_segs = prague_ca(sk)->max_tso_burst; + + if (prague_max_tso_segs) + tso_segs = min(tso_segs, prague_max_tso_segs); + + return tso_segs; +} + +static size_t prague_get_info(struct sock *sk, u32 ext, int *attr, + union tcp_cc_info *info) +{ + const struct prague *ca = prague_ca(sk); + + if (ext & (1 << (INET_DIAG_PRAGUEINFO - 1)) || + ext & (1 << (INET_DIAG_VEGASINFO - 1))) { + memset(&info->prague, 0, sizeof(info->prague)); + if (inet_csk(sk)->icsk_ca_ops != &prague_reno) { + info->prague.prague_alpha = + ca->upscaled_alpha >> PRAGUE_SHIFT_G; + info->prague.prague_max_burst = ca->max_tso_burst; + info->prague.prague_round = ca->round; + info->prague.prague_rate_bytes = + READ_ONCE(ca->rate_bytes); + info->prague.prague_frac_cwnd = + READ_ONCE(ca->frac_cwnd); + info->prague.prague_rtt_target = + prague_target_rtt(sk); + } + *attr = INET_DIAG_PRAGUEINFO; + return sizeof(info->prague); + } + return 0; +} + +static void prague_release(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + cmpxchg(&sk->sk_pacing_status, SK_PACING_NEEDED, SK_PACING_NONE); + tp->ecn_flags &= ~TCP_ECN_ECT_1; + if (!tcp_ecn_mode_any(tp)) + /* We forced the use of ECN, but failed to negotiate it */ + INET_ECN_dontxmit(sk); + + LOG(sk, "Released [delivered_ce=%u,received_ce=%u]", + tp->delivered_ce, tp->received_ce); +} + +static void prague_init(struct sock *sk) +{ + struct prague *ca = prague_ca(sk); + struct tcp_sock *tp = tcp_sk(sk); + + if (!tcp_ecn_mode_any(tp) && + sk->sk_state != TCP_LISTEN && sk->sk_state != TCP_CLOSE) { + prague_release(sk); + LOG(sk, "Switching to pure reno [ecn_status=%u,sk_state=%u]", + tcp_ecn_mode_any(tp), sk->sk_state); + inet_csk(sk)->icsk_ca_ops = &prague_reno; + return; + } + + tp->ecn_flags |= TCP_ECN_ECT_1; + cmpxchg(&sk->sk_pacing_status, SK_PACING_NONE, SK_PACING_NEEDED); + /* If we have an initial RTT estimate, ensure we have an initial pacing + * rate to use if net.ipv4.tcp_pace_iw is set. + */ + ca->alpha_stamp = tp->tcp_mstamp; + if (!prague_alpha_mode) + ca->upscaled_alpha = 0; + else + ca->upscaled_alpha = PRAGUE_MAX_ALPHA << PRAGUE_SHIFT_G; + ca->frac_cwnd = (u64)tcp_snd_cwnd(tp) << CWND_UNIT; + ca->max_tso_burst = 1; + + /* rate initialization */ + if (tp->srtt_us) { + ca->rate_bytes = div_u64(((u64)USEC_PER_SEC << 3) * + tcp_mss_to_mtu(sk, tp->mss_cache), + tp->srtt_us); + ca->rate_bytes = max_t(u64, ca->rate_bytes * tcp_snd_cwnd(tp), MINIMUM_RATE); + } else { + ca->rate_bytes = MINIMUM_RATE; + } + prague_update_pacing_rate(sk); + ca->loss_rate_bytes = 0; + ca->round = 0; + ca->saw_ce = !!tp->delivered_ce; + + ca->mtu_cache = tcp_mss_to_mtu(sk, tp->mss_cache) ?: MTU_SYS; + // Default as 1us + ca->hsrtt_us = tp->srtt_us ? (((u64)tp->srtt_us) << HSRTT_SHIFT) : (1 << (HSRTT_SHIFT + 3)); + ca->cwnd_mode = (prague_cwnd_mode <= 1) ? prague_cwnd_mode : 0; + + prague_new_round(sk); +} + +static struct tcp_congestion_ops prague __read_mostly = { + .init = prague_init, + .release = prague_release, + .cong_control = prague_cong_control, + .cwnd_event = prague_cwnd_event, + .ssthresh = prague_ssthresh, + .undo_cwnd = prague_cwnd_undo, + .set_state = prague_state, + .get_info = prague_get_info, + .tso_segs = prague_tso_segs, + .flags = TCP_CONG_NEEDS_ECN | + TCP_CONG_NEEDS_ACCECN | + TCP_CONG_NO_FALLBACK_RFC3168 | + TCP_CONG_NON_RESTRICTED, + .owner = THIS_MODULE, + .name = "prague", +}; + +static struct tcp_congestion_ops prague_reno __read_mostly = { + .ssthresh = tcp_reno_ssthresh, + .cong_avoid = tcp_reno_cong_avoid, + .undo_cwnd = tcp_reno_undo_cwnd, + .get_info = prague_get_info, + .owner = THIS_MODULE, + .name = "prague-reno", +}; + +static int __init prague_register(void) +{ + BUILD_BUG_ON(sizeof(struct prague) > ICSK_CA_PRIV_SIZE); + return tcp_register_congestion_control(&prague); +} + +static void __exit prague_unregister(void) +{ + tcp_unregister_congestion_control(&prague); +} + +module_init(prague_register); +module_exit(prague_unregister); + +MODULE_DESCRIPTION("TCP Prague"); +MODULE_AUTHOR("Chia-Yu Chang "); +MODULE_AUTHOR("Olivier Tilmans "); +MODULE_AUTHOR("Koen De Schepper "); +MODULE_AUTHOR("Bob briscoe "); + +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.7");