redirect.rst 2.0 KB

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