unix_diag: Move away from NLMSG_PUT().
And use nlmsg_data() while we're here too and remove useless casts. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -126,10 +126,12 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
|
|||||||
struct nlmsghdr *nlh;
|
struct nlmsghdr *nlh;
|
||||||
struct unix_diag_msg *rep;
|
struct unix_diag_msg *rep;
|
||||||
|
|
||||||
nlh = NLMSG_PUT(skb, pid, seq, SOCK_DIAG_BY_FAMILY, sizeof(*rep));
|
nlh = nlmsg_put(skb, pid, seq, SOCK_DIAG_BY_FAMILY, sizeof(*rep), 0);
|
||||||
|
if (!nlh)
|
||||||
|
goto out_nlmsg_trim;
|
||||||
nlh->nlmsg_flags = flags;
|
nlh->nlmsg_flags = flags;
|
||||||
|
|
||||||
rep = NLMSG_DATA(nlh);
|
rep = nlmsg_data(nlh);
|
||||||
|
|
||||||
rep->udiag_family = AF_UNIX;
|
rep->udiag_family = AF_UNIX;
|
||||||
rep->udiag_type = sk->sk_type;
|
rep->udiag_type = sk->sk_type;
|
||||||
@@ -139,32 +141,32 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
|
|||||||
|
|
||||||
if ((req->udiag_show & UDIAG_SHOW_NAME) &&
|
if ((req->udiag_show & UDIAG_SHOW_NAME) &&
|
||||||
sk_diag_dump_name(sk, skb))
|
sk_diag_dump_name(sk, skb))
|
||||||
goto nlmsg_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
if ((req->udiag_show & UDIAG_SHOW_VFS) &&
|
if ((req->udiag_show & UDIAG_SHOW_VFS) &&
|
||||||
sk_diag_dump_vfs(sk, skb))
|
sk_diag_dump_vfs(sk, skb))
|
||||||
goto nlmsg_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
if ((req->udiag_show & UDIAG_SHOW_PEER) &&
|
if ((req->udiag_show & UDIAG_SHOW_PEER) &&
|
||||||
sk_diag_dump_peer(sk, skb))
|
sk_diag_dump_peer(sk, skb))
|
||||||
goto nlmsg_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
if ((req->udiag_show & UDIAG_SHOW_ICONS) &&
|
if ((req->udiag_show & UDIAG_SHOW_ICONS) &&
|
||||||
sk_diag_dump_icons(sk, skb))
|
sk_diag_dump_icons(sk, skb))
|
||||||
goto nlmsg_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
if ((req->udiag_show & UDIAG_SHOW_RQLEN) &&
|
if ((req->udiag_show & UDIAG_SHOW_RQLEN) &&
|
||||||
sk_diag_show_rqlen(sk, skb))
|
sk_diag_show_rqlen(sk, skb))
|
||||||
goto nlmsg_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
if ((req->udiag_show & UDIAG_SHOW_MEMINFO) &&
|
if ((req->udiag_show & UDIAG_SHOW_MEMINFO) &&
|
||||||
sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO))
|
sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO))
|
||||||
goto nlmsg_failure;
|
goto out_nlmsg_trim;
|
||||||
|
|
||||||
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
|
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
|
||||||
return skb->len;
|
return skb->len;
|
||||||
|
|
||||||
nlmsg_failure:
|
out_nlmsg_trim:
|
||||||
nlmsg_trim(skb, b);
|
nlmsg_trim(skb, b);
|
||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
}
|
}
|
||||||
@@ -189,7 +191,7 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
struct unix_diag_req *req;
|
struct unix_diag_req *req;
|
||||||
int num, s_num, slot, s_slot;
|
int num, s_num, slot, s_slot;
|
||||||
|
|
||||||
req = NLMSG_DATA(cb->nlh);
|
req = nlmsg_data(cb->nlh);
|
||||||
|
|
||||||
s_slot = cb->args[0];
|
s_slot = cb->args[0];
|
||||||
num = s_num = cb->args[1];
|
num = s_num = cb->args[1];
|
||||||
@@ -309,7 +311,7 @@ static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
|
|||||||
};
|
};
|
||||||
return netlink_dump_start(sock_diag_nlsk, skb, h, &c);
|
return netlink_dump_start(sock_diag_nlsk, skb, h, &c);
|
||||||
} else
|
} else
|
||||||
return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h));
|
return unix_diag_get_exact(skb, h, nlmsg_data(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct sock_diag_handler unix_diag_handler = {
|
static const struct sock_diag_handler unix_diag_handler = {
|
||||||
|
Reference in New Issue
Block a user