Re: [PATCH] docs: netlink: Correct buffer sizing info
From: Konstantin Shabanov
Date: Fri May 15 2026 - 12:12:34 EST
On Tue, 12 May 2026 17:27:57 -0700 Jakub Kicinski wrote:
> On Tue, 12 May 2026 17:30:53 +0700 Konstantin Shabanov wrote:
> > Update the docs to match the code (include/linux/netlink.h):
> >
> > /*
> > * skb should fit one page. This choice is good for headerless malloc.
> > * But we should limit to 8K so that userspace does not have to
> > * use enormous buffer sizes on recvmsg() calls just to avoid
> > * MSG_TRUNC when PAGE_SIZE is very large.
> > */
> > #if PAGE_SIZE < 8192UL
> > #define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(PAGE_SIZE)
> > #else
> > #define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(8192UL)
> > #endif
>
> You should explain what you think the problem is in the commit message.
> Maybe if you did you'd realize you're comparing kernel header comment
> to user space guidance which are (obviously?) the inverse of each
> other..
I thought that the comment is self-explaining:
* But we should limit to 8K so that userspace does not have to
* use enormous buffer sizes on recvmsg() calls just to avoid
* MSG_TRUNC when PAGE_SIZE is very large.
The problem is that according to the comment, kernel isn't going to send
more than 8K in a single reply and the documentation is currently recommends the opposite:
to create _at least_ 8K buffer what looks excessive.
Also, the logic in the comment is aligned with userspace libraries (libmnl [1]
and wireguard-tools [2]).
[1]: https://git.netfilter.org/libmnl/tree/include/libmnl/libmnl.h?id=54dea548d796653534645c6e3c8577eaf7d77411#n20
[2]: https://git.zx2c4.com/wireguard-tools/tree/src/netlink.h?id=a998407747005ea7e4e0258d96f105c97241e1d3#n70