]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
net: Convert loopback_net_ops
authorKirill Tkhai <ktkhai@virtuozzo.com>
Tue, 13 Feb 2018 09:30:35 +0000 (12:30 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Feb 2018 15:36:09 +0000 (10:36 -0500)
commit9a4d105de78488526d8b0d6cdc5f2c22f122ca4a
tree444722f8dbb6e9ad807dfa3284323f4ed106a073
parent0bc9be67185ec90feedc971af6e7b84ab932703a
net: Convert loopback_net_ops

These pernet_operations have only init() method. It allocates
memory for net_device, calls register_netdev() and assigns
net::loopback_dev.

register_netdev() is allowed be used without additional locks,
as it's synchronized on rtnl_lock(). There are many examples
of using this functon directly from ioctl().

The only difference, compared to ioctl(), is that net is not
completely alive at this moment. But it looks like, there is
no way for parallel pernet_operations to dereference
the net_device, as the most of struct net_device lists,
where it's linked, are related to net, and the net is not liked.

The exceptions are net_device::unreg_list, close_list, todo_list,
used for unregistration, and ::link_watch_list, where net_device
may be linked to global lists.

Unregistration of loopback_dev obviously can't happen, when
loopback_net_init() is executing, as the net as alive. It occurs
in default_device_ops, which currently requires net_mutex,
and it behaves as a barrier at the moment. It will be considered
in next patch.

Speaking about link_watch_list, it seems, there is no way
for loopback_dev at time of registration to be linked in lweventlist
and be available for another pernet_operations.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/loopback.c