net-loopback: set lo dev initial state to UP

Traditionally loopback devices come up with initial state as DOWN for
any new network-namespace. This would mean that anyone needing this
device would have to bring this UP by issuing something like 'ip link
set lo up'. This can be avoided if the initial state is set as UP.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: Jian Yang <jianyang@google.com>
Link: https://lore.kernel.org/r/20210201233445.2044327-1-jianyang.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jian Yang 2021-02-01 15:34:45 -08:00 committed by Jakub Kicinski
parent e64ffa8875
commit c9dca822c7

View File

@ -219,6 +219,12 @@ static __net_init int loopback_net_init(struct net *net)
BUG_ON(dev->ifindex != LOOPBACK_IFINDEX);
net->loopback_dev = dev;
/* bring loopback device UP */
rtnl_lock();
dev_open(dev, NULL);
rtnl_unlock();
return 0;
out_free_netdev: