public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Stephen Suryaputra <ssuryaextr@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net,v2] vrf: check forwarding on the original netdevice when generating ICMP dest unreachable
Date: Wed, 28 Feb 2018 10:39:48 -0700	[thread overview]
Message-ID: <4405cafd-8736-ccc3-ac00-5c804c9756a4@gmail.com> (raw)
In-Reply-To: <CAHapkUisJkj9NNXyBsxn1uom-DekBZpKhq6k-=A=np3Fiv0dwg@mail.gmail.com>

On 2/28/18 9:55 AM, Stephen Suryaputra wrote:
> The concern only applies when the skb->dev is an l3mdev master, right?
> After I sent v2, I'm worried that rt shouldn't be derefrenced if
> in_dev is NULL. Even though I think it should be ok, it's better to
> keep the original execution order. So, how about this before I put
> another patch? The net for the iif is derived from skb->dev.
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index a4f44d8..9a29225 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -930,14 +930,23 @@ void ip_rt_send_redirect(struct sk_buff *skb)
> 
>  static int ip_error(struct sk_buff *skb)
>  {
> -       struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
>         struct rtable *rt = skb_rtable(skb);
> +       struct net_device *dev = skb->dev;
> +       struct in_device *in_dev;
>         struct inet_peer *peer;
>         unsigned long now;
>         struct net *net;
>         bool send;
>         int code;
> 
> +       if (netif_is_l3_master(skb->dev)) {
> +               dev = __dev_get_by_index(dev_net(skb->dev), IPCB(skb)->iif);
> +               if (!dev)
> +                       goto out;
> +       }
> +
> +       in_dev = __in_dev_get_rcu(dev);
> +
>         /* IP on this device is disabled. */
>         if (!in_dev)
>                 goto out;
> 

Using dev_net from skb is fine, preferable really since the real ingress
device and the VRF device have to be in the same network namespace.

      reply	other threads:[~2018-02-28 17:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 14:46 [PATCH net,v2] vrf: check forwarding on the original netdevice when generating ICMP dest unreachable Stephen Suryaputra
2018-02-28 15:49 ` David Ahern
2018-02-28 16:55   ` Stephen Suryaputra
2018-02-28 17:39     ` David Ahern [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=4405cafd-8736-ccc3-ac00-5c804c9756a4@gmail.com \
    --to=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=ssuryaextr@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox