Skip to content

Commit ebb7e95

Browse files
ebiedermdavem330
authored andcommitted
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>
1 parent b01a240 commit ebb7e95

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

‎include/net/netns/sctp.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
struct sock;
55
struct proc_dir_entry;
66
struct sctp_mib;
7+
struct ctl_table_header;
78

89
struct netns_sctp {
910
DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics);
1011

1112
#ifdef CONFIG_PROC_FS
1213
struct proc_dir_entry *proc_net_sctp;
1314
#endif
14-
15+
#ifdef CONFIG_SYSCTL
16+
struct ctl_table_header *sysctl_header;
17+
#endif
1518
/* This is the global socket data structure used for responding to
1619
* the Out-of-the-blue (OOTB) packets. A control sock will be created
1720
* for this socket at the initialization time.
@@ -32,6 +35,7 @@ struct netns_sctp {
3235

3336
/* Lock that protects the local_addr_list writers */
3437
spinlock_t local_addr_lock;
38+
3539
};
3640

3741
#endif /* __NETNS_SCTP_H__ */

‎include/net/sctp/sctp.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,13 @@ static inline void sctp_dbg_objcnt_exit(struct net *) { return; }
375375
#if defined CONFIG_SYSCTL
376376
void sctp_sysctl_register(void);
377377
void sctp_sysctl_unregister(void);
378+
int sctp_sysctl_net_register(struct net *net);
379+
void sctp_sysctl_net_unregister(struct net *net);
378380
#else
379381
static inline void sctp_sysctl_register(void) { return; }
380382
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; }
381385
#endif
382386

383387
/* Size of Supported Address Parameter for 'x' address types. */

‎net/sctp/protocol.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,10 @@ static int sctp_net_init(struct net *net)
11691169
{
11701170
int status;
11711171

1172+
status = sctp_sysctl_net_register(net);
1173+
if (status)
1174+
goto err_sysctl_register;
1175+
11721176
/* Allocate and initialise sctp mibs. */
11731177
status = init_sctp_mibs(net);
11741178
if (status)
@@ -1208,6 +1212,8 @@ static int sctp_net_init(struct net *net)
12081212
err_init_proc:
12091213
cleanup_sctp_mibs(net);
12101214
err_init_mibs:
1215+
sctp_sysctl_net_unregister(net);
1216+
err_sysctl_register:
12111217
return status;
12121218
}
12131219

@@ -1224,6 +1230,7 @@ static void sctp_net_exit(struct net *net)
12241230

12251231
sctp_proc_exit(net);
12261232
cleanup_sctp_mibs(net);
1233+
sctp_sysctl_net_unregister(net);
12271234
}
12281235

12291236
static struct pernet_operations sctp_net_ops = {

‎net/sctp/sysctl.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,27 @@ static ctl_table sctp_table[] = {
284284
{ /* sentinel */ }
285285
};
286286

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+
287308
static struct ctl_table_header * sctp_sysctl_header;
288309

289310
/* Sysctl registration. */

0 commit comments

Comments
 (0)