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

inet_diag: Split inet_diag_get_exact into parts

The 1st part locks the inet handler and the 2nd one dump the
inet connection sock.

In the next patches the 1st part will be generalized to call
the socket dumping routine indirectly (i.e. TCP/UDP/DCCP) and
the 2nd part 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 b005ab4e
...@@ -258,25 +258,14 @@ int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req) ...@@ -258,25 +258,14 @@ int inet_diag_check_cookie(struct sock *sk, struct inet_diag_req *req)
} }
EXPORT_SYMBOL_GPL(inet_diag_check_cookie); EXPORT_SYMBOL_GPL(inet_diag_check_cookie);
static int inet_diag_get_exact(struct sk_buff *in_skb, static int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_skb,
const struct nlmsghdr *nlh, const struct nlmsghdr *nlh, struct inet_diag_req *req)
struct inet_diag_req *req)
{ {
int err; int err;
struct sock *sk; struct sock *sk;
struct sk_buff *rep; struct sk_buff *rep;
struct inet_hashinfo *hashinfo;
const struct inet_diag_handler *handler;
handler = inet_diag_lock_handler(req->sdiag_protocol);
if (IS_ERR(handler)) {
err = PTR_ERR(handler);
goto unlock;
}
hashinfo = handler->idiag_hashinfo;
err = -EINVAL; err = -EINVAL;
if (req->sdiag_family == AF_INET) { if (req->sdiag_family == AF_INET) {
sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0], sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
req->id.idiag_dport, req->id.idiag_src[0], req->id.idiag_dport, req->id.idiag_src[0],
...@@ -293,12 +282,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb, ...@@ -293,12 +282,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
} }
#endif #endif
else { else {
goto unlock; goto out_nosk;
} }
err = -ENOENT; err = -ENOENT;
if (sk == NULL) if (sk == NULL)
goto unlock; goto out_nosk;
err = inet_diag_check_cookie(sk, req); err = inet_diag_check_cookie(sk, req);
if (err) if (err)
...@@ -332,8 +321,25 @@ static int inet_diag_get_exact(struct sk_buff *in_skb, ...@@ -332,8 +321,25 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
else else
sock_put(sk); sock_put(sk);
} }
unlock: out_nosk:
return err;
}
static int inet_diag_get_exact(struct sk_buff *in_skb,
const struct nlmsghdr *nlh,
struct inet_diag_req *req)
{
const struct inet_diag_handler *handler;
int err;
handler = inet_diag_lock_handler(req->sdiag_protocol);
if (IS_ERR(handler))
err = PTR_ERR(handler);
else
err = inet_diag_dump_one_icsk(handler->idiag_hashinfo,
in_skb, nlh, req);
inet_diag_unlock_handler(handler); inet_diag_unlock_handler(handler);
return err; return err;
} }
......
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