From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 5/7] selftests/bpf: Add netdevsim helper library
Date: Tue, 01 Sep 2026 10:59:17 +0000 [thread overview]
Message-ID: <20260901105917.64C911F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831110934.241898-6-a.s.protopopov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Busy loop in `recv_device_ifindex()` when `recv()` returns 0
--
commit a319bb58b65c3ac30499b9e1c997fd27ae962cff
Author: Anton Protopopov <a.s.protopopov@gmail.com>
selftests/bpf: Add netdevsim helper library
This patch adds a minimal netdevsim helper library for BPF selftests,
handling the creation of netdevsim devices with one port and one queue.
> diff --git a/tools/testing/selftests/bpf/netdevsim_helpers.c b/tools/testing/selftests/bpf/netdevsim_helpers.c
> new file mode 100644
> index 0000000000000..fbed7442b2e8d
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/netdevsim_helpers.c
[ ... ]
> +static int recv_device_ifindex(int fd, unsigned int id, unsigned int *ifindex)
> +{
[ ... ]
> + for (timeout = remaining_timeout_ms(&deadline); timeout > 0;
> + timeout = remaining_timeout_ms(&deadline)) {
> + ret = poll(&pfd, 1, timeout);
> + if (ret < 0) {
> + if (errno == EINTR)
> + continue;
> + return -errno;
> + }
> + if (!ret)
> + return -ETIMEDOUT;
> + if (!(pfd.revents & POLLIN))
> + return -EIO;
> +
> + len = recv(fd, buf, sizeof(buf), 0);
> + if (len < 0)
> + return -errno;
> +
> + for (nlh = (struct nlmsghdr *)buf; NLMSG_OK(nlh, len);
[Severity: Medium]
What happens when recv() returns 0 (e.g., on EOF)?
It looks like the len < 0 check is bypassed, and NLMSG_OK(nlh, 0) evaluates
to false. This means the code skips the message processing loop entirely.
Since the outer loop is driven by poll() which immediately returns POLLIN on
EOF, will this cause recv() to continually return 0?
Does this result in a tight busy-loop that consumes 100% CPU until the
5-second timeout expires?
> + nlh = NLMSG_NEXT(nlh, len)) {
> + struct ifinfomsg *ifm;
> + struct rtattr *attr;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831110934.241898-1-a.s.protopopov@gmail.com?part=5
next prev parent reply other threads:[~2026-09-01 10:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 11:09 [PATCH bpf-next 0/7] Add new way to add BPF LSM hooks Anton Protopopov
2026-08-31 11:09 ` [PATCH bpf-next 1/7] bpf: Allow BPF LSM programs to attach to more hooks Anton Protopopov
2026-08-31 11:50 ` bot+bpf-ci
2026-08-31 12:48 ` Anton Protopopov
2026-08-31 22:42 ` Paul Moore
2026-09-01 13:36 ` Anton Protopopov
2026-09-01 22:15 ` Paul Moore
2026-09-02 15:31 ` Anton Protopopov
2026-09-02 19:43 ` Paul Moore
2026-08-31 11:09 ` [PATCH bpf-next 2/7] net, bpf: Add a generic netlink hook on msg_rcv Anton Protopopov
2026-08-31 12:07 ` bot+bpf-ci
2026-08-31 13:22 ` Anton Protopopov
2026-08-31 11:09 ` [PATCH bpf-next 3/7] net, bpf: Add bpf hooks for ethtool control path Anton Protopopov
2026-09-01 10:59 ` sashiko-bot
2026-08-31 11:09 ` [PATCH bpf-next 4/7] selftests/bpf: Extract some helpers from tests to the netlink library Anton Protopopov
2026-08-31 11:09 ` [PATCH bpf-next 5/7] selftests/bpf: Add netdevsim helper library Anton Protopopov
2026-08-31 12:07 ` bot+bpf-ci
2026-08-31 12:55 ` Anton Protopopov
2026-09-01 10:59 ` sashiko-bot [this message]
2026-08-31 11:09 ` [PATCH bpf-next 6/7] selftests/bpf: Add tests for the generic netlink BPF hook Anton Protopopov
2026-08-31 12:07 ` bot+bpf-ci
2026-08-31 13:01 ` Anton Protopopov
2026-08-31 11:09 ` [PATCH bpf-next 7/7] selftests/bpf: Add tests for BPF ethtool hooks Anton Protopopov
2026-08-31 12:07 ` bot+bpf-ci
2026-08-31 13:12 ` Anton Protopopov
2026-08-31 22:34 ` [PATCH bpf-next 0/7] Add new way to add BPF LSM hooks Jakub Kicinski
2026-09-01 12:29 ` Anton Protopopov
2026-09-02 0:49 ` Jakub Kicinski
2026-09-02 15:11 ` Anton Protopopov
2026-09-02 18:07 ` Alexei Starovoitov
2026-09-02 19:31 ` Anton Protopopov
2026-09-03 12:16 ` Justin Suess
2026-09-03 13:23 ` Anton Protopopov
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=20260901105917.64C911F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.s.protopopov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@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 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.