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
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:
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);
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:
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);
}
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);
* we do not wish this socket to see incoming packets.
*/
(*sk)->sk_prot->unhash(*sk);
+
+ sk_change_net(*sk, net);
}
return rc;
}
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");
}
static int tcpv6_net_init(struct net *net)
{
- int err;
- struct sock *sk;
-
- err = inet_ctl_sock_create(&sk, PF_INET6, SOCK_RAW, IPPROTO_TCP);
- if (err)
- return err;
-
- net->ipv6.tcp_sk = sk;
- sk_change_net(sk, net);
- return err;
+ return inet_ctl_sock_create(&net->ipv6.tcp_sk, PF_INET6,
+ SOCK_RAW, IPPROTO_TCP, net);
}
static void tcpv6_net_exit(struct net *net)
{
- sk_release_kernel(net->ipv6.tcp_sk);
+ inet_ctl_sock_destroy(net->ipv6.tcp_sk);
}
static struct pernet_operations tcpv6_net_ops = {
family = PF_INET;
err = inet_ctl_sock_create(&sctp_ctl_sock, family,
- SOCK_SEQPACKET, IPPROTO_SCTP);
+ SOCK_SEQPACKET, IPPROTO_SCTP, &init_net);
if (err < 0) {
printk(KERN_ERR
"SCTP: Failed to create the SCTP control socket.\n");
sctp_v6_del_protocol();
err_add_protocol:
sctp_v4_del_protocol();
- sock_release(sctp_ctl_sock->sk_socket);
+ inet_ctl_sock_destroy(sctp_ctl_sock);
err_ctl_sock_init:
sctp_v6_protosw_exit();
err_v6_protosw_init:
sctp_v4_del_protocol();
/* Free the control endpoint. */
- sock_release(sctp_ctl_sock->sk_socket);
+ inet_ctl_sock_destroy(sctp_ctl_sock);
/* Free protosw registrations */
sctp_v6_protosw_exit();