From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH] net: Fix device name resolving crash in default_device_exit() Date: Sun, 17 Jun 2018 12:58:44 -0600 Message-ID: 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: Kirill Tkhai , netdev@vger.kernel.org Return-path: Received: from mail-pg0-f68.google.com ([74.125.83.68]:36986 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753455AbeFQS6s (ORCPT ); Sun, 17 Jun 2018 14:58:48 -0400 Received: by mail-pg0-f68.google.com with SMTP id r21-v6so6521481pgv.4 for ; Sun, 17 Jun 2018 11:58:48 -0700 (PDT) In-Reply-To: <25e1a375-051c-54f4-d5cb-677e281107fb@virtuozzo.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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. 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.