keep USETRAILERS from SIOCSARP
[unix-history] / usr / src / sys / netinet / tcp_output.c
index 7c3f009..4d150a4 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)tcp_output.c        7.7 (Berkeley) %G%
+ *     @(#)tcp_output.c        7.10 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -162,9 +162,14 @@ again:
         * next expected input.)  If the difference is 35% or more of the
         * maximum possible window, then want to send a window update to peer.
         */
         * next expected input.)  If the difference is 35% or more of the
         * maximum possible window, then want to send a window update to peer.
         */
-       if (win > 0 &&
-           ((100*(win-(tp->rcv_adv-tp->rcv_nxt))/so->so_rcv.sb_hiwat) >= 35))
-               goto send;
+       if (win > 0) {
+               int adv = win - (tp->rcv_adv - tp->rcv_nxt);
+
+               if (100 * adv / so->so_rcv.sb_hiwat >= 35)
+                       goto send;
+               if (adv >= 2 * tp->t_maxseg && so->so_rcv.sb_cc == 0)
+                       goto send;
+       }
 
        /*
         * TCP window updates are not reliable, rather a polling protocol
 
        /*
         * TCP window updates are not reliable, rather a polling protocol
@@ -252,7 +257,7 @@ send:
         * unless TCP set to not do any options.
         */
        opt = NULL;
         * unless TCP set to not do any options.
         */
        opt = NULL;
-       if (tp->t_state < TCPS_ESTABLISHED && (tp->t_flags & TF_NOOPT) == 0) {
+       if (flags & TH_SYN && (tp->t_flags & TF_NOOPT) == 0) {
                u_short mss;
 
                mss = MIN(so->so_rcv.sb_hiwat / 2, tcp_mss(tp));
                u_short mss;
 
                mss = MIN(so->so_rcv.sb_hiwat / 2, tcp_mss(tp));
@@ -261,9 +266,6 @@ send:
                        optlen = sizeof (tcp_initopt);
                        *(u_short *)(opt + 2) = htons(mss);
                }
                        optlen = sizeof (tcp_initopt);
                        *(u_short *)(opt + 2) = htons(mss);
                }
-       } else if (tp->t_tcpopt) {
-               opt = mtod(tp->t_tcpopt, u_char *);
-               optlen = tp->t_tcpopt->m_len;
        }
        if (opt) {
                m0 = m->m_next;
        }
        if (opt) {
                m0 = m->m_next;
@@ -328,15 +330,8 @@ send:
         * the retransmit.  In persist state, just set snd_max.
         */
        if (tp->t_force == 0 || tp->t_timer[TCPT_PERSIST] == 0) {
         * the retransmit.  In persist state, just set snd_max.
         */
        if (tp->t_force == 0 || tp->t_timer[TCPT_PERSIST] == 0) {
-               /*
-                * Time this transmission if not a retransmission and
-                * not currently timing anything.
-                */
-               if (tp->t_rtt == 0 && tp->snd_nxt == tp->snd_max) {
-                       tp->t_rtt = 1;
-                       tp->t_rtseq = tp->snd_nxt;
-                       tcpstat.tcps_segstimed++;
-               }
+               tcp_seq startseq = tp->snd_nxt;
+
                /*
                 * Advance snd_nxt over sequence space of this segment.
                 */
                /*
                 * Advance snd_nxt over sequence space of this segment.
                 */
@@ -347,8 +342,18 @@ send:
                        tp->t_flags |= TF_SENTFIN;
                }
                tp->snd_nxt += len;
                        tp->t_flags |= TF_SENTFIN;
                }
                tp->snd_nxt += len;
-               if (SEQ_GT(tp->snd_nxt, tp->snd_max))
+               if (SEQ_GT(tp->snd_nxt, tp->snd_max)) {
                        tp->snd_max = tp->snd_nxt;
                        tp->snd_max = tp->snd_nxt;
+                       /*
+                        * Time this transmission if not a retransmission and
+                        * not currently timing anything.
+                        */
+                       if (tp->t_rtt == 0) {
+                               tp->t_rtt = 1;
+                               tp->t_rtseq = startseq;
+                               tcpstat.tcps_segstimed++;
+                       }
+               }
 
                /*
                 * Set retransmit timer if not currently set,
 
                /*
                 * Set retransmit timer if not currently set,
@@ -360,11 +365,11 @@ send:
                 */
                if (tp->t_timer[TCPT_REXMT] == 0 &&
                    tp->snd_nxt != tp->snd_una) {
                 */
                if (tp->t_timer[TCPT_REXMT] == 0 &&
                    tp->snd_nxt != tp->snd_una) {
-                       TCPT_RANGESET(tp->t_timer[TCPT_REXMT],
-                         ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
-                         TCPTV_MIN, TCPTV_REXMTMAX);
-                       tp->t_rxtshift = 0;
-                       tp->t_timer[TCPT_PERSIST] = 0;
+                       tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
+                       if (tp->t_timer[TCPT_PERSIST]) {
+                               tp->t_timer[TCPT_PERSIST] = 0;
+                               tp->t_rxtshift = 0;
+                       }
                }
        } else
                if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
                }
        } else
                if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))