From: Maryam Tahhan <mtahhan@redhat.com>
To: Jesper Dangaard Brouer <jbrouer@redhat.com>,
bpf@vger.kernel.org, linux-doc@vger.kernel.org
Cc: brouer@redhat.com
Subject: Re: [PATCH bpf-next v3 1/1] doc: DEVMAPs and XDP_REDIRECT
Date: Tue, 25 Oct 2022 09:32:02 +0100 [thread overview]
Message-ID: <da45c2cb-72a0-066c-019e-c6f3f01c2093@redhat.com> (raw)
In-Reply-To: <afc6d835-3988-0b4a-afd6-496f392324dd@redhat.com>
On 24/10/2022 13:12, Jesper Dangaard Brouer wrote:
>
> First of all, I'm super happy that we are getting documentation added
> for this.
>
> Comments inlined below.
>
> On 17/10/2022 11.47, mtahhan@redhat.com wrote:
>> diff --git a/Documentation/bpf/redirect.rst
>> b/Documentation/bpf/redirect.rst
>> new file mode 100644
>> index 000000000000..5a0377a67ff0
>> --- /dev/null
>> +++ b/Documentation/bpf/redirect.rst
>
> Naming the file 'redirect.rst' is that in anticipating that TC-BPF also
> support invoking the bpf_redirect helper?
>
> IMHO we should remember to *also* promote TC-BPF redirect, and it would
> likely be good to have this in same file with XDP-redirect so end-users
> see this.
>
So I will leave the name as is...
>
>> @@ -0,0 +1,46 @@
>> +.. SPDX-License-Identifier: GPL-2.0-only
>> +.. Copyright (C) 2022 Red Hat, Inc.
>> +
>> +============
>> +XDP_REDIRECT
>> +============
>> +
>> +XDP_REDIRECT works by a three-step process, implemented as follows:
>> +
>> +1. The ``bpf_redirect()`` and ``bpf_redirect_map()`` helpers will
>> lookup the
>> + target of the redirect and store it (along with some other
>> metadata) in a
>> + per-CPU ``struct bpf_redirect_info``. This is where the maps above
>> come into
>> + play.
>> +
>> +2. When the program returns the ``XDP_REDIRECT`` return code, the
>> driver will
>> + call ``xdp_do_redirect()`` which will use the information in ``struct
>> + bpf_redirect_info`` to actually enqueue the frame into a map
>> type-specific
>> + bulk queue structure.
>> +
>> +3. Before exiting its NAPI poll loop, the driver will call
>> ``xdp_do_flush()``,
>> + which will flush all the different bulk queues, thus completing the
>> + redirect.
>
> Is this text more or less copied from net/core/filter.c ?
>
> I will suggest directly including this from the code via the DOC text
> trick. (note I've added these DOC tags in other XDP + page_pool code,
> but not fully utilized these yet).
>
Ok, I will update this. I had the v5 sent in before I saw your email.
>
>> +Pointers to the map entries will be kept around for this whole
>> sequence of
>> +steps, protected by RCU. However, there is no top-level
>> ``rcu_read_lock()`` in
>> +the core code; instead, the RCU protection relies on everything
>> happening
>> +inside a single NAPI poll sequence.
>> +
>> +.. note::
>> + Not all drivers support transmitting frames after a redirect, and
>> for
>> + those that do, not all of them support non-linear frames.
>> Non-linear xdp
>> + bufs/frames are bufs/frames that contain more than one fragment.
>> +
>
> I would like for us to extend this redirect.rst document with
> information on how to troubleshoot when XDP-redirect "silently" drops
> packets.
>
> Above note it one issue (but not visible to readers).
> Plus we should describe how to catch these silent drops, via tracepoints
> and even point to xdpdump tool.
>
> I recently helped someone on Slack debug a XDP redirect issue.
> During this session I wrote some bpftrace oneliners, that I added to
> XDP-tutorial sub-README[1]
>
> [1]
> https://github.com/xdp-project/xdp-tutorial/blob/master/tracing02-xdp-monitor/README.org
>
Ok, I will see what I can do.
>
>> +XDP_REDIRECT works with the following map types:
>> +
>> +- BPF_MAP_TYPE_DEVMAP
>> +- BPF_MAP_TYPE_DEVMAP_HASH
>> +- BPF_MAP_TYPE_CPUMAP
>> +- BPF_MAP_TYPE_XSKMAP
>> +
>> +For more information on these maps, please see the specific map
>> documentation.
>> +
>> +References
>> +===========
>> +
>> +-https://elixir.bootlin.com/linux/latest/source/net/core/filter.c#L4106
>
> I don't think this reference with a line-number will be stable.
Yep, will move to the doc reference as you suggested earlier.
>
> --Jesper
>
next prev parent reply other threads:[~2022-10-25 8:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 9:47 [PATCH bpf-next v3 0/1] doc: DEVMAPs and XDP_REDIRECT mtahhan
2022-10-17 9:47 ` [PATCH bpf-next v3 1/1] " mtahhan
2022-10-21 13:39 ` Donald Hunter
2022-10-24 12:12 ` Jesper Dangaard Brouer
2022-10-25 8:32 ` Maryam Tahhan [this message]
2022-10-25 15:17 ` Alexei Starovoitov
-- strict thread matches above, loose matches on Subject: below --
2022-10-21 12:15 [PATCH bpf-next v3 0/1] " mtahhan
2022-10-21 12:15 ` [PATCH bpf-next v3 1/1] " mtahhan
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=da45c2cb-72a0-066c-019e-c6f3f01c2093@redhat.com \
--to=mtahhan@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=jbrouer@redhat.com \
--cc=linux-doc@vger.kernel.org \
/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