interfac queueing, restrictions on packets, tcp keep alives done
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Mon, 15 Mar 1982 20:45:31 +0000 (12:45 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Mon, 15 Mar 1982 20:45:31 +0000 (12:45 -0800)
properly, bug fix to raw

SCCS-vsn: sys/net/if.c 4.10
SCCS-vsn: sys/net/if.h 4.9
SCCS-vsn: sys/vax/if/if_dmc.c 4.5
SCCS-vsn: sys/vax/if/if_en.c 4.40
SCCS-vsn: sys/deprecated/netimp/if_imp.c 4.15
SCCS-vsn: sys/deprecated/netimp/if_imphost.c 4.8
SCCS-vsn: sys/net/if_loop.c 4.6
SCCS-vsn: sys/netinet/ip_input.c 1.32
SCCS-vsn: sys/netinet/ip_output.c 1.26
SCCS-vsn: sys/netinet/raw_ip.c 4.8
SCCS-vsn: sys/net/raw_usrreq.c 4.10
SCCS-vsn: sys/netinet/tcp_input.c 1.61
SCCS-vsn: sys/netinet/tcp_output.c 4.34
SCCS-vsn: sys/netinet/tcp_subr.c 4.18
SCCS-vsn: sys/netinet/tcp_timer.c 4.16
SCCS-vsn: sys/netinet/udp_usrreq.c 4.22

16 files changed:
usr/src/sys/deprecated/netimp/if_imp.c
usr/src/sys/deprecated/netimp/if_imphost.c
usr/src/sys/net/if.c
usr/src/sys/net/if.h
usr/src/sys/net/if_loop.c
usr/src/sys/net/raw_usrreq.c
usr/src/sys/netinet/ip_input.c
usr/src/sys/netinet/ip_output.c
usr/src/sys/netinet/raw_ip.c
usr/src/sys/netinet/tcp_input.c
usr/src/sys/netinet/tcp_output.c
usr/src/sys/netinet/tcp_subr.c
usr/src/sys/netinet/tcp_timer.c
usr/src/sys/netinet/udp_usrreq.c
usr/src/sys/vax/if/if_dmc.c
usr/src/sys/vax/if/if_en.c

index c828e1a..dbc2097 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_imp.c        4.14    82/03/13        */
+/*     if_imp.c        4.15    82/03/15        */
 
 #include "imp.h"
 #if NIMP > 0
 
 #include "imp.h"
 #if NIMP > 0
@@ -96,6 +96,29 @@ COUNT(IMPATTACH);
        return ((int)&sc->imp_if);
 }
 
        return ((int)&sc->imp_if);
 }
 
+#ifdef notdef
+/*
+ * Timer routine to keep priming the IMP until it sends
+ * us the noops we need.  Since we depend on the host and
+ * imp values returned in the noop messages, we must wait
+ * for them before we allow any outgoing traffic.
+ */
+imptimer(sc)
+       register struct imp_softc *sc;
+{
+       int s = splimp();
+
+       if (sc->imp_state != IMPS_INIT) {
+               splx(s);
+               return;
+       }
+       sc->imp_dropcnt = IMP_DROPCNT;
+       impnoops(sc);
+       timeout(imptimer, (caddr_t)sc, 30 * hz);
+       splx(s);
+}
+#endif
+
 /*
  * IMP initialization routine: call hardware module to
  * setup UNIBUS resources, init state and get ready for
 /*
  * IMP initialization routine: call hardware module to
  * setup UNIBUS resources, init state and get ready for
@@ -111,8 +134,12 @@ impinit(unit)
                return;
        }
        sc->imp_state = IMPS_INIT;
                return;
        }
        sc->imp_state = IMPS_INIT;
+#ifdef notdef
+       imptimer(sc);
+#else
        sc->imp_dropcnt = IMP_DROPCNT;
        impnoops(sc);
        sc->imp_dropcnt = IMP_DROPCNT;
        impnoops(sc);
+#endif
 }
 
 struct sockproto impproto = { PF_IMPLINK };
 }
 
 struct sockproto impproto = { PF_IMPLINK };
@@ -335,6 +362,10 @@ COUNT(IMPINPUT);
                  (struct sockaddr *)&impsrc);
                return;
        }
                  (struct sockaddr *)&impsrc);
                return;
        }
+       if (IF_QFULL(inq)) {
+               IF_DROP(inq);
+               goto drop;
+       }
        IF_ENQUEUE(inq, m);
        return;
 
        IF_ENQUEUE(inq, m);
        return;
 
@@ -348,6 +379,7 @@ drop:
 impdown(sc)
        struct imp_softc *sc;
 {
 impdown(sc)
        struct imp_softc *sc;
 {
+
        sc->imp_state = IMPS_DOWN;
        impmsg(sc, "marked down");
        /* notify protocols with messages waiting? */
        sc->imp_state = IMPS_DOWN;
        impmsg(sc, "marked down");
        /* notify protocols with messages waiting? */
@@ -359,6 +391,7 @@ impmsg(sc, fmt, a1, a2)
        char *fmt;
        u_int a1;
 {
        char *fmt;
        u_int a1;
 {
+
        printf("imp%d: ", sc->imp_if.if_unit);
        printf(fmt, a1, a2);
        printf("\n");
        printf("imp%d: ", sc->imp_if.if_unit);
        printf(fmt, a1, a2);
        printf("\n");
@@ -499,6 +532,12 @@ COUNT(IMPSND);
                return (0);
        }
 enque:
                return (0);
        }
 enque:
+       if (IF_QFULL(&ifp->if_snd)) {
+               IF_DROP(&ifp->if_snd);
+               m_freem(m);
+               splx(x);
+               return (0);
+       }
        IF_ENQUEUE(&ifp->if_snd, m);
 start:
        splx(x);
        IF_ENQUEUE(&ifp->if_snd, m);
 start:
        splx(x);
index 4ffe1d5..1e18fdb 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_imphost.c    4.7     82/03/12        */
+/*     if_imphost.c    4.8     82/03/15        */
 
 #include "imp.h"
 #if NIMP > 0
 
 #include "imp.h"
 #if NIMP > 0
@@ -60,6 +60,7 @@ COUNT(HOSTENTER);
        addr.s_lh = 0;
        mprev = &hosts;
        while (m = *mprev) {
        addr.s_lh = 0;
        mprev = &hosts;
        while (m = *mprev) {
+               mprev = &m->m_next;
                hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
                if (hp->h_refcnt == 0) {
                        if (hp0 == 0)
                hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
                if (hp->h_refcnt == 0) {
                        if (hp0 == 0)
@@ -68,7 +69,6 @@ COUNT(HOSTENTER);
                }
                if (hp->h_addr.s_addr == addr.s_addr)    
                        goto foundhost;
                }
                if (hp->h_addr.s_addr == addr.s_addr)    
                        goto foundhost;
-               mprev = &m->m_next;
        }
 
        /*
        }
 
        /*
index d728cc9..c1c6c10 100644 (file)
@@ -1,4 +1,4 @@
-/*     if.c    4.9     82/03/09        */
+/*     if.c    4.10    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -6,13 +6,18 @@
 #include "../net/in_systm.h"
 #include "../net/if.h"
 
 #include "../net/in_systm.h"
 #include "../net/if.h"
 
+int    ifqmaxlen = IFQ_MAXLEN;
+
 ifinit()
 {
        register struct ifnet *ifp;
 
        for (ifp = ifnet; ifp; ifp = ifp->if_next)
 ifinit()
 {
        register struct ifnet *ifp;
 
        for (ifp = ifnet; ifp; ifp = ifp->if_next)
-               if (ifp->if_init)
+               if (ifp->if_init) {
                        (*ifp->if_init)();
                        (*ifp->if_init)();
+                       if (ifp->if_snd.ifq_maxlen == 0)
+                               ifp->if_snd.ifq_maxlen = ifqmaxlen;
+               }
 }
 
 ifubareset(uban)
 }
 
 ifubareset(uban)
index eb73d03..4ffe402 100644 (file)
@@ -1,4 +1,4 @@
-/*     if.h    4.8     82/03/09        */
+/*     if.h    4.9     82/03/15        */
 
 /*
  * Structures defining a network interface, providing a packet
 
 /*
  * Structures defining a network interface, providing a packet
@@ -42,6 +42,9 @@ struct ifnet {
        struct  ifqueue {
                struct  mbuf *ifq_head;
                struct  mbuf *ifq_tail;
        struct  ifqueue {
                struct  mbuf *ifq_head;
                struct  mbuf *ifq_tail;
+               int     ifq_len;
+               int     ifq_maxlen;
+               int     ifq_drops;
        } if_snd;                       /* output queue */
 /* procedure handles */
        int     (*if_init)();           /* init routine */
        } if_snd;                       /* output queue */
 /* procedure handles */
        int     (*if_init)();           /* init routine */
@@ -63,6 +66,8 @@ struct ifnet {
  * (defined above).  Entries are added to and deleted from these structures
  * by these macros, which should be called with ipl raised to splimp().
  */
  * (defined above).  Entries are added to and deleted from these structures
  * by these macros, which should be called with ipl raised to splimp().
  */
+#define        IF_QFULL(ifq)           ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
+#define        IF_DROP(ifq)            ((ifq)->ifq_drops++)
 #define        IF_ENQUEUE(ifq, m) { \
        (m)->m_act = 0; \
        if ((ifq)->ifq_tail == 0) \
 #define        IF_ENQUEUE(ifq, m) { \
        (m)->m_act = 0; \
        if ((ifq)->ifq_tail == 0) \
@@ -70,12 +75,14 @@ struct ifnet {
        else \
                (ifq)->ifq_tail->m_act = m; \
        (ifq)->ifq_tail = m; \
        else \
                (ifq)->ifq_tail->m_act = m; \
        (ifq)->ifq_tail = m; \
+       (ifq)->ifq_len++; \
 }
 #define        IF_PREPEND(ifq, m) { \
        (m)->m_act = (ifq)->ifq_head; \
        if ((ifq)->ifq_tail == 0) \
                (ifq)->ifq_tail = (m); \
        (ifq)->ifq_head = (m); \
 }
 #define        IF_PREPEND(ifq, m) { \
        (m)->m_act = (ifq)->ifq_head; \
        if ((ifq)->ifq_tail == 0) \
                (ifq)->ifq_tail = (m); \
        (ifq)->ifq_head = (m); \
+       (ifq)->ifq_len++; \
 }
 #define        IF_DEQUEUE(ifq, m) { \
        (m) = (ifq)->ifq_head; \
 }
 #define        IF_DEQUEUE(ifq, m) { \
        (m) = (ifq)->ifq_head; \
@@ -83,9 +90,12 @@ struct ifnet {
                if (((ifq)->ifq_head = (m)->m_act) == 0) \
                        (ifq)->ifq_tail = 0; \
                (m)->m_act = 0; \
                if (((ifq)->ifq_head = (m)->m_act) == 0) \
                        (ifq)->ifq_tail = 0; \
                (m)->m_act = 0; \
+               (ifq)->ifq_len--; \
        } \
 }
 
        } \
 }
 
+#define        IFQ_MAXLEN      50
+
 #ifdef KERNEL
 #ifdef INET
 struct ifqueue ipintrq;                /* ip packet input queue */
 #ifdef KERNEL
 #ifdef INET
 struct ifqueue ipintrq;                /* ip packet input queue */
index f630d45..633545d 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_loop.c       4.5     81/12/22        */
+/*     if_loop.c       4.6     82/03/15        */
 
 /*
  * Loopback interface driver for protocol testing and timing.
 
 /*
  * Loopback interface driver for protocol testing and timing.
@@ -39,13 +39,21 @@ looutput(ifp, m0, pf)
        int pf;
 {
        int s = splimp();
        int pf;
 {
        int s = splimp();
+       register struct ifqueue *ifq;
 
        ifp->if_opackets++;
        switch (pf) {
 
 #ifdef INET
        case PF_INET:
 
        ifp->if_opackets++;
        switch (pf) {
 
 #ifdef INET
        case PF_INET:
-               IF_ENQUEUE(&ipintrq, m0);
+               ifq = &ipintrq;
+               if (IF_QFULL(ifq)) {
+                       IF_DROP(ifq);
+                       (void) m_freem(m0);
+                       splx(s);
+                       return (0);
+               }
+               IF_ENQUEUE(ifq, m0);
                setipintr();
                break;
 #endif
                setipintr();
                break;
 #endif
@@ -53,7 +61,7 @@ looutput(ifp, m0, pf)
        default:
                splx(s);
                printf("lo%d: can't encapsulate pf%d\n", ifp->if_unit, pf);
        default:
                splx(s);
                printf("lo%d: can't encapsulate pf%d\n", ifp->if_unit, pf);
-               m_freem(m0);
+               (void) m_freem(m0);
                return (0);
        }
        ifp->if_ipackets++;
                return (0);
        }
        ifp->if_ipackets++;
index 5dbdd02..6e08ffb 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_usrreq.c    4.9     82/03/13        */
+/*     raw_usrreq.c    4.10    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 #include "../net/raw_cb.h"
 #include "../errno.h"
 
 #include "../net/raw_cb.h"
 #include "../errno.h"
 
+int    rawqmaxlen = IFQ_MAXLEN;
+
 /*
  * Initialize raw connection block q.
 /*
  * Initialize raw connection block q.
-*/
+ */
 raw_init()
 {
 raw_init()
 {
+
 COUNT(RAW_INIT);
        rawcb.rcb_next = rawcb.rcb_prev = &rawcb;
 COUNT(RAW_INIT);
        rawcb.rcb_next = rawcb.rcb_prev = &rawcb;
+       rawintrq.ifq_maxlen = IFQ_MAXLEN;
 }
 
 /*
 }
 
 /*
@@ -57,7 +61,10 @@ COUNT(RAW_INPUT);
         * running at software interrupt level.
         */
        s = splimp();
         * running at software interrupt level.
         */
        s = splimp();
-       IF_ENQUEUE(&rawintrq, m);
+       if (IF_QFULL(&rawintrq))
+               m_freem(m);
+       else
+               IF_ENQUEUE(&rawintrq, m);
        splx(s);
        setrawintr();
 }
        splx(s);
        setrawintr();
 }
@@ -180,8 +187,10 @@ COUNT(RAW_USRREQ);
         * the appropriate raw interface routine.
         */
        case PRU_ATTACH:
         * the appropriate raw interface routine.
         */
        case PRU_ATTACH:
+               if ((so->so_state & SS_PRIV) == 0)
+                       return (EPERM);
                if (rp)
                if (rp)
-                       return (EINVAL);;
+                       return (EINVAL);
                error = raw_attach(so, (struct sockaddr *)addr);
                break;
 
                error = raw_attach(so, (struct sockaddr *)addr);
                break;
 
index b9daeac..609856c 100644 (file)
@@ -1,4 +1,4 @@
-/*     ip_input.c      1.31    82/03/09        */
+/*     ip_input.c      1.32    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -15,6 +15,7 @@
 #include "../net/tcp.h"
 
 u_char ip_protox[IPPROTO_MAX];
 #include "../net/tcp.h"
 
 u_char ip_protox[IPPROTO_MAX];
+int    ipqmaxlen = IFQ_MAXLEN;
 
 /*
  * IP initialization: fill in IP protocol switch table.
 
 /*
  * IP initialization: fill in IP protocol switch table.
@@ -37,6 +38,7 @@ COUNT(IP_INIT);
                        ip_protox[pr->pr_protocol] = pr - protosw;
        ipq.next = ipq.prev = &ipq;
        ip_id = time & 0xffff;
                        ip_protox[pr->pr_protocol] = pr - protosw;
        ipq.next = ipq.prev = &ipq;
        ip_id = time & 0xffff;
+       ipintrq.ifq_maxlen = ipqmaxlen;
 }
 
 u_char ipcksum = 1;
 }
 
 u_char ipcksum = 1;
@@ -120,11 +122,12 @@ next:
        if (hlen > sizeof (struct ip))
                ip_dooptions(ip);
        if (ifnet && ip->ip_dst.s_addr != ifnet->if_addr.s_addr &&
        if (hlen > sizeof (struct ip))
                ip_dooptions(ip);
        if (ifnet && ip->ip_dst.s_addr != ifnet->if_addr.s_addr &&
-           ip->ip_dst.s_addr != ifnet->if_broadaddr.s_addr &&
            if_ifwithaddr(ip->ip_dst) == 0) {
            if_ifwithaddr(ip->ip_dst) == 0) {
-printf("ip->ip_dst %x ip->ip_ttl %x\n", ip->ip_dst, ip->ip_ttl);
-               if (1)
-                       goto bad;
+
+               goto bad;
+#ifdef notdef
+               printf("ip->ip_dst %x ip->ip_ttl %x\n",
+                   ip->ip_dst, ip->ip_ttl);
                if (--ip->ip_ttl == 0) {
                        icmp_error(ip, ICMP_TIMXCEED, 0);
                        goto next;
                if (--ip->ip_ttl == 0) {
                        icmp_error(ip, ICMP_TIMXCEED, 0);
                        goto next;
@@ -133,8 +136,10 @@ printf("ip->ip_dst %x ip->ip_ttl %x\n", ip->ip_dst, ip->ip_ttl);
                if (mopt == 0)
                        goto bad;
                ip_stripoptions(ip, mopt);
                if (mopt == 0)
                        goto bad;
                ip_stripoptions(ip, mopt);
-               (void) ip_output(m0, mopt);
+               /* 0 here means no directed broadcast */
+               (void) ip_output(m0, mopt, 0);
                goto next;
                goto next;
+#endif
        }
 
        /*
        }
 
        /*
index 59dd2a2..68a9d19 100644 (file)
@@ -1,4 +1,4 @@
-/*     ip_output.c     1.25    82/02/18        */
+/*     ip_output.c     1.26    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 
-ip_output(m, opt)
+ip_output(m, opt, allowbroadcast)
        struct mbuf *m;
        struct mbuf *opt;
        struct mbuf *m;
        struct mbuf *opt;
+       int allowbroadcast;
 {
        register struct ip *ip = mtod(m, struct ip *);
        register struct ifnet *ifp;
 {
        register struct ip *ip = mtod(m, struct ip *);
        register struct ifnet *ifp;
@@ -39,6 +40,9 @@ COUNT(IP_OUTPUT);
                if (ifp == 0)
                        goto bad;
        }
                if (ifp == 0)
                        goto bad;
        }
+       if (!allowbroadcast && ifp->if_broadaddr.s_addr != 0 &&
+           ifp->if_broadaddr.s_addr == ip->ip_dst.s_addr)
+               goto bad;
 
        /*
         * If small enough for interface, can just send directly.
 
        /*
         * If small enough for interface, can just send directly.
index 7e4df61..f1e9e18 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_ip.c        4.7     82/03/13        */
+/*     raw_ip.c        4.8     82/03/15        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
@@ -85,7 +85,7 @@ COUNT(RIP_OUTPUT);
        ip->ip_src =
                ((struct sockaddr_in *)&so->so_addr)->sin_addr;
        ip->ip_ttl = MAXTTL;
        ip->ip_src =
                ((struct sockaddr_in *)&so->so_addr)->sin_addr;
        ip->ip_ttl = MAXTTL;
-       return (ip_output(m, (struct mbuf *)0));
+       return (ip_output(m, (struct mbuf *)0, 1));
 }
 
 /*
 }
 
 /*
index cf96e45..1cbaa28 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_input.c     1.60    82/03/13        */
+/*     tcp_input.c     1.61    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -21,9 +21,7 @@
 #include "../net/tcp_debug.h"
 #include "../errno.h"
 
 #include "../net/tcp_debug.h"
 #include "../errno.h"
 
-#ifdef notdef
 int    tcpprintfs = 0;
 int    tcpprintfs = 0;
-#endif
 int    tcpcksum = 1;
 struct sockaddr_in tcp_in = { AF_INET };
 struct tcpiphdr tcp_saveti;
 int    tcpcksum = 1;
 struct sockaddr_in tcp_in = { AF_INET };
 struct tcpiphdr tcp_saveti;
@@ -80,7 +78,8 @@ COUNT(TCP_INPUT);
 #endif
                if (ti->ti_sum = in_cksum(m, len)) {
                        tcpstat.tcps_badsum++;
 #endif
                if (ti->ti_sum = in_cksum(m, len)) {
                        tcpstat.tcps_badsum++;
-                       printf("tcp cksum %x\n", ti->ti_sum);
+                       if (tcpprintfs)
+                               printf("tcp cksum %x\n", ti->ti_sum);
                        goto drop;
                }
        }
                        goto drop;
                }
        }
@@ -94,7 +93,8 @@ COUNT(TCP_INPUT);
                tcpstat.tcps_badoff++;
                goto drop;
        }
                tcpstat.tcps_badoff++;
                goto drop;
        }
-       ti->ti_len = tlen - off;
+       tlen -= off;
+       ti->ti_len = tlen;
        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++;
@@ -116,7 +116,7 @@ COUNT(TCP_INPUT);
        tiflags = ti->ti_flags;
 
        /*
        tiflags = ti->ti_flags;
 
        /*
-        * drop IP header
+        * Drop TCP and IP headers.
         */
        off += sizeof (struct ip);
        m->m_off += off;
         */
        off += sizeof (struct ip);
        m->m_off += off;
@@ -317,7 +317,8 @@ trimthenstep6:
                                        tiflags &= ~TH_URG;
                                todrop--;
                        }
                                        tiflags &= ~TH_URG;
                                todrop--;
                        }
-                       if (todrop > ti->ti_len)
+                       if (todrop > ti->ti_len ||
+                           todrop == ti->ti_len && (tiflags&TH_FIN) == 0)
                                goto dropafterack;
                        m_adj(m, todrop);
                        ti->ti_seq += todrop;
                                goto dropafterack;
                        m_adj(m, todrop);
                        ti->ti_seq += todrop;
@@ -336,7 +337,7 @@ trimthenstep6:
                 */
                todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd);
                if (todrop > 0) {
                 */
                todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd);
                if (todrop > 0) {
-                       if (todrop > ti->ti_len)
+                       if (todrop >= ti->ti_len)
                                goto dropafterack;
                        m_adj(m, -todrop);
                        ti->ti_len -= todrop;
                                goto dropafterack;
                        m_adj(m, -todrop);
                        ti->ti_len -= todrop;
@@ -681,10 +682,11 @@ step6:
 
 dropafterack:
        /*
 
 dropafterack:
        /*
-        * Generate an ACK dropping incoming segment.
-        * Make ACK reflect our state.
+        * Generate an ACK dropping incoming segment if it occupies
+        * sequence space, where the ACK reflects our state.
         */
         */
-       if (tiflags & TH_RST)
+       if ((tiflags&TH_RST) ||
+           tlen == 0 && (tiflags&(TH_SYN|TH_FIN)) == 0)
                goto drop;
        tcp_respond(tp, ti, tp->rcv_nxt, tp->snd_nxt, TH_ACK);
        return;
                goto drop;
        tcp_respond(tp, ti, tp->rcv_nxt, tp->snd_nxt, TH_ACK);
        return;
@@ -703,7 +705,8 @@ dropwithreset:
        else {
                if (tiflags & TH_SYN)
                        ti->ti_len++;
        else {
                if (tiflags & TH_SYN)
                        ti->ti_len++;
-               tcp_respond(tp, ti, ti->ti_seq+ti->ti_len, (tcp_seq)0, TH_RST|TH_ACK);
+               tcp_respond(tp, ti, ti->ti_seq+ti->ti_len, (tcp_seq)0,
+                   TH_RST|TH_ACK);
        }
        return;
 
        }
        return;
 
index 919407d..40e5a0d 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_output.c    4.33    82/03/13        */
+/*     tcp_output.c    4.34    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -285,7 +285,7 @@ noopt:
         */
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
         */
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
-       if (ip_output(m, tp->t_ipopt) == 0)
+       if (ip_output(m, tp->t_ipopt, 0) == 0)
                return (0);
 
        /*
                return (0);
 
        /*
index 5daa21a..fb20f7f 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_subr.c      4.17    82/03/13        */
+/*     tcp_subr.c      4.18    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -93,7 +93,7 @@ tcp_respond(tp, ti, ack, seq, flags)
        int flags;
 {
        struct mbuf *m;
        int flags;
 {
        struct mbuf *m;
-       int win = 0;
+       int win = 0, tlen;
 
 COUNT(TCP_RESPOND);
        if (tp)
 
 COUNT(TCP_RESPOND);
        if (tp)
@@ -103,10 +103,11 @@ COUNT(TCP_RESPOND);
                if (m == 0)
                        return;
                m->m_off = MMINOFF;
                if (m == 0)
                        return;
                m->m_off = MMINOFF;
-               m->m_len = sizeof (struct tcpiphdr);
+               m->m_len = sizeof (struct tcpiphdr) + 1;
                *mtod(m, struct tcpiphdr *) = *ti;
                ti = mtod(m, struct tcpiphdr *);
                flags = TH_ACK;
                *mtod(m, struct tcpiphdr *) = *ti;
                ti = mtod(m, struct tcpiphdr *);
                flags = TH_ACK;
+               tlen = 1;
        } else {
                m = dtom(ti);
                m_freem(m->m_next);
        } else {
                m = dtom(ti);
                m_freem(m->m_next);
@@ -117,10 +118,11 @@ COUNT(TCP_RESPOND);
                xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_long);
                xchg(ti->ti_dport, ti->ti_sport, u_short);
 #undef xchg
                xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_long);
                xchg(ti->ti_dport, ti->ti_sport, u_short);
 #undef xchg
+               tlen = 0;
        }
        ti->ti_next = ti->ti_prev = 0;
        ti->ti_x1 = 0;
        }
        ti->ti_next = ti->ti_prev = 0;
        ti->ti_x1 = 0;
-       ti->ti_len = sizeof (struct tcphdr);
+       ti->ti_len = sizeof (struct tcphdr) + tlen;
        ti->ti_seq = seq;
        ti->ti_ack = ack;
 #if vax
        ti->ti_seq = seq;
        ti->ti_ack = ack;
 #if vax
@@ -137,9 +139,9 @@ COUNT(TCP_RESPOND);
 #endif
        ti->ti_urp = 0;
        ti->ti_sum = in_cksum(m, sizeof(struct tcpiphdr));
 #endif
        ti->ti_urp = 0;
        ti->ti_sum = in_cksum(m, sizeof(struct tcpiphdr));
-       ((struct ip *)ti)->ip_len = sizeof(struct tcpiphdr);
+       ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + tlen;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
-       (void) ip_output(m, (struct mbuf *)0);
+       (void) ip_output(m, (struct mbuf *)0, 0);
 }
 
 /*
 }
 
 /*
index 4a4db37..ce8c3db 100644 (file)
@@ -1,4 +1,4 @@
-/* tcp_timer.c 4.15 82/02/25 */
+/* tcp_timer.c 4.16 82/03/15 */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -50,7 +50,7 @@ COUNT(TCP_FASTTIMO);
  */
 tcp_slowtimo()
 {
  */
 tcp_slowtimo()
 {
-       register struct inpcb *ip;
+       register struct inpcb *ip, *ipnxt;
        register struct tcpcb *tp;
        int s = splnet();
        register int i;
        register struct tcpcb *tp;
        int s = splnet();
        register int i;
@@ -64,19 +64,25 @@ COUNT(TCP_SLOWTIMO);
                splx(s);
                return;
        }
                splx(s);
                return;
        }
-       for (; ip != &tcb; ip = ip->inp_next) {
+       while (ip != &tcb) {
                tp = intotcpcb(ip);
                if (tp == 0)
                        continue;
                tp = intotcpcb(ip);
                if (tp == 0)
                        continue;
+               ipnxt = ip->inp_next;
                for (i = 0; i < TCPT_NTIMERS; i++) {
                for (i = 0; i < TCPT_NTIMERS; i++) {
-                       if (tp->t_timer[i] && --tp->t_timer[i] == 0)
+                       if (tp->t_timer[i] && --tp->t_timer[i] == 0) {
                                (void) tcp_usrreq(tp->t_inpcb->inp_socket,
                                    PRU_SLOWTIMO, (struct mbuf *)0,
                                    (caddr_t)i);
                                (void) tcp_usrreq(tp->t_inpcb->inp_socket,
                                    PRU_SLOWTIMO, (struct mbuf *)0,
                                    (caddr_t)i);
+                               if (ipnxt->inp_prev != ip)
+                                       goto tpgone;
+                       }
                }
                tp->t_idle++;
                if (tp->t_rtt)
                        tp->t_rtt++;
                }
                tp->t_idle++;
                if (tp->t_rtt)
                        tp->t_rtt++;
+tpgone:
+               ip = ipnxt;
        }
        tcp_iss += TCP_ISSINCR/PR_SLOWHZ;               /* increment iss */
        splx(s);
        }
        tcp_iss += TCP_ISSINCR/PR_SLOWHZ;               /* increment iss */
        splx(s);
@@ -161,11 +167,11 @@ printf("rexmt set to %d\n", tp->t_timer[TCPT_REXMT]);
                        tcp_drop(tp, ETIMEDOUT);
                        return;
                }
                        tcp_drop(tp, ETIMEDOUT);
                        return;
                }
