printf: Remove unused 'bprintf'
[drm/drm-misc.git] / Documentation / bpf / redirect.rst
blob2fa2b0b0500452c027847644f0cbf5cbf40cdff5
1 .. SPDX-License-Identifier: GPL-2.0-only
2 .. Copyright (C) 2022 Red Hat, Inc.
4 ========
5 Redirect
6 ========
7 XDP_REDIRECT
8 ############
9 Supported maps
10 --------------
12 XDP_REDIRECT works with the following map types:
14 - ``BPF_MAP_TYPE_DEVMAP``
15 - ``BPF_MAP_TYPE_DEVMAP_HASH``
16 - ``BPF_MAP_TYPE_CPUMAP``
17 - ``BPF_MAP_TYPE_XSKMAP``
19 For more information on these maps, please see the specific map documentation.
21 Process
22 -------
24 .. kernel-doc:: net/core/filter.c
25    :doc: xdp redirect
27 .. note::
28     Not all drivers support transmitting frames after a redirect, and for
29     those that do, not all of them support non-linear frames. Non-linear xdp
30     bufs/frames are bufs/frames that contain more than one fragment.
32 Debugging packet drops
33 ----------------------
34 Silent packet drops for XDP_REDIRECT can be debugged using:
36 - bpf_trace
37 - perf_record
39 bpf_trace
40 ^^^^^^^^^
41 The following bpftrace command can be used to capture and count all XDP tracepoints:
43 .. code-block:: none
45     sudo bpftrace -e 'tracepoint:xdp:* { @cnt[probe] = count(); }'
46     Attaching 12 probes...
47     ^C
49     @cnt[tracepoint:xdp:mem_connect]: 18
50     @cnt[tracepoint:xdp:mem_disconnect]: 18
51     @cnt[tracepoint:xdp:xdp_exception]: 19605
52     @cnt[tracepoint:xdp:xdp_devmap_xmit]: 1393604
53     @cnt[tracepoint:xdp:xdp_redirect]: 22292200
55 .. note::
56     The various xdp tracepoints can be found in ``source/include/trace/events/xdp.h``
58 The following bpftrace command can be used to extract the ``ERRNO`` being returned as
59 part of the err parameter:
61 .. code-block:: none
63     sudo bpftrace -e \
64     'tracepoint:xdp:xdp_redirect*_err {@redir_errno[-args->err] = count();}
65     tracepoint:xdp:xdp_devmap_xmit {@devmap_errno[-args->err] = count();}'
67 perf record
68 ^^^^^^^^^^^
69 The perf tool also supports recording tracepoints:
71 .. code-block:: none
73     perf record -a -e xdp:xdp_redirect_err \
74         -e xdp:xdp_redirect_map_err \
75         -e xdp:xdp_exception \
76         -e xdp:xdp_devmap_xmit
78 References
79 ===========
81 - https://github.com/xdp-project/xdp-tutorial/tree/master/tracing02-xdp-monitor