Commit 5677242f authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller
Browse files

[NETNS]: Inet control socket should not hold a namespace.



This is a generic requirement, so make inet_ctl_sock_create namespace
aware and create a inet_ctl_sock_destroy wrapper around
sk_release_kernel.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eee4fe4d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -42,7 +42,13 @@ extern int inet_ioctl(struct socket *sock,
extern int			inet_ctl_sock_create(struct sock **sk,
						     unsigned short family,
						     unsigned short type,
						     unsigned char protocol);
						     unsigned char protocol,
						     struct net *net);

static inline void inet_ctl_sock_destroy(struct sock *sk)
{
	sk_release_kernel(sk);
}

#endif

+2 −2
Original line number Diff line number Diff line
@@ -1003,7 +1003,7 @@ static int __init dccp_v4_init(void)
	inet_register_protosw(&dccp_v4_protosw);

	err = inet_ctl_sock_create(&dccp_v4_ctl_sk, PF_INET,
				   SOCK_DCCP, IPPROTO_DCCP);
				   SOCK_DCCP, IPPROTO_DCCP, &init_net);
	if (err)
		goto out_unregister_protosw;
out:
@@ -1018,7 +1018,7 @@ static int __init dccp_v4_init(void)

static void __exit dccp_v4_exit(void)
{
	sock_release(dccp_v4_ctl_sk->sk_socket);
	inet_ctl_sock_destroy(dccp_v4_ctl_sk);
	inet_unregister_protosw(&dccp_v4_protosw);
	inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
	proto_unregister(&dccp_v4_prot);
+2 −2
Original line number Diff line number Diff line
@@ -1185,7 +1185,7 @@ static int __init dccp_v6_init(void)
	inet6_register_protosw(&dccp_v6_protosw);

	err = inet_ctl_sock_create(&dccp_v6_ctl_sk, PF_INET6,
				   SOCK_DCCP, IPPROTO_DCCP);
				   SOCK_DCCP, IPPROTO_DCCP, &init_net);
	if (err != 0)
		goto out_unregister_protosw;
out:
@@ -1200,7 +1200,7 @@ static int __init dccp_v6_init(void)

static void __exit dccp_v6_exit(void)
{
	sock_release(dccp_v6_ctl_sk->sk_socket);
	inet_ctl_sock_destroy(dccp_v6_ctl_sk);
	inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
	inet6_unregister_protosw(&dccp_v6_protosw);
	proto_unregister(&dccp_v6_prot);
+4 −1
Original line number Diff line number Diff line
@@ -1251,7 +1251,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
}

int inet_ctl_sock_create(struct sock **sk, unsigned short family,
			 unsigned short type, unsigned char protocol)
			 unsigned short type, unsigned char protocol,
			 struct net *net)
{
	struct socket *sock;
	int rc = sock_create_kern(family, type, protocol, &sock);
@@ -1265,6 +1266,8 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
		 * we do not wish this socket to see incoming packets.
		 */
		(*sk)->sk_prot->unhash(*sk);

		sk_change_net(*sk, net);
	}
	return rc;
}
+1 −1
Original line number Diff line number Diff line
@@ -2491,7 +2491,7 @@ struct proto tcp_prot = {
void __init tcp_v4_init(void)
{
	if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW,
				 IPPROTO_TCP) < 0)
				 IPPROTO_TCP, &init_net) < 0)
		panic("Failed to create the TCP control socket.\n");
}

Loading