]> git.baikalelectronics.ru Git - kernel.git/commit
net: introduce a function to check if a netdev name is in use
authorAntoine Tenart <atenart@kernel.org>
Thu, 7 Oct 2021 16:16:50 +0000 (18:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Oct 2021 16:02:34 +0000 (17:02 +0100)
commit57b8b6a93b33d98e4c00c5522cc9c6c7349e01ae
tree1094255e54478f807aa24ec44aa5d46682dce13b
parent5ce82c8e63a3c3ea79d4558ce68d2dc87d28e6fc
net: introduce a function to check if a netdev name is in use

__dev_get_by_name is currently used to either retrieve a net device
reference using its name or to check if a name is already used by a
registered net device (per ns). In the later case there is no need to
return a reference to a net device.

Introduce a new helper, netdev_name_in_use, to check if a name is
currently used by a registered net device without leaking a reference
the corresponding net device. This helper uses netdev_name_node_lookup
instead of __dev_get_by_name as we don't need the extra logic retrieving
a reference to the corresponding net device.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/dev.c