diff mbox series

xsk: sample kernel code is now in libbpf

Message ID 20190621201310.12791-1-eric@regit.org
State Accepted
Delegated to: BPF Maintainers
Headers show
Series xsk: sample kernel code is now in libbpf | expand

Commit Message

Eric Leblond June 21, 2019, 8:13 p.m. UTC
Fix documentation that mention xdpsock_kern.c which has been
replaced by code embedded in libbpf.

Signed-off-by: Eric Leblond <eric@regit.org>
---
 Documentation/networking/af_xdp.rst | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Björn Töpel June 24, 2019, 10:01 a.m. UTC | #1
On Fri, 21 Jun 2019 at 22:55, Eric Leblond <eric@regit.org> wrote:
>
> Fix documentation that mention xdpsock_kern.c which has been
> replaced by code embedded in libbpf.
>
> Signed-off-by: Eric Leblond <eric@regit.org>

Thanks Eric!

Acked-by: Björn Töpel <bjorn.topel@intel.com>

> ---
>  Documentation/networking/af_xdp.rst | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/networking/af_xdp.rst b/Documentation/networking/af_xdp.rst
> index e14d7d40fc75..83dddc20f5d6 100644
> --- a/Documentation/networking/af_xdp.rst
> +++ b/Documentation/networking/af_xdp.rst
> @@ -220,7 +220,21 @@ Usage
>  In order to use AF_XDP sockets there are two parts needed. The
>  user-space application and the XDP program. For a complete setup and
>  usage example, please refer to the sample application. The user-space
> -side is xdpsock_user.c and the XDP side xdpsock_kern.c.
> +side is xdpsock_user.c and the XDP side is part of libbpf.
> +
> +The XDP code sample included in tools/lib/bpf/xsk.c is the following::
> +
> +   SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx)
> +   {
> +       int index = ctx->rx_queue_index;
> +
> +       // A set entry here means that the correspnding queue_id
> +       // has an active AF_XDP socket bound to it.
> +       if (bpf_map_lookup_elem(&xsks_map, &index))
> +           return bpf_redirect_map(&xsks_map, index, 0);
> +
> +       return XDP_PASS;
> +   }
>
>  Naive ring dequeue and enqueue could look like this::
>
> --
> 2.20.1
>
Daniel Borkmann June 24, 2019, 3 p.m. UTC | #2
On 06/21/2019 10:13 PM, Eric Leblond wrote:
> Fix documentation that mention xdpsock_kern.c which has been
> replaced by code embedded in libbpf.
> 
> Signed-off-by: Eric Leblond <eric@regit.org>

Applied, thanks!
diff mbox series

Patch

diff --git a/Documentation/networking/af_xdp.rst b/Documentation/networking/af_xdp.rst
index e14d7d40fc75..83dddc20f5d6 100644
--- a/Documentation/networking/af_xdp.rst
+++ b/Documentation/networking/af_xdp.rst
@@ -220,7 +220,21 @@  Usage
 In order to use AF_XDP sockets there are two parts needed. The
 user-space application and the XDP program. For a complete setup and
 usage example, please refer to the sample application. The user-space
-side is xdpsock_user.c and the XDP side xdpsock_kern.c.
+side is xdpsock_user.c and the XDP side is part of libbpf.
+
+The XDP code sample included in tools/lib/bpf/xsk.c is the following::
+
+   SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx)
+   {
+       int index = ctx->rx_queue_index;
+
+       // A set entry here means that the correspnding queue_id
+       // has an active AF_XDP socket bound to it.
+       if (bpf_map_lookup_elem(&xsks_map, &index))
+           return bpf_redirect_map(&xsks_map, index, 0);
+
+       return XDP_PASS;
+   }
 
 Naive ring dequeue and enqueue could look like this::