git: 0932fb565a08 - main - tcp: fix TCPSTAT accounting for SACK

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Thu, 25 Jan 2024 22:00:33 UTC
The branch main has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=0932fb565a08e6e13dd9843e7a60dae311911d0d

commit 0932fb565a08e6e13dd9843e7a60dae311911d0d
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2024-01-25 21:03:36 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2024-01-25 21:58:33 +0000

    tcp: fix TCPSTAT accounting for SACK
    
    Account for SACK retransmitted bytes once the actual length
    is known. This prevents a call to tcp_maxseg() and prepares
    for TSO support when transmitting from the SACK scoreboard.
    
    Reviewed By:           tuexen, #transport
    Sponsored by:          NetApp, Inc.
    Differential Revision: https://reviews.freebsd.org/D43447
---
 sys/netinet/tcp_output.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index 71a50d54d5ee..58f63b593b2a 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -330,9 +330,6 @@ again:
 			    __func__, off));
 			sack_rxmit = 1;
 			sendalot = 1;
-			TCPSTAT_INC(tcps_sack_rexmits);
-			TCPSTAT_ADD(tcps_sack_rexmit_bytes,
-			    min(len, tcp_maxseg(tp)));
 		}
 	}
 after_sack_rexmit:
@@ -1036,6 +1033,10 @@ send:
 			tp->t_sndrexmitpack++;
 			TCPSTAT_INC(tcps_sndrexmitpack);
 			TCPSTAT_ADD(tcps_sndrexmitbyte, len);
+			if (sack_rxmit) {
+				TCPSTAT_INC(tcps_sack_rexmits);
+				TCPSTAT_ADD(tcps_sack_rexmit_bytes, len);
+			}
 #ifdef STATS
 			stats_voi_update_abs_u32(tp->t_stats, VOI_TCP_RETXPB,
 			    len);