Skip to contentSkip to conversation

net: export TCP send buffer size via netlink

PATCH In review Amerigo Wang 2 participants 4 messages Feb 1, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: export TCP send buffer size via netlink

V1 -> V2:
Keep ABI compatiblity of struct tcp_info.

Currently, we can only get TCP send buffer size by getsockopt (SO_SNDBUF or TCP_INFO), this is not enough for the tools like netstat or ss to read.

Show TCP send buffer size via netlink NETLINK_INET_DIAG.

Cc David Miller <[email protected]>
Cc Eric Dumazet <[email protected]>

---

include/linux/tcp.h +2 -0
index 7fee8a4..b63f541 100644
@@ -163,6 +163,8 @@ struct tcp_info {
 	__u32	tcpi_rcv_space;
 
 	__u32	tcpi_total_retrans;
+
+	__u32	tcpi_sndbuf;
 };
 
 /* for TCP_MD5SIG socket option */
net/ipv4/tcp.c +1 -0
index b0a26bb..b3d6a62 100644
@@ -2385,6 +2385,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
 	info->tcpi_retransmits = icsk->icsk_retransmits;
 	info->tcpi_probes = icsk->icsk_probes_out;
 	info->tcpi_backoff = icsk->icsk_backoff;
+	info->tcpi_sndbuf = sk->sk_sndbuf;
 
 	if (tp->rx_opt.tstamp_ok)
 		info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
maintainer
#1 lore raw

From: Amerigo Wang <[email protected]>
Date: Mon, 1 Feb 2010 04:18:28 -0500

Quoted 10 lines

V1 -> V2:
Keep ABI compatiblity of struct tcp_info.

Currently, we can only get TCP send buffer size by getsockopt (SO_SNDBUF or TCP_INFO), this is not enough for the tools like netstat or ss to read.

Show TCP send buffer size via netlink NETLINK_INET_DIAG.

If the user has a "struct tcp_info info" on it's stack, and it's compiled against the header file before your changes, guess what the kernel is going to do?

It's going to write past the end of the user's variable into random stack locations.

You can't change the layout, at all.

maintainer
#2 lore raw

Before you spend the next couple hours trying to figure out what to do...

We already provide the information you're trying to export via linux/inet_diag.h:inet_diag_meminfo

I hope the light goes on now :-)

author
#3 lore raw
Quoted 8 lines · David Miller

Before you spend the next couple hours trying to figure out what to do...

We already provide the information you're trying to export via linux/inet_diag.h:inet_diag_meminfo

I hope the light goes on now :-)

Oh, I was just looking for a pointer.

Ok, ->idiag_wmem is gotten from sk->sk_wmem_queued, so ->sk_wmem_queued is the TCP send buffer size that we want? I thought it is ->sk_sndbuf...

Thanks for your help!