Commit 9f00d977 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by David S. Miller

netlink: hide struct module parameter in netlink_kernel_create

This patch defines netlink_kernel_create as a wrapper function of
__netlink_kernel_create to hide the struct module *me parameter
(which seems to be THIS_MODULE in all existing netlink subsystems).

Suggested by David S. Miller.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9785e10a
...@@ -500,8 +500,7 @@ static int __init crypto_user_init(void) ...@@ -500,8 +500,7 @@ static int __init crypto_user_init(void)
.input = crypto_netlink_rcv, .input = crypto_netlink_rcv,
}; };
crypto_nlsk = netlink_kernel_create(&init_net, NETLINK_CRYPTO, crypto_nlsk = netlink_kernel_create(&init_net, NETLINK_CRYPTO, &cfg);
THIS_MODULE, &cfg);
if (!crypto_nlsk) if (!crypto_nlsk)
return -ENOMEM; return -ENOMEM;
......
...@@ -264,8 +264,7 @@ static int __devinit cn_init(void) ...@@ -264,8 +264,7 @@ static int __devinit cn_init(void)
.input = dev->input, .input = dev->input,
}; };
dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR, dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR, &cfg);
THIS_MODULE, &cfg);
if (!dev->nls) if (!dev->nls)
return -EIO; return -EIO;
......
...@@ -177,7 +177,7 @@ int __init ibnl_init(void) ...@@ -177,7 +177,7 @@ int __init ibnl_init(void)
.input = ibnl_rcv, .input = ibnl_rcv,
}; };
nls = netlink_kernel_create(&init_net, NETLINK_RDMA, THIS_MODULE, &cfg); nls = netlink_kernel_create(&init_net, NETLINK_RDMA, &cfg);
if (!nls) { if (!nls) {
pr_warn("Failed to create netlink socket\n"); pr_warn("Failed to create netlink socket\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -501,7 +501,7 @@ scsi_netlink_init(void) ...@@ -501,7 +501,7 @@ scsi_netlink_init(void)
} }
scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT, scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT,
THIS_MODULE, &cfg); &cfg);
if (!scsi_nl_sock) { if (!scsi_nl_sock) {
printk(KERN_ERR "%s: register of receive handler failed\n", printk(KERN_ERR "%s: register of receive handler failed\n",
__func__); __func__);
......
...@@ -2969,8 +2969,7 @@ static __init int iscsi_transport_init(void) ...@@ -2969,8 +2969,7 @@ static __init int iscsi_transport_init(void)
if (err) if (err)
goto unregister_conn_class; goto unregister_conn_class;
nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, &cfg);
THIS_MODULE, &cfg);
if (!nls) { if (!nls) {
err = -ENOBUFS; err = -ENOBUFS;
goto unregister_session_class; goto unregister_session_class;
......
...@@ -95,7 +95,7 @@ struct sock *netlink_init(int unit, void (*cb)(struct net_device *dev, u16 type, ...@@ -95,7 +95,7 @@ struct sock *netlink_init(int unit, void (*cb)(struct net_device *dev, u16 type,
init_MUTEX(&netlink_mutex); init_MUTEX(&netlink_mutex);
#endif #endif
sock = netlink_kernel_create(&init_net, unit, THIS_MODULE, &cfg); sock = netlink_kernel_create(&init_net, unit, &cfg);
if (sock) if (sock)
rcv_cb = cb; rcv_cb = cb;
......
...@@ -153,6 +153,7 @@ struct nlattr { ...@@ -153,6 +153,7 @@ struct nlattr {
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/module.h>
#include <net/scm.h> #include <net/scm.h>
struct net; struct net;
...@@ -188,9 +189,15 @@ struct netlink_kernel_cfg { ...@@ -188,9 +189,15 @@ struct netlink_kernel_cfg {
unsigned int flags; unsigned int flags;
}; };
extern struct sock *netlink_kernel_create(struct net *net, int unit, extern struct sock *__netlink_kernel_create(struct net *net, int unit,
struct module *module, struct module *module,
struct netlink_kernel_cfg *cfg); struct netlink_kernel_cfg *cfg);
static inline struct sock *
netlink_kernel_create(struct net *net, int unit, struct netlink_kernel_cfg *cfg)
{
return __netlink_kernel_create(net, unit, THIS_MODULE, cfg);
}
extern void netlink_kernel_release(struct sock *sk); extern void netlink_kernel_release(struct sock *sk);
extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups); extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups);
extern int netlink_change_ngroups(struct sock *sk, unsigned int groups); extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
......
...@@ -971,8 +971,7 @@ static int __init audit_init(void) ...@@ -971,8 +971,7 @@ static int __init audit_init(void)
printk(KERN_INFO "audit: initializing netlink socket (%s)\n", printk(KERN_INFO "audit: initializing netlink socket (%s)\n",
audit_default ? "enabled" : "disabled"); audit_default ? "enabled" : "disabled");
audit_sock = netlink_kernel_create(&init_net, NETLINK_AUDIT, audit_sock = netlink_kernel_create(&init_net, NETLINK_AUDIT, &cfg);
THIS_MODULE, &cfg);
if (!audit_sock) if (!audit_sock)
audit_panic("cannot initialize netlink socket"); audit_panic("cannot initialize netlink socket");
else else
......
...@@ -382,8 +382,7 @@ static int uevent_net_init(struct net *net) ...@@ -382,8 +382,7 @@ static int uevent_net_init(struct net *net)
if (!ue_sk) if (!ue_sk)
return -ENOMEM; return -ENOMEM;
ue_sk->sk = netlink_kernel_create(net, NETLINK_KOBJECT_UEVENT, ue_sk->sk = netlink_kernel_create(net, NETLINK_KOBJECT_UEVENT, &cfg);
THIS_MODULE, &cfg);
if (!ue_sk->sk) { if (!ue_sk->sk) {
printk(KERN_ERR printk(KERN_ERR
"kobject_uevent: unable to create netlink socket!\n"); "kobject_uevent: unable to create netlink socket!\n");
......
...@@ -298,8 +298,7 @@ static int __init ebt_ulog_init(void) ...@@ -298,8 +298,7 @@ static int __init ebt_ulog_init(void)
spin_lock_init(&ulog_buffers[i].lock); spin_lock_init(&ulog_buffers[i].lock);
} }
ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, &cfg);
THIS_MODULE, &cfg);
if (!ebtulognl) if (!ebtulognl)
ret = -ENOMEM; ret = -ENOMEM;
else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0) else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0)
......
...@@ -2384,7 +2384,7 @@ static int __net_init rtnetlink_net_init(struct net *net) ...@@ -2384,7 +2384,7 @@ static int __net_init rtnetlink_net_init(struct net *net)
.flags = NL_CFG_F_NONROOT_RECV, .flags = NL_CFG_F_NONROOT_RECV,
}; };
sk = netlink_kernel_create(net, NETLINK_ROUTE, THIS_MODULE, &cfg); sk = netlink_kernel_create(net, NETLINK_ROUTE, &cfg);
if (!sk) if (!sk)
return -ENOMEM; return -ENOMEM;
net->rtnl = sk; net->rtnl = sk;
......
...@@ -172,8 +172,7 @@ static int __net_init diag_net_init(struct net *net) ...@@ -172,8 +172,7 @@ static int __net_init diag_net_init(struct net *net)
.input = sock_diag_rcv, .input = sock_diag_rcv,
}; };
net->diag_nlsk = netlink_kernel_create(net, NETLINK_SOCK_DIAG, net->diag_nlsk = netlink_kernel_create(net, NETLINK_SOCK_DIAG, &cfg);
THIS_MODULE, &cfg);
return net->diag_nlsk == NULL ? -ENOMEM : 0; return net->diag_nlsk == NULL ? -ENOMEM : 0;
} }
......
...@@ -130,8 +130,7 @@ static int __init dn_rtmsg_init(void) ...@@ -130,8 +130,7 @@ static int __init dn_rtmsg_init(void)
.input = dnrmg_receive_user_skb, .input = dnrmg_receive_user_skb,
}; };
dnrmg = netlink_kernel_create(&init_net, dnrmg = netlink_kernel_create(&init_net, NETLINK_DNRTMSG, &cfg);
NETLINK_DNRTMSG, THIS_MODULE, &cfg);
if (dnrmg == NULL) { if (dnrmg == NULL) {
printk(KERN_ERR "dn_rtmsg: Cannot create netlink socket"); printk(KERN_ERR "dn_rtmsg: Cannot create netlink socket");
return -ENOMEM; return -ENOMEM;
......
...@@ -986,7 +986,7 @@ static int __net_init nl_fib_lookup_init(struct net *net) ...@@ -986,7 +986,7 @@ static int __net_init nl_fib_lookup_init(struct net *net)
.input = nl_fib_input, .input = nl_fib_input,
}; };
sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, THIS_MODULE, &cfg); sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, &cfg);
if (sk == NULL) if (sk == NULL)
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
net->ipv4.fibnl = sk; net->ipv4.fibnl = sk;
......
...@@ -396,8 +396,7 @@ static int __init ulog_tg_init(void) ...@@ -396,8 +396,7 @@ static int __init ulog_tg_init(void)
for (i = 0; i < ULOG_MAXNLGROUPS; i++) for (i = 0; i < ULOG_MAXNLGROUPS; i++)
setup_timer(&ulog_buffers[i].timer, ulog_timer, i); setup_timer(&ulog_buffers[i].timer, ulog_timer, i);
nflognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, nflognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, &cfg);
THIS_MODULE, &cfg);
if (!nflognl) if (!nflognl)
return -ENOMEM; return -ENOMEM;
......
...@@ -241,7 +241,7 @@ static int __net_init nfnetlink_net_init(struct net *net) ...@@ -241,7 +241,7 @@ static int __net_init nfnetlink_net_init(struct net *net)
#endif #endif
}; };
nfnl = netlink_kernel_create(net, NETLINK_NETFILTER, THIS_MODULE, &cfg); nfnl = netlink_kernel_create(net, NETLINK_NETFILTER, &cfg);
if (!nfnl) if (!nfnl)
return -ENOMEM; return -ENOMEM;
net->nfnl_stash = nfnl; net->nfnl_stash = nfnl;
......
...@@ -1526,9 +1526,8 @@ static void netlink_data_ready(struct sock *sk, int len) ...@@ -1526,9 +1526,8 @@ static void netlink_data_ready(struct sock *sk, int len)
*/ */
struct sock * struct sock *
netlink_kernel_create(struct net *net, int unit, __netlink_kernel_create(struct net *net, int unit, struct module *module,
struct module *module, struct netlink_kernel_cfg *cfg)
struct netlink_kernel_cfg *cfg)
{ {
struct socket *sock; struct socket *sock;
struct sock *sk; struct sock *sk;
...@@ -1603,8 +1602,7 @@ netlink_kernel_create(struct net *net, int unit, ...@@ -1603,8 +1602,7 @@ netlink_kernel_create(struct net *net, int unit,
sock_release(sock); sock_release(sock);
return NULL; return NULL;
} }
EXPORT_SYMBOL(netlink_kernel_create); EXPORT_SYMBOL(__netlink_kernel_create);
void void
netlink_kernel_release(struct sock *sk) netlink_kernel_release(struct sock *sk)
......
...@@ -922,8 +922,7 @@ static int __net_init genl_pernet_init(struct net *net) ...@@ -922,8 +922,7 @@ static int __net_init genl_pernet_init(struct net *net)
}; };
/* we'll bump the group number right afterwards */ /* we'll bump the group number right afterwards */
net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, &cfg);
THIS_MODULE, &cfg);
if (!net->genl_sock && net_eq(net, &init_net)) if (!net->genl_sock && net_eq(net, &init_net))
panic("GENL: Cannot initialize generic netlink\n"); panic("GENL: Cannot initialize generic netlink\n");
......
...@@ -2963,7 +2963,7 @@ static int __net_init xfrm_user_net_init(struct net *net) ...@@ -2963,7 +2963,7 @@ static int __net_init xfrm_user_net_init(struct net *net)
.input = xfrm_netlink_rcv, .input = xfrm_netlink_rcv,
}; };
nlsk = netlink_kernel_create(net, NETLINK_XFRM, THIS_MODULE, &cfg); nlsk = netlink_kernel_create(net, NETLINK_XFRM, &cfg);
if (nlsk == NULL) if (nlsk == NULL)
return -ENOMEM; return -ENOMEM;
net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */ net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */
......
...@@ -116,8 +116,7 @@ static int __init selnl_init(void) ...@@ -116,8 +116,7 @@ static int __init selnl_init(void)
.flags = NL_CFG_F_NONROOT_RECV, .flags = NL_CFG_F_NONROOT_RECV,
}; };
selnl = netlink_kernel_create(&init_net, NETLINK_SELINUX, selnl = netlink_kernel_create(&init_net, NETLINK_SELINUX, &cfg);
THIS_MODULE, &cfg);
if (selnl == NULL) if (selnl == NULL)
panic("SELinux: Cannot create netlink socket."); panic("SELinux: Cannot create netlink socket.");
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment