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: Fri, 22 Jun 2018 11:36:38 +0300 Message-ID: <1240b7e7-9141-e88e-19bb-538d29b5014b@virtuozzo.com> References: <152897987484.3952.9263337756183251797.stgit@localhost.localdomain> <3c024347-a60e-69aa-42c9-fcb6244642cb@gmail.com> <25e1a375-051c-54f4-d5cb-677e281107fb@virtuozzo.com> <70df65eb-3ef6-20ca-be07-8d73e4e63bea@virtuozzo.com> <88c1a635-4404-253b-6144-d7f3f9779531@virtuozzo.com> <6d4ded39-d85d-7497-f0fb-af3df160b18b@gmail.com> <84f7019b-c1cb-9851-2ece-aa2e16d8d297@virtuozzo.com> <5e4b9ecd-e7f5-87e4-2b45-2aaaca125442@gmail.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-eopbgr70117.outbound.protection.outlook.com ([40.107.7.117]:61266 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751191AbeFVIgr (ORCPT ); Fri, 22 Jun 2018 04:36:47 -0400 In-Reply-To: <5e4b9ecd-e7f5-87e4-2b45-2aaaca125442@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 21.06.2018 18:28, David Ahern wrote: > On 6/21/18 4:03 AM, Kirill Tkhai wrote: >>> This patch does not remove the BUG, so does not really solve the >>> problem. ie., it is fairly trivial to write a script (32k dev%d named >>> devices in init_net) that triggers it again, so your commit subject and >>> commit log are not correct with the references to 'fixing the problem'. >> >> 1)I'm not agree with you and I don't think removing the BUG() is a good idea. >> This function is called from the place, where it must not fail. But it can >> fail, and the problem with name is not the only reason of this happens. >> We can't continue further pernet_operations in case of a problem happened >> in default_device_exit(), and we can't remove the BUG() before this function >> becomes of void type. But we are not going to make it of void type. So >> we can't remove the BUG(). > > You missed my point: that the function can still fail means you are not > "fixing" the problem, only delaying it. Till the function is of int type and it can fail, we can't remove the BUG(). And this does not connected with name resolution. >> >> 2)In case of the script is trivial, can't you just post it here to show >> what type of devices you mean? Is there real problem or this is >> a theoretical thinking? > > Current code: > > # ip li sh dev eth2 > 4: eth2: mtu 1500 qdisc mq state UP > mode DEFAULT group default qlen 1000 > link/ether 02:e0:f9:46:64:80 brd ff:ff:ff:ff:ff:ff > # ip netns add fubar > # ip li set eth2 netns fubar > # ip li add eth2 type dummy > # ip li add dev4 type dummy > # ip netns del fubar > --> BUG > kernel:[78079.127748] default_device_exit: failed to move eth2 to > init_net: -17 > > > With your patch: > > # ip li sh dev eth2 > 4: eth2: mtu 1500 qdisc mq state UP > mode DEFAULT group default qlen 1000 > link/ether 02:e0:f9:46:64:80 brd ff:ff:ff:ff:ff:ff > # ip netns add fubar > # ip li set eth2 netns fubar > # ip li add eth2 type dummy > # for n in $(seq 0 $((32*1024))); do > echo "li add dev${n} type dummy" > done > ip.batch > # ip -batch ip.batch > # ip netns del fubar > --> BUG > kernel:[ 25.800024] default_device_exit: failed to move eth2 to > init_net: -17 Yeah, this has a sense. >> >> All virtual devices I see have rtnl_link_ops, so that they just destroyed >> in default_device_exit_batch(). According to physical devices, it's difficult >> to imagine a node with 32k physical devices, and if someone tried to deploy >> them it may meet problems not only in this place. > > Nothing says it has to be a physical device. It is only checking for a name. > >> >>> The change does provide more variability in naming and reduces the >>> likelihood of not being able to push a device back to init_net. >> >> No, it provides. With the patch one may move real device to a container, >> and allow to do with the device anything including changing of device >> index. Then, the destruction of the container does not resilt a kernel >> panic just because of two devices have the same index.