netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/8] Add support for transmitting packets using XDP in bpf_prog_run()
@ 2021-12-02  0:02 Toke Høiland-Jørgensen
  2021-12-02  0:02 ` [PATCH bpf-next 1/8] page_pool: Add callback to init pages when they are allocated Toke Høiland-Jørgensen
                   ` (8 more replies)
  0 siblings, 9 replies; 21+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-12-02  0:02 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Jesper Dangaard Brouer, Ilias Apalodimas,
	David S. Miller, Jakub Kicinski
  Cc: Toke Høiland-Jørgensen, netdev, bpf

This series adds support for transmitting packets using XDP in
bpf_prog_run(), by enabling the xdp_do_redirect() callback so XDP programs
can perform "real" redirects to devices or maps, using an opt-in flag when
executing the program.

The primary use case for this is testing the redirect map types and the
ndo_xdp_xmit driver operation without generating external traffic. But it
turns out to also be useful for creating a programmable traffic generator.
The last patch adds a sample traffic generator to bpf/samples, which
can transmit up to 11.5 Mpps/core on my test machine.

To transmit the frames, the new mode instantiates a page_pool structure in
bpf_prog_run() and initialises the pages with the data passed in by
userspace. These pages can then be redirected using the normal redirection
mechanism, and the existing page_pool code takes care of returning and
recycling them. The setup is optimised for high performance with a high
number of repetitions to support stress testing and the traffic generator
use case; see patch 6 for details.

The series is structured as follows: Patches 1-2 adds a few features to
page_pool that are needed for the usage in bpf_prog_run(). Similarly,
patches 3-5 performs a couple of preparatory refactorings of the XDP
redirect and memory management code. Patch 6 adds the support to
bpf_prog_run() itself, patch 7 adds a selftest, and patch 8 adds the
traffic generator example to samples/bpf.

Toke Høiland-Jørgensen (8):
  page_pool: Add callback to init pages when they are allocated
  page_pool: Store the XDP mem id
  xdp: Allow registering memory model without rxq reference
  xdp: Move conversion to xdp_frame out of map functions
  xdp: add xdp_do_redirect_frame() for pre-computed xdp_frames
  bpf: Add XDP_REDIRECT support to XDP for bpf_prog_run()
  selftests/bpf: Add selftest for XDP_REDIRECT in bpf_prog_run()
  samples/bpf: Add xdp_trafficgen sample

 include/linux/bpf.h                           |  20 +-
 include/linux/filter.h                        |   4 +
 include/net/page_pool.h                       |  11 +-
 include/net/xdp.h                             |   3 +
 include/uapi/linux/bpf.h                      |   2 +
 kernel/bpf/Kconfig                            |   1 +
 kernel/bpf/cpumap.c                           |   8 +-
 kernel/bpf/devmap.c                           |  32 +-
 net/bpf/test_run.c                            | 197 +++++++-
 net/core/filter.c                             |  41 +-
 net/core/page_pool.c                          |   6 +-
 net/core/xdp.c                                |  94 ++--
 samples/bpf/.gitignore                        |   1 +
 samples/bpf/Makefile                          |   4 +
 samples/bpf/xdp_redirect.bpf.c                |  34 ++
 samples/bpf/xdp_trafficgen_user.c             | 444 ++++++++++++++++++
 tools/include/uapi/linux/bpf.h                |   2 +
 .../bpf/prog_tests/xdp_do_redirect.c          |  74 +++
 .../bpf/progs/test_xdp_do_redirect.c          |  34 ++
 19 files changed, 920 insertions(+), 92 deletions(-)
 create mode 100644 samples/bpf/xdp_trafficgen_user.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c

-- 
2.34.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-12-09 19:49 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-02  0:02 [PATCH bpf-next 0/8] Add support for transmitting packets using XDP in bpf_prog_run() Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 1/8] page_pool: Add callback to init pages when they are allocated Toke Høiland-Jørgensen
2021-12-08 22:30   ` John Fastabend
2021-12-09 16:01     ` Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 2/8] page_pool: Store the XDP mem id Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 3/8] xdp: Allow registering memory model without rxq reference Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 4/8] xdp: Move conversion to xdp_frame out of map functions Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 5/8] xdp: add xdp_do_redirect_frame() for pre-computed xdp_frames Toke Høiland-Jørgensen
2021-12-09  0:31   ` John Fastabend
2021-12-09 16:05     ` Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 6/8] bpf: Add XDP_REDIRECT support to XDP for bpf_prog_run() Toke Høiland-Jørgensen
2021-12-09  0:53   ` John Fastabend
2021-12-09 16:10     ` Toke Høiland-Jørgensen
2021-12-09 16:51       ` Toke Høiland-Jørgensen
2021-12-09 18:56         ` John Fastabend
2021-12-09 19:49           ` Toke Høiland-Jørgensen
2021-12-09 18:53       ` John Fastabend
2021-12-02  0:02 ` [PATCH bpf-next 7/8] selftests/bpf: Add selftest for XDP_REDIRECT in bpf_prog_run() Toke Høiland-Jørgensen
2021-12-02  0:02 ` [PATCH bpf-next 8/8] samples/bpf: Add xdp_trafficgen sample Toke Høiland-Jørgensen
2021-12-09  0:54 ` [PATCH bpf-next 0/8] Add support for transmitting packets using XDP in bpf_prog_run() John Fastabend
2021-12-09 16:01   ` Toke Høiland-Jørgensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).