Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by bot+bpf-ci
Thu, 08 Oct 2026 04:02
Re: [PATCH v5 bpf-next 04/10] bpf: tcp: Guard fast-path bpf_tcp_ops_call() under per-socket flag.
Author: bot+bpf-ci
Date: Thu, 08 Oct 2026 04:02
Date: Thu, 08 Oct 2026 04:02
90 lines
9061 bytes
9061 bytes
--===============0653454793552695213==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
> bpf: tcp: Guard fast-path bpf_tcp_ops_call() under per-socket flag.
TL;DR: Commit message only: it says the static key is checked in
bpf_tcp_ops_hdr_opt_len() and that __bpf_tcp_ops_call() checks it, but the
code checks it in tcp_bpf_hdr_opt_len() and bpf_tcp_ops_call_flag().
> bpf: tcp: Guard fast-path bpf_tcp_ops_call() under per-socket flag.
>
> bpf_tcp_ops.{parse_hdr,hdr_opt_len} are called for every
> incoming / outgoing skb.
>
> bpf_tcp_ops.rtt is called once per RTT, which is every
> incoming skb in ping-pong workloads like tcp_rr.
>
> Even attaching NULL callbacks in the fast path hurts performance.
>
> Let's guard them (and write_hdr_opt) with the new per-socket flags.
>
> __bpf_tcp_ops_call() and bpf_tcp_ops_call_flag() are added to check
> cgroup_bpf_enabled(CGROUP_TCP_SOCK_OPS) first and avoid accessing
> tp->bpf_tcp_ops_flags when no bpf_tcp_ops is attached.
>
> Note that bpf_tcp_ops_hdr_opt_len() has 3 callers and previously
> checked the static key both in tcp_established_options() and inside
> bpf_tcp_ops_call(). Now the static key is checked once at the
> beginning of bpf_tcp_ops_hdr_opt_len(), and the redundant check in
> tcp_established_options() is removed.
>
> tcp_bpf_hdr_opt_len() must use __always_inline, not just
> inline, otherwise Clang inlines bpf_tcp_ops_hdr_opt_len() to
> tcp_bpf_hdr_opt_len() instead.
>
[ ... ]
>
> bpf_skops_write_hdr_opt() is still not free, but it can be
> optimised later if needed.
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
The changelog says the static key is now checked "once at the beginning of
bpf_tcp_ops_hdr_opt_len()", but the code doesn't do that.
The only cgroup_bpf_enabled(CGROUP_TCP_SOCK_OPS) check on this path is in
the new tcp_bpf_hdr_opt_len() wrapper:
static __always_inline u32 tcp_bpf_hdr_opt_len(...)
{
if (cgroup_bpf_enabled(CGROUP_TCP_SOCK_OPS))
remaining = bpf_tcp_ops_hdr_opt_len(...);
return remaining;
}
bpf_tcp_ops_hdr_opt_len() itself now starts with the per-socket flag test
and then calls the unguarded __bpf_tcp_ops_call():
if (!BPF_TCP_OPS_TEST_FLAG(tcp_sk(sk), WRITE_HDR_OPT) ||
!remaining)
return remaining;
...
__bpf_tcp_ops_call(hdr_opt_len, sk, skb, req, syn_skb, synack_type,
&remaining_out);
So bpf_tcp_ops_hdr_opt_len() reads tp->bpf_tcp_ops_flags without checking
the static key, and must only be reached through tcp_bpf_hdr_opt_len().
Should the changelog say tcp_bpf_hdr_opt_len() here?
Similarly, the sentence saying __bpf_tcp_ops_call() and
bpf_tcp_ops_call_flag() are added "to check
cgroup_bpf_enabled(CGROUP_TCP_SOCK_OPS) first" doesn't match
__bpf_tcp_ops_call(), which is the variant that does not check the static
key.
Could that sentence be reworded to say that only bpf_tcp_ops_call_flag()
does?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/37723340307
--===============0653454793552695213==--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads