Skip to content

Commit

Permalink
xsk: sample kernel code is now in libbpf
Browse files Browse the repository at this point in the history
Fix documentation that mention xdpsock_kern.c which has been
replaced by code embedded in libbpf.

Signed-off-by: Eric Leblond <eric@regit.org>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Eric Leblond authored and Alexei Starovoitov committed Jun 25, 2019
1 parent 900de4a commit 0bed613
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Documentation/networking/af_xdp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down

0 comments on commit 0bed613

Please sign in to comment.