From patchwork Wed Feb 28 17:20:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Suryaputra X-Patchwork-Id: 879244 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BWSUVGYL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zs35n0Dnvz9rxq for ; Thu, 1 Mar 2018 04:51:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934370AbeB1RvW (ORCPT ); Wed, 28 Feb 2018 12:51:22 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=I2NYign9geWnOhWm5TGBQVazPaDTgTz0c+vWpO+ZHas=; b=BWSUVGYLxj4hfcbIGFIiGDMY3+qAln3EvAZTf4KZzs7nnbX47qg6GhabJLLDX2EsYW gtVI5by+K+gy7HFIwayOsc6sdEUgIWyoFooVTGsEPZK+FdfTwtn03wbC5YSDUUXhKaRS 214OOzO3AZxI75BlD0GCNQ8M5OlFS3/VhHABafI36LWAre9enlmeq/KdYA8uttROvxYS XJj1hOUOW4m+dc1PVdSqLFBkLvuBDyWywF7h03NvSGT5XOidQWO8G9s1Hf1dL7qEnH6/ M2dDh4FF+PKZxhT4Xb7grQqf9LsykpGEQ3472p9fbG2M5RZq034I0lmugeQ4rWRXd+fD a9iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=I2NYign9geWnOhWm5TGBQVazPaDTgTz0c+vWpO+ZHas=; b=dKLFNHArEFDCpZQL6XlSt1s7dXa2tEs4BqmBS1f8pKVSJK0jRZAwM/E4s3Z9+TSQEa 3II8WvyEIbl87xMRfIsOBuFuYUQ2CE/FZFxHFxzB8S/Ei068RBMGzMXxWSBd5gWNveDn CrAQn29NxVp6nsjXlw2Y1+AUK52s4ZFqfO8UETXqzrmASqPAOVVXRBid9lIM7kOpzq9q zJsmxMAwVXECN312J+AIs3iwWr19c/4v7e6bmpnLfhCvuVUjfgDjXebFEHCzI/zJaJTT SH2ZWQruRTNp5lH9qJLAgRYGL+FEIDUv3PkrIkHYLTfslJqPwNh5gPk4Q3xqk3BYlM+B S8og== X-Gm-Message-State: APf1xPApjEUsgxLs+bzfAL8xRHwNOLnjVIkusseGM2xUkiD2zc5pYokz F+yWY5q9X1M38vGp60u7k06dK5A= X-Google-Smtp-Source: AG47ELtbsdiWkVMfwRL+13fe9xA2YAww77bEFNXiUoFwvg+w5R3ZlejzMkXJv9q2a+IebET1x4do5g== X-Received: by 10.55.166.210 with SMTP id p201mr29694737qke.128.1519840277639; Wed, 28 Feb 2018 09:51:17 -0800 (PST) Received: from ubuntu.extremenetworks.com ([12.38.14.8]) by smtp.gmail.com with ESMTPSA id d184sm1478836qka.68.2018.02.28.09.51.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 09:51:16 -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> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: David Ahern --- 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;