git: 3604a050eedb - main - tcp_hpts: refactor the per tcpcb call to either input/output method

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 16 Dec 2024 14:53:00 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=3604a050eedbf5af3fd0beca8342cb3779342007

commit 3604a050eedbf5af3fd0beca8342cb3779342007
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-12-16 14:52:06 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-12-16 14:52:06 +0000

    tcp_hpts: refactor the per tcpcb call to either input/output method
    
    Either input or output return unlocked on failure.  Should be no
    functional change.
    
    Reviewed by:            rrs
    Differential Revision:  https://reviews.freebsd.org/D47925
---
 sys/netinet/tcp_hpts.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/sys/netinet/tcp_hpts.c b/sys/netinet/tcp_hpts.c
index 0c7338eb222b..5b39c94e0e58 100644
--- a/sys/netinet/tcp_hpts.c
+++ b/sys/netinet/tcp_hpts.c
@@ -1374,24 +1374,20 @@ again:
 			 * cause a call to output if it is needed so we do
 			 * not need a second call to tcp_output(). So we do
 			 * one or the other but not both.
+			 *
+			 * XXXGL: some KPI abuse here.  tfb_do_queued_segments
+			 * returns unlocked with positive error (always 1) and
+			 * tcp_output returns unlocked with negative error.
 			 */
 			tp->t_flags2 |= TF2_HPTS_CALLS;
 			if ((tp->t_flags2 & TF2_SUPPORTS_MBUFQ) &&
-			    !STAILQ_EMPTY(&tp->t_inqueue)) {
-				error = (*tp->t_fb->tfb_do_queued_segments)(tp, 0);
-				/*
-				 * A non-zero return for input queue processing
-				 * is the lock is released and most likely the
-				 * inp is gone.
-				 */
-				if (error)
-					goto skip_pacing;
-			} else
+			    !STAILQ_EMPTY(&tp->t_inqueue))
+				error = -(*tp->t_fb->tfb_do_queued_segments)(tp,
+				    0);
+			else
 				error = tcp_output(tp);
-			if (error < 0)
-				goto skip_pacing;
-			INP_WUNLOCK(inp);
-		skip_pacing:
+			if (__predict_true(error >= 0))
+				INP_WUNLOCK(inp);
 			CURVNET_RESTORE();
 		}
 		if (seen_endpoint) {