Commit ebb7e95d9351f77a8ec1fca20eb645051401b7b2

Authored by Eric W. Biederman
Committed by David S. Miller
1 parent b01a24078f

sctp: Add infrastructure for per net sysctls

Start with an empty sctp_net_table that will be populated as the various
tunable sysctls are made per net.

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>

Showing 4 changed files with 37 additions and 1 deletions Side-by-side Diff

include/net/netns/sctp.h
... ... @@ -4,6 +4,7 @@
4 4 struct sock;
5 5 struct proc_dir_entry;
6 6 struct sctp_mib;
  7 +struct ctl_table_header;
7 8  
8 9 struct netns_sctp {
9 10 DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics);
... ... @@ -11,7 +12,9 @@
11 12 #ifdef CONFIG_PROC_FS
12 13 struct proc_dir_entry *proc_net_sctp;
13 14 #endif
14   -
  15 +#ifdef CONFIG_SYSCTL
  16 + struct ctl_table_header *sysctl_header;
  17 +#endif
15 18 /* This is the global socket data structure used for responding to
16 19 * the Out-of-the-blue (OOTB) packets. A control sock will be created
17 20 * for this socket at the initialization time.
... ... @@ -32,6 +35,7 @@
32 35  
33 36 /* Lock that protects the local_addr_list writers */
34 37 spinlock_t local_addr_lock;
  38 +
35 39 };
36 40  
37 41 #endif /* __NETNS_SCTP_H__ */
include/net/sctp/sctp.h
... ... @@ -375,9 +375,13 @@
375 375 #if defined CONFIG_SYSCTL
376 376 void sctp_sysctl_register(void);
377 377 void sctp_sysctl_unregister(void);
  378 +int sctp_sysctl_net_register(struct net *net);
  379 +void sctp_sysctl_net_unregister(struct net *net);
378 380 #else
379 381 static inline void sctp_sysctl_register(void) { return; }
380 382 static inline void sctp_sysctl_unregister(void) { return; }
  383 +static inline int sctp_sysctl_net_register(struct net *net) { return 0; }
  384 +static inline void sctp_sysctl_net_unregister(struct net *net) { return; }
381 385 #endif
382 386  
383 387 /* Size of Supported Address Parameter for 'x' address types. */
... ... @@ -1169,6 +1169,10 @@
1169 1169 {
1170 1170 int status;
1171 1171  
  1172 + status = sctp_sysctl_net_register(net);
  1173 + if (status)
  1174 + goto err_sysctl_register;
  1175 +
1172 1176 /* Allocate and initialise sctp mibs. */
1173 1177 status = init_sctp_mibs(net);
1174 1178 if (status)
... ... @@ -1208,6 +1212,8 @@
1208 1212 err_init_proc:
1209 1213 cleanup_sctp_mibs(net);
1210 1214 err_init_mibs:
  1215 + sctp_sysctl_net_unregister(net);
  1216 +err_sysctl_register:
1211 1217 return status;
1212 1218 }
1213 1219  
... ... @@ -1224,6 +1230,7 @@
1224 1230  
1225 1231 sctp_proc_exit(net);
1226 1232 cleanup_sctp_mibs(net);
  1233 + sctp_sysctl_net_unregister(net);
1227 1234 }
1228 1235  
1229 1236 static struct pernet_operations sctp_net_ops = {
... ... @@ -284,6 +284,27 @@
284 284 { /* sentinel */ }
285 285 };
286 286  
  287 +static ctl_table sctp_net_table[] = {
  288 + { /* sentinel */ }
  289 +};
  290 +
  291 +int sctp_sysctl_net_register(struct net *net)
  292 +{
  293 + struct ctl_table *table;
  294 +
  295 + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
  296 + if (!table)
  297 + return -ENOMEM;
  298 +
  299 + net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
  300 + return 0;
  301 +}
  302 +
  303 +void sctp_sysctl_net_unregister(struct net *net)
  304 +{
  305 + unregister_net_sysctl_table(net->sctp.sysctl_header);
  306 +}
  307 +
287 308 static struct ctl_table_header * sctp_sysctl_header;
288 309  
289 310 /* Sysctl registration. */