From owner-freebsd-hackers Sat Feb 4 18:30:32 1995 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id SAA17749 for hackers-outgoing; Sat, 4 Feb 1995 18:30:32 -0800 Received: from p5.spnet.com (elh.com [204.156.130.1]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id SAA17743 for ; Sat, 4 Feb 1995 18:30:30 -0800 Received: from localhost (localhost [127.0.0.1]) by p5.spnet.com (8.6.9/8.6.6) with SMTP id SAA00370; Sat, 4 Feb 1995 18:29:59 GMT Message-Id: <199502041829.SAA00370@p5.spnet.com> X-Authentication-Warning: p5.spnet.com: Host localhost didn't use HELO protocol To: freebsd-hackers@FreeBSD.org cc: elh@spnet.com Subject: controllable-predictable slip interface units Date: Sat, 04 Feb 1995 18:29:59 +0000 From: Ed Hudson Sender: hackers-owner@FreeBSD.org Precedence: bulk howdy. old issue: management of multiple slip interfaces is simpler if the slip unit number returned by slattach is controllable i'd like to ask you folks to consider adding the following patch to the kernel slip interface, which makes the interface unit assigned by slattach controllable (well, predictable) under most circumstances. the patch takes the last four bits of the minor device number, and, if it is within the range of the slip interface indices, and that slip interface is available, it is returned as the slip unit. if none of these conditions are met, the behaviour defaults to the current one: return the first available slip interface unit. ie, sl# = ((minor&0xf)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; sc->sc_ttyp = tp; sc->sc_if.if_baudrate = tp->t_ospeed; --- 264,307 ---- if (tp->t_line == SLIPDISC) return (0); ! ! #ifdef PREDICTABLE_SL ! { ! /* ! * elh 9.19.1994 ! * make the interface number returned by slattach ! * predictable - make it equal to the last four bits ! * of the minor tty/cua number, if the last four bits are ! * less than NSL ! * ! * thus cuaa0 -> sl0 ! * ttyd1 -> sl1 ! * cuaa2 -> sl2 (if NSL >= 3) ! * cuaa45 -> old algorithm. ! * ! * if the interface is already taken (how? nunits > NSL, ! * or multiports?) then ! * the behaviour defaults to the old: it looks for ! * the lowest available sl interface ! */ ! unsigned int sl_num; ! sl_num= (unsigned int) dev; ! sl_num= sl_num & 0x0f; ! if (sl_num < NSL) { ! sc= &(sl_softc[sl_num]); ! if (sc->sc_ttyp == NULL) { ! if (slinit(sc) == 0) { } else goto got_sl; ! } ! } ! } ! #endif for (nsl = NSL, sc = sl_softc; --nsl >= 0; sc++) if (sc->sc_ttyp == NULL) { if (slinit(sc) == 0) return (ENOBUFS); + #ifdef PREDICTABLE_SL + got_sl: + #endif tp->t_sc = (caddr_t)sc; sc->sc_ttyp = tp; sc->sc_if.if_baudrate = tp->t_ospeed;