aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-01-09 17:56:56 -0500
committerDavid S. Miller <davem@davemloft.net>2006-01-09 17:56:56 -0500
commitdff2c03534f525813342ab8dec90c5bb1ee07471 (patch)
tree8aaf683cb0cd09ef5f2f79b3ca3df76e4caebded /net/ipv4
parentc7d58aabdc08aea92d6c5e01dcd7473a74b3642c (diff)
[INET_DIAG]: Introduce sk_diag_fill
To be called from inet_diag_get_exact, also rename inet_diag_fill to inet_csk_diag_fill, for consistency with inet_twsk_diag_fill. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/inet_diag.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 985c5730e4fb..457db99c76df 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -50,9 +50,10 @@ static struct sock *idiagnl;
50#define INET_DIAG_PUT(skb, attrtype, attrlen) \ 50#define INET_DIAG_PUT(skb, attrtype, attrlen) \
51 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen)) 51 RTA_DATA(__RTA_PUT(skb, attrtype, attrlen))
52 52
53static int inet_diag_fill(struct sk_buff *skb, struct sock *sk, 53static int inet_csk_diag_fill(struct sock *sk,
54 int ext, u32 pid, u32 seq, u16 nlmsg_flags, 54 struct sk_buff *skb,
55 const struct nlmsghdr *unlh) 55 int ext, u32 pid, u32 seq, u16 nlmsg_flags,
56 const struct nlmsghdr *unlh)
56{ 57{
57 const struct inet_sock *inet = inet_sk(sk); 58 const struct inet_sock *inet = inet_sk(sk);
58 const struct inet_connection_sock *icsk = inet_csk(sk); 59 const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -212,6 +213,17 @@ nlmsg_failure:
212 return -1; 213 return -1;
213} 214}
214 215
216static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
217 int ext, u32 pid, u32 seq, u16 nlmsg_flags,
218 const struct nlmsghdr *unlh)
219{
220 if (sk->sk_state == TCP_TIME_WAIT)
221 return inet_twsk_diag_fill((struct inet_timewait_sock *)sk,
222 skb, ext, pid, seq, nlmsg_flags,
223 unlh);
224 return inet_csk_diag_fill(sk, skb, ext, pid, seq, nlmsg_flags, unlh);
225}
226
215static int inet_diag_get_exact(struct sk_buff *in_skb, 227static int inet_diag_get_exact(struct sk_buff *in_skb,
216 const struct nlmsghdr *nlh) 228 const struct nlmsghdr *nlh)
217{ 229{
@@ -263,7 +275,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
263 if (!rep) 275 if (!rep)
264 goto out; 276 goto out;
265 277
266 if (inet_diag_fill(rep, sk, req->idiag_ext, 278 if (sk_diag_fill(sk, rep, req->idiag_ext,
267 NETLINK_CB(in_skb).pid, 279 NETLINK_CB(in_skb).pid,
268 nlh->nlmsg_seq, 0, nlh) <= 0) 280 nlh->nlmsg_seq, 0, nlh) <= 0)
269 BUG(); 281 BUG();
@@ -442,8 +454,9 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
442 return len == 0 ? 0 : -EINVAL; 454 return len == 0 ? 0 : -EINVAL;
443} 455}
444 456
445static int inet_diag_dump_sock(struct sk_buff *skb, struct sock *sk, 457static int inet_csk_diag_dump(struct sock *sk,
446 struct netlink_callback *cb) 458 struct sk_buff *skb,
459 struct netlink_callback *cb)
447{ 460{
448 struct inet_diag_req *r = NLMSG_DATA(cb->nlh); 461 struct inet_diag_req *r = NLMSG_DATA(cb->nlh);
449 462
@@ -473,8 +486,9 @@ static int inet_diag_dump_sock(struct sk_buff *skb, struct sock *sk,
473 return 0; 486 return 0;
474 } 487 }
475 488
476 return inet_diag_fill(skb, sk, r->idiag_ext, NETLINK_CB(cb->skb).pid, 489 return inet_csk_diag_fill(sk, skb, r->idiag_ext,
477 cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh); 490 NETLINK_CB(cb->skb).pid,
491 cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh);
478} 492}
479 493
480static int inet_twsk_diag_dump(struct inet_timewait_sock *tw, 494static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
@@ -694,7 +708,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
694 cb->args[3] > 0) 708 cb->args[3] > 0)
695 goto syn_recv; 709 goto syn_recv;
696 710
697 if (inet_diag_dump_sock(skb, sk, cb) < 0) { 711 if (inet_csk_diag_dump(sk, skb, cb) < 0) {
698 inet_listen_unlock(hashinfo); 712 inet_listen_unlock(hashinfo);
699 goto done; 713 goto done;
700 } 714 }
@@ -750,7 +764,7 @@ skip_listen_ht:
750 if (r->id.idiag_dport != inet->dport && 764 if (r->id.idiag_dport != inet->dport &&
751 r->id.idiag_dport) 765 r->id.idiag_dport)
752 goto next_normal; 766 goto next_normal;
753 if (inet_diag_dump_sock(skb, sk, cb) < 0) { 767 if (inet_csk_diag_dump(sk, skb, cb) < 0) {
754 read_unlock_bh(&head->lock); 768 read_unlock_bh(&head->lock);
755 goto done; 769 goto done;
756 } 770 }