Date: Sat, 04 Feb 1995 18:29:59 +0000 From: Ed Hudson <elh@p5.spnet.com> To: freebsd-hackers@FreeBSD.org Cc: elh@spnet.com Subject: controllable-predictable slip interface units Message-ID: <199502041829.SAA00370@p5.spnet.com>
next in thread | raw e-mail | index | archive | help
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)<NSL && slip_free(minor&0xf)) ? (minor&0xf) : first_slip_free with this, patch, slattach applied to /dev/cuaa0 uses slip interface sl0, slattach applied to /dev/cuaa1 uses sl1, and so on. yes, this is an imperfect solution to this problem in that it places requirements on minor device numbers, and fails (softly, with the old behaviour) in the face of more than min(NSL,16) slip interfaces, etc, but i think that it is easier to use than the current scheme(s) typically employed. thanks for considering adding this patch. -elh elh@spnet.com based on 950202-SNAP, /usr/src/sys/net/if_sl.c *** Orig/if_sl.c Sun Nov 27 15:29:57 1994 --- if_sl.c Sat Feb 4 18:15:45 1995 *************** *** 264,274 **** 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; 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199502041829.SAA00370>