From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Hutchings Subject: Re: [PATCH 3/5 (resend)] veth: Allow to create peer link with given ifindex Date: Tue, 7 Aug 2012 19:36:13 +0100 Message-ID: <1344364573.2688.13.camel@bwh-desktop.uk.solarflarecom.com> References: <501FD0F2.4040609@parallels.com> <501FD14F.2040209@parallels.com> <5020F5AB.3090101@parallels.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: David Miller , Eric Dumazet , "Eric W. Biederman" , Linux Netdev List To: Pavel Emelyanov Return-path: Received: from webmail.solarflare.com ([12.187.104.25]:12218 "EHLO ocex02.SolarFlarecom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751225Ab2HGSgR (ORCPT ); Tue, 7 Aug 2012 14:36:17 -0400 In-Reply-To: <5020F5AB.3090101@parallels.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 2012-08-07 at 15:02 +0400, Pavel Emelyanov wrote: > The ifinfomsg is in there (thanks kaber@ for foreseeing this long time ago), > so take the given ifidex and register netdev with it. > > Signed-off-by: Pavel Emelyanov > --- > drivers/net/veth.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 5852361..496c026 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -348,6 +348,9 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, > if (tbp[IFLA_ADDRESS] == NULL) > eth_hw_addr_random(peer); > > + if (ifmp) > + peer->ifindex = ifmp->ifi_index; > + > err = register_netdevice(peer); > put_net(net); > net = NULL; Is this safe, given that this code path previously ignored ifmp->ifi_index? Userland could be passing in garbage and may now fail occasionally because the value clashes with an existing interface. Ben. -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.