diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-06 04:45:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-15 02:29:53 -0400 |
commit | 13d782f6b4fbbaf9d0380a9947deb45a9de46ae7 (patch) | |
tree | a9b17830724d4470af1a37abec88902bd1a09aca /net/sctp | |
parent | 632c928a6a77fe96cda34a9978e1f6019ffc38f4 (diff) |
sctp: Make the proc files per network namespace.
- Convert all of the files under /proc/net/sctp to be per
network namespace.
- Don't print anything for /proc/net/sctp/snmp except in
the initial network namespaces as the snmp counters still
have to be converted to be per network namespace.
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')
-rw-r--r-- | net/sctp/objcnt.c | 8 | ||||
-rw-r--r-- | net/sctp/proc.c | 59 | ||||
-rw-r--r-- | net/sctp/protocol.c | 87 |
3 files changed, 81 insertions, 73 deletions
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c index 8ef8e7d9eb61..fe012c44f8df 100644 --- a/net/sctp/objcnt.c +++ b/net/sctp/objcnt.c | |||
@@ -129,20 +129,20 @@ static const struct file_operations sctp_objcnt_ops = { | |||
129 | }; | 129 | }; |
130 | 130 | ||
131 | /* Initialize the objcount in the proc filesystem. */ | 131 | /* Initialize the objcount in the proc filesystem. */ |
132 | void sctp_dbg_objcnt_init(void) | 132 | void sctp_dbg_objcnt_init(struct net *net) |
133 | { | 133 | { |
134 | struct proc_dir_entry *ent; | 134 | struct proc_dir_entry *ent; |
135 | 135 | ||
136 | ent = proc_create("sctp_dbg_objcnt", 0, | 136 | ent = proc_create("sctp_dbg_objcnt", 0, |
137 | proc_net_sctp, &sctp_objcnt_ops); | 137 | net->sctp.proc_net_sctp, &sctp_objcnt_ops); |
138 | if (!ent) | 138 | if (!ent) |
139 | pr_warn("sctp_dbg_objcnt: Unable to create /proc entry.\n"); | 139 | pr_warn("sctp_dbg_objcnt: Unable to create /proc entry.\n"); |
140 | } | 140 | } |
141 | 141 | ||
142 | /* Cleanup the objcount entry in the proc filesystem. */ | 142 | /* Cleanup the objcount entry in the proc filesystem. */ |
143 | void sctp_dbg_objcnt_exit(void) | 143 | void sctp_dbg_objcnt_exit(struct net *net) |
144 | { | 144 | { |
145 | remove_proc_entry("sctp_dbg_objcnt", proc_net_sctp); | 145 | remove_proc_entry("sctp_dbg_objcnt", net->sctp.proc_net_sctp); |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 1e2eee88c3ea..dc79a3aa0382 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -80,8 +80,12 @@ static const struct snmp_mib sctp_snmp_list[] = { | |||
80 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ | 80 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ |
81 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | 81 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) |
82 | { | 82 | { |
83 | struct net *net = seq->private; | ||
83 | int i; | 84 | int i; |
84 | 85 | ||
86 | if (!net_eq(net, &init_net)) | ||
87 | return 0; | ||
88 | |||
85 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) | 89 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) |
86 | seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, | 90 | seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, |
87 | snmp_fold_field((void __percpu **)sctp_statistics, | 91 | snmp_fold_field((void __percpu **)sctp_statistics, |
@@ -93,7 +97,7 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | |||
93 | /* Initialize the seq file operations for 'snmp' object. */ | 97 | /* Initialize the seq file operations for 'snmp' object. */ |
94 | static int sctp_snmp_seq_open(struct inode *inode, struct file *file) | 98 | static int sctp_snmp_seq_open(struct inode *inode, struct file *file) |
95 | { | 99 | { |
96 | return single_open(file, sctp_snmp_seq_show, NULL); | 100 | return single_open_net(inode, file, sctp_snmp_seq_show); |
97 | } | 101 | } |
98 | 102 | ||
99 | static const struct file_operations sctp_snmp_seq_fops = { | 103 | static const struct file_operations sctp_snmp_seq_fops = { |
@@ -105,11 +109,12 @@ static const struct file_operations sctp_snmp_seq_fops = { | |||
105 | }; | 109 | }; |
106 | 110 | ||
107 | /* Set up the proc fs entry for 'snmp' object. */ | 111 | /* Set up the proc fs entry for 'snmp' object. */ |
108 | int __init sctp_snmp_proc_init(void) | 112 | int __net_init sctp_snmp_proc_init(struct net *net) |
109 | { | 113 | { |
110 | struct proc_dir_entry *p; | 114 | struct proc_dir_entry *p; |
111 | 115 | ||
112 | p = proc_create("snmp", S_IRUGO, proc_net_sctp, &sctp_snmp_seq_fops); | 116 | p = proc_create("snmp", S_IRUGO, net->sctp.proc_net_sctp, |
117 | &sctp_snmp_seq_fops); | ||
113 | if (!p) | 118 | if (!p) |
114 | return -ENOMEM; | 119 | return -ENOMEM; |
115 | 120 | ||
@@ -117,9 +122,9 @@ int __init sctp_snmp_proc_init(void) | |||
117 | } | 122 | } |
118 | 123 | ||
119 | /* Cleanup the proc fs entry for 'snmp' object. */ | 124 | /* Cleanup the proc fs entry for 'snmp' object. */ |
120 | void sctp_snmp_proc_exit(void) | 125 | void sctp_snmp_proc_exit(struct net *net) |
121 | { | 126 | { |
122 | remove_proc_entry("snmp", proc_net_sctp); | 127 | remove_proc_entry("snmp", net->sctp.proc_net_sctp); |
123 | } | 128 | } |
124 | 129 | ||
125 | /* Dump local addresses of an association/endpoint. */ | 130 | /* Dump local addresses of an association/endpoint. */ |
@@ -197,6 +202,7 @@ static void * sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
197 | /* Display sctp endpoints (/proc/net/sctp/eps). */ | 202 | /* Display sctp endpoints (/proc/net/sctp/eps). */ |
198 | static int sctp_eps_seq_show(struct seq_file *seq, void *v) | 203 | static int sctp_eps_seq_show(struct seq_file *seq, void *v) |
199 | { | 204 | { |
205 | struct seq_net_private *priv = seq->private; | ||
200 | struct sctp_hashbucket *head; | 206 | struct sctp_hashbucket *head; |
201 | struct sctp_ep_common *epb; | 207 | struct sctp_ep_common *epb; |
202 | struct sctp_endpoint *ep; | 208 | struct sctp_endpoint *ep; |
@@ -213,6 +219,8 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v) | |||
213 | sctp_for_each_hentry(epb, node, &head->chain) { | 219 | sctp_for_each_hentry(epb, node, &head->chain) { |
214 | ep = sctp_ep(epb); | 220 | ep = sctp_ep(epb); |
215 | sk = epb->sk; | 221 | sk = epb->sk; |
222 | if (!net_eq(sock_net(sk), priv->net)) | ||
223 | continue; | ||
216 | seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, | 224 | seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, |
217 | sctp_sk(sk)->type, sk->sk_state, hash, | 225 | sctp_sk(sk)->type, sk->sk_state, hash, |
218 | epb->bind_addr.port, | 226 | epb->bind_addr.port, |
@@ -238,7 +246,8 @@ static const struct seq_operations sctp_eps_ops = { | |||
238 | /* Initialize the seq file operations for 'eps' object. */ | 246 | /* Initialize the seq file operations for 'eps' object. */ |
239 | static int sctp_eps_seq_open(struct inode *inode, struct file *file) | 247 | static int sctp_eps_seq_open(struct inode *inode, struct file *file) |
240 | { | 248 | { |
241 | return seq_open(file, &sctp_eps_ops); | 249 | return seq_open_net(inode, file, &sctp_eps_ops, |
250 | sizeof(struct seq_net_private)); | ||
242 | } | 251 | } |
243 | 252 | ||
244 | static const struct file_operations sctp_eps_seq_fops = { | 253 | static const struct file_operations sctp_eps_seq_fops = { |
@@ -249,11 +258,12 @@ static const struct file_operations sctp_eps_seq_fops = { | |||
249 | }; | 258 | }; |
250 | 259 | ||
251 | /* Set up the proc fs entry for 'eps' object. */ | 260 | /* Set up the proc fs entry for 'eps' object. */ |
252 | int __init sctp_eps_proc_init(void) | 261 | int __net_init sctp_eps_proc_init(struct net *net) |
253 | { | 262 | { |
254 | struct proc_dir_entry *p; | 263 | struct proc_dir_entry *p; |
255 | 264 | ||
256 | p = proc_create("eps", S_IRUGO, proc_net_sctp, &sctp_eps_seq_fops); | 265 | p = proc_create("eps", S_IRUGO, net->sctp.proc_net_sctp, |
266 | &sctp_eps_seq_fops); | ||
257 | if (!p) | 267 | if (!p) |
258 | return -ENOMEM; | 268 | return -ENOMEM; |
259 | 269 | ||
@@ -261,9 +271,9 @@ int __init sctp_eps_proc_init(void) | |||
261 | } | 271 | } |
262 | 272 | ||
263 | /* Cleanup the proc fs entry for 'eps' object. */ | 273 | /* Cleanup the proc fs entry for 'eps' object. */ |
264 | void sctp_eps_proc_exit(void) | 274 | void sctp_eps_proc_exit(struct net *net) |
265 | { | 275 | { |
266 | remove_proc_entry("eps", proc_net_sctp); | 276 | remove_proc_entry("eps", net->sctp.proc_net_sctp); |
267 | } | 277 | } |
268 | 278 | ||
269 | 279 | ||
@@ -300,6 +310,7 @@ static void * sctp_assocs_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
300 | /* Display sctp associations (/proc/net/sctp/assocs). */ | 310 | /* Display sctp associations (/proc/net/sctp/assocs). */ |
301 | static int sctp_assocs_seq_show(struct seq_file *seq, void *v) | 311 | static int sctp_assocs_seq_show(struct seq_file *seq, void *v) |
302 | { | 312 | { |
313 | struct seq_net_private *priv = seq->private; | ||
303 | struct sctp_hashbucket *head; | 314 | struct sctp_hashbucket *head; |
304 | struct sctp_ep_common *epb; | 315 | struct sctp_ep_common *epb; |
305 | struct sctp_association *assoc; | 316 | struct sctp_association *assoc; |
@@ -316,6 +327,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v) | |||
316 | sctp_for_each_hentry(epb, node, &head->chain) { | 327 | sctp_for_each_hentry(epb, node, &head->chain) { |
317 | assoc = sctp_assoc(epb); | 328 | assoc = sctp_assoc(epb); |
318 | sk = epb->sk; | 329 | sk = epb->sk; |
330 | if (!net_eq(sock_net(sk), priv->net)) | ||
331 | continue; | ||
319 | seq_printf(seq, | 332 | seq_printf(seq, |
320 | "%8pK %8pK %-3d %-3d %-2d %-4d " | 333 | "%8pK %8pK %-3d %-3d %-2d %-4d " |
321 | "%4d %8d %8d %7d %5lu %-5d %5d ", | 334 | "%4d %8d %8d %7d %5lu %-5d %5d ", |
@@ -354,7 +367,8 @@ static const struct seq_operations sctp_assoc_ops = { | |||
354 | /* Initialize the seq file operations for 'assocs' object. */ | 367 | /* Initialize the seq file operations for 'assocs' object. */ |
355 | static int sctp_assocs_seq_open(struct inode *inode, struct file *file) | 368 | static int sctp_assocs_seq_open(struct inode *inode, struct file *file) |
356 | { | 369 | { |
357 | return seq_open(file, &sctp_assoc_ops); | 370 | return seq_open_net(inode, file, &sctp_assoc_ops, |
371 | sizeof(struct seq_net_private)); | ||
358 | } | 372 | } |
359 | 373 | ||
360 | static const struct file_operations sctp_assocs_seq_fops = { | 374 | static const struct file_operations sctp_assocs_seq_fops = { |
@@ -365,11 +379,11 @@ static const struct file_operations sctp_assocs_seq_fops = { | |||
365 | }; | 379 | }; |
366 | 380 | ||
367 | /* Set up the proc fs entry for 'assocs' object. */ | 381 | /* Set up the proc fs entry for 'assocs' object. */ |
368 | int __init sctp_assocs_proc_init(void) | 382 | int __net_init sctp_assocs_proc_init(struct net *net) |
369 | { | 383 | { |
370 | struct proc_dir_entry *p; | 384 | struct proc_dir_entry *p; |
371 | 385 | ||
372 | p = proc_create("assocs", S_IRUGO, proc_net_sctp, | 386 | p = proc_create("assocs", S_IRUGO, net->sctp.proc_net_sctp, |
373 | &sctp_assocs_seq_fops); | 387 | &sctp_assocs_seq_fops); |
374 | if (!p) | 388 | if (!p) |
375 | return -ENOMEM; | 389 | return -ENOMEM; |
@@ -378,9 +392,9 @@ int __init sctp_assocs_proc_init(void) | |||
378 | } | 392 | } |
379 | 393 | ||
380 | /* Cleanup the proc fs entry for 'assocs' object. */ | 394 | /* Cleanup the proc fs entry for 'assocs' object. */ |
381 | void sctp_assocs_proc_exit(void) | 395 | void sctp_assocs_proc_exit(struct net *net) |
382 | { | 396 | { |
383 | remove_proc_entry("assocs", proc_net_sctp); | 397 | remove_proc_entry("assocs", net->sctp.proc_net_sctp); |
384 | } | 398 | } |
385 | 399 | ||
386 | static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos) | 400 | static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos) |
@@ -412,6 +426,7 @@ static void sctp_remaddr_seq_stop(struct seq_file *seq, void *v) | |||
412 | 426 | ||
413 | static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) | 427 | static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) |
414 | { | 428 | { |
429 | struct seq_net_private *priv = seq->private; | ||
415 | struct sctp_hashbucket *head; | 430 | struct sctp_hashbucket *head; |
416 | struct sctp_ep_common *epb; | 431 | struct sctp_ep_common *epb; |
417 | struct sctp_association *assoc; | 432 | struct sctp_association *assoc; |
@@ -426,6 +441,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) | |||
426 | sctp_local_bh_disable(); | 441 | sctp_local_bh_disable(); |
427 | read_lock(&head->lock); | 442 | read_lock(&head->lock); |
428 | sctp_for_each_hentry(epb, node, &head->chain) { | 443 | sctp_for_each_hentry(epb, node, &head->chain) { |
444 | if (!net_eq(sock_net(epb->sk), priv->net)) | ||
445 | continue; | ||
429 | assoc = sctp_assoc(epb); | 446 | assoc = sctp_assoc(epb); |
430 | list_for_each_entry(tsp, &assoc->peer.transport_addr_list, | 447 | list_for_each_entry(tsp, &assoc->peer.transport_addr_list, |
431 | transports) { | 448 | transports) { |
@@ -489,14 +506,15 @@ static const struct seq_operations sctp_remaddr_ops = { | |||
489 | }; | 506 | }; |
490 | 507 | ||
491 | /* Cleanup the proc fs entry for 'remaddr' object. */ | 508 | /* Cleanup the proc fs entry for 'remaddr' object. */ |
492 | void sctp_remaddr_proc_exit(void) | 509 | void sctp_remaddr_proc_exit(struct net *net) |
493 | { | 510 | { |
494 | remove_proc_entry("remaddr", proc_net_sctp); | 511 | remove_proc_entry("remaddr", net->sctp.proc_net_sctp); |
495 | } | 512 | } |
496 | 513 | ||
497 | static int sctp_remaddr_seq_open(struct inode *inode, struct file *file) | 514 | static int sctp_remaddr_seq_open(struct inode *inode, struct file *file) |
498 | { | 515 | { |
499 | return seq_open(file, &sctp_remaddr_ops); | 516 | return seq_open_net(inode, file, &sctp_remaddr_ops, |
517 | sizeof(struct seq_net_private)); | ||
500 | } | 518 | } |
501 | 519 | ||
502 | static const struct file_operations sctp_remaddr_seq_fops = { | 520 | static const struct file_operations sctp_remaddr_seq_fops = { |
@@ -506,11 +524,12 @@ static const struct file_operations sctp_remaddr_seq_fops = { | |||
506 | .release = seq_release, | 524 | .release = seq_release, |
507 | }; | 525 | }; |
508 | 526 | ||
509 | int __init sctp_remaddr_proc_init(void) | 527 | int __net_init sctp_remaddr_proc_init(struct net *net) |
510 | { | 528 | { |
511 | struct proc_dir_entry *p; | 529 | struct proc_dir_entry *p; |
512 | 530 | ||
513 | p = proc_create("remaddr", S_IRUGO, proc_net_sctp, &sctp_remaddr_seq_fops); | 531 | p = proc_create("remaddr", S_IRUGO, net->sctp.proc_net_sctp, |
532 | &sctp_remaddr_seq_fops); | ||
514 | if (!p) | 533 | if (!p) |
515 | return -ENOMEM; | 534 | return -ENOMEM; |
516 | return 0; | 535 | return 0; |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 48a5989c98ce..de7994edb4ca 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -71,10 +71,6 @@ | |||
71 | struct sctp_globals sctp_globals __read_mostly; | 71 | struct sctp_globals sctp_globals __read_mostly; |
72 | DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly; | 72 | DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly; |
73 | 73 | ||
74 | #ifdef CONFIG_PROC_FS | ||
75 | struct proc_dir_entry *proc_net_sctp; | ||
76 | #endif | ||
77 | |||
78 | struct idr sctp_assocs_id; | 74 | struct idr sctp_assocs_id; |
79 | DEFINE_SPINLOCK(sctp_assocs_id_lock); | 75 | DEFINE_SPINLOCK(sctp_assocs_id_lock); |
80 | 76 | ||
@@ -91,60 +87,52 @@ int sysctl_sctp_rmem[3]; | |||
91 | int sysctl_sctp_wmem[3]; | 87 | int sysctl_sctp_wmem[3]; |
92 | 88 | ||
93 | /* Set up the proc fs entry for the SCTP protocol. */ | 89 | /* Set up the proc fs entry for the SCTP protocol. */ |
94 | static __init int sctp_proc_init(void) | 90 | static __net_init int sctp_proc_init(struct net *net) |
95 | { | 91 | { |
96 | #ifdef CONFIG_PROC_FS | 92 | #ifdef CONFIG_PROC_FS |
97 | if (!proc_net_sctp) { | 93 | net->sctp.proc_net_sctp = proc_net_mkdir(net, "sctp", net->proc_net); |
98 | proc_net_sctp = proc_mkdir("sctp", init_net.proc_net); | 94 | if (!net->sctp.proc_net_sctp) |
99 | if (!proc_net_sctp) | 95 | goto out_proc_net_sctp; |
100 | goto out_free_percpu; | 96 | if (sctp_snmp_proc_init(net)) |
101 | } | ||
102 | |||
103 | if (sctp_snmp_proc_init()) | ||
104 | goto out_snmp_proc_init; | 97 | goto out_snmp_proc_init; |
105 | if (sctp_eps_proc_init()) | 98 | if (sctp_eps_proc_init(net)) |
106 | goto out_eps_proc_init; | 99 | goto out_eps_proc_init; |
107 | if (sctp_assocs_proc_init()) | 100 | if (sctp_assocs_proc_init(net)) |
108 | goto out_assocs_proc_init; | 101 | goto out_assocs_proc_init; |
109 | if (sctp_remaddr_proc_init()) | 102 | if (sctp_remaddr_proc_init(net)) |
110 | goto out_remaddr_proc_init; | 103 | goto out_remaddr_proc_init; |
111 | 104 | ||
112 | return 0; | 105 | return 0; |
113 | 106 | ||
114 | out_remaddr_proc_init: | 107 | out_remaddr_proc_init: |
115 | sctp_assocs_proc_exit(); | 108 | sctp_assocs_proc_exit(net); |
116 | out_assocs_proc_init: | 109 | out_assocs_proc_init: |
117 | sctp_eps_proc_exit(); | 110 | sctp_eps_proc_exit(net); |
118 | out_eps_proc_init: | 111 | out_eps_proc_init: |
119 | sctp_snmp_proc_exit(); | 112 | sctp_snmp_proc_exit(net); |
120 | out_snmp_proc_init: | 113 | out_snmp_proc_init: |
121 | if (proc_net_sctp) { | 114 | remove_proc_entry("sctp", net->proc_net); |
122 | proc_net_sctp = NULL; | 115 | net->sctp.proc_net_sctp = NULL; |
123 | remove_proc_entry("sctp", init_net.proc_net); | 116 | out_proc_net_sctp: |
124 | } | ||
125 | out_free_percpu: | ||
126 | #else | ||
127 | return 0; | ||
128 | #endif /* CONFIG_PROC_FS */ | ||
129 | return -ENOMEM; | 117 | return -ENOMEM; |
118 | #endif /* CONFIG_PROC_FS */ | ||
119 | return 0; | ||
130 | } | 120 | } |
131 | 121 | ||
132 | /* Clean up the proc fs entry for the SCTP protocol. | 122 | /* Clean up the proc fs entry for the SCTP protocol. |
133 | * Note: Do not make this __exit as it is used in the init error | 123 | * Note: Do not make this __exit as it is used in the init error |
134 | * path. | 124 | * path. |
135 | */ | 125 | */ |
136 | static void sctp_proc_exit(void) | 126 | static void sctp_proc_exit(struct net *net) |
137 | { | 127 | { |
138 | #ifdef CONFIG_PROC_FS | 128 | #ifdef CONFIG_PROC_FS |
139 | sctp_snmp_proc_exit(); | 129 | sctp_snmp_proc_exit(net); |
140 | sctp_eps_proc_exit(); | 130 | sctp_eps_proc_exit(net); |
141 | sctp_assocs_proc_exit(); | 131 | sctp_assocs_proc_exit(net); |
142 | sctp_remaddr_proc_exit(); | 132 | sctp_remaddr_proc_exit(net); |
143 | 133 | ||
144 | if (proc_net_sctp) { | 134 | remove_proc_entry("sctp", net->proc_net); |
145 | proc_net_sctp = NULL; | 135 | net->sctp.proc_net_sctp = NULL; |
146 | remove_proc_entry("sctp", init_net.proc_net); | ||
147 | } | ||
148 | #endif | 136 | #endif |
149 | } | 137 | } |
150 | 138 | ||
@@ -1180,6 +1168,13 @@ static int sctp_net_init(struct net *net) | |||
1180 | { | 1168 | { |
1181 | int status; | 1169 | int status; |
1182 | 1170 | ||
1171 | /* Initialize proc fs directory. */ | ||
1172 | status = sctp_proc_init(net); | ||
1173 | if (status) | ||
1174 | goto err_init_proc; | ||
1175 | |||
1176 | sctp_dbg_objcnt_init(net); | ||
1177 | |||
1183 | /* Initialize the control inode/socket for handling OOTB packets. */ | 1178 | /* Initialize the control inode/socket for handling OOTB packets. */ |
1184 | if ((status = sctp_ctl_sock_init(net))) { | 1179 | if ((status = sctp_ctl_sock_init(net))) { |
1185 | pr_err("Failed to initialize the SCTP control sock\n"); | 1180 | pr_err("Failed to initialize the SCTP control sock\n"); |
@@ -1202,6 +1197,9 @@ static int sctp_net_init(struct net *net) | |||
1202 | return 0; | 1197 | return 0; |
1203 | 1198 | ||
1204 | err_ctl_sock_init: | 1199 | err_ctl_sock_init: |
1200 | sctp_dbg_objcnt_exit(net); | ||
1201 | sctp_proc_exit(net); | ||
1202 | err_init_proc: | ||
1205 | return status; | 1203 | return status; |
1206 | } | 1204 | } |
1207 | 1205 | ||
@@ -1213,6 +1211,10 @@ static void sctp_net_exit(struct net *net) | |||
1213 | 1211 | ||
1214 | /* Free the control endpoint. */ | 1212 | /* Free the control endpoint. */ |
1215 | inet_ctl_sock_destroy(net->sctp.ctl_sock); | 1213 | inet_ctl_sock_destroy(net->sctp.ctl_sock); |
1214 | |||
1215 | sctp_dbg_objcnt_exit(net); | ||
1216 | |||
1217 | sctp_proc_exit(net); | ||
1216 | } | 1218 | } |
1217 | 1219 | ||
1218 | static struct pernet_operations sctp_net_ops = { | 1220 | static struct pernet_operations sctp_net_ops = { |
@@ -1259,14 +1261,6 @@ SCTP_STATIC __init int sctp_init(void) | |||
1259 | if (status) | 1261 | if (status) |
1260 | goto err_percpu_counter_init; | 1262 | goto err_percpu_counter_init; |
1261 | 1263 | ||
1262 | /* Initialize proc fs directory. */ | ||
1263 | status = sctp_proc_init(); | ||
1264 | if (status) | ||
1265 | goto err_init_proc; | ||
1266 | |||
1267 | /* Initialize object count debugging. */ | ||
1268 | sctp_dbg_objcnt_init(); | ||
1269 | |||
1270 | /* | 1264 | /* |
1271 | * 14. Suggested SCTP Protocol Parameter Values | 1265 | * 14. Suggested SCTP Protocol Parameter Values |
1272 | */ | 1266 | */ |
@@ -1476,9 +1470,6 @@ err_ehash_alloc: | |||
1476 | get_order(sctp_assoc_hashsize * | 1470 | get_order(sctp_assoc_hashsize * |
1477 | sizeof(struct sctp_hashbucket))); | 1471 | sizeof(struct sctp_hashbucket))); |
1478 | err_ahash_alloc: | 1472 | err_ahash_alloc: |
1479 | sctp_dbg_objcnt_exit(); | ||
1480 | sctp_proc_exit(); | ||
1481 | err_init_proc: | ||
1482 | percpu_counter_destroy(&sctp_sockets_allocated); | 1473 | percpu_counter_destroy(&sctp_sockets_allocated); |
1483 | err_percpu_counter_init: | 1474 | err_percpu_counter_init: |
1484 | cleanup_sctp_mibs(); | 1475 | cleanup_sctp_mibs(); |
@@ -1520,9 +1511,7 @@ SCTP_STATIC __exit void sctp_exit(void) | |||
1520 | get_order(sctp_port_hashsize * | 1511 | get_order(sctp_port_hashsize * |
1521 | sizeof(struct sctp_bind_hashbucket))); | 1512 | sizeof(struct sctp_bind_hashbucket))); |
1522 | 1513 | ||
1523 | sctp_dbg_objcnt_exit(); | ||
1524 | percpu_counter_destroy(&sctp_sockets_allocated); | 1514 | percpu_counter_destroy(&sctp_sockets_allocated); |
1525 | sctp_proc_exit(); | ||
1526 | cleanup_sctp_mibs(); | 1515 | cleanup_sctp_mibs(); |
1527 | 1516 | ||
1528 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 1517 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |