Debian Codegraph @

Documentation/bpf/redirect.rst

raw
1 .. SPDX-License-Identifier: GPL-2.0-only
2 .. Copyright (C) 2022 Red Hat, Inc.
3
4 ========
5 Redirect
6 ========
7 XDP_REDIRECT
8 ############
9 Supported maps
10 --------------
11
12 XDP_REDIRECT works with the following map types:
13
14 - ``BPF_MAP_TYPE_DEVMAP``
15 - ``BPF_MAP_TYPE_DEVMAP_HASH``
16 - ``BPF_MAP_TYPE_CPUMAP``
17 - ``BPF_MAP_TYPE_XSKMAP``
18
19 For more information on these maps, please see the specific map documentation.
20
21 Process
22 -------
23
24 .. kernel-doc:: net/core/filter.c
25 :doc: xdp redirect
26
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.
31
32 Debugging packet drops
33 ----------------------
34 Silent packet drops for XDP_REDIRECT can be debugged using:
35
36 - bpf_trace
37 - perf_record
38
39 bpf_trace
40 ^^^^^^^^^
41 The following bpftrace command can be used to capture and count all XDP tracepoints:
42
43 .. code-block:: none
44
45 sudo bpftrace -e 'tracepoint:xdp:* { @cnt[probe] = count(); }'
46 Attaching 12 probes...
47 ^C
48
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
54
55 .. note::
56 The various xdp tracepoints can be found in ``source/include/trace/events/xdp.h``
57
58 The following bpftrace command can be used to extract the ``ERRNO`` being returned as
59 part of the err parameter:
60
61 .. code-block:: none
62
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();}'
66
67 perf record
68 ^^^^^^^^^^^
69 The perf tool also supports recording tracepoints:
70
71 .. code-block:: none
72
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
77
78 References
79 ===========
80
81 - https://github.com/xdp-project/xdp-tutorial/tree/master/tracing02-xdp-monitor