From nobody Wed Jun 10 00:32:24 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gZmvD5573z6h25h for ; Wed, 10 Jun 2026 00:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gZmvD30Ptz3X3t for ; Wed, 10 Jun 2026 00:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781051544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SFd19c9FTb1zHi+CtVbZuL5eyeYJT7MRub8O/f8ZQLc=; b=wWvd2KpMZAtDFLt71vgkL0siG3+B3CpTcqgM1cyNwfOD9Ee/Dp4RFnc1qXFToF+EOtt/VR D8q+a8q8S7znMyxCzj6V4k5Pb3y0osVUyxDSsmUhHe3yUNsadFxDvGzWvZECIYPaxInHZY OrqgGmajLs2Dcdc1kiAAarvHc+toHFZBpJNAxLvOeenfvs0VNCUIOpSUlPp+4x4bvq/mwx 9384bkEn/VT3uPH+fGX6JzzGhpQj2o7Cbp9IPvlO5LgIZyzjKvjpl82vfvW4KgIO7Jdu3N 3pFz45m9Q/3OzHPAj1oAkGYtkOGPUKeYCUVseUlO0r0rF5QAQOqUiIZjAd6ltw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781051544; a=rsa-sha256; cv=none; b=TDaAOU31GajzhkythbjQy+qLMNAdNR1i5D6IETYJ7keaYhXiYfvPLRuR0NReK4zyrCN02B MQRnj+hyOGwq0RqLaeawju19EbQXNP+8jVhwnf+1ou9O4N37cdlY0iCi6HBtwL0TaGdML6 xKo+R9/jjvz5hq4sAEq1nilzMkFFKawReAKDfgEEAaHLK8Bjr755Oxp3ZNnwhD5Sm4qRUS diuCT78G6CM/dp+s35rjFgxMUITWoLBN8FmK4Q17HVOUFdEiFvnlW081T118wmGXcZcmkh u/yX68WF7AiwMo5CY2z75Ff6lh7HVM2cgCB7l2pz34AWlEq6tHbDRvKYAbqG8g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781051544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SFd19c9FTb1zHi+CtVbZuL5eyeYJT7MRub8O/f8ZQLc=; b=q3q8Y/LQxRb3ue4r/DJNUs3pwnXNnUeItBc4t9eYsgZdEjTgnV6c+wRFXkBYl8ybplI9pD DDoC8VxfWpoRPWR0V4+RLBCuULSo/1e4qbW/5z05BTS2+oZUz5ybt6VQS50NqhbBFvrHKd RK2oTDA0HZ6JiNbA3cQlI35ko2aljHV6XbyJw2180ZdtKvULOYhD0CI1qr+OwjZVVDc9LF ePzkri9U4snSPP4SLNp7xH1wDPWeElZarbFHyLBK7b+2TlwZT/BdA2QBxyVgvuyp1Nt4C3 x1sLLtjqvRf/wr5s9uI6/QQ56MZfPoehLaOp+YUiHKatXDgdjxIRb6D167ywHg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gZmvD21wCzyHF for ; Wed, 10 Jun 2026 00:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3fec0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 10 Jun 2026 00:32:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Chuck Tuffli Subject: git: 925ca9b8355d - main - linux: Add TCP_INFO support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: chuck X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 925ca9b8355d10a0dc85175dc865095c9b3370c4 Auto-Submitted: auto-generated Date: Wed, 10 Jun 2026 00:32:24 +0000 Message-Id: <6a28b098.3fec0.1bb5ef47@gitrepo.freebsd.org> The branch main has been updated by chuck: URL: https://cgit.FreeBSD.org/src/commit/?id=925ca9b8355d10a0dc85175dc865095c9b3370c4 commit 925ca9b8355d10a0dc85175dc865095c9b3370c4 Author: Chuck Tuffli AuthorDate: 2026-06-10 00:22:49 +0000 Commit: Chuck Tuffli CommitDate: 2026-06-10 00:23:24 +0000 linux: Add TCP_INFO support Implement the getsockopt for TCP_INFO by mapping FreeBSD's version to what Linux expects. MFC after: 1 month Relnotes: yes Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D55882 --- sys/compat/linux/linux_socket.c | 47 +++++++++++++++++++-- sys/compat/linux/linux_socket.h | 92 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 3 deletions(-) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 12ba6a3adfce..7b579958158a 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -591,9 +591,7 @@ linux_to_bsd_tcp_sockopt(int opt) case LINUX_TCP_KEEPCNT: return (TCP_KEEPCNT); case LINUX_TCP_INFO: - LINUX_RATELIMIT_MSG_OPT1( - "unsupported TCP socket option TCP_INFO (%d)", opt); - return (-2); + return (TCP_INFO); case LINUX_TCP_MD5SIG: return (TCP_MD5SIG); case LINUX_TCP_USER_TIMEOUT: @@ -2407,6 +2405,42 @@ linux_getsockopt_so_linger(struct thread *td, return (linux_sockopt_copyout(td, &ling, len, args)); } +static int +linux_getsockopt_tcp_info(struct thread *td, + struct linux_getsockopt_args *args) +{ + struct tcp_info tinfo; + struct l_tcp_info l_tinfo; + socklen_t len; + int error; + + len = sizeof(tinfo); + error = kern_getsockopt(td, args->s, IPPROTO_TCP, TCP_INFO, &tinfo, + UIO_SYSSPACE, &len); + if (error != 0) + return (error); + memset(&l_tinfo, 0, sizeof(l_tinfo)); + l_tinfo.tcpi_state = tinfo.tcpi_state; + l_tinfo.tcpi_options = tinfo.tcpi_options; + l_tinfo.tcpi_snd_wscale = tinfo.tcpi_snd_wscale; + l_tinfo.tcpi_rcv_wscale = tinfo.tcpi_rcv_wscale; + l_tinfo.tcpi_rto = tinfo.tcpi_rto; + l_tinfo.tcpi_snd_mss = tinfo.tcpi_snd_mss; + l_tinfo.tcpi_rcv_mss = tinfo.tcpi_rcv_mss; + l_tinfo.tcpi_last_data_recv = tinfo.tcpi_last_data_recv; + l_tinfo.tcpi_rtt = tinfo.tcpi_rtt; + l_tinfo.tcpi_rttvar = tinfo.tcpi_rttvar; + l_tinfo.tcpi_snd_ssthresh = tinfo.tcpi_snd_ssthresh; + l_tinfo.tcpi_snd_cwnd = tinfo.tcpi_snd_cwnd; + l_tinfo.tcpi_rcv_space = tinfo.tcpi_rcv_space; + l_tinfo.tcpi_snd_wnd = tinfo.tcpi_snd_wnd; + l_tinfo.tcpi_rcv_ooopack = tinfo.tcpi_rcv_ooopack; + /* Eqivalent */ + l_tinfo.tcpi_total_retrans = tinfo.tcpi_snd_rexmitpack; + + return (linux_sockopt_copyout(td, &l_tinfo, len, args)); +} + int linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) { @@ -2505,6 +2539,13 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) name = linux_to_bsd_ip6_sockopt(args->optname); break; case IPPROTO_TCP: + switch (args->optname) { + case LINUX_TCP_INFO: + return (linux_getsockopt_tcp_info(td, args)); + /* NOTREACHED */ + default: + break; + } name = linux_to_bsd_tcp_sockopt(args->optname); switch (name) { case TCP_MAXUNACKTIME: diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h index d30d68409496..47fc140259c5 100644 --- a/sys/compat/linux/linux_socket.h +++ b/sys/compat/linux/linux_socket.h @@ -359,6 +359,98 @@ struct l_ifreq { } ifr_ifru; }; +/* + * Linux TCP_INFO structure as of v6.19.8 + * + * Comments indicate last field for the given kernel version + */ +struct l_tcp_info { + uint8_t tcpi_state; + uint8_t tcpi_ca_state; + uint8_t tcpi_retransmits; + uint8_t tcpi_probes; + uint8_t tcpi_backoff; + uint8_t tcpi_options; + uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; + uint8_t tcpi_delivery_rate_app_limited:1, tcpi_fastopen_client_fail:2; + + uint32_t tcpi_rto; + uint32_t tcpi_ato; + uint32_t tcpi_snd_mss; + uint32_t tcpi_rcv_mss; + + uint32_t tcpi_unacked; + uint32_t tcpi_sacked; + uint32_t tcpi_lost; + uint32_t tcpi_retrans; + uint32_t tcpi_fackets; + + uint32_t tcpi_last_data_sent; + uint32_t tcpi_last_ack_sent; + uint32_t tcpi_last_data_recv; + uint32_t tcpi_last_ack_recv; + + uint32_t tcpi_pmtu; + uint32_t tcpi_rcv_ssthresh; + uint32_t tcpi_rtt; + uint32_t tcpi_rttvar; + uint32_t tcpi_snd_ssthresh; + uint32_t tcpi_snd_cwnd; + uint32_t tcpi_advmss; + uint32_t tcpi_reordering; + + uint32_t tcpi_rcv_rtt; + uint32_t tcpi_rcv_space; + + uint32_t tcpi_total_retrans; /* v3.6 */ + + uint64_t tcpi_pacing_rate; + uint64_t tcpi_max_pacing_rate; /* v3.14 */ + uint64_t tcpi_bytes_acked; + uint64_t tcpi_bytes_received; + uint32_t tcpi_segs_out; + uint32_t tcpi_segs_in; /* v4.1 */ + + uint32_t tcpi_notsent_bytes; + uint32_t tcpi_min_rtt; + uint32_t tcpi_data_segs_in; + uint32_t tcpi_data_segs_out; /* v4.5 */ + + uint64_t tcpi_delivery_rate; /* v4.8 */ + + uint64_t tcpi_busy_time; + uint64_t tcpi_rwnd_limited; + uint64_t tcpi_sndbuf_limited; /* v4.9 */ + + uint32_t tcpi_delivered; + uint32_t tcpi_delivered_ce; /* v4.16 */ + + uint64_t tcpi_bytes_sent; + uint64_t tcpi_bytes_retrans; + uint32_t tcpi_dsack_dups; + uint32_t tcpi_reord_seen; /* v4.18 */ + + uint32_t tcpi_rcv_ooopack; + + uint32_t tcpi_snd_wnd; /* v5.3 */ + uint32_t tcpi_rcv_wnd; + + uint32_t tcpi_rehash; /* v6.1 */ + + uint16_t tcpi_total_rto; + uint16_t tcpi_total_rto_recoveries; + uint32_t tcpi_total_rto_time; /* v6.6 */ + uint32_t tcpi_received_ce; + uint32_t tcpi_delivered_e1_bytes; + uint32_t tcpi_delivered_e0_bytes; + uint32_t tcpi_delivered_ce_bytes; + uint32_t tcpi_received_e1_bytes; + uint32_t tcpi_received_e0_bytes; + uint32_t tcpi_received_ce_bytes; + uint16_t tcpi_accecn_fail_mode; + uint16_t tcpi_accecn_opt_seen; /* v6.17 */ +}; + /* * Define here members which are not exists in the FreeBSD struct ifreq. */