From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com ([209.85.192.193]:45070 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750762AbeBZQxG (ORCPT ); Mon, 26 Feb 2018 11:53:06 -0500 Received: by mail-pf0-f193.google.com with SMTP id j24so6732645pff.12 for ; Mon, 26 Feb 2018 08:53:06 -0800 (PST) Subject: Re: [PATCH] net: allow interface to be set into vrf if a vif in same vrf To: Mike Manning , netdev@vger.kernel.org References: <1519663736-28904-1-git-send-email-mmanning@vyatta.mail-att.com> From: David Ahern Message-ID: <18fbff9e-b44f-1656-e3cb-12bef4dc8733@gmail.com> Date: Mon, 26 Feb 2018 09:53:04 -0700 MIME-Version: 1.0 In-Reply-To: <1519663736-28904-1-git-send-email-mmanning@vyatta.mail-att.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 2/26/18 9:48 AM, Mike Manning wrote: > Setting an interface into a vrf fails with 'RTNETLINK answers: File > exists' if one of its vifs is already in the same vrf. As the vrf is an > upper device of the vif, it is also showing up as an upper device of > the interface itself. The solution is to restrict this check to devices > other than master. As only one master device can be linked to a device, > in this case the check is for the upper device (vrf) to be linked to as > being the master device rather than any other upper device. I'm not understanding what you mean by vif in this context. Can you elaborate and show an example set of commands? > > Signed-off-by: Mike Manning > --- > net/core/dev.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index d4362be..2cedf52 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -6396,6 +6396,7 @@ static int __netdev_upper_dev_link(struct net_device *dev, > .linking = true, > .upper_info = upper_info, > }; > + struct net_device *master_dev; > int ret = 0; > > ASSERT_RTNL(); > @@ -6407,11 +6408,14 @@ static int __netdev_upper_dev_link(struct net_device *dev, > if (netdev_has_upper_dev(upper_dev, dev)) > return -EBUSY; > > - if (netdev_has_upper_dev(dev, upper_dev)) > - return -EEXIST; > - > - if (master && netdev_master_upper_dev_get(dev)) > - return -EBUSY; > + if (!master) { > + if (netdev_has_upper_dev(dev, upper_dev)) > + return -EEXIST; > + } else { > + master_dev = netdev_master_upper_dev_get(dev); > + if (master_dev) > + return master_dev == upper_dev ? -EEXIST : -EBUSY; > + } > > ret = call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER, > &changeupper_info.info); >