mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
net: diag: Support SOCK_DESTROY for inet sockets.
This passes the SOCK_DESTROY operation to the underlying protocol diag handler, or returns -EOPNOTSUPP if that handler does not define a destroy operation. Most of this patch is just renaming functions. This is not strictly necessary, but it would be fairly counterintuitive to have the code to destroy inet sockets be in a function whose name starts with inet_diag_get. [Backport of net-next 6eb5d2e08f071c05ecbe135369c9ad418826cab2] Change-Id: I70a700ec66e0ea8526a17137ba6cb5a3f2dce45f Signed-off-by: Lorenzo Colitti <lorenzo@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2f68f939e1
commit
3975e500c0
2 changed files with 20 additions and 8 deletions
|
@ -154,6 +154,10 @@ struct inet_diag_handler {
|
|||
void (*idiag_get_info)(struct sock *sk,
|
||||
struct inet_diag_msg *r,
|
||||
void *info);
|
||||
|
||||
int (*destroy)(struct sk_buff *in_skb,
|
||||
struct inet_diag_req_v2 *req);
|
||||
|
||||
__u16 idiag_type;
|
||||
};
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ out:
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(inet_diag_dump_one_icsk);
|
||||
|
||||
static int inet_diag_get_exact(struct sk_buff *in_skb,
|
||||
static int inet_diag_cmd_exact(int cmd, struct sk_buff *in_skb,
|
||||
const struct nlmsghdr *nlh,
|
||||
struct inet_diag_req_v2 *req)
|
||||
{
|
||||
|
@ -370,8 +370,12 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
|
|||
handler = inet_diag_lock_handler(req->sdiag_protocol);
|
||||
if (IS_ERR(handler))
|
||||
err = PTR_ERR(handler);
|
||||
else
|
||||
else if (cmd == SOCK_DIAG_BY_FAMILY)
|
||||
err = handler->dump_one(in_skb, nlh, req);
|
||||
else if (cmd == SOCK_DESTROY_BACKPORT && handler->destroy)
|
||||
err = handler->destroy(in_skb, req);
|
||||
else
|
||||
err = -EOPNOTSUPP;
|
||||
inet_diag_unlock_handler(handler);
|
||||
|
||||
return err;
|
||||
|
@ -971,7 +975,7 @@ static int inet_diag_get_exact_compat(struct sk_buff *in_skb,
|
|||
req.idiag_states = rc->idiag_states;
|
||||
req.id = rc->id;
|
||||
|
||||
return inet_diag_get_exact(in_skb, nlh, &req);
|
||||
return inet_diag_cmd_exact(SOCK_DIAG_BY_FAMILY, in_skb, nlh, &req);
|
||||
}
|
||||
|
||||
static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
|
||||
|
@ -1004,14 +1008,15 @@ static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
|
|||
return inet_diag_get_exact_compat(skb, nlh);
|
||||
}
|
||||
|
||||
static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
|
||||
static int inet_diag_handler_cmd(struct sk_buff *skb, struct nlmsghdr *h)
|
||||
{
|
||||
int hdrlen = sizeof(struct inet_diag_req_v2);
|
||||
|
||||
if (nlmsg_len(h) < hdrlen)
|
||||
return -EINVAL;
|
||||
|
||||
if (h->nlmsg_flags & NLM_F_DUMP) {
|
||||
if (h->nlmsg_type == SOCK_DIAG_BY_FAMILY &&
|
||||
h->nlmsg_flags & NLM_F_DUMP) {
|
||||
if (nlmsg_attrlen(h, hdrlen)) {
|
||||
struct nlattr *attr;
|
||||
attr = nlmsg_find_attr(h, hdrlen,
|
||||
|
@ -1029,17 +1034,20 @@ static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
|
|||
}
|
||||
}
|
||||
|
||||
return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h));
|
||||
return inet_diag_cmd_exact(h->nlmsg_type, skb, h,
|
||||
(struct inet_diag_req_v2 *)NLMSG_DATA(h));
|
||||
}
|
||||
|
||||
static struct sock_diag_handler inet_diag_handler = {
|
||||
.family = AF_INET,
|
||||
.dump = inet_diag_handler_dump,
|
||||
.dump = inet_diag_handler_cmd,
|
||||
.destroy = inet_diag_handler_cmd,
|
||||
};
|
||||
|
||||
static struct sock_diag_handler inet6_diag_handler = {
|
||||
.family = AF_INET6,
|
||||
.dump = inet_diag_handler_dump,
|
||||
.dump = inet_diag_handler_cmd,
|
||||
.destroy = inet_diag_handler_cmd,
|
||||
};
|
||||
|
||||
int inet_diag_register(const struct inet_diag_handler *h)
|
||||
|
|
Loading…
Reference in a new issue