From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f194.google.com ([209.85.220.194]:34013 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932464AbeB1RvT (ORCPT ); Wed, 28 Feb 2018 12:51:19 -0500 Received: by mail-qk0-f194.google.com with SMTP id l206so4089696qke.1 for ; Wed, 28 Feb 2018 09:51:19 -0800 (PST) From: Stephen Suryaputra To: netdev@vger.kernel.org Cc: Stephen Suryaputra Subject: [PATCH net,v3] vrf: check forwarding on the original netdevice when generating ICMP dest unreachable Date: Wed, 28 Feb 2018 12:20:44 -0500 Message-Id: <1519838444-20309-1-git-send-email-ssuryaextr@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 v2: - Handle the original device disappearing (per David Ahern) - Minimize the change in code order 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, 10 insertions(+), 1 deletion(-) 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; -- 2.7.4