From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kirill Tkhai Subject: Re: [PATCH] net: Fix device name resolving crash in default_device_exit() Date: Mon, 18 Jun 2018 14:26:46 +0300 Message-ID: <70df65eb-3ef6-20ca-be07-8d73e4e63bea@virtuozzo.com> References: <152897987484.3952.9263337756183251797.stgit@localhost.localdomain> <3c024347-a60e-69aa-42c9-fcb6244642cb@gmail.com> <25e1a375-051c-54f4-d5cb-677e281107fb@virtuozzo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: davem@davemloft.net, daniel@iogearbox.net, jakub.kicinski@netronome.com, ast@kernel.org, linux@rasmusvillemoes.dk, john.fastabend@gmail.com, brouer@redhat.com To: David Ahern , netdev@vger.kernel.org Return-path: Received: from mail-ve1eur01on0115.outbound.protection.outlook.com ([104.47.1.115]:15648 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933510AbeFRL0x (ORCPT ); Mon, 18 Jun 2018 07:26:53 -0400 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 18.06.2018 14:21, Kirill Tkhai wrote: > On 17.06.2018 21:58, David Ahern wrote: >> On 6/15/18 3:44 AM, Kirill Tkhai wrote: >>> Hm, but is this a likely case, when real device is moved to net ns, so it >>> requires moving to init_net back? It seems the most devices moved to !init_net >>> are virtual and they just destroyed in default_device_exit_batch(). Or we have >>> more devices to care here? >>> >>> I don't much want to insert here something like below: >>> >>> if (__dev_get_by_name(&init_net, dev->name)) >>> snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); >>> err = dev_change_net_namespace(dev, &init_net, "dev%d"); >>> >>> because dev_change_net_namespace() is generic interface and it's used not only here, >>> and this will crumble the code in corner cases. >>> >>> Maybe you have better ideas about this? >> >> There are a lot of use cases these days (e.g., switch NOS) with 1000's >> (10's of 1000's) of netdevices. On top of that support for port netdevs >> in a namespace to create virtual switches needs to happen (and I suspect >> will happen in the next few years). That becomes one example where >> netdevices representing physical ports can be pushed back to init_net. > > Oh, then we really need to do something with rtnl_mutex. Otherwise > this will stop working at all. > >> That said, not many easy options at the moment for the bug you are fixing. >> >> Further, panic'ing a node because the move back to init_net fails is >> just wrong. > > So, let's fix it for now like in the patch to avoid the panic. Then we > can rework this in generic way to make the generic fallback name for moved > devices. Maybe, something like to give all moved device a fallback name > like "__moved--". Just to clarify, I mean that this small fix will be easy to backport to stable. Kirill