diff mbox

[2/2] loopback: bringup 'lo' by default at initialization

Message ID 20170704191623.6583-1-mahesh@bandewar.net
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Mahesh Bandewar July 4, 2017, 7:16 p.m. UTC
From: Mahesh Bandewar <maheshb@google.com>

loopback devices are always brought up right after its initialization
including the case of network namespace creation. e.g.

    ip netns add foo
    ip -netns foo link set lo up

This patch will eliminate the need to do that separately and would bring
it up as part of the loopback initialization.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
 drivers/net/loopback.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 30612497643c..3216977935d1 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -217,6 +217,12 @@  static __net_init int loopback_net_init(struct net *net)
 
 	BUG_ON(dev->ifindex != LOOPBACK_IFINDEX);
 	net->loopback_dev = dev;
+
+	/* Set the loopback device UP */
+	rtnl_lock();
+	dev_open(net->loopback_dev);
+	rtnl_unlock();
+
 	return 0;
 
 out_free_netdev: