fix keep alives and timeouts: checksum problem and doing keeps
authorBill Joy <root@ucbvax.Berkeley.EDU>
Thu, 25 Mar 1982 13:56:37 +0000 (05:56 -0800)
committerBill Joy <root@ucbvax.Berkeley.EDU>
Thu, 25 Mar 1982 13:56:37 +0000 (05:56 -0800)
on all connections by mistake (still needs more work to do keeps more
persistantly!)

SCCS-vsn: sys/netinet/tcp_debug.h 4.2
SCCS-vsn: sys/netinet/tcp_input.c 1.63
SCCS-vsn: sys/netinet/tcp_subr.c 4.19
SCCS-vsn: sys/netinet/tcp_timer.c 4.18

usr/src/sys/netinet/tcp_debug.h
usr/src/sys/netinet/tcp_input.c
usr/src/sys/netinet/tcp_subr.c
usr/src/sys/netinet/tcp_timer.c

index 4bc0330..887fa89 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_debug.h     4.1     81/12/22        */
+/*     tcp_debug.h     4.2     82/03/24        */
 
 struct tcp_debug {
        n_time  td_time;
 
 struct tcp_debug {
        n_time  td_time;
@@ -13,9 +13,12 @@ struct       tcp_debug {
 #define        TA_INPUT        0
 #define        TA_OUTPUT       1
 #define        TA_USER         2
 #define        TA_INPUT        0
 #define        TA_OUTPUT       1
 #define        TA_USER         2
+#define        TA_RESPOND      3
+#define        TA_DROP         4
 
 #ifdef TANAMES
 
 #ifdef TANAMES
-char   *tanames[] = { "input", "output", "user" };
+char   *tanames[] =
+    { "input", "output", "user", "respond", "drop" };
 #endif
 
 #define        TCP_NDEBUG 100
 #endif
 
 #define        TCP_NDEBUG 100
index d2ce8d1..ca3896e 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_input.c     1.62    82/03/19        */
+/*     tcp_input.c     1.63    82/03/24        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -690,6 +690,8 @@ dropafterack:
        if ((tiflags&TH_RST) ||
            tlen == 0 && (tiflags&(TH_SYN|TH_FIN)) == 0)
                goto drop;
        if ((tiflags&TH_RST) ||
            tlen == 0 && (tiflags&(TH_SYN|TH_FIN)) == 0)
                goto drop;
+       if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+               tcp_trace(TA_RESPOND, ostate, tp, &tcp_saveti, 0);
        tcp_respond(tp, ti, tp->rcv_nxt, tp->snd_nxt, TH_ACK);
        return;
 
        tcp_respond(tp, ti, tp->rcv_nxt, tp->snd_nxt, TH_ACK);
        return;
 
@@ -716,6 +718,8 @@ drop:
        /*
         * Drop space held by incoming segment and return.
         */
        /*
         * Drop space held by incoming segment and return.
         */
+       if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+               tcp_trace(TA_DROP, ostate, tp, &tcp_saveti, 0);
        m_freem(m);
        return;
 }
        m_freem(m);
        return;
 }
index fb20f7f..22da4cc 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_subr.c      4.18    82/03/15        */
+/*     tcp_subr.c      4.19    82/03/24        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -138,7 +138,7 @@ COUNT(TCP_RESPOND);
        ti->ti_win = htons(ti->ti_win);
 #endif
        ti->ti_urp = 0;
        ti->ti_win = htons(ti->ti_win);
 #endif
        ti->ti_urp = 0;
-       ti->ti_sum = in_cksum(m, sizeof(struct tcpiphdr));
+       ti->ti_sum = in_cksum(m, sizeof (struct tcpiphdr) + tlen);
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
        (void) ip_output(m, (struct mbuf *)0, 0);
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
        (void) ip_output(m, (struct mbuf *)0, 0);
index f038b4e..ab04a29 100644 (file)
@@ -1,4 +1,4 @@
-/* tcp_timer.c 4.17 82/03/19 */
+/* tcp_timer.c 4.18 82/03/24 */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -162,12 +162,11 @@ printf("rexmt set to %d\n", tp->t_timer[TCPT_REXMT]);
         * or drop connection if idle for too long.
         */
        case TCPT_KEEP:
         * or drop connection if idle for too long.
         */
        case TCPT_KEEP:
-               if (tp->t_state < TCPS_ESTABLISHED ||
-                   tp->t_idle >= TCPTV_MAXIDLE) {
-                       tcp_drop(tp, ETIMEDOUT);
-                       return;
-               }
+               if (tp->t_state < TCPS_ESTABLISHED)
+                       goto dropit;
                if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) {
                if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE) {
+                       if (tp->t_idle >= TCPTV_MAXIDLE)
+                               goto dropit;
                        /*
                         * Saying tp->rcv_nxt-1 lies about what
                         * we have received, and by the protocol spec
                        /*
                         * Saying tp->rcv_nxt-1 lies about what
                         * we have received, and by the protocol spec
@@ -184,6 +183,9 @@ printf("rexmt set to %d\n", tp->t_timer[TCPT_REXMT]);
                        tp->t_idle = 0;
                tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
                return;
                        tp->t_idle = 0;
                tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
                return;
+       dropit:
+               tcp_drop(tp, ETIMEDOUT);
+               return;
 
 #ifdef TCPTRUEOOB
        /*
 
 #ifdef TCPTRUEOOB
        /*