From 6f250766ac09a3fb1fff425169aa045caa4bbbf1 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Fri, 24 Feb 2023 16:41:46 -0500 Subject: [PATCH] unix: define extended TCPInfo on Linux On Linux platforms, the kernel can fill out an extended version of the tcp_info struct. Allow users of the sys package to have access to that information. Change-Id: Ib42ad572dd56c774c6d9e8b17fe3bdd8126147bb Reviewed-on: https://go-review.googlesource.com/c/sys/+/471275 Run-TryBot: Matt Layher Reviewed-by: Tobias Klauser Reviewed-by: Matt Layher TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- unix/linux/types.go | 3 +- unix/ztypes_linux.go | 88 ++++++++++++++++++++++++++++---------------- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/unix/linux/types.go b/unix/linux/types.go index f3fb38fad..3a564a10d 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -11,6 +11,7 @@ Input to cgo -godefs. See README.md // +godefs map struct_in_addr [4]byte /* in_addr */ // +godefs map struct_in6_addr [16]byte /* in6_addr */ +// +godefs map struct___kernel_sockaddr_storage SockaddrStorage package unix @@ -31,7 +32,7 @@ package unix #include #include -#include +#include #include #include diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index cb13d5b71..65155b3a8 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -456,36 +456,60 @@ type Ucred struct { } type TCPInfo struct { - State uint8 - Ca_state uint8 - Retransmits uint8 - Probes uint8 - Backoff uint8 - Options uint8 - Rto uint32 - Ato uint32 - Snd_mss uint32 - Rcv_mss uint32 - Unacked uint32 - Sacked uint32 - Lost uint32 - Retrans uint32 - Fackets uint32 - Last_data_sent uint32 - Last_ack_sent uint32 - Last_data_recv uint32 - Last_ack_recv uint32 - Pmtu uint32 - Rcv_ssthresh uint32 - Rtt uint32 - Rttvar uint32 - Snd_ssthresh uint32 - Snd_cwnd uint32 - Advmss uint32 - Reordering uint32 - Rcv_rtt uint32 - Rcv_space uint32 - Total_retrans uint32 + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 + Pacing_rate uint64 + Max_pacing_rate uint64 + Bytes_acked uint64 + Bytes_received uint64 + Segs_out uint32 + Segs_in uint32 + Notsent_bytes uint32 + Min_rtt uint32 + Data_segs_in uint32 + Data_segs_out uint32 + Delivery_rate uint64 + Busy_time uint64 + Rwnd_limited uint64 + Sndbuf_limited uint64 + Delivered uint32 + Delivered_ce uint32 + Bytes_sent uint64 + Bytes_retrans uint64 + Dsack_dups uint32 + Reord_seen uint32 + Rcv_ooopack uint32 + Snd_wnd uint32 + Rcv_wnd uint32 + Rehash uint32 } type CanFilter struct { @@ -528,7 +552,7 @@ const ( SizeofIPv6MTUInfo = 0x20 SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc - SizeofTCPInfo = 0x68 + SizeofTCPInfo = 0xf0 SizeofCanFilter = 0x8 SizeofTCPRepairOpt = 0x8 ) @@ -1239,7 +1263,7 @@ type TCPMD5Sig struct { Flags uint8 Prefixlen uint8 Keylen uint16 - _ uint32 + Ifindex int32 Key [80]uint8 }