From: Jian Yang <jianyang.kernel@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org
Cc: Mahesh Bandewar <maheshb@google.com>, Jian Yang <jianyang@google.com>
Subject: [PATCH net-next v3] net-loopback: set lo dev initial state to UP
Date: Mon, 1 Feb 2021 15:34:45 -0800 [thread overview]
Message-ID: <20210201233445.2044327-1-jianyang.kernel@gmail.com> (raw)
From: Jian Yang <jianyang@google.com>
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>
---
v3:
* Addressed Jakub's comment to remove the sysctl knob
v2:
* Updated sysctl name from `netdev_loopback_state` to `loopback_init_state`
* Fixed the linking error when CONFIG_SYSCTL is not defined
drivers/net/loopback.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index a1c77cc00416..24487ec17f8b 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -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:
--
2.30.0.365.g02bc693789-goog
next reply other threads:[~2021-02-01 23:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 23:34 Jian Yang [this message]
2021-02-05 3:00 ` [PATCH net-next v3] net-loopback: set lo dev initial state to UP patchwork-bot+netdevbpf
2021-02-09 11:54 ` Petr Machata
2021-02-09 16:23 ` Jakub Kicinski
2021-02-09 17:19 ` Petr Machata
2021-02-09 18:49 ` Mahesh Bandewar (महेश बंडेवार)
2021-02-09 19:04 ` Jakub Kicinski
2021-02-09 19:18 ` Mahesh Bandewar (महेश बंडेवार)
2021-02-09 19:43 ` Jakub Kicinski
2021-02-09 19:06 ` Ido Schimmel
2021-02-09 19:19 ` Mahesh Bandewar (महेश बंडेवार)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210201233445.2044327-1-jianyang.kernel@gmail.com \
--to=jianyang.kernel@gmail.com \
--cc=davem@davemloft.net \
--cc=jianyang@google.com \
--cc=kuba@kernel.org \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).