-               if (tp->t_inpcb->inp_socket->so_options & SO_NOKEEPALIVE)
-                       tp->t_idle = 0;
-               else
+               if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE)
                        tcp_respond(tp,
                            tp->t_template, tp->rcv_nxt, tp->snd_una-1, 0);
                        tcp_respond(tp,
                            tp->t_template, tp->rcv_nxt, tp->snd_una-1, 0);
+               else
+                       tp->t_idle = 0;
                tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
                return;
 
                tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
                return;
 
index 0a95375..5b5324d 100644 (file)
@@ -1,4 +1,4 @@
-/*     udp_usrreq.c    4.21    82/03/03        */
+/*     udp_usrreq.c    4.22    82/03/15        */
 
 #include "../h/param.h"
 #include "../h/dir.h"
 
 #include "../h/param.h"
 #include "../h/dir.h"
@@ -159,7 +159,8 @@ COUNT(UDP_OUTPUT);
        ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len);
        ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
        ((struct ip *)ui)->ip_ttl = MAXTTL;
        ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len);
        ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
        ((struct ip *)ui)->ip_ttl = MAXTTL;
-       (void) ip_output(m, (struct mbuf *)0);
+       (void) ip_output(m, (struct mbuf *)0,
+           inp->inp_socket->so_state & SS_PRIV);
        return;
 bad:
        m_freem(m);
        return;
 bad:
        m_freem(m);
