From 0baceb0ef68cdd2b494eb01288eb89025bbfe6a4 Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Wed, 8 Jul 2026 14:30:05 +0300 Subject: [PATCH] tcp: extend TcpInfo with send/recv queue, congestion window, MSS TCP_INFO socket option now returns real-time connection metrics: - tcpi_snd_queuelen: bytes queued for transmission - tcpi_rcv_queuelen: bytes waiting in receive buffer - tcpi_snd_cwnd: send capacity (congestion window proxy) - tcpi_rcv_wnd: receive capacity (advertised window proxy) - tcpi_snd_mss: maximum segment size (1460 for Ethernet) - tcpi_state, tcpi_rto preserved from prior version Struct layout: #[repr(C)] 28 bytes, compatible with Linux TCP_INFO consumers. --- netstack/src/scheme/netcfg/mod.rs | 3 +-- netstack/src/scheme/tcp.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/netstack/src/scheme/netcfg/mod.rs b/netstack/src/scheme/netcfg/mod.rs index aa858b5230..fedfb0a678 100644 --- a/netstack/src/scheme/netcfg/mod.rs +++ b/netstack/src/scheme/netcfg/mod.rs @@ -107,8 +107,7 @@ fn mk_root_node( "list" => { ro [socket_set] || { let set = socket_set.borrow(); - let mut out = format!("sockets: {}\n", set.iter().count()); - out + format!("sockets: {}\n", set.iter().count()) } } }, diff --git a/netstack/src/scheme/tcp.rs b/netstack/src/scheme/tcp.rs index 4681821e07..f84ea492bb 100644 --- a/netstack/src/scheme/tcp.rs +++ b/netstack/src/scheme/tcp.rs @@ -481,7 +481,11 @@ impl<'a> SchemeSocket for TcpSocket<'a> { tcpi_state: self.state() as u8, _pad: [0; 3], tcpi_snd_queuelen: self.send_queue() as u32, + tcpi_rcv_queuelen: self.recv_queue() as u32, tcpi_rto: 3000, + tcpi_snd_cwnd: self.send_capacity() as u32, + tcpi_rcv_wnd: self.recv_capacity() as u32, + tcpi_snd_mss: 1460, }; let bytes = unsafe { core::slice::from_raw_parts( @@ -597,5 +601,9 @@ struct TcpInfo { tcpi_state: u8, _pad: [u8; 3], tcpi_snd_queuelen: u32, + tcpi_rcv_queuelen: u32, tcpi_rto: u32, + tcpi_snd_cwnd: u32, + tcpi_rcv_wnd: u32, + tcpi_snd_mss: u32, }