BSD 4_3_Tahoe release
[unix-history] / usr / src / sys / netinet / tcp_timer.c
index ca92942..45f827f 100644 (file)
@@ -3,13 +3,18 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  *
- *     @(#)tcp_timer.c 7.11.1.1 (Berkeley) %G%
+ *     @(#)tcp_timer.c 7.14 (Berkeley) 6/29/88
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -35,7 +40,9 @@
 #include "tcp_var.h"
 #include "tcpip.h"
 
 #include "tcp_var.h"
 #include "tcpip.h"
 
-int    tcpnodelack = 0;
+int    tcp_keepidle = TCPTV_KEEP_IDLE;
+int    tcp_keepintvl = TCPTV_KEEPINTVL;
+int    tcp_maxidle;
 /*
  * Fast timeout routine for processing delayed acks
  */
 /*
  * Fast timeout routine for processing delayed acks
  */
@@ -70,6 +77,7 @@ tcp_slowtimo()
        int s = splnet();
        register int i;
 
        int s = splnet();
        register int i;
 
+       tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
        /*
         * Search through tcb's and update active timers.
         */
        /*
         * Search through tcb's and update active timers.
         */
@@ -141,8 +149,8 @@ tcp_timers(tp, timer)
         */
        case TCPT_2MSL:
                if (tp->t_state != TCPS_TIME_WAIT &&
         */
        case TCPT_2MSL:
                if (tp->t_state != TCPS_TIME_WAIT &&
-                   tp->t_idle <= TCPTV_MAXIDLE)
-                       tp->t_timer[TCPT_2MSL] = TCPTV_KEEP;
+                   tp->t_idle <= tcp_maxidle)
+                       tp->t_timer[TCPT_2MSL] = tcp_keepintvl;
                else
                        tp = tcp_close(tp);
                break;
                else
                        tp = tcp_close(tp);
                break;
@@ -173,9 +181,7 @@ tcp_timers(tp, timer)
                 * retransmit times until then.
                 */
                if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
                 * retransmit times until then.
                 */
                if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
-#if BSD>=43
                        in_losing(tp->t_inpcb);
                        in_losing(tp->t_inpcb);
-#endif
                        tp->t_rttvar += (tp->t_srtt >> 2);
                        tp->t_srtt = 0;
                }
                        tp->t_rttvar += (tp->t_srtt >> 2);
                        tp->t_srtt = 0;
                }
@@ -240,7 +246,7 @@ tcp_timers(tp, timer)
                        goto dropit;
                if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE &&
                    tp->t_state <= TCPS_CLOSE_WAIT) {
                        goto dropit;
                if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE &&
                    tp->t_state <= TCPS_CLOSE_WAIT) {
-                       if (tp->t_idle >= TCPTV_MAXIDLE)
+                       if (tp->t_idle >= tcp_keepidle + tcp_maxidle)
                                goto dropit;
                        /*
                         * Send a packet designed to force a response
                                goto dropit;
                        /*
                         * Send a packet designed to force a response
@@ -266,8 +272,9 @@ tcp_timers(tp, timer)
                        tcp_respond(tp, tp->t_template,
                            tp->rcv_nxt, tp->snd_una - 1, 0);
 #endif
                        tcp_respond(tp, tp->t_template,
                            tp->rcv_nxt, tp->snd_una - 1, 0);
 #endif
-               }
-               tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
+                       tp->t_timer[TCPT_KEEP] = tcp_keepintvl;
+               } else
+                       tp->t_timer[TCPT_KEEP] = tcp_keepidle;
                break;
        dropit:
                tcpstat.tcps_keepdrops++;
                break;
        dropit:
                tcpstat.tcps_keepdrops++;