Commit efb3cb42 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

inet_diag: Split inet_diag_get_exact into parts

Similar to previous patch: the 1st part locks the inet handler
and will get generalized and the 2nd one dumps icsk-s and will
be used by TCP and DCCP handlers.
Signed-off-by: default avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 476f7dbf
...@@ -709,19 +709,11 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, ...@@ -709,19 +709,11 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
return err; return err;
} }
static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, static void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
struct inet_diag_req *r, struct nlattr *bc) struct netlink_callback *cb, struct inet_diag_req *r, struct nlattr *bc)
{ {
int i, num; int i, num;
int s_i, s_num; int s_i, s_num;
const struct inet_diag_handler *handler;
struct inet_hashinfo *hashinfo;
handler = inet_diag_lock_handler(r->sdiag_protocol);
if (IS_ERR(handler))
goto unlock;
hashinfo = handler->idiag_hashinfo;
s_i = cb->args[1]; s_i = cb->args[1];
s_num = num = cb->args[2]; s_num = num = cb->args[2];
...@@ -790,7 +782,7 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -790,7 +782,7 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
} }
if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV))) if (!(r->idiag_states & ~(TCPF_LISTEN | TCPF_SYN_RECV)))
goto unlock; goto out;
for (i = s_i; i <= hashinfo->ehash_mask; i++) { for (i = s_i; i <= hashinfo->ehash_mask; i++) {
struct inet_ehash_bucket *head = &hashinfo->ehash[i]; struct inet_ehash_bucket *head = &hashinfo->ehash[i];
...@@ -863,8 +855,20 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -863,8 +855,20 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
done: done:
cb->args[1] = i; cb->args[1] = i;
cb->args[2] = num; cb->args[2] = num;
unlock: out:
;
}
static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
struct inet_diag_req *r, struct nlattr *bc)
{
const struct inet_diag_handler *handler;
handler = inet_diag_lock_handler(r->sdiag_protocol);
if (!IS_ERR(handler))
inet_diag_dump_icsk(handler->idiag_hashinfo, skb, cb, r, bc);
inet_diag_unlock_handler(handler); inet_diag_unlock_handler(handler);
return skb->len; return skb->len;
} }
......
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