🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19150

Re: [PATCH net v3 2/2] tcp: accecn: initialize AccECN fields in syncookie path

#19150
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 12:47
168 lines
14560 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] On the BPF custom-syncookie path (bpf_sk_assign_tcp_reqsk() ->
  cookie_bpf_check()), the patch sets syn_ect_snt from a SYN-ACK the…
- [Medium] tcp: accecn: missing 3rd ACK option init in
  cookie_tcp_reqsk_init()

--

tcp: accecn: initialize AccECN fields in syncookie path

This patch initializes saw_accecn_opt, accecn_fail_mode and syn_ect_rcv in
cookie_tcp_reqsk_init(). That function is shared by the regular syncookie
path and the bpf_sk_assign_tcp_reqsk() path. The patch also sets
syn_ect_snt from the listener's TOS/tclass in cookie_{v4,v6}_check(), to
match what tcp_{v4,v6}_send_synack() would have sent on the wire.

> diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
> index 4e0ff3b820627..1a837ed6efa00 100644
> --- a/net/ipv4/syncookies.c
> +++ b/net/ipv4/syncookies.c
> @@ -290,6 +290,9 @@ static int cookie_tcp_reqsk_init(struct sock *sk, struct sk_buff *skb,
>  	 */
>  	treq->txhash = treq->snt_isn;
>  	treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
> +	treq->saw_accecn_opt = TCP_ACCECN_OPT_NOT_SEEN;
> +	treq->accecn_fail_mode = 0;
> +	treq->syn_ect_rcv = 0;
>  
>  #if IS_ENABLED(CONFIG_MPTCP)
>  	treq->is_mptcp = sk_is_mptcp(sk);
> @@ -502,6 +505,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
>  		ireq->rcv_wscale = rcv_wscale;
>  	ireq->ecn_ok &= cookie_ecn_ok(net, &rt->dst);
>  	treq->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th);
> +	treq->syn_ect_snt = READ_ONCE(inet_sk(sk)->tos) & INET_ECN_MASK;

[Severity: Medium]
Does the syncookie path ever look at the AccECN option carried on
the third ACK?

On the normal SYN-RECV path, tcp_openreq_init() also sets
saw_accecn_opt to TCP_ACCECN_OPT_NOT_SEEN. tcp_check_req() then
checks tmp_opt.accecn on the third ACK and calls
tcp_accecn_option_init() before syn_recv_sock() runs. That updates
tcp_rsk(req)->saw_accecn_opt and, when the option was zeroed, ORs
TCP_ACCECN_OPT_FAIL_RECV into accecn_fail_mode.
tcp_ecn_openreq_child() then copies both fields into the child.

cookie_v4_check() and cookie_v6_check() process the third ACK
directly and never go through tcp_check_req(). cookie_tcp_check()
does call tcp_parse_options(), so tcp_opt.accecn is filled in.
Nothing passes it to tcp_accecn_option_init(), though. With this
patch, saw_accecn_opt is always TCP_ACCECN_OPT_NOT_SEEN when the
child is created, even when the peer did send an AccECN option on
the third ACK.

The child also does not seem to catch up when it processes the same
skb. In tcp_child_process() -> tcp_rcv_state_process() -> tcp_ack():

  - snd_una already equals the ACK sequence and there are no packets
    in flight, so FLAG_FORWARD_PROGRESS is not set.
  - ts_recent was already copied from req->ts_recent, so
    FLAG_TS_PROGRESS is not set either.

__tcp_accecn_process() therefore returns before it calls
tcp_accecn_process_option().

As a result, tp->saw_accecn_opt stays at 0 on the child:

  - tcp_established_options() requires tp->saw_accecn_opt to be
    non-zero, so no AccECN options are sent even though
    accecn_opt_demand is set.
  - A zeroed option on the third ACK is never detected as
    TCP_ACCECN_OPT_FAIL_SEEN, and TCP_ACCECN_OPT_FAIL_RECV is never
    set.
  - tcpi_accecn_opt_seen in TCP_INFO reads 0 even when an option was
    received. It is no longer random, but it is still wrong.

Should cookie_v4_check() and cookie_v6_check() repeat the
tcp_accecn_option_init() step from tcp_check_req() once accecn_ok is
known? That would mean passing tcp_opt.accecn out of
cookie_tcp_check(), or parsing the options again. The
cookie_bpf_check() path would presumably need the same handling.

[Severity: Medium]
Is this value correct on the BPF custom syncookie path?

