Commit 06628607 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETLINK]: Add "groups" argument to netlink_kernel_create

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9a4595bc
...@@ -88,7 +88,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, ...@@ -88,7 +88,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
dev->groups = 1; dev->groups = 1;
dev->seq = 1; dev->seq = 1;
dev->nls = netlink_kernel_create(NETLINK_W1, NULL, THIS_MODULE); dev->nls = netlink_kernel_create(NETLINK_W1, 1, NULL, THIS_MODULE);
if (!dev->nls) { if (!dev->nls) {
printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n", printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
NETLINK_NFLOG, dev->dev.bus_id); NETLINK_NFLOG, dev->dev.bus_id);
......
...@@ -125,7 +125,7 @@ struct netlink_skb_parms ...@@ -125,7 +125,7 @@ struct netlink_skb_parms
#define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds) #define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)
extern struct sock *netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len), struct module *module); extern struct sock *netlink_kernel_create(int unit, unsigned int groups, void (*input)(struct sock *sk, int len), struct module *module);
extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock); extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid, extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
......
...@@ -514,7 +514,7 @@ static int __init audit_init(void) ...@@ -514,7 +514,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(NETLINK_AUDIT, audit_receive, audit_sock = netlink_kernel_create(NETLINK_AUDIT, 0, audit_receive,
THIS_MODULE); THIS_MODULE);
if (!audit_sock) if (!audit_sock)
audit_panic("cannot initialize netlink socket"); audit_panic("cannot initialize netlink socket");
......
...@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(kobject_uevent_atomic); ...@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(kobject_uevent_atomic);
static int __init kobject_uevent_init(void) static int __init kobject_uevent_init(void)
{ {
uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, NULL, uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL,
THIS_MODULE); THIS_MODULE);
if (!uevent_sock) { if (!uevent_sock) {
......
...@@ -258,7 +258,8 @@ static int __init init(void) ...@@ -258,7 +258,8 @@ static int __init init(void)
spin_lock_init(&ulog_buffers[i].lock); spin_lock_init(&ulog_buffers[i].lock);
} }
ebtulognl = netlink_kernel_create(NETLINK_NFLOG, NULL, THIS_MODULE); ebtulognl = netlink_kernel_create(NETLINK_NFLOG, EBT_ULOG_MAXNLGROUPS,
NULL, THIS_MODULE);
if (!ebtulognl) if (!ebtulognl)
ret = -ENOMEM; ret = -ENOMEM;
else if ((ret = ebt_register_watcher(&ulog))) else if ((ret = ebt_register_watcher(&ulog)))
......
...@@ -708,7 +708,8 @@ void __init rtnetlink_init(void) ...@@ -708,7 +708,8 @@ void __init rtnetlink_init(void)
if (!rta_buf) if (!rta_buf)
panic("rtnetlink_init: cannot allocate rta_buf\n"); panic("rtnetlink_init: cannot allocate rta_buf\n");
rtnl = netlink_kernel_create(NETLINK_ROUTE, rtnetlink_rcv, THIS_MODULE); rtnl = netlink_kernel_create(NETLINK_ROUTE, RTNLGRP_MAX, rtnetlink_rcv,
THIS_MODULE);
if (rtnl == NULL) if (rtnl == NULL)
panic("rtnetlink_init: cannot initialize rtnetlink\n"); panic("rtnetlink_init: cannot initialize rtnetlink\n");
netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV); netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
......
...@@ -138,8 +138,8 @@ static int __init init(void) ...@@ -138,8 +138,8 @@ static int __init init(void)
{ {
int rv = 0; int rv = 0;
dnrmg = netlink_kernel_create(NETLINK_DNRTMSG, dnrmg_receive_user_sk, dnrmg = netlink_kernel_create(NETLINK_DNRTMSG, DNRNG_NLGRP_MAX,
THIS_MODULE); dnrmg_receive_user_sk, THIS_MODULE);
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;
......
...@@ -566,7 +566,7 @@ static void nl_fib_input(struct sock *sk, int len) ...@@ -566,7 +566,7 @@ static void nl_fib_input(struct sock *sk, int len)
static void nl_fib_lookup_init(void) static void nl_fib_lookup_init(void)
{ {
netlink_kernel_create(NETLINK_FIB_LOOKUP, nl_fib_input, THIS_MODULE); netlink_kernel_create(NETLINK_FIB_LOOKUP, 0, nl_fib_input, THIS_MODULE);
} }
static void fib_disable_ip(struct net_device *dev, int force) static void fib_disable_ip(struct net_device *dev, int force)
......
...@@ -845,7 +845,7 @@ static int __init inet_diag_init(void) ...@@ -845,7 +845,7 @@ static int __init inet_diag_init(void)
goto out; goto out;
memset(inet_diag_table, 0, inet_diag_table_size); memset(inet_diag_table, 0, inet_diag_table_size);
idiagnl = netlink_kernel_create(NETLINK_INET_DIAG, inet_diag_rcv, idiagnl = netlink_kernel_create(NETLINK_INET_DIAG, 0, inet_diag_rcv,
THIS_MODULE); THIS_MODULE);
if (idiagnl == NULL) if (idiagnl == NULL)
goto out_free_table; goto out_free_table;
......
...@@ -671,7 +671,7 @@ init_or_cleanup(int init) ...@@ -671,7 +671,7 @@ init_or_cleanup(int init)
goto cleanup; goto cleanup;
netlink_register_notifier(&ipq_nl_notifier); netlink_register_notifier(&ipq_nl_notifier);
ipqnl = netlink_kernel_create(NETLINK_FIREWALL, ipq_rcv_sk, ipqnl = netlink_kernel_create(NETLINK_FIREWALL, 0, ipq_rcv_sk,
THIS_MODULE); THIS_MODULE);
if (ipqnl == NULL) { if (ipqnl == NULL) {
printk(KERN_ERR "ip_queue: failed to create netlink socket\n"); printk(KERN_ERR "ip_queue: failed to create netlink socket\n");
......
...@@ -388,7 +388,8 @@ static int __init init(void) ...@@ -388,7 +388,8 @@ static int __init init(void)
ulog_buffers[i].timer.data = i; ulog_buffers[i].timer.data = i;
} }
nflognl = netlink_kernel_create(NETLINK_NFLOG, NULL, THIS_MODULE); nflognl = netlink_kernel_create(NETLINK_NFLOG, ULOG_MAXNLGROUPS, NULL,
THIS_MODULE);
if (!nflognl) if (!nflognl)
return -ENOMEM; return -ENOMEM;
......
...@@ -667,7 +667,8 @@ init_or_cleanup(int init) ...@@ -667,7 +667,8 @@ init_or_cleanup(int init)
goto cleanup; goto cleanup;
netlink_register_notifier(&ipq_nl_notifier); netlink_register_notifier(&ipq_nl_notifier);
ipqnl = netlink_kernel_create(NETLINK_IP6_FW, ipq_rcv_sk, THIS_MODULE); ipqnl = netlink_kernel_create(NETLINK_IP6_FW, 0, ipq_rcv_sk,
THIS_MODULE);
if (ipqnl == NULL) { if (ipqnl == NULL) {
printk(KERN_ERR "ip6_queue: failed to create netlink socket\n"); printk(KERN_ERR "ip6_queue: failed to create netlink socket\n");
goto cleanup_netlink_notifier; goto cleanup_netlink_notifier;
......
...@@ -355,8 +355,8 @@ int __init nfnetlink_init(void) ...@@ -355,8 +355,8 @@ int __init nfnetlink_init(void)
{ {
printk("Netfilter messages via NETLINK v%s.\n", nfversion); printk("Netfilter messages via NETLINK v%s.\n", nfversion);
nfnl = netlink_kernel_create(NETLINK_NETFILTER, nfnetlink_rcv, nfnl = netlink_kernel_create(NETLINK_NETFILTER, NFNLGRP_MAX,
THIS_MODULE); nfnetlink_rcv, THIS_MODULE);
if (!nfnl) { if (!nfnl) {
printk(KERN_ERR "cannot initialize nfnetlink!\n"); printk(KERN_ERR "cannot initialize nfnetlink!\n");
return -1; return -1;
......
...@@ -1204,7 +1204,9 @@ static void netlink_data_ready(struct sock *sk, int len) ...@@ -1204,7 +1204,9 @@ static void netlink_data_ready(struct sock *sk, int len)
*/ */
struct sock * struct sock *
netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len), struct module *module) netlink_kernel_create(int unit, unsigned int groups,
void (*input)(struct sock *sk, int len),
struct module *module)
{ {
struct socket *sock; struct socket *sock;
struct sock *sk; struct sock *sk;
...@@ -1234,7 +1236,7 @@ netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len), struct ...@@ -1234,7 +1236,7 @@ netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len), struct
nlk->flags |= NETLINK_KERNEL_SOCKET; nlk->flags |= NETLINK_KERNEL_SOCKET;
netlink_table_grab(); netlink_table_grab();
nl_table[unit].groups = 32; nl_table[unit].groups = groups < 32 ? 32 : groups;
nl_table[unit].module = module; nl_table[unit].module = module;
nl_table[unit].registered = 1; nl_table[unit].registered = 1;
netlink_table_ungrab(); netlink_table_ungrab();
......
...@@ -1520,8 +1520,8 @@ static int __init xfrm_user_init(void) ...@@ -1520,8 +1520,8 @@ static int __init xfrm_user_init(void)
{ {
printk(KERN_INFO "Initializing IPsec netlink socket\n"); printk(KERN_INFO "Initializing IPsec netlink socket\n");
xfrm_nl = netlink_kernel_create(NETLINK_XFRM, xfrm_netlink_rcv, xfrm_nl = netlink_kernel_create(NETLINK_XFRM, XFRMNLGRP_MAX,
THIS_MODULE); xfrm_netlink_rcv, THIS_MODULE);
if (xfrm_nl == NULL) if (xfrm_nl == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -104,7 +104,8 @@ void selnl_notify_policyload(u32 seqno) ...@@ -104,7 +104,8 @@ void selnl_notify_policyload(u32 seqno)
static int __init selnl_init(void) static int __init selnl_init(void)
{ {
selnl = netlink_kernel_create(NETLINK_SELINUX, NULL, THIS_MODULE); selnl = netlink_kernel_create(NETLINK_SELINUX, SELNLGRP_MAX, NULL,
THIS_MODULE);
if (selnl == NULL) if (selnl == NULL)
panic("SELinux: Cannot create netlink socket."); panic("SELinux: Cannot create netlink socket.");
netlink_set_nonroot(NETLINK_SELINUX, NL_NONROOT_RECV); netlink_set_nonroot(NETLINK_SELINUX, NL_NONROOT_RECV);
......
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