diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-02-24 09:30:15 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-26 14:10:06 -0500 |
commit | 80d326fab534a5380e8f6e509a0b9076655a9670 (patch) | |
tree | 57c636de934b3f8abb7db9bcde64360ecc4eaf66 | |
parent | 48e316bc2e045206248c6c75c0d5bbc0c9ddc32c (diff) |
netlink: add netlink_dump_control structure for netlink_dump_start()
Davem considers that the argument list of this interface is getting
out of control. This patch tries to address this issue following
his proposal:
struct netlink_dump_control c = { .dump = dump, .done = done, ... };
netlink_dump_start(..., &c);
Suggested by David S. Miller.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | crypto/crypto_user.c | 10 | ||||
-rw-r--r-- | drivers/infiniband/core/netlink.c | 10 | ||||
-rw-r--r-- | include/linux/netlink.h | 10 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 9 | ||||
-rw-r--r-- | net/ipv4/inet_diag.c | 18 | ||||
-rw-r--r-- | net/netfilter/ipset/ip_set_core.c | 10 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 18 | ||||
-rw-r--r-- | net/netfilter/nfnetlink_acct.c | 6 | ||||
-rw-r--r-- | net/netlink/af_netlink.c | 11 | ||||
-rw-r--r-- | net/netlink/genetlink.c | 9 | ||||
-rw-r--r-- | net/unix/diag.c | 10 | ||||
-rw-r--r-- | net/xfrm/xfrm_user.c | 9 |
12 files changed, 87 insertions, 43 deletions
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c index 16f8693cc147..b6ac1387770c 100644 --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c | |||
@@ -389,9 +389,13 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
389 | (nlh->nlmsg_flags & NLM_F_DUMP))) { | 389 | (nlh->nlmsg_flags & NLM_F_DUMP))) { |
390 | if (link->dump == NULL) | 390 | if (link->dump == NULL) |
391 | return -EINVAL; | 391 | return -EINVAL; |
392 | 392 | { | |
393 | return netlink_dump_start(crypto_nlsk, skb, nlh, | 393 | struct netlink_dump_control c = { |
394 | link->dump, link->done, 0); | 394 | .dump = link->dump, |
395 | .done = link->done, | ||
396 | }; | ||
397 | return netlink_dump_start(crypto_nlsk, skb, nlh, &c); | ||
398 | } | ||
395 | } | 399 | } |
396 | 400 | ||
397 | err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX, | 401 | err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX, |
diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c index d1c8196d15d7..396e29370304 100644 --- a/drivers/infiniband/core/netlink.c +++ b/drivers/infiniband/core/netlink.c | |||
@@ -147,9 +147,13 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
147 | if (op < 0 || op >= client->nops || | 147 | if (op < 0 || op >= client->nops || |
148 | !client->cb_table[RDMA_NL_GET_OP(op)].dump) | 148 | !client->cb_table[RDMA_NL_GET_OP(op)].dump) |
149 | return -EINVAL; | 149 | return -EINVAL; |
150 | return netlink_dump_start(nls, skb, nlh, | 150 | |
151 | client->cb_table[op].dump, | 151 | { |
152 | NULL, 0); | 152 | struct netlink_dump_control c = { |
153 | .dump = client->cb_table[op].dump, | ||
154 | }; | ||
155 | return netlink_dump_start(nls, skb, nlh, &c); | ||
156 | } | ||
153 | } | 157 | } |
154 | } | 158 | } |
155 | 159 | ||
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index a390e9d54827..1f8c1a95f57c 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h | |||
@@ -248,11 +248,15 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) | |||
248 | #define NLMSG_PUT(skb, pid, seq, type, len) \ | 248 | #define NLMSG_PUT(skb, pid, seq, type, len) \ |
249 | NLMSG_NEW(skb, pid, seq, type, len, 0) | 249 | NLMSG_NEW(skb, pid, seq, type, len, 0) |
250 | 250 | ||
251 | struct netlink_dump_control { | ||
252 | int (*dump)(struct sk_buff *skb, struct netlink_callback *); | ||
253 | int (*done)(struct netlink_callback*); | ||
254 | u16 min_dump_alloc; | ||
255 | }; | ||
256 | |||
251 | extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | 257 | extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, |
252 | const struct nlmsghdr *nlh, | 258 | const struct nlmsghdr *nlh, |
253 | int (*dump)(struct sk_buff *skb, struct netlink_callback*), | 259 | struct netlink_dump_control *control); |
254 | int (*done)(struct netlink_callback*), | ||
255 | u16 min_dump_alloc); | ||
256 | 260 | ||
257 | 261 | ||
258 | #define NL_NONROOT_RECV 0x1 | 262 | #define NL_NONROOT_RECV 0x1 |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 65aebd450027..7aef62e53113 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -1981,8 +1981,13 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1981 | 1981 | ||
1982 | __rtnl_unlock(); | 1982 | __rtnl_unlock(); |
1983 | rtnl = net->rtnl; | 1983 | rtnl = net->rtnl; |
1984 | err = netlink_dump_start(rtnl, skb, nlh, dumpit, | 1984 | { |
1985 | NULL, min_dump_alloc); | 1985 | struct netlink_dump_control c = { |
1986 | .dump = dumpit, | ||
1987 | .min_dump_alloc = min_dump_alloc, | ||
1988 | }; | ||
1989 | err = netlink_dump_start(rtnl, skb, nlh, &c); | ||
1990 | } | ||
1986 | rtnl_lock(); | 1991 | rtnl_lock(); |
1987 | return err; | 1992 | return err; |
1988 | } | 1993 | } |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index fcf281819cd4..8d25a1c557eb 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -960,9 +960,12 @@ static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
960 | inet_diag_bc_audit(nla_data(attr), nla_len(attr))) | 960 | inet_diag_bc_audit(nla_data(attr), nla_len(attr))) |
961 | return -EINVAL; | 961 | return -EINVAL; |
962 | } | 962 | } |
963 | 963 | { | |
964 | return netlink_dump_start(sock_diag_nlsk, skb, nlh, | 964 | struct netlink_dump_control c = { |
965 | inet_diag_dump_compat, NULL, 0); | 965 | .dump = inet_diag_dump_compat, |
966 | }; | ||
967 | return netlink_dump_start(sock_diag_nlsk, skb, nlh, &c); | ||
968 | } | ||
966 | } | 969 | } |
967 | 970 | ||
968 | return inet_diag_get_exact_compat(skb, nlh); | 971 | return inet_diag_get_exact_compat(skb, nlh); |
@@ -985,9 +988,12 @@ static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) | |||
985 | inet_diag_bc_audit(nla_data(attr), nla_len(attr))) | 988 | inet_diag_bc_audit(nla_data(attr), nla_len(attr))) |
986 | return -EINVAL; | 989 | return -EINVAL; |
987 | } | 990 | } |
988 | 991 | { | |
989 | return netlink_dump_start(sock_diag_nlsk, skb, h, | 992 | struct netlink_dump_control c = { |
990 | inet_diag_dump, NULL, 0); | 993 | .dump = inet_diag_dump, |
994 | }; | ||
995 | return netlink_dump_start(sock_diag_nlsk, skb, h, &c); | ||
996 | } | ||
991 | } | 997 | } |
992 | 998 | ||
993 | return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h)); | 999 | return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h)); |
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index 32dbf0fa89db..e7f90e7082b4 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c | |||
@@ -1162,9 +1162,13 @@ ip_set_dump(struct sock *ctnl, struct sk_buff *skb, | |||
1162 | if (unlikely(protocol_failed(attr))) | 1162 | if (unlikely(protocol_failed(attr))) |
1163 | return -IPSET_ERR_PROTOCOL; | 1163 | return -IPSET_ERR_PROTOCOL; |
1164 | 1164 | ||
1165 | return netlink_dump_start(ctnl, skb, nlh, | 1165 | { |
1166 | ip_set_dump_start, | 1166 | struct netlink_dump_control c = { |
1167 | ip_set_dump_done, 0); | 1167 | .dump = ip_set_dump_start, |
1168 | .done = ip_set_dump_done, | ||
1169 | }; | ||
1170 | return netlink_dump_start(ctnl, skb, nlh, &c); | ||
1171 | } | ||
1168 | } | 1172 | } |
1169 | 1173 | ||
1170 | /* Add, del and test */ | 1174 | /* Add, del and test */ |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 9307b033c0c9..61f7feb7932b 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -977,9 +977,13 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, | |||
977 | u16 zone; | 977 | u16 zone; |
978 | int err; | 978 | int err; |
979 | 979 | ||
980 | if (nlh->nlmsg_flags & NLM_F_DUMP) | 980 | if (nlh->nlmsg_flags & NLM_F_DUMP) { |
981 | return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table, | 981 | struct netlink_dump_control c = { |
982 | ctnetlink_done, 0); | 982 | .dump = ctnetlink_dump_table, |
983 | .done = ctnetlink_done, | ||
984 | }; | ||
985 | return netlink_dump_start(ctnl, skb, nlh, &c); | ||
986 | } | ||
983 | 987 | ||
984 | err = ctnetlink_parse_zone(cda[CTA_ZONE], &zone); | 988 | err = ctnetlink_parse_zone(cda[CTA_ZONE], &zone); |
985 | if (err < 0) | 989 | if (err < 0) |
@@ -1850,9 +1854,11 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, | |||
1850 | int err; | 1854 | int err; |
1851 | 1855 | ||
1852 | if (nlh->nlmsg_flags & NLM_F_DUMP) { | 1856 | if (nlh->nlmsg_flags & NLM_F_DUMP) { |
1853 | return netlink_dump_start(ctnl, skb, nlh, | 1857 | struct netlink_dump_control c = { |
1854 | ctnetlink_exp_dump_table, | 1858 | .dump = ctnetlink_exp_dump_table, |
1855 | ctnetlink_exp_done, 0); | 1859 | .done = ctnetlink_exp_done, |
1860 | }; | ||
1861 | return netlink_dump_start(ctnl, skb, nlh, &c); | ||
1856 | } | 1862 | } |
1857 | 1863 | ||
1858 | err = ctnetlink_parse_zone(cda[CTA_EXPECT_ZONE], &zone); | 1864 | err = ctnetlink_parse_zone(cda[CTA_EXPECT_ZONE], &zone); |
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c index 11ba013e47f6..3eb348bfc4fb 100644 --- a/net/netfilter/nfnetlink_acct.c +++ b/net/netfilter/nfnetlink_acct.c | |||
@@ -171,8 +171,10 @@ nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb, | |||
171 | char *acct_name; | 171 | char *acct_name; |
172 | 172 | ||
173 | if (nlh->nlmsg_flags & NLM_F_DUMP) { | 173 | if (nlh->nlmsg_flags & NLM_F_DUMP) { |
174 | return netlink_dump_start(nfnl, skb, nlh, nfnl_acct_dump, | 174 | struct netlink_dump_control c = { |
175 | NULL, 0); | 175 | .dump = nfnl_acct_dump, |
176 | }; | ||
177 | return netlink_dump_start(nfnl, skb, nlh, &c); | ||
176 | } | 178 | } |
177 | 179 | ||
178 | if (!tb[NFACCT_NAME]) | 180 | if (!tb[NFACCT_NAME]) |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 4d751e3d4b4b..ab74845876d2 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1736,10 +1736,7 @@ errout_skb: | |||
1736 | 1736 | ||
1737 | int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | 1737 | int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, |
1738 | const struct nlmsghdr *nlh, | 1738 | const struct nlmsghdr *nlh, |
1739 | int (*dump)(struct sk_buff *skb, | 1739 | struct netlink_dump_control *control) |
1740 | struct netlink_callback *), | ||
1741 | int (*done)(struct netlink_callback *), | ||
1742 | u16 min_dump_alloc) | ||
1743 | { | 1740 | { |
1744 | struct netlink_callback *cb; | 1741 | struct netlink_callback *cb; |
1745 | struct sock *sk; | 1742 | struct sock *sk; |
@@ -1750,10 +1747,10 @@ int netlink_dump_start(struct sock *ssk, struct sk_buff *skb, | |||
1750 | if (cb == NULL) | 1747 | if (cb == NULL) |
1751 | return -ENOBUFS; | 1748 | return -ENOBUFS; |
1752 | 1749 | ||
1753 | cb->dump = dump; | 1750 | cb->dump = control->dump; |
1754 | cb->done = done; | 1751 | cb->done = control->done; |
1755 | cb->nlh = nlh; | 1752 | cb->nlh = nlh; |
1756 | cb->min_dump_alloc = min_dump_alloc; | 1753 | cb->min_dump_alloc = control->min_dump_alloc; |
1757 | atomic_inc(&skb->users); | 1754 | atomic_inc(&skb->users); |
1758 | cb->skb = skb; | 1755 | cb->skb = skb; |
1759 | 1756 | ||
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index a1154717219e..9f40441d7a7d 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -563,8 +563,13 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
563 | return -EOPNOTSUPP; | 563 | return -EOPNOTSUPP; |
564 | 564 | ||
565 | genl_unlock(); | 565 | genl_unlock(); |
566 | err = netlink_dump_start(net->genl_sock, skb, nlh, | 566 | { |
567 | ops->dumpit, ops->done, 0); | 567 | struct netlink_dump_control c = { |
568 | .dump = ops->dumpit, | ||
569 | .done = ops->done, | ||
570 | }; | ||
571 | err = netlink_dump_start(net->genl_sock, skb, nlh, &c); | ||
572 | } | ||
568 | genl_lock(); | 573 | genl_lock(); |
569 | return err; | 574 | return err; |
570 | } | 575 | } |
diff --git a/net/unix/diag.c b/net/unix/diag.c index 6b7697fd911b..4195555aea65 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c | |||
@@ -301,10 +301,12 @@ static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) | |||
301 | if (nlmsg_len(h) < hdrlen) | 301 | if (nlmsg_len(h) < hdrlen) |
302 | return -EINVAL; | 302 | return -EINVAL; |
303 | 303 | ||
304 | if (h->nlmsg_flags & NLM_F_DUMP) | 304 | if (h->nlmsg_flags & NLM_F_DUMP) { |
305 | return netlink_dump_start(sock_diag_nlsk, skb, h, | 305 | struct netlink_dump_control c = { |
306 | unix_diag_dump, NULL, 0); | 306 | .dump = unix_diag_dump, |
307 | else | 307 | }; |
308 | return netlink_dump_start(sock_diag_nlsk, skb, h, &c); | ||
309 | } else | ||
308 | return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h)); | 310 | return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h)); |
309 | } | 311 | } |
310 | 312 | ||
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 66b84fbf2746..7128dde0fe1a 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -2299,8 +2299,13 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
2299 | if (link->dump == NULL) | 2299 | if (link->dump == NULL) |
2300 | return -EINVAL; | 2300 | return -EINVAL; |
2301 | 2301 | ||
2302 | return netlink_dump_start(net->xfrm.nlsk, skb, nlh, | 2302 | { |
2303 | link->dump, link->done, 0); | 2303 | struct netlink_dump_control c = { |
2304 | .dump = link->dump, | ||
2305 | .done = link->done, | ||
2306 | }; | ||
2307 | return netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c); | ||
2308 | } | ||
2304 | } | 2309 | } |
2305 | 2310 | ||
2306 | err = nlmsg_parse(nlh, xfrm_msg_min[type], attrs, XFRMA_MAX, | 2311 | err = nlmsg_parse(nlh, xfrm_msg_min[type], attrs, XFRMA_MAX, |