netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <amwang@redhat.com>
To: netdev@vger.kernel.org
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	"David S. Miller" <davem@davemloft.net>,
	Cong Wang <amwang@redhat.com>
Subject: [Patch net-next 2/2] netpoll: use the net namespace of current process instead of init_net
Date: Wed, 23 Jan 2013 17:02:11 +0800	[thread overview]
Message-ID: <1358931731-17438-2-git-send-email-amwang@redhat.com> (raw)
In-Reply-To: <1358931731-17438-1-git-send-email-amwang@redhat.com>

From: Cong Wang <amwang@redhat.com>

This will allow us to setup netconsole in a different namespace
rather than where init_net is.

Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
---
 net/core/netpoll.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index a6f39b6..c3b2589 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -1046,11 +1046,16 @@ int netpoll_setup(struct netpoll *np)
 {
 	struct net_device *ndev = NULL;
 	struct in_device *in_dev;
+	struct net *net = &init_net;
+	struct nsproxy *ns = task_nsproxy(current);
 	int err;
 
 	rtnl_lock();
-	if (np->dev_name)
-		ndev = __dev_get_by_name(&init_net, np->dev_name);
+	if (np->dev_name) {
+		if (ns != NULL)
+			net = get_net(ns->net_ns);
+		ndev = __dev_get_by_name(net, np->dev_name);
+	}
 	if (!ndev) {
 		np_err(np, "%s doesn't exist, aborting\n", np->dev_name);
 		err = -ENODEV;
@@ -1159,6 +1164,8 @@ int netpoll_setup(struct netpoll *np)
 put:
 	dev_put(ndev);
 unlock:
+	if (net != &init_net)
+		put_net(net);
 	rtnl_unlock();
 	return err;
 }
-- 
1.7.7.6

  reply	other threads:[~2013-01-23  9:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23  9:02 [Patch net-next 1/2] netpoll: use ipv6_addr_equal() to compare ipv6 addr Cong Wang
2013-01-23  9:02 ` Cong Wang [this message]
2013-01-26 10:00   ` [Patch net-next 2/2] netpoll: use the net namespace of current process instead of init_net Cong Wang
2013-01-27  5:16     ` Eric W. Biederman
2013-01-28  1:36       ` Cong Wang

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=1358931731-17438-2-git-send-email-amwang@redhat.com \
    --to=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.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).