From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Kuniyuki Iwashima <kuniyu@google.com>
Cc: netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
Neal Cardwell <ncardwell@google.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH net-next v1] net: add missing syncookie statistics for BPF custom syncookies
Date: Sat, 11 Apr 2026 09:05:16 +0800 [thread overview]
Message-ID: <ce0aeb2f-55a5-4445-8a5a-e2a0fef75f4a@linux.dev> (raw)
In-Reply-To: <CAAVpQUCK-d6YwYW+ZAH5OvmYZmAFnmunnoctdZfFFMhqY26aTQ@mail.gmail.com>
On 4/11/26 6:31 AM, Kuniyuki Iwashima wrote:
>> 1. Replace IS_ENABLED(CONFIG_BPF) with CONFIG_BPF_SYSCALL for
>> cookie_bpf_ok() and cookie_bpf_check(). CONFIG_BPF is selected by
>> CONFIG_NET unconditionally, so IS_ENABLED(CONFIG_BPF) is always
>> true and provides no real guard. CONFIG_BPF_SYSCALL is the correct
>> config for BPF program functionality.
>>
>> 2. Remove the CONFIG_BPF_SYSCALL guard around struct bpf_tcp_req_attrs.
>> This struct is referenced by bpf_sk_assign_tcp_reqsk() in
>> net/core/filter.c which is compiled unconditionally, so wrapping
>> the definition in a config guard could cause build failures when
>> CONFIG_BPF_SYSCALL=n.
>>
>> 3. Fix mismatched declaration of cookie_bpf_check() between the
>> CONFIG_BPF_SYSCALL and stub paths: the real definition takes
>> 'struct net *net' but the declaration in the header did not.
>> Add the net parameter to the declaration and all call sites.
>>
>> 4. Add missing LINUX_MIB_SYNCOOKIESRECV and LINUX_MIB_SYNCOOKIESFAILED
>> statistics in cookie_bpf_check(), so that BPF custom syncookie
>> validation is accounted for in SNMP counters just like the
>> non-BPF path.
>>
>> Compile-tested with CONFIG_BPF_SYSCALL=y and CONFIG_BPF_SYSCALL
>> not set.
> Can you add SNMP test in tcp_custom_syncookie.c by checking
> the delta before connect_to_fd() and after accept() ?
Thanks for the suggestion. I've added the following to the existing test
case and it works correctly:
+ recv_before = read_tcpext("SyncookiesRecv");
+ failed_before = read_tcpext("SyncookiesFailed");
client = connect_to_fd(server, 0);
if (!ASSERT_NEQ(client, -1, "connect_to_fd"))
goto close_server;
child = accept(server, NULL, 0);
if (!ASSERT_NEQ(child, -1, "accept"))
goto close_client;
+ recv_after = read_tcpext("SyncookiesRecv");
+ failed_after = read_tcpext("SyncookiesFailed");
+ ASSERT_EQ(recv_after - recv_before, 1, "SyncookiesRecv delta");
+ ASSERT_EQ(failed_after - failed_before, 0, "SyncookiesFailed delta");
Will include it in v2.
prev parent reply other threads:[~2026-04-11 1:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 12:41 [PATCH net-next v1] net: add missing syncookie statistics for BPF custom syncookies Jiayuan Chen
2026-04-10 22:31 ` Kuniyuki Iwashima
2026-04-11 1:05 ` Jiayuan Chen [this message]
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=ce0aeb2f-55a5-4445-8a5a-e2a0fef75f4a@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@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=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.