aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-06-29 02:15:21 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-29 19:46:02 -0400
commita31f2d17b331db970259e875b7223d3aba7e3821 (patch)
tree0d10021be81446ab360f4240b0d16729f518387f /net/core
parentdd7f36ba3ce17d4fe85987d83efd5901b0935816 (diff)
netlink: add netlink_kernel_cfg parameter to netlink_kernel_create
This patch adds the following structure: struct netlink_kernel_cfg { unsigned int groups; void (*input)(struct sk_buff *skb); struct mutex *cb_mutex; }; That can be passed to netlink_kernel_create to set optional configurations for netlink kernel sockets. I've populated this structure by looking for NULL and zero parameters at the existing code. The remaining parameters that always need to be set are still left in the original interface. That includes optional parameters for the netlink socket creation. This allows easy extensibility of this interface in the future. This patch also adapts all callers to use this new interface. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/rtnetlink.c9
-rw-r--r--net/core/sock_diag.c8
2 files changed, 13 insertions, 4 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index bc8a1cdaac98..2b325c340b44 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2353,8 +2353,13 @@ static struct notifier_block rtnetlink_dev_notifier = {
2353static int __net_init rtnetlink_net_init(struct net *net) 2353static int __net_init rtnetlink_net_init(struct net *net)
2354{ 2354{
2355 struct sock *sk; 2355 struct sock *sk;
2356 sk = netlink_kernel_create(net, NETLINK_ROUTE, RTNLGRP_MAX, 2356 struct netlink_kernel_cfg cfg = {
2357 rtnetlink_rcv, &rtnl_mutex, THIS_MODULE); 2357 .groups = RTNLGRP_MAX,
2358 .input = rtnetlink_rcv,
2359 .cb_mutex = &rtnl_mutex,
2360 };
2361
2362 sk = netlink_kernel_create(net, NETLINK_ROUTE, THIS_MODULE, &cfg);
2358 if (!sk) 2363 if (!sk)
2359 return -ENOMEM; 2364 return -ENOMEM;
2360 net->rtnl = sk; 2365 net->rtnl = sk;
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index ff2967acbfae..07a29eb34a41 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -171,8 +171,12 @@ EXPORT_SYMBOL_GPL(sock_diag_nlsk);
171 171
172static int __init sock_diag_init(void) 172static int __init sock_diag_init(void)
173{ 173{
174 sock_diag_nlsk = netlink_kernel_create(&init_net, NETLINK_SOCK_DIAG, 0, 174 struct netlink_kernel_cfg cfg = {
175 sock_diag_rcv, NULL, THIS_MODULE); 175 .input = sock_diag_rcv,
176 };
177
178 sock_diag_nlsk = netlink_kernel_create(&init_net, NETLINK_SOCK_DIAG,
179 THIS_MODULE, &cfg);
176 return sock_diag_nlsk == NULL ? -ENOMEM : 0; 180 return sock_diag_nlsk == NULL ? -ENOMEM : 0;
177} 181}
178 182