When cookie_bpf_ok(skb) is true, req comes from cookie_bpf_check(). In that
case a tc ingress BPF program built and sent the SYN-ACK.
tcp_v4_send_synack() and tcp_v6_send_synack() never run for that
connection, so the listener's tos/tclass may not match the ECN codepoint
that was actually sent. The same question applies to the new
tcp_rsk(req)->syn_ect_snt assignment in cookie_v6_check(), and to
syn_ect_rcv = 0 in cookie_tcp_reqsk_init(), which the BPF path also uses
whatever the SYN's ECN field was.

bpf_sk_assign_tcp_reqsk() fills the request sock only from
struct bpf_tcp_req_attrs:

net/core/filter.c:bpf_sk_assign_tcp_reqsk() {
    ...
	ireq->wscale_ok = !!attrs->wscale_ok;
	ireq->ecn_ok = !!attrs->ecn_ok;
    ...
}

and that struct has no field for the SYN-ACK or SYN ECN codepoint:

include/net/tcp.h:
struct bpf_tcp_req_attrs {
	...
	u8 ecn_ok;
	...
	u8 usec_ts_ok;
	u8 reserved[3];
};

The in-tree example already chooses its SYN-ACK TOS without looking at the
listener:

tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c:
		ctx->ipv4->tos = 0;

Here is one example:

  - The listener has ECT bits in IP_TOS or IPV6_TCLASS (for example a
    DCTCP listener, which gets ECT(0)), and tcp_ecn >= 3.
  - The BPF program sends a Not-ECT SYN-ACK that negotiates AccECN and
    passes ecn_ok=1.
  - The peer's third ACK reflects Not-ECT (ACE=0b010), so
    cookie_accecn_ok() is true and accecn_ok=1.

The child socket setup then goes:

tcp_ecn_openreq_child()
  tcp_accecn_third_ack()
    tcp_accecn_validate_syn_feedback()
      tcp_ect_transition_valid(ECT_0, NOT_ECT) returns false
      tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV)

With the default tcp_ecn_fallback=1, this sets TCP_ACCECN_ACE_FAIL_RECV.
After that, tcp_ecn_send() uses INET_ECN_dontxmit() for the rest of the
connection.

This looks like the same false ACE_FAIL_RECV that the commit message says
it fixes, and it can still happen through bpf_sk_assign_tcp_reqsk(). Does
the BPF path need a way to pass the SYN-ACK (and SYN) ECN codepoint in
through bpf_tcp_req_attrs, instead of using the listener's tos/tclass?

