From: sashiko-bot@kernel.org
To: "Ishu Brar" <patches@brar.si>
Cc: sparclinux@vger.kernel.org
Subject: Re: [PATCH RFC net-next 2/2] selftests: af_unix: Add test for SO_MAX_DGRAM_QLEN
Date: Thu, 03 Dec 2026 07:09:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-247267@kernel.org> (raw)
In-Reply-To: <20261202-af-unix-dgram-qlen-v1-2-043723f83d6d@brar.si>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] selftests: af_unix: missing stddef.h include for offsetof()
in dgram_qlen.c
- [Low] selftests: af_unix: unprivileged EPERM in dgram_qlen wakeup
tests
- [Low] selftests: af_unix: missing dgram_qlen entry in .gitignore
--
commit 945f90bd1ff3e537024ec7cf72598717163e9cd7
Author: Ishu Brar <patches@brar.si>
selftests: af_unix: Add test for SO_MAX_DGRAM_QLEN
This commit adds a kselftest covering the SO_MAX_DGRAM_QLEN socket option
for AF_UNIX datagram sockets.
> diff --git a/tools/testing/selftests/net/af_unix/Makefile b/tools/testing/selftests/net/af_unix/Makefile
> index fb2e09f0f44bb..110cc339598bc 100644
> --- a/tools/testing/selftests/net/af_unix/Makefile
> +++ b/tools/testing/selftests/net/af_unix/Makefile
> @@ -6,6 +6,7 @@ cc-option = $(call __cc-option, $(CC),,$(1),$(2))
> CFLAGS += $(KHDR_INCLUDES) -Wall $(call cc-option,-Wflex-array-member-not-at-end)
>
> TEST_GEN_PROGS := \
> + dgram_qlen \
> diag_uid \
> scm_inq \
> scm_pidfd \
[Severity: Low]
Should dgram_qlen also be added to
tools/testing/selftests/net/af_unix/.gitignore alongside the other binaries
in TEST_GEN_PROGS?
> diff --git a/tools/testing/selftests/net/af_unix/dgram_qlen.c b/tools/testing/selftests/net/af_unix/dgram_qlen.c
> new file mode 100644
> index 0000000000000..7a5f423397311
> --- /dev/null
> +++ b/tools/testing/selftests/net/af_unix/dgram_qlen.c
> @@ -0,0 +1,243 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* SO_MAX_DGRAM_QLEN: per-socket datagram queue length for AF_UNIX. */
> +
> +#define _GNU_SOURCE
> +#include <errno.h>
> +#include <poll.h>
> +#include <stdio.h>
> +#include <sys/socket.h>
> +#include <sys/types.h>
> +#include <sys/un.h>
> +#include <sys/wait.h>
> +#include <time.h>
> +#include <unistd.h>
> +
> +#include "kselftest_harness.h"
[ ... ]
> +FIXTURE_SETUP(dgram_qlen)
> +{
> + /* A bound receiver, not a socketpair: a receiver whose peer is the
> + * sender is exempt from the queue limit in unix_dgram_sendmsg().
> + */
> + self->addr.sun_family = AF_UNIX;
> + self->addrlen = offsetof(struct sockaddr_un, sun_path) + 1 +
> + snprintf(self->addr.sun_path + 1,
> + sizeof(self->addr.sun_path) - 1,
> + "dgram_qlen.%d", getpid());
[Severity: Medium]
Does this fail to build because stddef.h is not included for offsetof()?
None of the included headers or kselftest_harness.h pull in offsetof() on
glibc or musl, so compiling dgram_qlen.c fails with an undeclared identifier
error.
[ ... ]
> +/* Raising the limit must wake a sender blocked in send(), with no recv(). */
> +TEST_F(dgram_qlen, raise_wakes_blocked_sender)
> +{
[ ... ]
> + usleep(200 * 1000);
> + ASSERT_EQ(0, set_qlen(self->rcv, 100));
> + ASSERT_EQ(pid, waitpid(pid, &status, 0));
> + ASSERT_EQ(0, WEXITSTATUS(status));
> + close(fd);
> +}
> +
> +/* Same for a sender waiting in poll() for POLLOUT. */
> +TEST_F(dgram_qlen, raise_wakes_poller)
> +{
[ ... ]
> + usleep(200 * 1000);
> + ASSERT_EQ(0, set_qlen(self->rcv, 100));
> + ASSERT_EQ(pid, waitpid(pid, &status, 0));
> + ASSERT_EQ(0, WEXITSTATUS(status));
> + close(fd);
> +}
[Severity: Low]
Will set_qlen(self->rcv, 100) fail with EPERM in raise_wakes_blocked_sender
and raise_wakes_poller when the test runs without CAP_NET_ADMIN?
The default net.unix.max_dgram_qlen sysctl is 10, so raising the limit to 100
requires CAP_NET_ADMIN and aborts via ASSERT_EQ() before waitpid() reaps the
child process. Raising the limit from 2 to a value at or below 10 (such as 4
or 8, as in limit_applies and lower_keeps_queue) would wake the child without
requiring privileges.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-af-unix-dgram-qlen-v1-0-043723f83d6d@brar.si?part=2
prev parent reply other threads:[~2026-12-03 7:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 7:09 [PATCH RFC net-next 0/2] af_unix: Per-socket datagram queue length Ishu Brar via B4 Relay
2026-12-02 7:09 ` Ishu Brar
2026-12-02 7:09 ` [PATCH RFC net-next 1/2] af_unix: Add SO_MAX_DGRAM_QLEN for per-socket " Ishu Brar via B4 Relay
2026-12-02 7:09 ` Ishu Brar
2026-12-03 7:09 ` sashiko-bot
2026-12-02 7:09 ` [PATCH RFC net-next 2/2] selftests: af_unix: Add test for SO_MAX_DGRAM_QLEN Ishu Brar via B4 Relay
2026-12-02 7:09 ` Ishu Brar
2026-12-03 7:09 ` 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=sashiko-outbox-247267@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=patches@brar.si \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sparclinux@vger.kernel.org \
/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.