aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Scheffenegger <rscheff@FreeBSD.org>2024-02-24 15:35:23 +0000
committerRichard Scheffenegger <rscheff@FreeBSD.org>2024-02-28 00:21:47 +0000
commit6e298c3612da3d04a75d380cf457774cb1a25a47 (patch)
tree759c7cc1c9d5c87096ed49521a974740839f6150
parentfe5468bdf404160b05ad892e944161edbd00240c (diff)
downloadsrc-6e298c3612da3d04a75d380cf457774cb1a25a47.tar.gz
src-6e298c3612da3d04a75d380cf457774cb1a25a47.zip
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)
-rw-r--r--sys/netinet/cc/cc_htcp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/netinet/cc/cc_htcp.c b/sys/netinet/cc/cc_htcp.c
index 70ac0bebffe9..6568c5ae672e 100644
--- a/sys/netinet/cc/cc_htcp.c
+++ b/sys/netinet/cc/cc_htcp.c
@@ -226,9 +226,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;
}
}
}