Skip to content

Commit 97577e3

Browse files
xemuldavem330
authored andcommitted
[UNIX]: Extend unix_sysctl_(un)register prototypes
Add the struct net * argument to both of them to use in the future. Also make the register one return an error code. It is useless right now, but will make the future patches much simpler. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dd88590 commit 97577e3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

include/net/af_unix.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ struct unix_sock {
6060

6161
#ifdef CONFIG_SYSCTL
6262
extern int sysctl_unix_max_dgram_qlen;
63-
extern void unix_sysctl_register(void);
64-
extern void unix_sysctl_unregister(void);
63+
extern int unix_sysctl_register(struct net *net);
64+
extern void unix_sysctl_unregister(struct net *net);
6565
#else
66-
static inline void unix_sysctl_register(void) {}
67-
static inline void unix_sysctl_unregister(void) {}
66+
static inline int unix_sysctl_register(struct net *net) { return 0; }
67+
static inline void unix_sysctl_unregister(struct net *net) {}
6868
#endif
6969
#endif
7070
#endif

net/unix/af_unix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2175,15 +2175,15 @@ static int __init af_unix_init(void)
21752175

21762176
sock_register(&unix_family_ops);
21772177
register_pernet_subsys(&unix_net_ops);
2178-
unix_sysctl_register();
2178+
unix_sysctl_register(&init_net);
21792179
out:
21802180
return rc;
21812181
}
21822182

21832183
static void __exit af_unix_exit(void)
21842184
{
21852185
sock_unregister(PF_UNIX);
2186-
unix_sysctl_unregister();
2186+
unix_sysctl_unregister(&init_net);
21872187
proto_unregister(&unix_proto);
21882188
unregister_pernet_subsys(&unix_net_ops);
21892189
}

net/unix/sysctl_net_unix.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ static ctl_table unix_root_table[] = {
4848

4949
static struct ctl_table_header * unix_sysctl_header;
5050

51-
void unix_sysctl_register(void)
51+
int unix_sysctl_register(struct net *net)
5252
{
5353
unix_sysctl_header = register_sysctl_table(unix_root_table);
54+
return unix_sysctl_header == NULL ? -ENOMEM : 0;
5455
}
5556

56-
void unix_sysctl_unregister(void)
57+
void unix_sysctl_unregister(struct net *net)
5758
{
5859
unregister_sysctl_table(unix_sysctl_header);
5960
}

0 commit comments

Comments
 (0)