>  
>  	ret = tcp_get_cookie_sock(sk, skb, req, &rt->dst);
>  	/* ip_queue_xmit() depends on our flow being setup

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117124710.1338951-1-thaisonphan%40google.com
Technical Details
Message-ID: <179509244451.3136.7632749576749189281@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367017-linux-kernel-netdev=dewy.ru
References: <20261117124710.1338951-3-thaisonphan@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367017-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 2/2] tcp: accecn: initialize AccECN fields in
 syncookie path
Date: Thu, 19 Nov 2026 12:47:24 +0000
Organization: Usenet Network
Message-ID: <179509244451.3136.7632749576749189281@kernel.org>
References: <20261117124710.1338951-3-thaisonphan@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2873012"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:zW0qRO6IXU1APhDrNLT24iJpzcg= sha256:StT7XPtupkK6fIeF5LMVDRWRimgH7Pr09Ljcns3IJy8=
	sha1:tuFRX/DdabZ136bu7KkgmZB8MdI= sha256:bWZ6SyNYNkPJh4lgCTOdbrxyPll1A1RjnbJg67Iofg4=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C639011564B; Thu, 19 Nov 2026 15:47:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id C6ZkAA8nvEWX;
	Thu, 19 Nov 2026 15:47:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367017-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 9D6AB115647; Thu, 19 Nov 2026 15:47:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 185BD1C2A94; Thu, 19 Nov 2026 12:47:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795092447;
	b=RIOLJF7voljp+y6S2Qb57JTTHCTg5vEzFIV7QmDOqNnO+/F28YKErnJgIrrR02ulAogP
	 CGflAO0jMzKLSUOsBiEyc3s0C1zlSMo3+65mcnqhLxeYwbbjbVsaw/cA1adsu1fl5TBpv
	 0+pxqc2JD767wieyML5IuC0UVtabVaZpzkVvmXNlf5LdrlL20Pk5v2JzySTDjfhCnMQKi
	 EtRDIyW3tKM6R1jSIKuXE6h5rSsayNqMahP5RCT8cTkkh61bUW0W/7itveyfJBVTAkVhp
	 Wvk7bCK5V7V9wgBKx5IyBvDpvERFwrFhwl0iKHcDSuIBIaxxRn65CQCk0bA0H+v/eiA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795092447;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=rVqv6cMnMJmJyMaeUNnqrTWyRG9aoHyUEoKzK90L2Yc=;
	b=LZ/iHSXr9a6G2XaQMCvKYPsWNo5Pb++ra0hhuktIll2Jd4aR4PT7LPAk08RUe0dR0s3e
	 fzP2usD2YwfU5wZGoI30xTTqkto00qiMzGCz4XrvOHP0j60imPzHPQN2oz16ZZi9sFEtd
	 MsQ3UDW2R8p+KkGw0PhSGF36voWXNxhj+Qkld3OsO6iI4I9pCfiX6rgRQ27KRJ8LrWPap
	 Ff3JwJ+T/Hays7Yz8mDb2ZKCRAGCZ5UtwLRDcykAyxPR/BIASTWtCPaAoBsLsX6/e4sR/
	 kPp4zJxA5y6Bv1hPHBcXDbnkdgti8jQm0TSIaM+fb25vZDJf7i5nAiCb+IXeQMsOMVg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kf9C+Lfx;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C810606A33E;
	Thu, 19 Nov 2026 12:47:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kf9C+Lfx
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795092446;
	b=BlOSeIzVm6SZKYV8WntRcs1TXmgr7W9EIQgVASZsPpPJwn9oPlBQ97OgPIBQJyDaBicp
	 mxR3tgcj49CdhMFc3q5AxZjRtfIFbU+OgXnGwfDSBpuDw4VV5rl94ESRwOoXvzkWeKjA1
	 3Sw51dF3CdQTl/hhVwW2+g5UTBS8DhHw60jrgSDgRsrNYM21t5xmULw+6U/fjVkzIXAq3
	 6l5Ysw0AZJcmO3Y4SacvIuOer09JZWuUd0AvK2gBR+AOjTNjwr9LpXahh+8thrsJz2U5t
	 x7Kd7/rJVmA39BQIZynrkF987rVf9hVs0JY8ZqeFchTeYr2o17bLKofZN3lbTqp7LlQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795092446;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=rVqv6cMnMJmJyMaeUNnqrTWyRG9aoHyUEoKzK90L2Yc=;
	b=alCayhQSqniz8NgAVq6lO5OF9rjMycLZrf361x8vCXoIFM1P186/s+PRqeAQYN0U6FbF
	 0IwT/Yk/3vvlHxMppBXpG6D/eQ2ESx4BiXA8Jp0ztdnPWBHliADWdjZOlI44gboNWpLDC
	 0YO9PvwPYe7PwGgKFAesTz7oQqpVQHaGVZMH3WrO8UmOCE8YvMvulTeW2Sdt9SNFUfJ7P
	 bws11zKSg9sN6uzHz/qacKWyUafqHu7RyN5kJK8neFSNe8f1/l/1PC3L4D7Afy1P4hF75
	 +YYYVecp/XUs9RV5dWgeOJWqhkhEgl+vFRb6IGHDgw0ynIhUnStdjMjE0MZUVz8c97A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kf9C+Lfx;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A8BD606A32A;
	Thu, 19 Nov 2026 12:47:25 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F03CB1F000C4;
	Thu, 19 Nov 2026 12:47:24 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795092445;
	bh=rVqv6cMnMJmJyMaeUNnqrTWyRG9aoHyUEoKzK90L2Yc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Kf9C+LfxLK+jbKCM/dMadCkX6r2Bp8cYJ0gIjnVucPSfgIhGGx6ZoqrKwt/tzmsme
	 EiAAxB4ywBXraUF+7/OzMrFMpRhzc+MxLhuWSifQX95xpIkYVh5OrdXR4VuiMfC6xy
	 J6kuCARjxacBn28iYfgZjo8o4DhW7CeaM469B3BAalrbo/qDeUwqbbi690SnmDlmp9
	 3tx/HcVdk/ooRIs78YqHXt6JnMkni/evh0I16OGR/Vb09ojHVApwyAE7fnD/2dKObS
	 /mdrdX891R4yXi+HMsjjdWbxmd4fSjTedVmg2hy1pxDhZ/1u5q6MxLaDnb0vOlJ5+1
	 ujPEvt+6I+maQ==
X-Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com,
 davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, ij@kernel.org, olivier.tilmans@nokia.com,
 chia-yu.chang@nokia-bell-labs.com, stani@google.com, netdev@vger.kernel.org,
 bpf@vger.kernel.org, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261117124710.1338951-3-thaisonphan@google.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list