diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-06 04:43:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-15 02:17:26 -0400 |
commit | 2ce955035081112cf1590c961da8d94324142b5e (patch) | |
tree | 1c9c9afdcac42e283a7383fa67842470753a0bb4 /net/sctp/protocol.c | |
parent | 4db67e808640e3934d82ce61ee8e2e89fd877ba8 (diff) |
sctp: Make the ctl_sock per network namespace
- Kill sctp_get_ctl_sock, it is useless now.
- Pass struct net where needed so net->sctp.ctl_sock is accessible.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 7025d96bae5f..f20bd708e89c 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -78,12 +78,6 @@ struct proc_dir_entry *proc_net_sctp; | |||
78 | struct idr sctp_assocs_id; | 78 | struct idr sctp_assocs_id; |
79 | DEFINE_SPINLOCK(sctp_assocs_id_lock); | 79 | DEFINE_SPINLOCK(sctp_assocs_id_lock); |
80 | 80 | ||
81 | /* This is the global socket data structure used for responding to | ||
82 | * the Out-of-the-blue (OOTB) packets. A control sock will be created | ||
83 | * for this socket at the initialization time. | ||
84 | */ | ||
85 | static struct sock *sctp_ctl_sock; | ||
86 | |||
87 | static struct sctp_pf *sctp_pf_inet6_specific; | 81 | static struct sctp_pf *sctp_pf_inet6_specific; |
88 | static struct sctp_pf *sctp_pf_inet_specific; | 82 | static struct sctp_pf *sctp_pf_inet_specific; |
89 | static struct sctp_af *sctp_af_v4_specific; | 83 | static struct sctp_af *sctp_af_v4_specific; |
@@ -96,12 +90,6 @@ long sysctl_sctp_mem[3]; | |||
96 | int sysctl_sctp_rmem[3]; | 90 | int sysctl_sctp_rmem[3]; |
97 | int sysctl_sctp_wmem[3]; | 91 | int sysctl_sctp_wmem[3]; |
98 | 92 | ||
99 | /* Return the address of the control sock. */ | ||
100 | struct sock *sctp_get_ctl_sock(void) | ||
101 | { | ||
102 | return sctp_ctl_sock; | ||
103 | } | ||
104 | |||
105 | /* Set up the proc fs entry for the SCTP protocol. */ | 93 | /* Set up the proc fs entry for the SCTP protocol. */ |
106 | static __init int sctp_proc_init(void) | 94 | static __init int sctp_proc_init(void) |
107 | { | 95 | { |
@@ -822,7 +810,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, | |||
822 | * Initialize the control inode/socket with a control endpoint data | 810 | * Initialize the control inode/socket with a control endpoint data |
823 | * structure. This endpoint is reserved exclusively for the OOTB processing. | 811 | * structure. This endpoint is reserved exclusively for the OOTB processing. |
824 | */ | 812 | */ |
825 | static int sctp_ctl_sock_init(void) | 813 | static int sctp_ctl_sock_init(struct net *net) |
826 | { | 814 | { |
827 | int err; | 815 | int err; |
828 | sa_family_t family = PF_INET; | 816 | sa_family_t family = PF_INET; |
@@ -830,14 +818,14 @@ static int sctp_ctl_sock_init(void) | |||
830 | if (sctp_get_pf_specific(PF_INET6)) | 818 | if (sctp_get_pf_specific(PF_INET6)) |
831 | family = PF_INET6; | 819 | family = PF_INET6; |
832 | 820 | ||
833 | err = inet_ctl_sock_create(&sctp_ctl_sock, family, | 821 | err = inet_ctl_sock_create(&net->sctp.ctl_sock, family, |
834 | SOCK_SEQPACKET, IPPROTO_SCTP, &init_net); | 822 | SOCK_SEQPACKET, IPPROTO_SCTP, net); |
835 | 823 | ||
836 | /* If IPv6 socket could not be created, try the IPv4 socket */ | 824 | /* If IPv6 socket could not be created, try the IPv4 socket */ |
837 | if (err < 0 && family == PF_INET6) | 825 | if (err < 0 && family == PF_INET6) |
838 | err = inet_ctl_sock_create(&sctp_ctl_sock, AF_INET, | 826 | err = inet_ctl_sock_create(&net->sctp.ctl_sock, AF_INET, |
839 | SOCK_SEQPACKET, IPPROTO_SCTP, | 827 | SOCK_SEQPACKET, IPPROTO_SCTP, |
840 | &init_net); | 828 | net); |
841 | 829 | ||
842 | if (err < 0) { | 830 | if (err < 0) { |
843 | pr_err("Failed to create the SCTP control socket\n"); | 831 | pr_err("Failed to create the SCTP control socket\n"); |
@@ -1196,6 +1184,14 @@ static void sctp_v4_del_protocol(void) | |||
1196 | 1184 | ||
1197 | static int sctp_net_init(struct net *net) | 1185 | static int sctp_net_init(struct net *net) |
1198 | { | 1186 | { |
1187 | int status; | ||
1188 | |||
1189 | /* Initialize the control inode/socket for handling OOTB packets. */ | ||
1190 | if ((status = sctp_ctl_sock_init(net))) { | ||
1191 | pr_err("Failed to initialize the SCTP control sock\n"); | ||
1192 | goto err_ctl_sock_init; | ||
1193 | } | ||
1194 | |||
1199 | /* Initialize the local address list. */ | 1195 | /* Initialize the local address list. */ |
1200 | INIT_LIST_HEAD(&net->sctp.local_addr_list); | 1196 | INIT_LIST_HEAD(&net->sctp.local_addr_list); |
1201 | spin_lock_init(&net->sctp.local_addr_lock); | 1197 | spin_lock_init(&net->sctp.local_addr_lock); |
@@ -1210,6 +1206,9 @@ static int sctp_net_init(struct net *net) | |||
1210 | (unsigned long)net); | 1206 | (unsigned long)net); |
1211 | 1207 | ||
1212 | return 0; | 1208 | return 0; |
1209 | |||
1210 | err_ctl_sock_init: | ||
1211 | return status; | ||
1213 | } | 1212 | } |
1214 | 1213 | ||
1215 | static void sctp_net_exit(struct net *net) | 1214 | static void sctp_net_exit(struct net *net) |
@@ -1217,6 +1216,9 @@ static void sctp_net_exit(struct net *net) | |||
1217 | /* Free the local address list */ | 1216 | /* Free the local address list */ |
1218 | sctp_free_addr_wq(net); | 1217 | sctp_free_addr_wq(net); |
1219 | sctp_free_local_addr_list(net); | 1218 | sctp_free_local_addr_list(net); |
1219 | |||
1220 | /* Free the control endpoint. */ | ||
1221 | inet_ctl_sock_destroy(net->sctp.ctl_sock); | ||
1220 | } | 1222 | } |
1221 | 1223 | ||
1222 | static struct pernet_operations sctp_net_ops = { | 1224 | static struct pernet_operations sctp_net_ops = { |
@@ -1438,12 +1440,6 @@ SCTP_STATIC __init int sctp_init(void) | |||
1438 | if (status) | 1440 | if (status) |
1439 | goto err_v6_protosw_init; | 1441 | goto err_v6_protosw_init; |
1440 | 1442 | ||
1441 | /* Initialize the control inode/socket for handling OOTB packets. */ | ||
1442 | if ((status = sctp_ctl_sock_init())) { | ||
1443 | pr_err("Failed to initialize the SCTP control sock\n"); | ||
1444 | goto err_ctl_sock_init; | ||
1445 | } | ||
1446 | |||
1447 | status = register_pernet_subsys(&sctp_net_ops); | 1443 | status = register_pernet_subsys(&sctp_net_ops); |
1448 | if (status) | 1444 | if (status) |
1449 | goto err_register_pernet_subsys; | 1445 | goto err_register_pernet_subsys; |
@@ -1465,8 +1461,6 @@ err_v6_add_protocol: | |||
1465 | err_add_protocol: | 1461 | err_add_protocol: |
1466 | unregister_pernet_subsys(&sctp_net_ops); | 1462 | unregister_pernet_subsys(&sctp_net_ops); |
1467 | err_register_pernet_subsys: | 1463 | err_register_pernet_subsys: |
1468 | inet_ctl_sock_destroy(sctp_ctl_sock); | ||
1469 | err_ctl_sock_init: | ||
1470 | sctp_v6_protosw_exit(); | 1464 | sctp_v6_protosw_exit(); |
1471 | err_v6_protosw_init: | 1465 | err_v6_protosw_init: |
1472 | sctp_v4_protosw_exit(); | 1466 | sctp_v4_protosw_exit(); |
@@ -1506,9 +1500,6 @@ SCTP_STATIC __exit void sctp_exit(void) | |||
1506 | sctp_v6_del_protocol(); | 1500 | sctp_v6_del_protocol(); |
1507 | sctp_v4_del_protocol(); | 1501 | sctp_v4_del_protocol(); |
1508 | 1502 | ||
1509 | /* Free the control endpoint. */ | ||
1510 | inet_ctl_sock_destroy(sctp_ctl_sock); | ||
1511 | |||
1512 | unregister_pernet_subsys(&sctp_net_ops); | 1503 | unregister_pernet_subsys(&sctp_net_ops); |
1513 | 1504 | ||
1514 | /* Free protosw registrations */ | 1505 | /* Free protosw registrations */ |