aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2011-12-09 01:23:18 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-09 14:14:08 -0500
commit1942c518ca017f376b267a7c5e78c15d37202442 (patch)
tree9ead5443adf15f2264240c928ff2514349fdcade /net/ipv4
parent3c4d05c8056724aff3abc20650807dd828fded54 (diff)
inet_diag: Generalize inet_diag dump and get_exact calls
Introduce two callbacks in inet_diag_handler -- one for dumping all sockets (with filters) and the other one for dumping a single sk. Replace direct calls to icsk handlers with indirect calls to callbacks provided by handlers. Make existing TCP and DCCP handlers use provided helpers for icsk-s. The UDP diag module will provide its own. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/inet_diag.c11
-rw-r--r--net/ipv4/tcp_diag.c15
2 files changed, 20 insertions, 6 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index dc8611e3e66f..9b3e0b179cd2 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -273,7 +273,7 @@ int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req)
273} 273}
274EXPORT_SYMBOL_GPL(inet_diag_check_cookie); 274EXPORT_SYMBOL_GPL(inet_diag_check_cookie);
275 275
276static int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_skb, 276int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_skb,
277 const struct nlmsghdr *nlh, struct inet_diag_req *req) 277 const struct nlmsghdr *nlh, struct inet_diag_req *req)
278{ 278{
279 int err; 279 int err;
@@ -339,6 +339,7 @@ out:
339out_nosk: 339out_nosk:
340 return err; 340 return err;
341} 341}
342EXPORT_SYMBOL_GPL(inet_diag_dump_one_icsk);
342 343
343static int inet_diag_get_exact(struct sk_buff *in_skb, 344static int inet_diag_get_exact(struct sk_buff *in_skb,
344 const struct nlmsghdr *nlh, 345 const struct nlmsghdr *nlh,
@@ -351,8 +352,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
351 if (IS_ERR(handler)) 352 if (IS_ERR(handler))
352 err = PTR_ERR(handler); 353 err = PTR_ERR(handler);
353 else 354 else
354 err = inet_diag_dump_one_icsk(handler->idiag_hashinfo, 355 err = handler->dump_one(in_skb, nlh, req);
355 in_skb, nlh, req);
356 inet_diag_unlock_handler(handler); 356 inet_diag_unlock_handler(handler);
357 357
358 return err; 358 return err;
@@ -731,7 +731,7 @@ out:
731 return err; 731 return err;
732} 732}
733 733
734static void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb, 734void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
735 struct netlink_callback *cb, struct inet_diag_req *r, struct nlattr *bc) 735 struct netlink_callback *cb, struct inet_diag_req *r, struct nlattr *bc)
736{ 736{
737 int i, num; 737 int i, num;
@@ -880,6 +880,7 @@ done:
880out: 880out:
881 ; 881 ;
882} 882}
883EXPORT_SYMBOL_GPL(inet_diag_dump_icsk);
883 884
884static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 885static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
885 struct inet_diag_req *r, struct nlattr *bc) 886 struct inet_diag_req *r, struct nlattr *bc)
@@ -888,7 +889,7 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
888 889
889 handler = inet_diag_lock_handler(r->sdiag_protocol); 890 handler = inet_diag_lock_handler(r->sdiag_protocol);
890 if (!IS_ERR(handler)) 891 if (!IS_ERR(handler))
891 inet_diag_dump_icsk(handler->idiag_hashinfo, skb, cb, r, bc); 892 handler->dump(skb, cb, r, bc);
892 inet_diag_unlock_handler(handler); 893 inet_diag_unlock_handler(handler);
893 894
894 return skb->len; 895 return skb->len;
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 42e6bec7bd3e..6334b1f71f2d 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -34,8 +34,21 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
34 tcp_get_info(sk, info); 34 tcp_get_info(sk, info);
35} 35}
36 36
37static void tcp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
38 struct inet_diag_req *r, struct nlattr *bc)
39{
40 inet_diag_dump_icsk(&tcp_hashinfo, skb, cb, r, bc);
41}
42
43static int tcp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
44 struct inet_diag_req *req)
45{
46 return inet_diag_dump_one_icsk(&tcp_hashinfo, in_skb, nlh, req);
47}
48
37static const struct inet_diag_handler tcp_diag_handler = { 49static const struct inet_diag_handler tcp_diag_handler = {
38 .idiag_hashinfo = &tcp_hashinfo, 50 .dump = tcp_diag_dump,
51 .dump_one = tcp_diag_dump_one,
39 .idiag_get_info = tcp_diag_get_info, 52 .idiag_get_info = tcp_diag_get_info,
40 .idiag_type = IPPROTO_TCP, 53 .idiag_type = IPPROTO_TCP,
41}; 54};