Skip to content

Commit

Permalink
tcp: prevent div by zero in cc_htcp
Browse files Browse the repository at this point in the history
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 38983d4)
  • Loading branch information
rscheff authored and fichtner committed Feb 29, 2024
1 parent 61e3a1e commit 7b99b5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sys/netinet/cc/cc_htcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,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;
}
}
}
Expand Down

0 comments on commit 7b99b5f

Please sign in to comment.