netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v3 8/8] samples/bpf: Add xdp_trafficgen sample
Date: Mon, 13 Dec 2021 17:28:27 +0100	[thread overview]
Message-ID: <87r1ageafo.fsf@toke.dk> (raw)
In-Reply-To: <CAADnVQKiPgDtEUwg7WQ2YVByBUTRYuCZn-Y17td+XHazFXchaA@mail.gmail.com>

Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:

> On Sat, Dec 11, 2021 at 10:43 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>>
>> This adds an XDP-based traffic generator sample which uses the DO_REDIRECT
>> flag of bpf_prog_run(). It works by building the initial packet in
>> userspace and passing it to the kernel where an XDP program redirects the
>> packet to the target interface. The traffic generator supports two modes of
>> operation: one that just sends copies of the same packet as fast as it can
>> without touching the packet data at all, and one that rewrites the
>> destination port number of each packet, making the generated traffic span a
>> range of port numbers.
>>
>> The dynamic mode is included to demonstrate how the bpf_prog_run() facility
>> enables building a completely programmable packet generator using XDP.
>> Using the dynamic mode has about a 10% overhead compared to the static
>> mode, because the latter completely avoids touching the page data.
>>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>> ---
>>  samples/bpf/.gitignore            |   1 +
>>  samples/bpf/Makefile              |   4 +
>>  samples/bpf/xdp_redirect.bpf.c    |  34 +++
>>  samples/bpf/xdp_trafficgen_user.c | 421 ++++++++++++++++++++++++++++++
>>  4 files changed, 460 insertions(+)
>>  create mode 100644 samples/bpf/xdp_trafficgen_user.c
>
> I think it deserves to be in tools/bpf/
> samples/bpf/ bit rots too often now.
> imo everything in there either needs to be converted to selftests/bpf
> or deleted.

I think there's value in having a separate set of utilities that are
more user-facing than the selftests. But I do agree that it's annoying
they bit rot. So how about we fix that instead? Andrii suggested just
integrating the build of samples/bpf into selftests[0], so I'll look
into that after the holidays. But in the meantime I don't think there's
any harm in adding this utility here?

-Toke

[0] https://lore.kernel.org/r/CAEf4BzYv3ONhy-JnQUtknzgBSK0gpm9GBJYtbAiJQe50_eX7Uw@mail.gmail.com


  reply	other threads:[~2021-12-13 16:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-11 18:41 [PATCH bpf-next v3 0/8] Add support for transmitting packets using XDP in bpf_prog_run() Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 1/8] xdp: Allow registering memory model without rxq reference Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 2/8] page_pool: Add callback to init pages when they are allocated Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 3/8] page_pool: Store the XDP mem id Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 4/8] xdp: Move conversion to xdp_frame out of map functions Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 5/8] xdp: add xdp_do_redirect_frame() for pre-computed xdp_frames Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 6/8] bpf: Add XDP_REDIRECT support to XDP for bpf_prog_run() Toke Høiland-Jørgensen
2021-12-12  2:43   ` Alexei Starovoitov
2021-12-13 16:26     ` Toke Høiland-Jørgensen
2021-12-14  0:02       ` Alexei Starovoitov
2021-12-14  0:36         ` Toke Høiland-Jørgensen
2021-12-14  3:45           ` Alexei Starovoitov
2021-12-14 11:46             ` Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 7/8] selftests/bpf: Add selftest for XDP_REDIRECT in bpf_prog_run() Toke Høiland-Jørgensen
2021-12-11 18:41 ` [PATCH bpf-next v3 8/8] samples/bpf: Add xdp_trafficgen sample Toke Høiland-Jørgensen
2021-12-12  2:47   ` Alexei Starovoitov
2021-12-13 16:28     ` Toke Høiland-Jørgensen [this message]
2021-12-14  0:05       ` Alexei Starovoitov
2021-12-14  0:37         ` Toke Høiland-Jørgensen
2021-12-14  3:28           ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1ageafo.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).