-extern int tcp_do_rfc3465;
-extern int tcp_do_rfc3465_lim2;
-extern int maxseg_unacked;
-extern u_int32_t tcp_autosndbuf_max;
-
-#define SET_SNDSB_IDEAL_SIZE(sndsb, size) \
- sndsb->sb_idealsize = min(max(tcp_sendspace, tp->snd_ssthresh), \
- tcp_autosndbuf_max);
-
-void tcp_cc_resize_sndbuf(struct tcpcb *tp) {
- struct sockbuf *sb;
- /* If the send socket buffer size is bigger than ssthresh,
- * it is time to trim it because we do not want to hold
- * too many mbufs in the socket buffer
- */
- sb = &(tp->t_inpcb->inp_socket->so_snd);
- if (sb->sb_hiwat > tp->snd_ssthresh &&
- (sb->sb_flags & SB_AUTOSIZE) != 0) {
- if (sb->sb_idealsize > tp->snd_ssthresh) {
- SET_SNDSB_IDEAL_SIZE(sb, tp->snd_ssthresh);
- }
- sb->sb_flags |= SB_TRIM;
- }
-}
-
-void tcp_bad_rexmt_fix_sndbuf(struct tcpcb *tp) {
- struct sockbuf *sb;
- sb = &(tp->t_inpcb->inp_socket->so_snd);
- if ((sb->sb_flags & (SB_TRIM|SB_AUTOSIZE)) == (SB_TRIM|SB_AUTOSIZE)) {
- /* If there was a retransmission that was not necessary
- * then the size of socket buffer can be restored to
- * what it was before
- */
- SET_SNDSB_IDEAL_SIZE(sb, tp->snd_ssthresh);
- if (sb->sb_hiwat <= sb->sb_idealsize) {
- sbreserve(sb, sb->sb_idealsize);
- sb->sb_flags &= ~SB_TRIM;
- }
- }
-}
-