git: 22dc8609c565 - main - tcp: use signed IsLost() related accounting variables

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Tue, 17 Oct 2023 14:38:47 UTC
The branch main has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=22dc8609c565456fda3de6ddc34e07af98f11203

commit 22dc8609c565456fda3de6ddc34e07af98f11203
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2023-10-17 14:07:23 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2023-10-17 14:37:09 +0000

    tcp: use signed IsLost() related accounting variables
    
    Coverity found that one safety check (kassert) was not
    functional, as possible incorrect subtractions during
    the accounting wouldn't show up as (invalid) negative
    values.
    
    Reported by: gallatin
    Reviewed By: cc, #transport
    Sponsored By: NetApp, Inc.
    Differential Revision: https://reviews.freebsd.org/D42180
---
 sys/netinet/tcp_sack.c | 4 ++--
 sys/netinet/tcp_var.h  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c
index 8647630bb6bc..589b0c424acb 100644
--- a/sys/netinet/tcp_sack.c
+++ b/sys/netinet/tcp_sack.c
@@ -888,10 +888,10 @@ tcp_free_sackholes(struct tcpcb *tp)
 	while ((q = TAILQ_FIRST(&tp->snd_holes)) != NULL)
 		tcp_sackhole_remove(tp, q);
 	tp->sackhint.sack_bytes_rexmit = 0;
-	tp->sackhint.sacked_bytes = 0;
 	tp->sackhint.delivered_data = 0;
-	tp->sackhint.lost_bytes = 0;
+	tp->sackhint.sacked_bytes = 0;
 	tp->sackhint.hole_bytes = 0;
+	tp->sackhint.lost_bytes = 0;
 
 	KASSERT(tp->snd_numholes == 0, ("tp->snd_numholes == 0"));
 	KASSERT(tp->sackhint.nexthole == NULL,
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 11509a87c6e7..c6e24b187e0f 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -128,8 +128,8 @@ struct sackhint {
 	uint32_t	recover_fs;	/* Flight Size at the start of Loss recovery */
 	uint32_t	prr_delivered;	/* Total bytes delivered using PRR */
 	uint32_t	prr_out;	/* Bytes sent during IN_RECOVERY */
-	uint32_t	hole_bytes;	/* current number of bytes in scoreboard holes */
-	uint32_t	lost_bytes;	/* number of rfc6675 IsLost() bytes */
+	int32_t		hole_bytes;	/* current number of bytes in scoreboard holes */
+	int32_t		lost_bytes;	/* number of rfc6675 IsLost() bytes */
 };
 
 #define SEGQ_EMPTY(tp) TAILQ_EMPTY(&(tp)->t_segq)