Re: [PATCH v3] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF
From: Alejandro Colomar <alx@kernel.org>
Date: 2025-12-31 16:00:27
Hi Vincent, Craig, On Tue, Dec 02, 2025 at 10:49:03AM -0500, Craig Gallek wrote:
On Mon, Dec 1, 2025 at 2:57 PM Vincent Bernat [off-list ref] wrote:quoted
When using eBPF, there are two possible cases depending on the program type. Only the first case was described. In the second case, the program should not return an index, but a decision (SK_PASS/SK_DROP). The socket should be selected using the sk_select_reuseport helper. Cc: Craig Gallek <redacted> Signed-off-by: Vincent Bernat <redacted> ---
I have applied the patch, with some important reorganization of the text. <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=41788bdd42312828532c4ddbadc0a4d28426d4fd>
quoted
man/man7/socket.7 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)diff --git a/man/man7/socket.7 b/man/man7/socket.7 index b4d58a23d5da..e4e85dc9345d 100644 --- a/man/man7/socket.7 +++ b/man/man7/socket.7@@ -354,20 +354,34 @@ the sockets in the reuseport group (that is, all sockets which have .B SO_REUSEPORT set and are using the same local address to receive packets). .IP -The BPF program must return an index between 0 and N\-1 representing +The classic BPF program must return an index between 0 and N\-1 representing the socket which should receive the packet (where N is the number of sockets in the group). If the BPF program returns an invalid index, socket selection will fall back to the plain .B SO_REUSEPORT mechanism. -.IP Sockets are numbered in the order in which they are added to the group (that is, the order of .BR bind (2) calls for UDP sockets or the order of .BR listen (2) calls for TCP sockets). +.IP +The extended BPF program can be of two types: +.B BPF_PROG_TYPE_SOCKET_FILTER +or +.BR BPF_PROG_TYPE_SK_REUSEPORT . +In the first case, the extended BPF program must return an index between 0 and N\-1, +like a classic BPF program. +In the second case, it must return an action +.RB ( SK_PASS +or +.BR SK_DROP ) +and the +.B bpf_sk_select_reuseport +helper can be used to select the socket which should receive the packet. +.IP New sockets added to a reuseport group will inherit the BPF program. When a socket is removed from a reuseport group (via .BR close (2)),@@ -386,7 +400,10 @@ takes the same argument type as .BR SO_ATTACH_BPF . .IP UDP support for this feature is available since Linux 4.5; -TCP support is available since Linux 4.6. +TCP support is available since Linux 4.6; +support for +.B BPF_PROG_TYPE_SK_REUSEPORT +program type is available since Linux 4.19. .TP .B SO_BINDTODEVICE Bind this socket to a particular device like \[lq]eth0\[rq], --2.51.0Looks good to me, thank you for the clean up!
Thanks! I took this as an Acked-by. (I prefer them to be explicitly stated, though.) Have a lovely day! Alex -- <https://www.alejandro-colomar.es>
Attachments
- signature.asc [application/pgp-signature] 833 bytes