[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1430988770-28907-5-git-send-email-ying.xue@windriver.com>
Date: Thu, 7 May 2015 16:52:43 +0800
From: Ying Xue <ying.xue@...driver.com>
To: <netdev@...r.kernel.org>
CC: <cwang@...pensource.com>, <herbert@...dor.apana.org.au>,
<xemul@...nvz.org>, <davem@...emloft.net>,
<eric.dumazet@...il.com>, <ebiederm@...ssion.com>,
<maxk@....qualcomm.com>, <stephen@...workplumber.org>,
<tgraf@...g.ch>, <nicolas.dichtel@...nd.com>,
<tom@...bertland.com>, <jchapman@...alix.com>,
<erik.hugne@...csson.com>, <jon.maloy@...csson.com>,
<horms@...ge.net.au>
Subject: [RFC PATCH net-next 04/11] inet: avoid unnecessary namespace switch during kernel socket creation
As the race between put_net() and kernel socket's creation is gone,
it's unnecessary to switch namespace for a kernel socket from init_net
to its desirable one. But as the kernel socket is part of a namespace,
we should not hold a reference counter to the namespace, otherwise,
probably modules relying on it cannot be stopped.
Signed-off-by: Ying Xue <ying.xue@...driver.com>
---
include/net/inet_common.h | 3 ++-
net/ipv4/af_inet.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 4a92423..cedc7c7 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -41,7 +41,8 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
static inline void inet_ctl_sock_destroy(struct sock *sk)
{
- sk_release_kernel(sk);
+ get_net(sock_net(sk));
+ sock_release(sk->sk_socket);
}
#endif
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 8b47a4d..50e6292 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1430,7 +1430,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
struct net *net)
{
struct socket *sock;
- int rc = sock_create_kern(family, type, protocol, &sock);
+ int rc = __sock_create(net, family, type, protocol, &sock, 1);
if (rc == 0) {
*sk = sock->sk;
@@ -1441,7 +1441,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
*/
(*sk)->sk_prot->unhash(*sk);
- sk_change_net(*sk, net);
+ put_net(sock_net(*sk));
}
return rc;
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists