From patchwork Mon Apr 14 13:13:07 2025 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: 14050382 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2079.outbound.protection.outlook.com [40.107.241.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 C97F42D3A6C; Mon, 14 Apr 2025 13:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744636452; cv=fail; b=W28donqMGMONzwhcvuP002aPvrEX9Cq5fBrg0EiOTUm73E3mVe7QqHOuXRZpdCCMgNi48yxqNS8DBxFDwaUocqhmOOJOSQ/tSiHYGEzc0xL4uN2xDPQE0itmD/JGp8e5e025fH4KT7L740g2LZmxCiKP/rQEam5BR10nvEaVmcI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744636452; c=relaxed/simple; bh=bnrDau03MTqEb+55uE4ECIXJc1PXmTb+6uznb2nRdxQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=E1prt6lnIuoEvNbPhmhoELwOvWZzxR0BdL1rF9jEd+dNf+iUgzWzo9t2pWgnPtqTZEfxF0V6ozGl1KJaBEYaRveWriXcj7EuQ5kVzdK4LuRF7JTUYawuGMpbfOBrx2wXgQuNfIul+69SXxtenCaalsbU0xV5NeotSz9tavwbgvM= 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=n5ilQgUv; arc=fail smtp.client-ip=40.107.241.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="n5ilQgUv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wSvllEQLbzbDCYsMY7/HdzuatcjWAp94zPLGrotqfGz97fuTdX5fjys6VksUPNFYYaZXqSjpDlUF6tze/3XvL7yF5EmCYNEgmWZwVMb9aqwLgyQ52LGoTVYFF4yvo6eyuzOX5hBqsYOT3KmywE3T6r7mvUf6GOkEHhFkgcsbZtfPAdmnRyumID5E7Z9CI8/lQ9/P8zSXYwFJKmu89fGac6dr1O+ISl2n1nPBD0U921iZ3nj73oyGJGCQEedUTrEmI8wkqGyenoNEr8xz21rOpQme3aokP2CVvin7JcJV/t1JxphH+Y8Fm105PoGFoewyP4l4w2Tin0HkhCEo18myGQ== 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=PF6XTXiEfjIReTh6hy2n4CrqURGfKz4X+CBDtXd3M1A=; b=REklVo2ctWOBo/PJ/RqAN1nDtJGvix10DYm/WkzpP5gcK+un7jDy9Voh4Xiqfy94d6T7kHctgQshbaLxdN2CLBNuqcZ8tgEA6jRXQtLbtppPyoq59gQioKK0ooPUoZZi79A9SGzNOb6PF44zanVOxSfbJtKe+yJHWx81PQsf9jM7U5e+WsvhX1jUyyTGM1N+UeAOdLgT3W7i95ojUi2G5/QQPo77vNi41aUol+7WAOfk7JDzHd1BsImY0+yR2eVUVbJE0cPawm1qJ8tlbckfwwTWDmyJcBfFr0F0iA5hsZFKQRwr7XDvOW2K9JbBBACugeIx7B6b971g+z4JZq+FJw== 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=PF6XTXiEfjIReTh6hy2n4CrqURGfKz4X+CBDtXd3M1A=; b=n5ilQgUvBxxQYPIxws9IWng+FRkcocO22xoXBlx++hBBUYCtM2qnpuRnxiJiNsB9Cn6fcCwvYacNpw+FGp+/fhGGVsK1WkWwYxc+Nj/bl4EeI+nhu5M6HfAogpQ1nyM9twhUVzWK00nf38AsmyNr0foasAh3crwFGfAeO+qk0uJ0C2RJfGcH5S+x5GFqdbSHDHCdEgOEQQ4Ce+i8TKB4lrC2uX3UTCgigaspPTQIpDE6CSszH5oH/7XnmCWv3JxrErjNv83DXBLwu3idJs4IuUj1evpBI+JdQ1EVlZ8ao62sB8W5Tdo9XS6Mt3VV14S/azXcXvsajVZLVuSuFaIj+A== Received: from AS9PR06CA0287.eurprd06.prod.outlook.com (2603:10a6:20b:45a::21) by AS8PR07MB7992.eurprd07.prod.outlook.com (2603:10a6:20b:39c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.27; Mon, 14 Apr 2025 13:14:07 +0000 Received: from AMS0EPF00000191.eurprd05.prod.outlook.com (2603:10a6:20b:45a:cafe::3b) by AS9PR06CA0287.outlook.office365.com (2603:10a6:20b:45a::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.34 via Frontend Transport; Mon, 14 Apr 2025 13:14:07 +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.8655.12 via Frontend Transport; Mon, 14 Apr 2025 13:14:07 +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 53EDDQBI009623; Mon, 14 Apr 2025 13:14:05 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, dave.taht@gmail.com, pabeni@redhat.com, jhs@mojatatu.com, kuba@kernel.org, stephen@networkplumber.org, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, horms@kernel.org, andrew+netdev@lunn.ch, donald.hunter@gmail.com, ast@fiberby.net, liuhangbin@gmail.com, shuah@kernel.org, linux-kselftest@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 v3 net-next 07/15] tcp: allow embedding leftover into option padding Date: Mon, 14 Apr 2025 15:13:07 +0200 Message-Id: <20250414131315.97456-8-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250414131315.97456-1-chia-yu.chang@nokia-bell-labs.com> References: <20250414131315.97456-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_|AS8PR07MB7992:EE_ X-MS-Office365-Filtering-Correlation-Id: c12c9cdf-a623-4225-e67b-08dd7b563cbb X-LD-Processed: 5d471751-9675-428d-917b-70f44f9630b0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?kHYZhIvjwPWmXlb9EZjazn72loZBGnX?= =?utf-8?q?63xJ8C0+1kaaJ7auekEb4lkz9ImiCZjiK0OhT5x/4mL/q1EXK3Lwy3QfhKIcHoggd?= =?utf-8?q?3ke1OT2KHLjYxXYrSg7NniNDiSRMuAt9AOQvzrumd6G50ZtWe3UnN3QB4sEPV5bIm?= =?utf-8?q?CwWfEYvWH4MCCFgvTnFZHMl4P0cSflsURjwdny6yv3u/5yR9MKk9kxRlihI1cRC9o?= =?utf-8?q?ClSCk3Y/Fy2+vw0zCwrI7wzWCPJY69Mt40Y9kJ2Ag+fvWB/HILft3LyjozgM2Xbzy?= =?utf-8?q?38RTXZxFrp0oDeljpw6g75z9vAuDYAN7YAT9kgAa6SQoEQaiFmbzeHoC7P8cEY5RV?= =?utf-8?q?Dz7rc6HKcPVeSBP6feKq1j0tK/upUkLGLIiyOoYfDm+BaCyoiyErbOyDclH3DaXcp?= =?utf-8?q?cEZCaA+YrlBtmqW1kU4FWS5toPV4CY+gFpPlBvwJPxAUC4NoIQQm89s0FuOI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EG3OuHP?= =?utf-8?q?C78tgAPvPOkyRo7HSSvEZDN1sl2u5Suz2PKOpxNYDQtqDWknyMzLcy0mUEsRE6A0e?= =?utf-8?q?VcXm6imByZN7Od+2CG9Tvm7FI10ziflb2JcTimgY5WrYRaMm+A/XwJvsFlq/HzNr+?= =?utf-8?q?/OdA+fes/96tz7hVdJSm4ykQelenEQ/g=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)(82310400026)(7416014)(376014)(36860700013)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2025 13:14:07.2048 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c12c9cdf-a623-4225-e67b-08dd7b563cbb 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: AS8PR07MB7992 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 b4eac0725682..d63f505a30e2 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -709,6 +709,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 @@ -727,8 +729,10 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, struct tcp_out_options *opts, struct tcp_key *key) { + u16 leftover_bytes = NOP_LEFTOVER; /* replace next NOPs if avail */ __be32 *ptr = (__be32 *)(th + 1); u16 options = opts->options; /* mungable copy */ + int leftover_size = 2; if (tcp_key_is_md5(key)) { *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | @@ -763,17 +767,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)) { @@ -781,8 +790,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))); @@ -794,6 +802,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)) {