Thread (9 messages) 9 messages, 3 authors, 2025-12-31

[PATCH v2] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF

From: Vincent Bernat <hidden>
Date: 2025-12-01 05:48:24
Subsystem: the rest · Maintainer: Linus Torvalds

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>
---
 man/man7/socket.7 | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/man/man7/socket.7 b/man/man7/socket.7
index b4d58a23d5da..426cf63a7d0b 100644
--- a/man/man7/socket.7
+++ b/man/man7/socket.7
@@ -354,20 +354,32 @@ 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 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
+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
+mechanism. 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 +398,9 @@ 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.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help