BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@meta.com>
To: mtahhan@redhat.com, bpf@vger.kernel.org, linux-doc@vger.kernel.org
Cc: jbrouer@redhat.com, thoiland@redhat.com, donhunte@redhat.com
Subject: Re: [PATCH bpf-next v6 1/1] doc: DEVMAPs and XDP_REDIRECT
Date: Tue, 8 Nov 2022 22:37:00 -0800	[thread overview]
Message-ID: <f3ca47ae-381a-649a-6577-9585ddee4977@meta.com> (raw)
In-Reply-To: <20221108174833.1106947-2-mtahhan@redhat.com>



On 11/8/22 9:48 AM, mtahhan@redhat.com wrote:
> From: Maryam Tahhan <mtahhan@redhat.com>
> 
> Add documentation for BPF_MAP_TYPE_DEVMAP and
> BPF_MAP_TYPE_DEVMAP_HASH including kernel version
> introduced, usage and examples.
> 
> Add documentation that describes XDP_REDIRECT.
> 
> Signed-off-by: Maryam Tahhan <mtahhan@redhat.com>

LGTM with a couple of nits below.

Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   Documentation/bpf/index.rst      |   1 +
>   Documentation/bpf/map_devmap.rst | 221 +++++++++++++++++++++++++++++++
>   Documentation/bpf/redirect.rst   |  81 +++++++++++
>   net/core/filter.c                |   8 +-
>   4 files changed, 309 insertions(+), 2 deletions(-)
>   create mode 100644 Documentation/bpf/map_devmap.rst
>   create mode 100644 Documentation/bpf/redirect.rst
> 
> diff --git a/Documentation/bpf/index.rst b/Documentation/bpf/index.rst
> index 1b50de1983ee..1088d44634d6 100644
> --- a/Documentation/bpf/index.rst
> +++ b/Documentation/bpf/index.rst
> @@ -29,6 +29,7 @@ that goes into great technical depth about the BPF Architecture.
>      clang-notes
>      linux-notes
>      other
> +   redirect
>   
>   .. only::  subproject and html
>   
[...]
> +
> +User space
> +----------
> +
> +The following code snippet shows how to update a devmap called ``tx_port``.
> +
> +.. code-block:: c
> +
> +    int update_devmap(int ifindex, int redirect_ifindex)
> +    {
> +        int ret = -1;

There is no need to initialize the value to -1, the below is 'ret = ...'.

> +
> +        ret = bpf_map_update_elem(bpf_map__fd(tx_port), &ifindex, &redirect_ifindex, 0);
> +        if (ret < 0) {
> +            fprintf(stderr, "Failed to update devmap_ value: %s\n",
> +                strerror(errno));
> +        }
> +
> +        return ret;
> +    }
> +
> +The following code snippet shows how to update a hash_devmap called ``forward_map``.
> +
> +.. code-block:: c
> +
> +    int update_devmap(int ifindex, int redirect_ifindex)
> +    {
> +        struct bpf_devmap_val devmap_val = { .ifindex = redirect_ifindex };
> +        int ret = -1;

same here, no need to have '-1'.

> +
> +        ret = bpf_map_update_elem(bpf_map__fd(forward_map), &ifindex, &devmap_val, 0);
> +        if (ret < 0) {
> +            fprintf(stderr, "Failed to update devmap_ value: %s\n",
> +                strerror(errno));
> +        }
> +        return ret;
> +    }
> +
[...]

      reply	other threads:[~2022-11-09  6:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 17:48 [PATCH bpf-next v6 0/1] doc: DEVMAPs and XDP_REDIRECT mtahhan
2022-11-08 17:48 ` [PATCH bpf-next v6 1/1] " mtahhan
2022-11-09  6:37   ` Yonghong Song [this message]

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=f3ca47ae-381a-649a-6577-9585ddee4977@meta.com \
    --to=yhs@meta.com \
    --cc=bpf@vger.kernel.org \
    --cc=donhunte@redhat.com \
    --cc=jbrouer@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=mtahhan@redhat.com \
    --cc=thoiland@redhat.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