Commit 62ad6fcd authored by Shan Wei's avatar Shan Wei Committed by David S. Miller

udp_diag: implement idiag_get_info for udp/udplite to get queue information

When we use netlink to monitor queue information for udp socket,
idiag_rqueue and idiag_wqueue of inet_diag_msg are returned with 0.

Keep consistent with netstat, just return back allocated rmem/wmem size.
Signed-off-by: default avatarShan Wei <davidshan@tencent.com>
Acked-by: default avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 20214926
...@@ -141,7 +141,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, ...@@ -141,7 +141,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
goto rtattr_failure; goto rtattr_failure;
if (icsk == NULL) { if (icsk == NULL) {
r->idiag_rqueue = r->idiag_wqueue = 0; handler->idiag_get_info(sk, r, NULL);
goto out; goto out;
} }
......
...@@ -146,9 +146,17 @@ static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, ...@@ -146,9 +146,17 @@ static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
return udp_dump_one(&udp_table, in_skb, nlh, req); return udp_dump_one(&udp_table, in_skb, nlh, req);
} }
static void udp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
void *info)
{
r->idiag_rqueue = sk_rmem_alloc_get(sk);
r->idiag_wqueue = sk_wmem_alloc_get(sk);
}
static const struct inet_diag_handler udp_diag_handler = { static const struct inet_diag_handler udp_diag_handler = {
.dump = udp_diag_dump, .dump = udp_diag_dump,
.dump_one = udp_diag_dump_one, .dump_one = udp_diag_dump_one,
.idiag_get_info = udp_diag_get_info,
.idiag_type = IPPROTO_UDP, .idiag_type = IPPROTO_UDP,
}; };
...@@ -167,6 +175,7 @@ static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr * ...@@ -167,6 +175,7 @@ static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *
static const struct inet_diag_handler udplite_diag_handler = { static const struct inet_diag_handler udplite_diag_handler = {
.dump = udplite_diag_dump, .dump = udplite_diag_dump,
.dump_one = udplite_diag_dump_one, .dump_one = udplite_diag_dump_one,
.idiag_get_info = udp_diag_get_info,
.idiag_type = IPPROTO_UDPLITE, .idiag_type = IPPROTO_UDPLITE,
}; };
......
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