mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: thaisonphan@google.com
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,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] tcp: accecn: initialize AccECN fields in syncookie path
Date: Wed, 18 Nov 2026 05:40:01 +0000	[thread overview]
Message-ID: <179498040151.3136.12001610371899379772@kernel.org> (raw)
In-Reply-To: <20261116023709.132684-3-thaisonphan@google.com>

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, the new syn_ect_snt
  assignment in cookie_v4_check() (net/ipv4/syncookies.c:508) and…
- [Medium] tcp: accecn: missing option init on 3rd ACK in syncookie path

--

tcp: accecn: initialize AccECN fields in syncookie path

This commit initializes saw_accecn_opt, accecn_fail_mode and syn_ect_rcv
in cookie_tcp_reqsk_init() so they match tcp_openreq_init(). It also sets
syn_ect_snt from the listener's tos/tclass in cookie_v4_check() and
cookie_v6_check(), so the child socket's AccECN validation knows which ECN
codepoint the cookie SYN-ACK carried.

> 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

[ ... ]

> @@ -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]
Is the AccECN option on the third ACK ever looked at on the syncookie
path? With cookies the listener kept no state, so the client's first
AccECN option arrives on the same ACK that cookie_v4_check() and
cookie_v6_check() turn into a child. On the normal SYN_RECV path,
tcp_check_req() records it before the child is created:

net/ipv4/tcp_minisocks.c:tcp_check_req() {
    ...
	if (tcp_rsk(req)->accecn_ok && tmp_opt.accecn &&
	    tcp_rsk(req)->saw_accecn_opt < TCP_ACCECN_OPT_COUNTER_SEEN) {
		u8 saw_opt = tcp_accecn_option_init(skb, tmp_opt.accecn);

		tcp_rsk(req)->saw_accecn_opt = saw_opt;
    ...
}

Here cookie_tcp_reqsk_init() sets saw_accecn_opt to
TCP_ACCECN_OPT_NOT_SEEN. Nothing between cookie_tcp_check() and
tcp_ecn_openreq_child() calls tcp_accecn_option_init(), even though
cookie_tcp_check() already parses the options into tcp_opt.accecn.
The child therefore starts with tp->saw_accecn_opt ==
TCP_ACCECN_OPT_NOT_SEEN.

The tcp_child_process() -> tcp_rcv_state_process() -> tcp_ack()
pass on the same skb does not fix this. snd_una already equals
ack_seq, and ts_recent was copied from req->ts_recent. So neither
FLAG_FORWARD_PROGRESS nor FLAG_TS_PROGRESS is set, and
__tcp_accecn_process() returns before it reaches
tcp_accecn_process_option().

With saw_accecn_opt stuck at zero:

 - tcp_established_options() never emits AccECN options, even though
   accecn_opt_demand is set.
 - A zeroed option on the third ACK is not caught as
   TCP_ACCECN_OPT_FAIL_SEEN.
 - TCP_INFO reports tcpi_accecn_opt_seen as 0.
 - Later processing in tcp_accecn_process_option() can flag
   TCP_ACCECN_OPT_FAIL_RECV on a connection where the peer did send
   the option.

This patch is aligning the cookie path with tcp_openreq_init(), so
should cookie_v4_check() and cookie_v6_check() also do the equivalent
of the tcp_check_req() block once accecn_ok is known? The parsed
tcp_opt is local to cookie_tcp_check() and is not available on the
cookie_bpf_check() path. Would you prefer to re-parse the options
there or plumb them through? Or is this meant as a separate fix?

[Severity: Medium]
Does this assignment also apply to requests that come from
cookie_bpf_check()? On that path the kernel never sent the SYN-ACK. A
TC/XDP program built it, and bpf_sk_assign_tcp_reqsk() only gets an
ecn_ok bit from struct bpf_tcp_req_attrs:

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

So the program has no way to report which ECN codepoint it put on the
SYN-ACK, and the listener's tos/tclass is only a guess here.

The in-tree reference program sends Not-ECT for both families, in
tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c:tcp_handle_syn():

	ctx->ipv4->tos = 0;
    ...
	*(__be32 *)ctx->ipv6 = bpf_htonl(0x60000000);

When the listener runs DCTCP or another TCP_CONG_NEEDS_ECN CC, its
tos/tclass carries ECT(0), so syn_ect_snt becomes ECT(0) here.

An AccECN client that receives the Not-ECT SYN-ACK reflects it in the
third ACK through tcp_accecn_reflector_flags(), giving ACE=0b010.
cookie_accecn_ok() then sets accecn_ok, and the child setup does:

tcp_get_cookie_sock()
  ->syn_recv_sock()
    tcp_ecn_openreq_child()
      tcp_accecn_third_ack(sk, skb, treq->syn_ect_snt)
        tcp_accecn_validate_syn_feedback()
            if (!tcp_ect_transition_valid(sent_ect, ect)) {
                tcp_accecn_fail_mode_set(tp, TCP_ACCECN_ACE_FAIL_RECV);

Would this set a false TCP_ACCECN_ACE_FAIL_RECV, the same failure the
commit message describes, on every BPF syncookie connection to an
ECT-marking listener? Before this patch the field was uninitialized. On
zeroed memory it read as 0, which happened to match the Not-ECT SYN-ACK
from that program.

The same applies to the IPv6 line below, which uses np->tclass.

Could the listener's tos/tclass be skipped for BPF-validated requests
(req->syncookie set by the kfunc)? Alternatively, struct
bpf_tcp_req_attrs could carry the SYN-ACK ECN codepoint.

>  
>  	ret = tcp_get_cookie_sock(sk, skb, req, &rt->dst);
>  	/* ip_queue_xmit() depends on our flow being setup
> diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
> index b33011b71fff6..7435ebcc366cd 100644
> --- a/net/ipv6/syncookies.c
> +++ b/net/ipv6/syncookies.c
> @@ -276,6 +276,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
>  		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);
> +	tcp_rsk(req)->syn_ect_snt = READ_ONCE(np->tclass) & INET_ECN_MASK;

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116023709.132684-1-thaisonphan%40google.com

  parent reply	other threads:[~2026-11-18  5:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  2:37 [PATCH net v2 0/2] tcp: initialize missing request_sock " Thaison Phan
2026-11-16  2:37 ` [PATCH net v2 1/2] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check() Thaison Phan
2026-11-16  2:37 ` [PATCH net v2 2/2] tcp: accecn: initialize AccECN fields in syncookie path Thaison Phan
2026-11-17 17:37   ` Matthieu Baerts
2026-11-18  5:40   ` netdev-bot+sashiko [this message]
2026-11-18  9:30   ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179498040151.3136.12001610371899379772@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=chia-yu.chang@nokia-bell-labs.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=ij@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=olivier.tilmans@nokia.com \
    --cc=pabeni@redhat.com \
    --cc=stani@google.com \
    --cc=thaisonphan@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®