Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Feb 2024 11:02:45 GMT
From:      Richard Scheffenegger <rscheff@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 419848219b40 - stable/14 - tcp: prevent div by zero in cc_htcp
Message-ID:  <202402271102.41RB2jRZ014241@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=419848219b408cc52befcaa7849a2905f3812a83

commit 419848219b408cc52befcaa7849a2905f3812a83
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2024-02-24 15:35:23 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2024-02-27 11:00:55 +0000

    tcp: prevent div by zero in cc_htcp
    
    Make sure the divident is at least one. While cwnd should
    never be smaller than t_maxseg, this can happen during
    Path MTU Discovery, or when TCP options are considered
    in other parts of the stack.
    
    PR:                     276674
    MFC after:              3 days
    Reviewed By:            tuexen, #transport
    Sponsored by:           NetApp, Inc.
    Differential Revision:  https://reviews.freebsd.org/D43797
    
    (cherry picked from commit 38983d40c18ec5705dcba19ac320b86c5efe8e7e)
---
 sys/netinet/cc/cc_htcp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/netinet/cc/cc_htcp.c b/sys/netinet/cc/cc_htcp.c
index 93720c407d5d..4581b05280e0 100644
--- a/sys/netinet/cc/cc_htcp.c
+++ b/sys/netinet/cc/cc_htcp.c
@@ -230,9 +230,9 @@ htcp_ack_received(struct cc_var *ccv, uint16_t type)
 				 * per RTT.
 				 */
 				CCV(ccv, snd_cwnd) += (((htcp_data->alpha <<
-				    HTCP_SHIFT) / (CCV(ccv, snd_cwnd) /
-				    CCV(ccv, t_maxseg))) * CCV(ccv, t_maxseg))
-				    >> HTCP_SHIFT;
+				    HTCP_SHIFT) / (max(1,
+				    CCV(ccv, snd_cwnd) / CCV(ccv, t_maxseg)))) *
+				    CCV(ccv, t_maxseg))  >> HTCP_SHIFT;
 		}
 	}
 }



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