From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f68.google.com ([209.85.160.68]:39975 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932696AbeB1Pt1 (ORCPT ); Wed, 28 Feb 2018 10:49:27 -0500 Received: by mail-pl0-f68.google.com with SMTP id i6-v6so1731812plt.7 for ; Wed, 28 Feb 2018 07:49:27 -0800 (PST) Subject: Re: [PATCH net,v2] vrf: check forwarding on the original netdevice when generating ICMP dest unreachable To: Stephen Suryaputra , netdev@vger.kernel.org References: <1519829219-29623-1-git-send-email-ssuryaextr@gmail.com> From: David Ahern Message-ID: Date: Wed, 28 Feb 2018 08:49:25 -0700 MIME-Version: 1.0 In-Reply-To: <1519829219-29623-1-git-send-email-ssuryaextr@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 2/28/18 7:46 AM, Stephen Suryaputra wrote: > When ip_error() is called the device is the l3mdev master instead of the > original device. So the forwarding check should be on the original one. > > Changes from v1: > - Only need to reset the device on which __in_dev_get_rcu() is done (per > David Ahern). > > Signed-off-by: Stephen Suryaputra > --- > net/ipv4/route.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/net/ipv4/route.c b/net/ipv4/route.c > index a4f44d8..89c020f 100644 > --- a/net/ipv4/route.c > +++ b/net/ipv4/route.c > @@ -930,19 +930,26 @@ 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; > > + net = dev_net(rt->dst.dev); > + > + if (netif_is_l3_master(skb->dev)) > + dev = __dev_get_by_index(net, IPCB(skb)->iif); Do need to handle the device disappearing. if (!dev) goto out; > + > + in_dev = __in_dev_get_rcu(dev); > + > /* IP on this device is disabled. */ > if (!in_dev) > goto out; > > - net = dev_net(rt->dst.dev); > if (!IN_DEV_FORWARD(in_dev)) { > switch (rt->dst.error) { > case EHOSTUNREACH: >