* [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF
@ 2025-10-27 13:17 Vincent Bernat
2025-10-27 13:24 ` Alejandro Colomar
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Vincent Bernat @ 2025-10-27 13:17 UTC (permalink / raw)
To: Alejandro Colomar, linux-man; +Cc: Vincent Bernat, Craig Gallek
When using eBPF, 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 <kraig@google.com>
Signed-off-by: Vincent Bernat <vincent@bernat.ch>
---
man/man7/socket.7 | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/man/man7/socket.7 b/man/man7/socket.7
index b4d58a23d5da..d85fdd931e42 100644
--- a/man/man7/socket.7
+++ b/man/man7/socket.7
@@ -354,20 +354,25 @@ 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
.BR bind (2)
calls for UDP sockets or the order of
.BR listen (2)
calls for TCP sockets).
+.IP
+The extended BPF program must return a decision and the
+.B bpf_sk_select_reuseport
+helper should 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)),
--
2.51.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-10-27 13:17 [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF Vincent Bernat @ 2025-10-27 13:24 ` Alejandro Colomar 2025-10-27 19:11 ` Vincent Bernat 2025-12-01 5:44 ` [PATCH v2] " Vincent Bernat 2025-12-01 19:57 ` [PATCH v3] " Vincent Bernat 2 siblings, 1 reply; 11+ messages in thread From: Alejandro Colomar @ 2025-10-27 13:24 UTC (permalink / raw) To: Vincent Bernat; +Cc: linux-man, Craig Gallek [-- Attachment #1: Type: text/plain, Size: 2264 bytes --] Hi Vincent, On Mon, Oct 27, 2025 at 02:17:00PM +0100, Vincent Bernat wrote: > When using eBPF, 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 <kraig@google.com> > Signed-off-by: Vincent Bernat <vincent@bernat.ch> Would you mind adding a Fixes: tag for the commit that introduced the incorrect text? Also, do you have a guess of why the wrong text was written? It would be useful to have an idea of that. Have a lovely day! Alex > --- > man/man7/socket.7 | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/man/man7/socket.7 b/man/man7/socket.7 > index b4d58a23d5da..d85fdd931e42 100644 > --- a/man/man7/socket.7 > +++ b/man/man7/socket.7 > @@ -354,20 +354,25 @@ 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 > .BR bind (2) > calls for UDP sockets or the order of > .BR listen (2) > calls for TCP sockets). > +.IP > +The extended BPF program must return a decision and the > +.B bpf_sk_select_reuseport > +helper should 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)), > -- > 2.51.0 > -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>). [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-10-27 13:24 ` Alejandro Colomar @ 2025-10-27 19:11 ` Vincent Bernat [not found] ` <CAEfhGiz9OLu=arVoPFJhYTr3h-wB5QR5sOkgNDMzwR+74NUEBw@mail.gmail.com> 0 siblings, 1 reply; 11+ messages in thread From: Vincent Bernat @ 2025-10-27 19:11 UTC (permalink / raw) To: Alejandro Colomar; +Cc: linux-man, Craig Gallek On 2025-10-27 14:24, Alejandro Colomar wrote: > On Mon, Oct 27, 2025 at 02:17:00PM +0100, Vincent Bernat wrote: >> When using eBPF, 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 <kraig@google.com> >> Signed-off-by: Vincent Bernat <vincent@bernat.ch> > > Would you mind adding a Fixes: tag for the commit that introduced the > incorrect text? This is 1fa871f5378e (2016-03-01; "socket.7: Document some BPF-related socket options") > Also, do you have a guess of why the wrong text was written? It would > be useful to have an idea of that. Not a clue, but maybe let's wait when Craig comes back from vacation so he could say if there was a change or not and tell if I am correct. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <CAEfhGiz9OLu=arVoPFJhYTr3h-wB5QR5sOkgNDMzwR+74NUEBw@mail.gmail.com>]
* Re: [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF [not found] ` <CAEfhGiz9OLu=arVoPFJhYTr3h-wB5QR5sOkgNDMzwR+74NUEBw@mail.gmail.com> @ 2025-11-03 20:28 ` Vincent Bernat 2025-11-24 16:47 ` Alejandro Colomar 0 siblings, 1 reply; 11+ messages in thread From: Vincent Bernat @ 2025-11-03 20:28 UTC (permalink / raw) To: Craig Gallek; +Cc: Alejandro Colomar, linux-man, Martin KaFai Lau On 2025-11-03 17:31, Craig Gallek wrote: > > On Mon, Oct 27, 2025 at 02:17:00PM +0100, Vincent Bernat wrote: > >> When using eBPF, 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 <kraig@google.com <mailto:kraig@google.com>> > >> Signed-off-by: Vincent Bernat <vincent@bernat.ch > <mailto:vincent@bernat.ch>> > > > > Would you mind adding a Fixes: tag for the commit that introduced the > > incorrect text? > > This is 1fa871f5378e (2016-03-01; "socket.7: Document some BPF-related > socket options") > > Also, do you have a guess of why the wrong text was written? It > would > > be useful to have an idea of that. > > Not a clue, but maybe let's wait when Craig comes back from vacation so > he could say if there was a change or not and tell if I am correct. > > > It's been a while since I've used this code, but it looks like the > sk_select_reuseport helper was added a few years later by Martin KaFai > Lau in 2dbb9b9e6df6. The execution of the bpf program (run_bpf_filter > in sock_reuseport.c) still uses the program's 'returned' value in both > the cbpf and ebpf cases, but it looks like Martin's change tightened up > the 'type' of eBPF program that can be used for this purpose and > included this helper function to allow for an explicit validation > instead of just having the program return a raw integer value. > > So I think this is just a case of the documentation not keeping up with > the code. I'm less familiar with the PASS/DROP syntax, but I'm guessing > that came along after the initial implementation of these reuseport BPF > programs as well. > > In any event, my quick read of the code lines up with your proposed > documentation change. It might be worth having Martin verify as well, > but this looks good to me. OK, so, two things are possible and the kernel selects depending on the program type (BPF_PROG_TYPE_SOCKET_FILTER or BPF_PROG_TYPE_SK_REUSEPORT). if (prog->type == BPF_PROG_TYPE_SK_REUSEPORT) sk2 = bpf_run_sk_reuseport(reuse, sk, prog, skb, NULL, hash); else sk2 = run_bpf_filter(reuse, socks, prog, skb, hdr_len); So, I can update the documentation for that, as I have missed it. Waiting for Martin feedback in case there is something else. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-11-03 20:28 ` Vincent Bernat @ 2025-11-24 16:47 ` Alejandro Colomar 0 siblings, 0 replies; 11+ messages in thread From: Alejandro Colomar @ 2025-11-24 16:47 UTC (permalink / raw) To: Vincent Bernat; +Cc: Craig Gallek, linux-man, Martin KaFai Lau [-- Attachment #1: Type: text/plain, Size: 1829 bytes --] Hi Vincent, On Mon, Nov 03, 2025 at 09:28:04PM +0100, Vincent Bernat wrote: > On 2025-11-03 17:31, Craig Gallek wrote: [...] > > It's been a while since I've used this code, but it looks like the > > sk_select_reuseport helper was added a few years later by Martin KaFai > > Lau in 2dbb9b9e6df6. The execution of the bpf program (run_bpf_filter > > in sock_reuseport.c) still uses the program's 'returned' value in both > > the cbpf and ebpf cases, but it looks like Martin's change tightened up > > the 'type' of eBPF program that can be used for this purpose and > > included this helper function to allow for an explicit validation > > instead of just having the program return a raw integer value. > > > > So I think this is just a case of the documentation not keeping up with > > the code. I'm less familiar with the PASS/DROP syntax, but I'm guessing > > that came along after the initial implementation of these reuseport BPF > > programs as well. > > > > In any event, my quick read of the code lines up with your proposed > > documentation change. It might be worth having Martin verify as well, > > but this looks good to me. > > OK, so, two things are possible and the kernel selects depending on the > program type (BPF_PROG_TYPE_SOCKET_FILTER or BPF_PROG_TYPE_SK_REUSEPORT). > > if (prog->type == BPF_PROG_TYPE_SK_REUSEPORT) > sk2 = bpf_run_sk_reuseport(reuse, sk, prog, skb, NULL, hash); > else > sk2 = run_bpf_filter(reuse, socks, prog, skb, hdr_len); > > So, I can update the documentation for that, as I have missed it. Waiting > for Martin feedback in case there is something else. You can send an updated patch in the meanwhile, if you want. Have a lovely day! Alex -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>). [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-10-27 13:17 [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF Vincent Bernat 2025-10-27 13:24 ` Alejandro Colomar @ 2025-12-01 5:44 ` Vincent Bernat 2025-12-01 5:49 ` Vincent Bernat 2025-12-01 14:03 ` Alejandro Colomar 2025-12-01 19:57 ` [PATCH v3] " Vincent Bernat 2 siblings, 2 replies; 11+ messages in thread From: Vincent Bernat @ 2025-12-01 5:44 UTC (permalink / raw) To: Alejandro Colomar, Craig Gallek, linux-man, Martin KaFai Lau Cc: Vincent Bernat 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 <kraig@google.com> Signed-off-by: Vincent Bernat <vincent@bernat.ch> --- 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 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-12-01 5:44 ` [PATCH v2] " Vincent Bernat @ 2025-12-01 5:49 ` Vincent Bernat 2025-12-01 14:03 ` Alejandro Colomar 1 sibling, 0 replies; 11+ messages in thread From: Vincent Bernat @ 2025-12-01 5:49 UTC (permalink / raw) To: Alejandro Colomar, Craig Gallek, linux-man, Martin KaFai Lau On 2025-12-01 06:44, Vincent Bernat wrote: > 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. I didn't add a "Fix:", as this is an update (introduced in Linux 4.19). This is not 100% complete as it does not explain socket migration (https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_SK_REUSEPORT/) but I didn't want to go too much in details. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-12-01 5:44 ` [PATCH v2] " Vincent Bernat 2025-12-01 5:49 ` Vincent Bernat @ 2025-12-01 14:03 ` Alejandro Colomar 1 sibling, 0 replies; 11+ messages in thread From: Alejandro Colomar @ 2025-12-01 14:03 UTC (permalink / raw) To: Vincent Bernat; +Cc: Craig Gallek, linux-man, Martin KaFai Lau [-- Attachment #1: Type: text/plain, Size: 3645 bytes --] Hi Vincent, On Mon, Dec 01, 2025 at 06:44:23AM +0100, Vincent Bernat wrote: > 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 <kraig@google.com> > Signed-off-by: Vincent Bernat <vincent@bernat.ch> > --- > 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 Please use semantic newlines. See man-pages(7): $ MANWIDTH=72 man man-pages | sed -n '/Use semantic newlines/,/^$/p' Use semantic newlines In the source of a manual page, new sentences should be started on new lines, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase boundaries. This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of individual sentences, clauses, or phrases. Have a lovely day! Alex > +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 > > -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>). [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-10-27 13:17 [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF Vincent Bernat 2025-10-27 13:24 ` Alejandro Colomar 2025-12-01 5:44 ` [PATCH v2] " Vincent Bernat @ 2025-12-01 19:57 ` Vincent Bernat 2025-12-02 15:49 ` Craig Gallek 2 siblings, 1 reply; 11+ messages in thread From: Vincent Bernat @ 2025-12-01 19:57 UTC (permalink / raw) To: Alejandro Colomar, linux-man, Martin KaFai Lau Cc: Vincent Bernat, Craig Gallek 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 <kraig@google.com> Signed-off-by: Vincent Bernat <vincent@bernat.ch> --- 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.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-12-01 19:57 ` [PATCH v3] " Vincent Bernat @ 2025-12-02 15:49 ` Craig Gallek 2025-12-31 16:00 ` Alejandro Colomar 0 siblings, 1 reply; 11+ messages in thread From: Craig Gallek @ 2025-12-02 15:49 UTC (permalink / raw) To: Vincent Bernat; +Cc: Alejandro Colomar, linux-man, Martin KaFai Lau On Mon, Dec 1, 2025 at 2:57 PM Vincent Bernat <vincent@bernat.ch> wrote: > > 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 <kraig@google.com> > Signed-off-by: Vincent Bernat <vincent@bernat.ch> > --- > 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.0 Looks good to me, thank you for the clean up! ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF 2025-12-02 15:49 ` Craig Gallek @ 2025-12-31 16:00 ` Alejandro Colomar 0 siblings, 0 replies; 11+ messages in thread From: Alejandro Colomar @ 2025-12-31 16:00 UTC (permalink / raw) To: Craig Gallek; +Cc: Vincent Bernat, linux-man, Martin KaFai Lau [-- Attachment #1: Type: text/plain, Size: 3229 bytes --] 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 <vincent@bernat.ch> wrote: > > > > 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 <kraig@google.com> > > Signed-off-by: Vincent Bernat <vincent@bernat.ch> > > --- 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> > > 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.0 > > Looks 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> [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-12-31 16:00 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-27 13:17 [PATCH] man/man7/socket.7: fix documentation for SO_ATTACH_REUSEPORT_EBPF Vincent Bernat
2025-10-27 13:24 ` Alejandro Colomar
2025-10-27 19:11 ` Vincent Bernat
[not found] ` <CAEfhGiz9OLu=arVoPFJhYTr3h-wB5QR5sOkgNDMzwR+74NUEBw@mail.gmail.com>
2025-11-03 20:28 ` Vincent Bernat
2025-11-24 16:47 ` Alejandro Colomar
2025-12-01 5:44 ` [PATCH v2] " Vincent Bernat
2025-12-01 5:49 ` Vincent Bernat
2025-12-01 14:03 ` Alejandro Colomar
2025-12-01 19:57 ` [PATCH v3] " Vincent Bernat
2025-12-02 15:49 ` Craig Gallek
2025-12-31 16:00 ` Alejandro Colomar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox