Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Apr 1996 18:56:50 +0300
From:      Oleg N Panashchenko <helg@tav.kiev.ua>
To:        scm@silver.wcape.school.za, freebsd-questions@freebsd.org
Subject:   Re: Bug? Two sl0 interfaces listed by ifconfig -au
Message-ID:  <199604011556.SAA28783@tav.kiev.ua>

next in thread | raw e-mail | index | archive | help
In article <m0u3kZv-000KUSC@ucthpx.uct.ac.za> you wrote:
: ifconfig -au gives:

:  ed0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
:  	inet 196.21.102.10 netmask 0xfffffff8 broadcast 196.21.102.15
:  lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 16384
:  	inet 127.0.0.1 netmask 0xff000000 
:  sl0: flags=8011<UP,POINTOPOINT,MULTICAST> mtu 552
:  	inet 196.21.102.17 --> 196.21.102.18 netmask 0xfffffff8 
:  sl0: flags=8011<UP,POINTOPOINT,MULTICAST> mtu 552
:  	inet 196.21.102.17 --> 196.21.102.18 netmask 0xfffffff8 
:  
: As far as I can see this arose from trying to ifconfig sl1 to something
: else.

This can happen if you are using -S switch in slattach. Try to avoid it
if possible. I was needed -S for traffic collection. Attached is
patch for if_sl.c, which is working in my box. With the patch using this option 
does not duplicate slip unit.

Is it worth to insert this patch to -current/-stable?

Oleg

*** if_sl.c.21  Sat Mar 30 16:30:36 1996
--- if_sl.c     Sat Mar 30 16:40:41 1996
***************
*** 63,68 ****
--- 63,74 ----
   *
   * Note that splimp() is used throughout to block both (tty) input
   * interrupts and network activity; thus, splimp must be >= spltty.
+  *
+  * 1996/03/28, helg@tav.kiev.ua
+  * - fixed bug with static unit allocation
+  * - option SLIP_DYNALLOC_FROMHIGH will allocate dynamic slip units
+  *   starting from high numbers, so you can use sl0,sl1, etc for
+  *   static allocations.
   */

  #include "sl.h"
***************
*** 245,274 ****
        return (1);
  }

! /*
!  * Line specific open routine.
!  * Attach the given tty to the first available sl unit.
!  */
! /* ARGSUSED */
! int
! slopen(dev, tp)
!       dev_t dev;
!       register struct tty *tp;
  {
-       struct proc *p = curproc;               /* XXX */
        register struct sl_softc *sc;
        register int nsl;
!       int s, error;
!
!       error = suser(p->p_ucred, &p->p_acflag);
!       if (error)
!               return (error);

        if (tp->t_line == SLIPDISC)
                return (0);

!       for (nsl = NSL, sc = sl_softc; --nsl >= 0; sc++)
!               if (sc->sc_ttyp == NULL) {
                        if (slinit(sc) == 0)
                                return (ENOBUFS);
                        tp->t_sc = (caddr_t)sc;
--- 251,282 ----
        return (1);
  }

! #define SLIPUNIT_DYNAMIC -1
! static int attachslunit(struct tty* tp, int unit)
  {
        register struct sl_softc *sc;
        register int nsl;
!       int s;

        if (tp->t_line == SLIPDISC)
                return (0);

!   if(unit==SLIPUNIT_DYNAMIC) {
!
! #ifdef SLIP_DYNALLOC_FROMHIGH
!         for (nsl = NSL, sc = sl_softc+NSL-1; --nsl >= 0; sc--)
! #else
!         for (nsl = NSL, sc = sl_softc; --nsl >= 0; sc++)
! #endif
!                 if (sc->sc_ttyp == NULL)  break;
!               if(nsl<=0) return (ENXIO);
!       } else {
!               if( unit < 0 || unit >= NSL )
!                       return (ENXIO);
!               sc = & sl_softc[unit];
!               if( sc->sc_ttyp != NULL)
!                       return (ENXIO);
!       }
                        if (slinit(sc) == 0)
                                return (ENOBUFS);
                        tp->t_sc = (caddr_t)sc;
***************
*** 297,304 ****
                        if_up(&sc->sc_if);
                        splx(s);
                        return (0);
!               }
!       return (ENXIO);
  }

  /*
--- 305,331 ----
                        if_up(&sc->sc_if);
                        splx(s);
                        return (0);
! }
!
! /*
!  * Line specific open routine.
!  * Attach the given tty to the first available sl unit.
!  */
! /* ARGSUSED */
! int
! slopen(dev, tp)
!       dev_t dev;
!       register struct tty *tp;
! {
!       struct proc *p = curproc;               /* XXX */
!       int error;
!
!       error = suser(p->p_ucred, &p->p_acflag);
!       if (error)
!               return (error);
!
!       return attachslunit(tp,SLIPUNIT_DYNAMIC);
!
  }

  /*
***************
*** 368,374 ****
                break;

        case SLIOCSUNIT:
!               sc->sc_if.if_unit = *(u_int *)data;
                break;

        case SLIOCSKEEPAL:
--- 395,409 ----
                break;

        case SLIOCSUNIT:
!               {
!                       int newunit=*(u_int *)data;
!                       if(newunit == sc->sc_if.if_unit) break;
!                       slclose(tp,0);
!                       if(attachslunit(tp,newunit)) {
!                               splx(s);
!                               return (ENXIO);
!                       }
!               }
                break;

        case SLIOCSKEEPAL:




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604011556.SAA28783>