From patchwork Wed Apr 24 18:54:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Suryaputra X-Patchwork-Id: 1090446 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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="nbmMdiLN"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44qB6p0CTyz9s4Y for ; Thu, 25 Apr 2019 06:02:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729696AbfDXUCI (ORCPT ); Wed, 24 Apr 2019 16:02:08 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:34141 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727528AbfDXUCI (ORCPT ); Wed, 24 Apr 2019 16:02:08 -0400 Received: by mail-it1-f196.google.com with SMTP id z17so265185itc.1 for ; Wed, 24 Apr 2019 13:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VjjKBzsyB6OTbXPIqPIVtJXFr6MgF5/D/TkEo1cgx7E=; b=nbmMdiLNVdBPYNtQWEEz9IwsfxWlpvzeknQU3mhyKJSW4IoTlI3C39pGF1UJANNxrJ LMsE499TJu2vdWfqCh80eU/wrP9W+KGC4LKQE6a6sU5dWviA4UJ+sfgNXGA1cb/ITg8Q J4tAVcjQ8T8l9f+rAWI/3MPJVuhCw4m7SnFbkI1nauDrARbyOa4+57+ERGOhvw5+rCx1 uZ5dlw/04nqBdVuUwveyOIyKIYMv0FwuPvBUCgt/k/6HHUUzQFMIfN6xnejiKSw8XkhB sU9BkdjZnrj//JYMQGfVhpP47xuz1yi3Bbw4Jly2+C5SN05pEhhKLclLS+kzPm56T63n sGaw== 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=VjjKBzsyB6OTbXPIqPIVtJXFr6MgF5/D/TkEo1cgx7E=; b=SbdqqTVeUoAAjMe4X6QBFpGbp9uPcqV55zhRIsuJ3iVXO5Zys364yq3yC+TKKDNVnU S1KJ8tnafaDKo2BV679SK2UKuRT8JWBh4iyb8NKk8BmtO2KcC949A7Q52vRihKe5DnlY IoxgCIJCAo9Iaz3SIYjuOaeOLPOvHBEyN3yD4KoXTGpnUH2WJ5X4uEInqluszXWfLFt9 fyMibAgFnJa92RwXWJzIRKrajGRDcPQuXczAO8e4C2iCuY1EOsfrfcIQiQ/cLugiXha8 hxT3fM9QU4SNvMhYJask3ZJSrAnhFDWroARdYrZSBUVNwqgcJp4p6i8QF41JYlrjWvEb 8RWA== X-Gm-Message-State: APjAAAVnhXuAhp6TgDnDV5flzlvQrtKvi/MRokt7uVv2Uc0TXgPZRl5D y99bKpIlg9LXdwDNdvjGmDLPvxg= X-Google-Smtp-Source: APXvYqydcSYPx86uDWFQvS8EWEbzjADQiif+sVwG2t1QwFua/nid3Ya0vK9cEOBK8DGXm0Zw2WbIWw== X-Received: by 2002:a24:5f8c:: with SMTP id r134mr737956itb.110.1556136127134; Wed, 24 Apr 2019 13:02:07 -0700 (PDT) Received: from ubuntu.extremenetworks.com ([12.38.14.8]) by smtp.gmail.com with ESMTPSA id p5sm3896548iom.51.2019.04.24.13.02.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 13:02:06 -0700 (PDT) From: Stephen Suryaputra To: netdev@vger.kernel.org Cc: dsahern@gmail.com, Stephen Suryaputra Subject: [PATCH net, v2] vrf: Use orig netdev to count Ip6InNoRoutes and a fresh route lookup when sending dest unreach Date: Wed, 24 Apr 2019 14:54:44 -0400 Message-Id: <20190424185444.20978-1-ssuryaextr@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When there is no route to an IPv6 dest addr, skb_dst(skb) points to loopback dev in the case of that the IP6CB(skb)->iif is enslaved to a vrf. This causes Ip6InNoRoutes to be incremented on the loopback dev. This also causes the lookup to fail on icmpv6_send() and the dest unreachable to not sent and Ip6OutNoRoutes gets incremented on the loopback dev. To reproduce: * Gateway configuration: ip link add dev vrf_258 type vrf table 258 ip link set dev enp0s9 master vrf_258 ip addr add 66:1/64 dev enp0s9 ip -6 route add unreachable default metric 8192 table 258 sysctl -w net.ipv6.conf.all.forwarding=1 sysctl -w net.ipv6.conf.enp0s9.forwarding=1 * Sender configuration: ip addr add 66::2/64 dev enp0s9 ip -6 route add default via 66::1 and ping 67::1 for example from the sender. Fix this by counting on the original netdev and reset the skb dst to force a fresh lookup. v2: Fix typo of destination address in the repro steps. Signed-off-by: Stephen Suryaputra Reviewed-by: David Ahern Tested-by: David Ahern --- net/ipv6/route.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index e8c73b7782cd..3b026a310b3e 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3772,23 +3772,33 @@ int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg) static int ip6_pkt_drop(struct sk_buff *skb, u8 code, int ipstats_mib_noroutes) { - int type; struct dst_entry *dst = skb_dst(skb); + struct inet6_dev *idev = ip6_dst_idev(dst); + struct net *net = dev_net(dst->dev); + int type; + + if (netif_is_l3_master(skb->dev) && + idev == __in6_dev_get(net->loopback_dev)) { + idev = __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif)); + } + switch (ipstats_mib_noroutes) { case IPSTATS_MIB_INNOROUTES: type = ipv6_addr_type(&ipv6_hdr(skb)->daddr); if (type == IPV6_ADDR_ANY) { - IP6_INC_STATS(dev_net(dst->dev), - __in6_dev_get_safely(skb->dev), - IPSTATS_MIB_INADDRERRORS); + IP6_INC_STATS(net, idev, IPSTATS_MIB_INADDRERRORS); break; } /* FALLTHROUGH */ case IPSTATS_MIB_OUTNOROUTES: - IP6_INC_STATS(dev_net(dst->dev), ip6_dst_idev(dst), - ipstats_mib_noroutes); + IP6_INC_STATS(net, idev, ipstats_mib_noroutes); break; } + + /* Start over by dropping the dst for l3mdev case */ + if (netif_is_l3_master(skb->dev)) + skb_dst_drop(skb); + icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0); kfree_skb(skb); return 0;