git: 1d15c4548576 - stable/13 - tcp_info: Add and export more FreeBSD-specific fields

From: Marius Strobl <marius_at_FreeBSD.org>
Date: Sat, 06 Jan 2024 19:25:32 UTC
The branch stable/13 has been updated by marius:

URL: https://cgit.FreeBSD.org/src/commit/?id=1d15c4548576763843ea7268e494bf6015758ef8

commit 1d15c4548576763843ea7268e494bf6015758ef8
Author:     Marius Strobl <marius@FreeBSD.org>
AuthorDate: 2023-08-22 18:12:59 +0000
Commit:     Marius Strobl <marius@FreeBSD.org>
CommitDate: 2024-01-06 01:15:23 +0000

    tcp_info: Add and export more FreeBSD-specific fields
    
    This change adds struct tcp_info fields corresponding to the following
    struct tcpcb ones:
    - snd_una
    - snd_max
    - rcv_numsacks
    - rcv_adv
    - dupacks
    
    Note that while both tcp_fill_info() and fill_tcp_info_from_tcb() are
    extended accordingly, no counterpart of rcv_numsacks is available in
    the cxgbe(4) TOE PCB, though.
    
    Sponsored by:   NetApp, Inc. (originally)
    
    (cherry picked from commit dc485b968ddeb070d23354f55164a8c336acf081)
    
    Conflicts (due tue missing 945f9a7c):
            sys/netinet/tcp.h
---
 sys/dev/cxgbe/tom/t4_tom.c |  4 ++++
 sys/netinet/tcp.h          | 11 ++++++++++-
 sys/netinet/tcp_usrreq.c   |  5 +++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index b1982341f4d5..2939ec9b5564 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -737,9 +737,13 @@ fill_tcp_info_from_tcb(struct adapter *sc, uint64_t *tcb, struct tcp_info *ti)
 	ti->tcpi_snd_ssthresh = GET_TCB_FIELD(tcb, SND_SSTHRESH);
 	ti->tcpi_snd_cwnd = GET_TCB_FIELD(tcb, SND_CWND);
 	ti->tcpi_rcv_nxt = GET_TCB_FIELD(tcb, RCV_NXT);
+	ti->tcpi_rcv_adv = GET_TCB_FIELD(tcb, RCV_ADV);
+	ti->tcpi_dupacks = GET_TCB_FIELD(tcb, T_DUPACKS);
 
 	v = GET_TCB_FIELD(tcb, TX_MAX);
 	ti->tcpi_snd_nxt = v - GET_TCB_FIELD(tcb, SND_NXT_RAW);
+	ti->tcpi_snd_una = v - GET_TCB_FIELD(tcb, SND_UNA_RAW);
+	ti->tcpi_snd_max = v - GET_TCB_FIELD(tcb, SND_MAX_RAW);
 
 	/* Receive window being advertised by us. */
 	ti->tcpi_rcv_wscale = GET_TCB_FIELD(tcb, SND_SCALE);	/* Yes, SND. */
diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h
index 16307161e6ac..25a02f1b4319 100644
--- a/sys/netinet/tcp.h
+++ b/sys/netinet/tcp.h
@@ -398,8 +398,17 @@ struct tcp_info {
 	u_int32_t	__tcpi_received_e0_bytes;
 	u_int32_t	__tcpi_received_ce_bytes;
 
+	u_int32_t	__tcpi_total_tlp;	/* tail loss probes sent */
+	u_int64_t	__tcpi_total_tlp_bytes;	/* tail loss probe bytes sent */
+
+	u_int32_t	tcpi_snd_una;		/* Unacked seqno sent */
+	u_int32_t	tcpi_snd_max;		/* Highest seqno sent */
+	u_int32_t	tcpi_rcv_numsacks;	/* Distinct SACK blks present */
+	u_int32_t	tcpi_rcv_adv;		/* Peer advertised window */
+	u_int32_t	tcpi_dupacks;		/* Consecutive dup ACKs recvd */
+
 	/* Padding to grow without breaking ABI. */
-	u_int32_t	__tcpi_pad[18];		/* Padding. */
+	u_int32_t	__tcpi_pad[10];		/* Padding. */
 };
 
 /*
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 7e9c871df87a..f1c7fbafc210 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1672,6 +1672,11 @@ tcp_fill_info(const struct tcpcb *tp, struct tcp_info *ti)
 	ti->tcpi_snd_rexmitpack = tp->t_sndrexmitpack;
 	ti->tcpi_rcv_ooopack = tp->t_rcvoopack;
 	ti->tcpi_snd_zerowin = tp->t_sndzerowin;
+	ti->tcpi_snd_una = tp->snd_una;
+	ti->tcpi_snd_max = tp->snd_max;
+	ti->tcpi_rcv_numsacks = tp->rcv_numsacks;
+	ti->tcpi_rcv_adv = tp->rcv_adv;
+	ti->tcpi_dupacks = tp->t_dupacks;
 #ifdef TCP_OFFLOAD
 	if (tp->t_flags & TF_TOE) {
 		ti->tcpi_options |= TCPI_OPT_TOE;