free queued segments carefully, runs at splnet, not splimp
[unix-history] / usr / src / sys / netinet / tcp_input.c
index 7ee72ab..416942d 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_input.c     1.89    83/02/10        */
+/*     tcp_input.c     1.93    83/05/01        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -77,9 +77,9 @@ tcp_input(m0)
                ti->ti_len = (u_short)tlen;
                ti->ti_len = htons((u_short)ti->ti_len);
                if (ti->ti_sum = in_cksum(m, len)) {
                ti->ti_len = (u_short)tlen;
                ti->ti_len = htons((u_short)ti->ti_len);
                if (ti->ti_sum = in_cksum(m, len)) {
-                       tcpstat.tcps_badsum++;
                        if (tcpprintfs)
                        if (tcpprintfs)
-                               printf("tcp cksum %x\n", ti->ti_sum);
+                               printf("tcp sum: src %x\n", ti->ti_src);
+                       tcpstat.tcps_badsum++;
                        goto drop;
                }
        }
                        goto drop;
                }
        }
@@ -90,6 +90,8 @@ tcp_input(m0)
         */
        off = ti->ti_off << 2;
        if (off < sizeof (struct tcphdr) || off > tlen) {
         */
        off = ti->ti_off << 2;
        if (off < sizeof (struct tcphdr) || off > tlen) {
+               if (tcpprintfs)
+                       printf("tcp off: src %x off %d\n", ti->ti_src, off);
                tcpstat.tcps_badoff++;
                goto drop;
        }
                tcpstat.tcps_badoff++;
                goto drop;
        }
@@ -98,7 +100,7 @@ tcp_input(m0)
        if (off > sizeof (struct tcphdr)) {
                if ((m = m_pullup(m, sizeof (struct ip) + off)) == 0) {
                        tcpstat.tcps_hdrops++;
        if (off > sizeof (struct tcphdr)) {
                if ((m = m_pullup(m, sizeof (struct ip) + off)) == 0) {
                        tcpstat.tcps_hdrops++;
-                       goto drop;
+                       return;
                }
                ti = mtod(m, struct tcpiphdr *);
                om = m_get(M_DONTWAIT, MT_DATA);
                }
                ti = mtod(m, struct tcpiphdr *);
                om = m_get(M_DONTWAIT, MT_DATA);
@@ -706,8 +708,10 @@ dropafterack:
        return;
 
 dropwithreset:
        return;
 
 dropwithreset:
-       if (om)
+       if (om) {
                (void) m_free(om);
                (void) m_free(om);
+               om = 0;
+       }
        /*
         * Generate a RST, dropping incoming segment.
         * Make ACK acceptable to originator of segment.
        /*
         * Generate a RST, dropping incoming segment.
         * Make ACK acceptable to originator of segment.
@@ -728,6 +732,8 @@ dropwithreset:
        return;
 
 drop:
        return;
 
 drop:
+       if (om)
+               (void) m_free(om);
        /*
         * Drop space held by incoming segment and return.
         */
        /*
         * Drop space held by incoming segment and return.
         */
@@ -755,8 +761,11 @@ tcp_dooptions(tp, om)
                        break;
                if (opt == TCPOPT_NOP)
                        optlen = 1;
                        break;
                if (opt == TCPOPT_NOP)
                        optlen = 1;
-               else
+               else {
                        optlen = cp[1];
                        optlen = cp[1];
+                       if (optlen <= 0)
+                               break;
+               }
                switch (opt) {
 
                default:
                switch (opt) {
 
                default: