Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5A15C43218 for ; Fri, 26 Apr 2019 16:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8365E208CB for ; Fri, 26 Apr 2019 16:03:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nIUNcqAV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbfDZQDb (ORCPT ); Fri, 26 Apr 2019 12:03:31 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44573 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbfDZQDb (ORCPT ); Fri, 26 Apr 2019 12:03:31 -0400 Received: by mail-pf1-f193.google.com with SMTP id y13so1926865pfm.11 for ; Fri, 26 Apr 2019 09:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fkshiUgldYjfPwl0xwMfQV3yGWNqjGyklYd0LYryj90=; b=nIUNcqAVbSwIpdvspGobqvMr+LwiCCvtMiJ0NHEqIw6G4bxIi9xPxT/9TGU1e9wy61 i9e136rIzLj2F2lv1UtEh9jKDbToCrsk/83tAJXFBV2p9bNUVAc2K8/6WUkWa3t1cmLo zb8RmfdL0fOwYbwzNCmxpVKmxAj7m5ppi99YoT/QDi/ELjOGzJvJ5StE3qoPaPPXwK9Y XTpdaxDPiw4OKtcHncBJAg/Vk8/BboHyq6fre2C4RUMVFOu0kPVVEwQLcI0AuHTO+ZFt vcXSF1f/kMD1ZyS2pKoxPwzrONTHUAXDeB4akrxj++lfg0SgYe3qGwhsFTSX9u/H5CnC Cayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fkshiUgldYjfPwl0xwMfQV3yGWNqjGyklYd0LYryj90=; b=DGaU+Z0RA2dPyUqBUDQd5lDrj7OyQJSz00yQzDMVLW7ogTFvs5fXhBO3KSw4DPB1wG SR/rLsSNWT0l0lCN2jvxHxHDqwZws0yjgPGbxzv8RekqpZ8jaS4q9lUdmllIKTtdFmY+ quVI71FwkmqBSIFN97MtkqRex3VYzwt4eUdwXvBgQB4fUfxCPKWMDw5VaiIlSg7UKGzP K73e2YguNrwYyYawkchki6xUxE5Td05HVOp+vUBS2RR7lVd9oq/6N3QOkwosK70YriwP R6x+xSFtusi2U1Ivb47Ld1GSleIesDsuv1x14deDHROPTH9pCi8MZPjDa32w0+IP6d6U zmlw== X-Gm-Message-State: APjAAAW8W3UugHpnpAagUyQA5ZclcVqwXx7esN4uu8J98D6EAar6b2+Z 7qk3A/y8XvXVZYb+YRVE55PkhzwM X-Google-Smtp-Source: APXvYqzwLFCnlj3fYoeyAPj1BrW5bIMqFU9+UzsW31ZpLE/XoHgdEiTqgStKnz7diYSUjt7ZcBK/ug== X-Received: by 2002:a63:cc0b:: with SMTP id x11mr43375594pgf.35.1556294609976; Fri, 26 Apr 2019 09:03:29 -0700 (PDT) Received: from ?IPv6:2601:282:800:fd80:c824:60cf:2bea:8fbc? ([2601:282:800:fd80:c824:60cf:2bea:8fbc]) by smtp.googlemail.com with ESMTPSA id v1sm49246627pff.81.2019.04.26.09.03.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 09:03:29 -0700 (PDT) Subject: Re: [PATCH net,v2] vrf: Use orig netdev to count Ip6InNoRoutes and a fresh route lookup when sending dest unreach To: Stephen Suryaputra , netdev@vger.kernel.org References: <20190424185444.20978-1-ssuryaextr@gmail.com> From: David Ahern Message-ID: <6061f502-48dd-0804-74e3-e30ddde349a3@gmail.com> Date: Fri, 26 Apr 2019 10:03:27 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190424185444.20978-1-ssuryaextr@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 4/24/19 12:54 PM, Stephen Suryaputra wrote: > 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. The root cause is the 'special' dst entries ipv6 has. I want to convert those to generated ones like IPv4 has in which case the vrf device is used over the loopback. The changes for nexthops move the code in the right direction for this to happen. But that is a future change. > > 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. here's another self contained test case: ip netns add foo ip -netns foo li set lo up ip -netns foo link add dev red up type vrf table 258 ip -6 -netns foo ro add vrf red unreachable default ip link add veth1 type veth peer name veth2 ip link set veth2 netns foo ip -netns foo li set veth2 vrf red up ip li set veth1 up ip -6 addr add 2001:d8:66::1/64 dev veth1 ip -6 -netns foo addr add 2001:d8:66::2/64 dev veth2 ip -6 ro add 2001:db8:67::64/128 via 2001:d8:66::2 ip netns exec foo sysctl -w net.ipv6.conf.veth2.forwarding=1 ping6 -c1 -w1 -I veth1 2001:db8:67::64 # fails Destination unreachable: No route ip -netns foo -6 ru add pref 66 to 2001:db8:67::64 prohibit ping6 -c1 -w1 -I veth1 2001:db8:67::64 # Destination unreachable: Administratively prohibited I am adding the above to my vrf tests. > > 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 > --- > 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)) { dst->dev == net->loopback_dev should work as well. > + idev = __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif)); theoretically this function is called for the output path (dst->output) as well in which case iif is not set. But, I was not able to create a test case that hit this function for it; local traffic is failing much sooner (connect, sendmsg). Reviewed-by: David Ahern Tested-by: David Ahern