From patchwork Tue Oct 20 23:47:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brenden Blanco X-Patchwork-Id: 533552 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 110F8140323 for ; Wed, 21 Oct 2015 10:48:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751683AbbJTXri (ORCPT ); Tue, 20 Oct 2015 19:47:38 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:32851 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbbJTXrh (ORCPT ); Tue, 20 Oct 2015 19:47:37 -0400 Received: by pabrc13 with SMTP id rc13so35190820pab.0 for ; Tue, 20 Oct 2015 16:47:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=dBjdESIlqRWWBQKg/fXSQD+r0aGwl0y5PQoKPwiRVeY=; b=jTPaJ/kqnLnBKReX/NhypgigUqLwZ/7XoCddFbX44HN2k/LBEN3Brj0rkElSkq7Z7k 3b+xUdejv9X9SnNyxtHxUHUwP9chlLRIG3gGKrYwvNj0xyw2ZpUSR+2lOeXacdUkxtx5 Bgp8ZQupFyHzsRetqtkbaV5cWmzjiMGqZqnxedlJu+d6LQNTYKpUsbM/+lirfVhLuR02 Oo0aF7ALQiAkgngeKoTm6YwIiQ8df1wpf4vJA6yqCvimcGXVT6DtfDdpXqV40aW2kWm1 HFLe4Xy3ow/8HYVMmq2nVeKeMR4V08wNgc1kSXmYdrqxisoMBpTwUJlNzuk+u2KxUQzy WgRA== X-Gm-Message-State: ALoCoQmfcrU8VxvFWa1Bo29kk8OyJ00L0l1KIhYts2n57+6RO0QjhJ/HFwNBX1df24haq45XTzhu X-Received: by 10.68.129.231 with SMTP id nz7mr6869037pbb.53.1445384856624; Tue, 20 Oct 2015 16:47:36 -0700 (PDT) Received: from gmail.com ([12.97.19.194]) by smtp.gmail.com with ESMTPSA id bh4sm5732723pbb.62.2015.10.20.16.47.35 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Oct 2015 16:47:36 -0700 (PDT) Date: Tue, 20 Oct 2015 16:47:33 -0700 From: Brenden Blanco To: davem@davemloft.net Cc: netdev@vger.kernel.org, maheshb@google.com Subject: [PATCH net-next] ipvlan: read direct ifindex instead of iflink Message-ID: <20151020234732.GA16302@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the ipv4 outbound path of an ipvlan device in l3 mode, the ifindex is being grabbed from dev_get_iflink. This works for the physical device case, since as the documentation of that function notes: "Physical interfaces have the same 'ifindex' and 'iflink' values.". However, if the master device is a veth, and the pairs are in separate net namespaces, the route lookup will fail with -ENODEV due to outer veth pair being in a separate namespace from the ipvlan master/routing namespace. ns0 | ns1 | ns2 veth0a--|--veth0b--|--ipvl0 In ipvlan_process_v4_outbound(), a packet sent from ipvl0 in the above configuration will pass fl.flowi4_oif == veth0a to ip_route_output_flow(), but *net == ns1. Notice also that ipv6 processing is not using iflink. Since there is a discrepancy in usage, fixup both v4 and v6 case to use local dev variable. Tested this with l3 ipvlan on top of veth, as well as with single physical interface in the top namespace. Signed-off-by: Brenden Blanco Reviewed-by: Jiri Benc Acked-by: Mahesh Bandewar --- drivers/net/ipvlan/ipvlan_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c index 24f8dbc..d50887e 100644 --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c @@ -348,7 +348,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb) struct rtable *rt; int err, ret = NET_XMIT_DROP; struct flowi4 fl4 = { - .flowi4_oif = dev_get_iflink(dev), + .flowi4_oif = dev->ifindex, .flowi4_tos = RT_TOS(ip4h->tos), .flowi4_flags = FLOWI_FLAG_ANYSRC, .daddr = ip4h->daddr, @@ -386,7 +386,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb) struct dst_entry *dst; int err, ret = NET_XMIT_DROP; struct flowi6 fl6 = { - .flowi6_iif = skb->dev->ifindex, + .flowi6_iif = dev->ifindex, .daddr = ip6h->daddr, .saddr = ip6h->saddr, .flowi6_flags = FLOWI_FLAG_ANYSRC,