From 41788bdd42312828532c4ddbadc0a4d28426d4fd Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 1 Dec 2025 20:57:15 +0100 Subject: [PATCH] man/man7/socket.7: Fix documentation for SO_ATTACH_REUSEPORT_EBPF 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. Signed-off-by: Vincent Bernat Message-ID: <20251201195726.3669864-1-vincent@bernat.ch> Acked-by: Craig Gallek Message-ID: [alx: reorganize text more schematically] Signed-off-by: Alejandro Colomar --- man/man7/socket.7 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/man/man7/socket.7 b/man/man7/socket.7 index 57ad0e108..4b133d85a 100644 --- a/man/man7/socket.7 +++ b/man/man7/socket.7 @@ -354,7 +354,7 @@ 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, @@ -368,6 +368,26 @@ Sockets are numbered in the order in which they are added to the group 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: +.RS +.TP +.B BPF_PROG_TYPE_SOCKET_FILTER +In this case, +the extended BPF program must return an index between 0 and N\-1, +like a classic BPF program. +.TP +.BR BPF_PROG_TYPE_SK_REUSEPORT " (since Linux 4.19)" +In this 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. +.RE +.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)), -- 2.47.3