From patchwork Fri Dec 27 19:12: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: 13922100 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2044.outbound.protection.outlook.com [40.107.103.44]) (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 B51A71F9435; Fri, 27 Dec 2024 19:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735326778; cv=fail; b=dZxSHbiNLPn90wq/dqrzkc2aV2Zorz97+tLLMZOhEJHA97//E1mAgy0USAIp033CrxTfsRaqofn1XtJDWUn3AQ+RIbps9XfW8KQirnZIFjq0urNdGbiJ4WexMkFZfchUlFOUHcnfiYdx+0hApVovv3x9eyT+yoqGWPXNi3DqNKk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735326778; c=relaxed/simple; bh=vvKl+hRd4P2c+aZzDb6E/7ggWjkmkGN8GiwvcfahwnE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=HJntuppDOzNqfXHAJwDWXvSG7VvIbhKPzVAOuVGpvCwt2wp6y60kfigpzKI/grZMH5tedgDODnUYy06+gkVkd8YE7f97kFTROWiC3LBz8icRQVL0+nbyVl3PBCVYdkLSWEfIZgv0TRRmgnTqNpP9/IzmgqcoowSpyO2QKMu768s= 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=jRTEDt+1; arc=fail smtp.client-ip=40.107.103.44 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="jRTEDt+1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LK1GTpovFIBlR1XvyXruSIZT1X4krwDsXeujeJZbUBGwBISyXfcRV+vp6lr/sMIwTVD7LX2wK+yy0V5Ug47DS5WPBtt6bKluVVIXWcDcq6jGD8RFXM4rXGYNw6J1EiJGPXN1H85KZOSTNVsWYirO96XJ0y2CRkGIC1GvQFiKD4266/PPALSi4J71cdt/eKoEYQDhTfEkTrsW0tZFeIZJZ/iSkxjBHy8X4kYBWhyw7mTTqtVkOecW7F6B+MQeWWbAPemYp0HunXhbV+Lj+ZjfdW9RsGvzYpBwc6VWgfZqwNO/AQ2LhsUIksYl76U34ShOIPYwN4ZHPTtXJYkDxxKvsA== 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=9F9YbHQ4+dUQbRnzdxmTs7ibFUXoiEd2WYHYKLzw36Y=; b=xPKeMMKL67CV7aYdGFMxnapf6TxwxKzah1Zmsh1D9TE+eP4tTvkg+1qr5G4cPQbyhI3CNNzTkMCJC/LydUoNvNiUJHOK8LLqBZXR35WklGOy38rZa8EjTz78H9Nlz0M8fGNPWhOxcJ/R9qm9G7NuZUauNQrBXRHgPUnzZafWOP7hVzDBLzGKJ7I3/ZqUvoZ8X37h1IZGHpAmVgSfgxqa2brynJjPtdXRCsexBgilWnGm9Jy3QHFQAnKBIY8vJNEo2ZsCYn+GNBH4hrzZgA06YwtUIOeDT+gZWq3sWdHtSghJ5t0yIjs6/jfJEwIA1oqj7pqwB+4RVXngiTk870NR8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.100) 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=9F9YbHQ4+dUQbRnzdxmTs7ibFUXoiEd2WYHYKLzw36Y=; b=jRTEDt+1pROuF9L248df65fi6MJAh2CMWcm//YJn4R8kNJju7+nB1H4mi29luUgHmYgX2Z2UBplhCnDoyo0IkLfhI8a3X3epDfZKJBMcdRXWsDplpkwXkHlEO+PtyqrJgm63TUnnf++NQgHvUqU9YGL1L6Oi5vOFShu1K4fPsr7AEfdl7yTtiIPOB+AkZvHRf70nJyjlG6dseq6cr8XdiysNGNnW4y5npjV4/Fv5PJuaoqrr8p+3JAR5fS3GmPCBIW2qTjrLpG6L8XJzmfQ8+d/LakPEK/ZY7qSUnrfDwX0FbHW4IpatGpi1fOgGziXp7sqjR5+6a55EcyujzwDCCg== Received: from AM5PR0601CA0057.eurprd06.prod.outlook.com (2603:10a6:206::22) by AS2PR07MB9183.eurprd07.prod.outlook.com (2603:10a6:20b:5e9::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.15; Fri, 27 Dec 2024 19:12:47 +0000 Received: from AM3PEPF00009B9D.eurprd04.prod.outlook.com (2603:10a6:206:0:cafe::10) by AM5PR0601CA0057.outlook.office365.com (2603:10a6:206::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8293.16 via Frontend Transport; Fri, 27 Dec 2024 19:12:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.100) 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.100 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.100; helo=fr711usmtp2.zeu.alcatel-lucent.com; pr=C Received: from fr711usmtp2.zeu.alcatel-lucent.com (131.228.6.100) by AM3PEPF00009B9D.mail.protection.outlook.com (10.167.16.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.12 via Frontend Transport; Fri, 27 Dec 2024 19:12:47 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr711usmtp2.zeu.alcatel-lucent.com (GMO) with ESMTP id 4BRJCH2X011940; Fri, 27 Dec 2024 19:12:47 GMT From: chia-yu.chang@nokia-bell-labs.com To: netdev@vger.kernel.org, dsahern@gmail.com, davem@davemloft.net, edumazet@google.com, dsahern@kernel.org, pabeni@redhat.com, joel.granados@kernel.org, kuba@kernel.org, andrew+netdev@lunn.ch, horms@kernel.org, pablo@netfilter.org, kadlec@netfilter.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, shenjian15@huawei.com, salil.mehta@huawei.com, shaojijie@huawei.com, saeedm@nvidia.com, tariqt@nvidia.com, mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, virtualization@lists.linux.dev, 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 v6 net-next 07/14] tcp: helpers for ECN mode handling Date: Fri, 27 Dec 2024 20:12:04 +0100 Message-Id: <20241227191211.12485-8-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241227191211.12485-1-chia-yu.chang@nokia-bell-labs.com> References: <20241227191211.12485-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: AM3PEPF00009B9D:EE_|AS2PR07MB9183:EE_ X-MS-Office365-Filtering-Correlation-Id: 28af2c69-09ca-403a-474a-08dd26aa7311 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024|7416014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?TKyOSumrXxweHJRQVO7rkSExmv2A+P/?= =?utf-8?q?IoAuqlgAJbjzed1Skxc3b44mE6e/W5aR9+fPnBEebA73YSGiqgqQsljhTqaS6zfrk?= =?utf-8?q?pX7iZVFtGhcmPoJEfTHRPyZaIc+lZ4RtueWoLKKMj0U3n87Gp3/tvpRf1o7M6G1o/?= =?utf-8?q?dceKb+iXnl9Ne7elrh1N01U7hMuJRR3p1jxdgt+Z4rvSEhdoCeFZ/Qz8WNRhrxlbt?= =?utf-8?q?pD0iPNP/15JNQzZGQbv7SCyn/irOInU5LB8aGYIffHlUETF1f1JCbabeY2uFko22q?= =?utf-8?q?2n6QCjrXYCwtU8wtqJz0JhUw1qmnJ7TXPBWYLR5I2hZuE+r4HqLgYFgzE0Bx0ojF5?= =?utf-8?q?lwTms/2Zkyzb/N+7jYfbUgaqeR6ZbODzeBkplckUTLJSeaBm6Yui2t32nCwoTKqE8?= =?utf-8?q?F2HW8sfBVhgxhnexCK6jMxfLjD6yMpKnvPsoTgq5ABx62izciDbPm9zwx83pa9gMW?= =?utf-8?q?xENVU2tfFXBtddx5GkEDZfQkCQCKQEI08rJrJt+fX6AtC8lALUjc37xKe9Q8RkNhL?= =?utf-8?q?pRjBaoc04vWS/oTVL3LN3IEcOYm/rbrGLfx8Le4t4lpLvrHfgHBAjmGS7M93fU70p?= =?utf-8?q?xz7CK6MOK239P5TX3NEOTtOg8LXYoy6v78N7V5B0EAGFUzeQmBeKo06zwLTsVqBLK?= =?utf-8?q?mPe0Dhk0KSvWRje9MuHNrzUITh8KjicprYq6zC1aX11FPAMBzpYE+ZT/1xHg2H82R?= =?utf-8?q?Mo3MTvfMqjAwaalaxtOOgzJ5jYmjUvektPC7uPCgvi6R8nABtyYm8coEjtFfSM/ac?= =?utf-8?q?cnoirmKAPcCJQYIsgQ+EMHfSCE/rsdTntsRbISCiLTwFqufSFkzZzNcZspWentfN3?= =?utf-8?q?fpTmQq9BUsAmWDob+Hmvow5SYt0Kd48oI1gwRm82u6Bi6DejjBbnBLTxUiZiPhW5I?= =?utf-8?q?i0oTOmZj6SCwi3w1TJEz5LRW4xCRMIYz7VuwClcQtfjuXTzarJLkdS5/n/eJm/ewf?= =?utf-8?q?4qBLXEahKp2fD3rzutcnrsAOpjRN8JQRcGqUo1DrrmLobfOMTu48SP5nC4Adoq2Bn?= =?utf-8?q?H2j8+EqeedG7Ii5vXtQ9Ucii+Fo4rVKY0q3gXOgLmQF+UcjeoX61+60EGQGfgcHd3?= =?utf-8?q?d0d0fUoZxaRq4dKbdjKD/C4f/5rGehUdR/0KcUCaZ92jgsqiNIEbuEZf/OqYk5+qZ?= =?utf-8?q?4uSPvM/WGoSZ5SeouEaF2gstKi8GiWfgkMtfvO2SWfVNXNi7pp0Fj2Xz+TDqo/I20?= =?utf-8?q?+7WsxbIz0gNSdoRAn4APYHYoe6xwClMA7BjtwoKy8B9M485Dljd/K+WGFBUEGldqK?= =?utf-8?q?+Pjf4ZnV3uzzJMA6GT5SH7hRpEs4KafHv0PKwRNwR9/59D2ZQt4QaMNY5h1+OzO0o?= =?utf-8?q?gx7Xn7ahuWDAkcibIGX+NAiV/yxqUXNQMz6gZXmRBIgCwbOf/hUoh8El2N/uO8EhL?= =?utf-8?q?BuBJ9Hrp2UIUtTQIg/dhHuVflouS2Y1yQBmg85ICQgdcZP9qOPyeA85V423wqZhwW?= =?utf-8?q?WRfQ+UG35I?= X-Forefront-Antispam-Report: CIP:131.228.6.100;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fr711usmtp2.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024)(7416014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2024 19:12:47.2348 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28af2c69-09ca-403a-474a-08dd26aa7311 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.100];Helo=[fr711usmtp2.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF00009B9D.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR07MB9183 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 Reviewed-by: Eric Dumazet --- 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 c9bab41685cf..4987cb0c59c4 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 0d704bda6c41..e30204394175 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 4751f55a79ad..0804f146d6dc 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 b089b08e9617..64d242571449 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -462,7 +462,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 fde40ffc32ff..c2763c3361ad 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)) {