index 31503f6..9a4ed46 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_dmc.c        4.4     82/03/13        */
+/*     if_dmc.c        4.5     82/03/15        */
 
 #include "dmc.h"
 #if NDMC > 0
 
 #include "dmc.h"
 #if NDMC > 0
@@ -327,7 +327,11 @@ dmcxint(unit)
                m = if_rubaget(&sc->sc_ifuba, len, 0);
                if (m == 0)
                        goto setup;
                m = if_rubaget(&sc->sc_ifuba, len, 0);
                if (m == 0)
                        goto setup;
-               IF_ENQUEUE(inq, m);
+               if (IF_QFULL(inq)) {
+                       IF_DROP(inq);
+                       (void) m_freem(m);
+               } else
+                       IF_ENQUEUE(inq, m);
 
 setup:
                arg = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
 
 setup:
                arg = sc->sc_ifuba.ifu_r.ifrw_info & 0x3ffff;
@@ -345,7 +349,7 @@ setup:
                sc->sc_if.if_opackets++;
                sc->sc_oactive = 0;
                if (sc->sc_ifuba.ifu_xtofree) {
                sc->sc_if.if_opackets++;
                sc->sc_oactive = 0;
                if (sc->sc_ifuba.ifu_xtofree) {
-                       m_freem(sc->sc_ifuba.ifu_xtofree);
+                       (void) m_freem(sc->sc_ifuba.ifu_xtofree);
                        sc->sc_ifuba.ifu_xtofree = 0;
                }
                if (sc->sc_if.if_snd.ifq_head == 0)
                        sc->sc_ifuba.ifu_xtofree = 0;
                }
                if (sc->sc_if.if_snd.ifq_head == 0)
@@ -387,10 +391,16 @@ dmcoutput(ifp, m, pf)
        printd("dmcoutput\n");
        if (pf != (ui->ui_flags & DMC_PF)) {
                printf("dmc%d: protocol %d not supported\n", ifp->if_unit, pf);
        printd("dmcoutput\n");
        if (pf != (ui->ui_flags & DMC_PF)) {
                printf("dmc%d: protocol %d not supported\n", ifp->if_unit, pf);
-               m_freem(m);
+               (void) m_freem(m);
                return (0);
        }
        s = splimp();
                return (0);
        }
        s = splimp();
+       if (IF_QFULL(&ifp->if_snd)) {
+               IF_DROP(&ifp->if_snd);
+               (void) m_freem(m);
+               splx(s);
+               return (0);
+       }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (dmc_softc[ifp->if_unit].sc_oactive == 0)
                dmcstart(ifp->if_unit);
        IF_ENQUEUE(&ifp->if_snd, m);
        if (dmc_softc[ifp->if_unit].sc_oactive == 0)
                dmcstart(ifp->if_unit);
index 1e0c8f7..381c0d9 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_en.c 4.39    82/03/13        */
+/*     if_en.c 4.40    82/03/15        */
 
 #include "en.h"
 
 
 #include "en.h"
 
@@ -413,7 +413,11 @@ COUNT(ENRINT);
                goto setup;
                }
        }
                goto setup;
                }
        }
-       IF_ENQUEUE(inq, m);
+       if (IF_QFULL(inq)) {
+               IF_DROP(inq);
+               (void) m_freem(m);
+       } else
+               IF_ENQUEUE(inq, m);
 
 setup:
        /*
 
 setup:
        /*
@@ -532,6 +536,12 @@ gottype:
         * not yet active.
         */
        s = splimp();
         * not yet active.
         */
        s = splimp();
+       if (IF_QFULL(&ifp->if_snd)) {
+               IF_DROP(&ifp->if_snd);
+               m_freem(m);
+               splx(s);
+               return (0);
+       }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);
        IF_ENQUEUE(&ifp->if_snd, m);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);