[PATCH RFC net-next 0/2] af_unix: Per-socket datagram queue length

From: Ishu Brar via B4 Relay

Date: Wed Dec 02 2026 - 02:09:37 EST


Datagram queue length of AF_UNIX socket is copied from
net.unix.max_dgram_qlen at creation, can't be changed later. journald's
/dev/log is created by PID 1 before sysctl.d runs, and kept across
journald restarts, so admin's value never reaches it, all syslog(3)
callers share one queue, systemd works around it with global sysctl bump
early in boot [1]. Lennart asked for socket option instead [1], it's
also KF.71 on UAPI group wishlist [2].

Patch 1 adds SO_MAX_DGRAM_QLEN for SOCK_DGRAM sockets, patch 2 adds
selftest. Tested in virtme-ng VM (x86_64, clang, PROVE_LOCKING), 6/6
pass, no lockdep reports, both wakeup cases fail when wake_up call is
removed.

Questions for this RFC:

1. Permission, going above netns sysctl needs CAP_NET_ADMIN in user ns
owning netns, since sysctl can be set there after commit cec16052d5a7
("net: Enable max_dgram_qlen unix sysctl to be configurable by
non-init user namespaces"). Or init_user_ns, like SO_RCVBUFFORCE?

2. Read-back, no getsockopt(), af_unix has no unix_getsockopt() yet, and
sock_diag shows sk_max_ack_backlog only for listening sockets. Add
one of them?

SO_RCVBUF is no alternative, AF_UNIX datagram sockets don't check
receiver's sk_rcvbuf.

AI was used to write selftest and edit this message

[1] https://github.com/systemd/systemd/issues/45144
[2] https://github.com/uapi-group/kernel-features

Signed-off-by: Ishu Brar <patches@xxxxxxx>
---
Ishu Brar (2):
af_unix: Add SO_MAX_DGRAM_QLEN for per-socket datagram queue length
selftests: af_unix: Add test for SO_MAX_DGRAM_QLEN

arch/alpha/include/uapi/asm/socket.h | 2 +
arch/mips/include/uapi/asm/socket.h | 2 +
arch/parisc/include/uapi/asm/socket.h | 2 +
arch/sparc/include/uapi/asm/socket.h | 2 +
include/uapi/asm-generic/socket.h | 2 +
net/unix/af_unix.c | 27 ++-
tools/testing/selftests/net/af_unix/Makefile | 1 +
tools/testing/selftests/net/af_unix/dgram_qlen.c | 243 +++++++++++++++++++++++
8 files changed, 280 insertions(+), 1 deletion(-)
---
base-commit: 0a837a30e55bbea2afb01cf0b3ec0c1d789a73ad
change-id: 20261202-af-unix-dgram-qlen-1112c811d5cf

Best regards,
--
Ishu Brar <patches@xxxxxxx>