CLEAN UP SLIP INTERFACE TO KEEP FROM HANGING
authorPoul-Henning Kamp <phk@FreeBSD.org>
Sun, 30 Aug 1992 00:00:00 +0000 (00:00 +0000)
committerPoul-Henning Kamp <phk@FreeBSD.org>
Sun, 30 Aug 1992 00:00:00 +0000 (00:00 +0000)
Here is a patch to clean up the interface between the tty-drivers, in
particular the com driver, and the sl# interfaces, this is not a work-around
but a genuine bug-fix.

Symptoms: after a number of "com#: silo overflow" SLIP ceases to work.

Overview of the problem:  the slip interface will disregard any notice
from the tty-driver on problems (parity errors, framing errors or overruns),
which basicly means the one might as well throw the packet away right away.
Also overrun in the packetizing will go relatively unnotized.

AUTHOR:         Poul-Henning Kamp (phk@data.fls.dk)
386BSD-Patchkit: patch00019

usr/src/sys.386bsd/i386/isa/com.c
usr/src/sys.386bsd/net/if_sl.c
usr/src/sys.386bsd/net/if_slvar.h

index 5b1c5fd..b370f30 100644 (file)
  *
  * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
  * --------------------         -----   ----------------------
  *
  * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
  * --------------------         -----   ----------------------
- * CURRENT PATCH LEVEL:         1       00018
+ * CURRENT PATCH LEVEL:         2       00019
  * --------------------         -----   ----------------------
  *
  * --------------------         -----   ----------------------
  *
+ * 30 Aug 92   Poul-Henning Kamp       Stabilize SLIP on lossy lines/UARTS
  * 09 Aug 92   Christoph Robitschko    Correct minor number on com ports
  */
 static char rcsid[] = "$Header: /usr/bill/working/sys/i386/isa/RCS/com.c,v 1.2 92/01/21 14:34:11 william Exp $";
  * 09 Aug 92   Christoph Robitschko    Correct minor number on com ports
  */
 static char rcsid[] = "$Header: /usr/bill/working/sys/i386/isa/RCS/com.c,v 1.2 92/01/21 14:34:11 william Exp $";
@@ -375,8 +376,10 @@ comeint(unit, stat, com)
                c |= TTY_FE;
        else if (stat & LSR_PE)
                c |= TTY_PE;
                c |= TTY_FE;
        else if (stat & LSR_PE)
                c |= TTY_PE;
-       else if (stat & LSR_OE)
+       else if (stat & LSR_OE) {                       /* 30 Aug 92*/
+               c |= TTY_PE;    /* Ought to have it's own define... */
                log(LOG_WARNING, "com%d: silo overflow\n", unit);
                log(LOG_WARNING, "com%d: silo overflow\n", unit);
+       }
        (*linesw[tp->t_line].l_rint)(c, tp);
 }
 
        (*linesw[tp->t_line].l_rint)(c, tp);
 }
 
index 733c7b2..7e97e07 100644 (file)
  * SUCH DAMAGE.
  *
  *     @(#)if_sl.c     7.22 (Berkeley) 4/20/91
  * SUCH DAMAGE.
  *
  *     @(#)if_sl.c     7.22 (Berkeley) 4/20/91
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00019
+ * --------------------         -----   ----------------------
+ *
+ * 30 Aug 92    Poul-Henning Kamp       Stabilize SLIP on lossy lines/UARTS
  */
 
 /*
  */
 
 /*
@@ -623,8 +630,10 @@ slinput(c, tp)
        sc = (struct sl_softc *)tp->t_sc;
        if (sc == NULL)
                return;
        sc = (struct sl_softc *)tp->t_sc;
        if (sc == NULL)
                return;
-       if (!(tp->t_state&TS_CARR_ON))  /* XXX */
+       if (c > 255 || !(tp->t_state&TS_CARR_ON)) {       /* XXX 30 Aug 92*/
+               sc->sc_flags |= SC_ERROR;
                return;
                return;
+       }
 
        ++sc->sc_bytesrcvd;
        ++sc->sc_if.if_ibytes;
 
        ++sc->sc_bytesrcvd;
        ++sc->sc_if.if_ibytes;
@@ -674,7 +683,12 @@ slinput(c, tp)
                return;
 
        case FRAME_END:
                return;
 
        case FRAME_END:
+               if(sc->sc_flags & SC_ERROR) {                   /* 30 Aug 92*/
+                       sc->sc_flags &= ~SC_ERROR;
+                       goto newpack;
+               }
                len = sc->sc_mp - sc->sc_buf;
                len = sc->sc_mp - sc->sc_buf;
+
                if (len < 3)
                        /* less than min length packet - ignore */
                        goto newpack;
                if (len < 3)
                        /* less than min length packet - ignore */
                        goto newpack;
@@ -730,6 +744,7 @@ slinput(c, tp)
                sc->sc_escape = 0;
                return;
        }
                sc->sc_escape = 0;
                return;
        }
+       sc->sc_flags |= SC_ERROR;                       /* 30 Aug 92*/
 error:
        sc->sc_if.if_ierrors++;
 newpack:
 error:
        sc->sc_if.if_ierrors++;
 newpack:
index 076c051..8fc8193 100644 (file)
  *     @(#)if_slvar.h  7.7 (Berkeley) 5/7/91
  *
  * $Header: if_slvar.h,v 1.3 89/05/31 02:25:18 van Exp $
  *     @(#)if_slvar.h  7.7 (Berkeley) 5/7/91
  *
  * $Header: if_slvar.h,v 1.3 89/05/31 02:25:18 van Exp $
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00019
+ * --------------------         -----   ----------------------
+ *
+ * 30 Aug 92    Poul-Henning Kamp       Stabilize SLIP on lossy lines/UARTS
  */
 
 /*
  */
 
 /*
@@ -65,6 +72,7 @@ struct sl_softc {
 #define        SC_NOICMP       0x0004          /* supress ICMP traffic */
 #define        SC_AUTOCOMP     0x0008          /* auto-enable TCP compression */
 /* internal flags (should be separate) */
 #define        SC_NOICMP       0x0004          /* supress ICMP traffic */
 #define        SC_AUTOCOMP     0x0008          /* auto-enable TCP compression */
 /* internal flags (should be separate) */
+#define        SC_ERROR        0x08000         /* had an input error - 30 Aug 92*/
 #define        SC_ABORT        0x10000         /* have been sent an abort request */
 
 /* this stuff doesn't belong here... */
 #define        SC_ABORT        0x10000         /* have been sent an abort request */
 
 /* this stuff doesn't belong here... */