All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: William Tu <u9012063@gmail.com>
Cc: netdev@vger.kernel.org, john.fastabend@gmail.com
Subject: Re: [PATCH net-next] bpf: fix the printing of ifindex
Date: Wed, 02 Aug 2017 17:53:45 +0200	[thread overview]
Message-ID: <5981F589.80000@iogearbox.net> (raw)
In-Reply-To: <1501688632-2709-1-git-send-email-u9012063@gmail.com>

On 08/02/2017 05:43 PM, William Tu wrote:
> Save the ifindex before it gets zeroed so the invalid
> ifindex can be printed out.
>
> Signed-off-by: William Tu <u9012063@gmail.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

>   net/core/filter.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 7e9708653c6f..78d00933dbe7 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2509,15 +2509,16 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,
>   {
>   	struct redirect_info *ri = this_cpu_ptr(&redirect_info);
>   	struct net_device *fwd;
> +	u32 index = ri->ifindex;
>
>   	if (ri->map)
>   		return xdp_do_redirect_map(dev, xdp, xdp_prog);
>
> -	fwd = dev_get_by_index_rcu(dev_net(dev), ri->ifindex);
> +	fwd = dev_get_by_index_rcu(dev_net(dev), index);
>   	ri->ifindex = 0;
>   	ri->map = NULL;

Unrelated, but setting ri->map to NULL is not really needed here
given we have the ri->map test earlier.

>   	if (unlikely(!fwd)) {
> -		bpf_warn_invalid_xdp_redirect(ri->ifindex);
> +		bpf_warn_invalid_xdp_redirect(index);
>   		return -EINVAL;
>   	}
>
> @@ -2531,11 +2532,12 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb)
>   {
>   	struct redirect_info *ri = this_cpu_ptr(&redirect_info);
>   	unsigned int len;
> +	u32 index = ri->ifindex;
>
> -	dev = dev_get_by_index_rcu(dev_net(dev), ri->ifindex);
> +	dev = dev_get_by_index_rcu(dev_net(dev), index);
>   	ri->ifindex = 0;
>   	if (unlikely(!dev)) {
> -		bpf_warn_invalid_xdp_redirect(ri->ifindex);
> +		bpf_warn_invalid_xdp_redirect(index);
>   		goto err;
>   	}
>
>

  reply	other threads:[~2017-08-02 15:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 15:43 [PATCH net-next] bpf: fix the printing of ifindex William Tu
2017-08-02 15:53 ` Daniel Borkmann [this message]
2017-08-02 16:06 ` John Fastabend
2017-08-03 16:25 ` David Miller

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=5981F589.80000@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=u9012063@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.