diff options
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 87 |
1 files changed, 38 insertions, 49 deletions
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 */ |