netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: switch net_ns only if net is not init_net
@ 2014-03-07 10:47 Gu Zheng
  2014-03-09 23:09 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Gu Zheng @ 2014-03-07 10:47 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel

Many netlink users create netlink sock in the init_net, and the
switching nes_ns(init_net-->net) is needless in this case. So here
we add a pre-check to avoid this.

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 net/netlink/af_netlink.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index fdf5135..e9e4be9 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2429,7 +2429,8 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
 		goto out_sock_release_nosk;
 
 	sk = sock->sk;
-	sk_change_net(sk, net);
+	if (!net_eq(net, &init_net))
+		sk_change_net(sk, net);
 
 	if (!cfg || cfg->groups < 32)
 		groups = 32;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-10 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 10:47 [PATCH] netlink: switch net_ns only if net is not init_net Gu Zheng
2014-03-09 23:09 ` David Miller
2014-03-10  1:11   ` Gu Zheng
2014-03-10  1:57   ` [PATCH] net: add a pre-check of net_ns in sk_change_net() Gu Zheng
2014-03-10 20:30     ` David Miller

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).