Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Aug 2025 15:29:35 -0700
From:      Gleb Smirnoff <glebius@freebsd.org>
To:        Michael Tuexen <tuexen@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: feeb19201dca - main - tcp: improve consistency of KASSERTs in tcp_sack.c
Message-ID:  <aJPXT123XljlcxoX@cell.glebi.us>
In-Reply-To: <202508060830.5768UUcN052133@gitrepo.freebsd.org>
References:  <202508060830.5768UUcN052133@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 06, 2025 at 08:30:30AM +0000, Michael Tuexen wrote:
M>     When panicing, don't print the condition, which was violated,
M>     but the condition which holds at the time of the panic.
M>     
M>     Reviewed by:            Nick Banks
M>     MFC after:              1 week
M>     Sponsored by:           Netflix, Inc.
M>     Differential Revision:  https://reviews.freebsd.org/D51726
M> ---
M>  sys/netinet/tcp_sack.c | 30 +++++++++++++++++-------------
M>  1 file changed, 17 insertions(+), 13 deletions(-)
M> 
M> diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c
M> index 4405098a8620..f48e60207cc2 100644
M> --- a/sys/netinet/tcp_sack.c
M> +++ b/sys/netinet/tcp_sack.c
M> @@ -283,7 +283,7 @@ tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_start, tcp_seq rcv_end)
M>  	INP_WLOCK_ASSERT(tptoinpcb(tp));
M>  
M>  	/* Check arguments. */
M> -	KASSERT(SEQ_LEQ(rcv_start, rcv_end), ("rcv_start <= rcv_end"));
M> +	KASSERT(SEQ_LEQ(rcv_start, rcv_end), ("SEG_GT(rcv_start, rcv_end)"));
M>  
M>  	if ((rcv_start == rcv_end) &&
M>  	    (tp->rcv_numsacks >= 1) &&
M> @@ -498,8 +498,8 @@ tcp_sackhole_free(struct tcpcb *tp, struct sackhole *hole)
M>  	tp->snd_numholes--;
M>  	atomic_subtract_int(&V_tcp_sack_globalholes, 1);
M>  
M> -	KASSERT(tp->snd_numholes >= 0, ("tp->snd_numholes >= 0"));
M> -	KASSERT(V_tcp_sack_globalholes >= 0, ("tcp_sack_globalholes >= 0"));
M> +	KASSERT(tp->snd_numholes >= 0, ("tp->snd_numholes < 0"));
M> +	KASSERT(V_tcp_sack_globalholes >= 0, ("tcp_sack_globalholes < 0"));

IMHO, better just through MPASS() instead of self-repetitive KASSERT.

-- 
Gleb Smirnoff



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aJPXT123XljlcxoX>