public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: verify syncookie statistics in tcp_custom_syncookie
Date: Tue, 28 Apr 2026 00:12:17 +0000	[thread overview]
Message-ID: <20260428001217.D1045C2BCB6@smtp.kernel.org> (raw)
In-Reply-To: <20260427001006.14465-3-jiayuan.chen@linux.dev>

Sashiko AI review found 1 potential issue(s):
- [Medium] nstat command in read_tcpext_snmp() clobbers global history file due to missing -s flag
--

commit 6d6b9a4b92f87f759fc396b394eb46513c637ea5
Author: Jiayuan Chen <jiayuan.chen@linux.dev>

selftests/bpf: verify syncookie statistics in tcp_custom_syncookie

This commit adds a read_tcpext_snmp() helper to network_helpers.c to read
TcpExt SNMP counters via nstat. It uses this helper in the tcp_custom_syncookie
test to verify that LINUX_MIB_SYNCOOKIESRECV increments appropriately.

> diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
> --- a/tools/testing/selftests/bpf/network_helpers.c
> +++ b/tools/testing/selftests/bpf/network_helpers.c

[ ... ]

> @@ -621,6 +621,28 @@ int get_socket_local_port(int sock_fd)
>  	return -1;
>  }
>  
> +int read_tcpext_snmp(const char *name, unsigned long *val)
> +{
> +	char cmd[128], buf[128];
> +	int ret = 0;
> +	FILE *f;
> +
> +	snprintf(cmd, sizeof(cmd),
> +		 "nstat -az TcpExt%s | awk '/TcpExt/ {print $2}'", name);

Does invoking nstat without the -s flag clobber the global history file?

By default, nstat writes its state to a shared history file in the
temporary directory. Because BPF selftests run in parallel and share the
/tmp filesystem, multiple threads executing read_tcpext_snmp() might race
to write to this file.

Can this also corrupt the baseline for any concurrent networking tests that
rely on nstat delta calculations?

Would it be safer to invoke this as nstat -asz instead?

> +	f = popen(cmd, "r");
> +	if (!f)
> +		return -errno;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260427001006.14465-1-jiayuan.chen@linux.dev?part=2

      reply	other threads:[~2026-04-28  0:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  0:09 [PATCH bpf-next v3 0/2] bpf,net: add missing custom syncookie statistics and add selftest Jiayuan Chen
2026-04-27  0:09 ` [PATCH bpf-next v3 1/2] net: add missing syncookie statistics for BPF custom syncookies Jiayuan Chen
2026-04-28  0:12   ` sashiko-bot
2026-04-27  0:09 ` [PATCH bpf-next v3 2/2] selftests/bpf: verify syncookie statistics in tcp_custom_syncookie Jiayuan Chen
2026-04-28  0:12   ` sashiko-bot [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=20260428001217.D1045C2BCB6@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=sashiko@lists.linux.dev \
    /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