diff options
author | ache <ache@FreeBSD.org> | 1996-05-13 14:09:34 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-05-13 14:09:34 +0000 |
commit | b4272ea59ba9378df0a091cc4b4cd4870dabe230 (patch) | |
tree | 657fb556942f7f9b61330a82c893ce0c999642d9 /sys/net | |
parent | bde67b9082eadd157b58a9ecf59c6b81c731a15e (diff) | |
download | FreeBSD-src-b4272ea59ba9378df0a091cc4b4cd4870dabe230.zip FreeBSD-src-b4272ea59ba9378df0a091cc4b4cd4870dabe230.tar.gz |
Prevent mixing of static and dynamic unit allocation strategies
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_sl.c | 27 | ||||
-rw-r--r-- | sys/net/if_slvar.h | 3 |
2 files changed, 23 insertions, 7 deletions
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index 18e7f40..bfce9af 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_sl.c 8.6 (Berkeley) 2/1/94 - * $Id: if_sl.c,v 1.38 1996/04/24 15:44:34 phk Exp $ + * $Id: if_sl.c,v 1.39 1996/04/25 02:34:37 davidg Exp $ */ /* @@ -275,7 +275,7 @@ slopen(dev, tp) return (0); for (nsl = NSL, sc = sl_softc; --nsl >= 0; sc++) - if (sc->sc_ttyp == NULL) { + if (sc->sc_ttyp == NULL && !(sc->sc_flags & SC_STATIC)) { if (slinit(sc) == 0) return (ENOBUFS); tp->t_sc = (caddr_t)sc; @@ -340,7 +340,7 @@ slclose(tp,flag) untimeout(sl_keepalive, sc); } if_down(&sc->sc_if); - sc->sc_flags = 0; + sc->sc_flags &= SC_STATIC; sc->sc_ttyp = NULL; tp->t_sc = NULL; MCLFREE((caddr_t)(sc->sc_ep - SLBUFSIZE)); @@ -365,8 +365,8 @@ sltioctl(tp, cmd, data, flag, p) int flag; struct proc *p; { - struct sl_softc *sc = (struct sl_softc *)tp->t_sc; - int s; + struct sl_softc *sc = (struct sl_softc *)tp->t_sc, *nc; + int s, nsl; s = splimp(); switch (cmd) { @@ -375,7 +375,22 @@ sltioctl(tp, cmd, data, flag, p) break; case SLIOCSUNIT: - sc->sc_if.if_unit = *(u_int *)data; + if (sc->sc_if.if_unit != *(u_int *)data) { + for (nsl = NSL, nc = sl_softc; --nsl >= 0; nc++) { + if ( nc->sc_if.if_unit == *(u_int *)data + && nc->sc_ttyp == NULL + ) { + nc->sc_if.if_unit = sc->sc_if.if_unit; + nc->sc_flags &= ~SC_STATIC; + sc->sc_if.if_unit = *(u_int *)data; + goto slfound; + } + } + splx(s); + return (ENXIO); + } + slfound: + sc->sc_flags |= SC_STATIC; break; case SLIOCSKEEPAL: diff --git a/sys/net/if_slvar.h b/sys/net/if_slvar.h index c73ca47..cbb24ae 100644 --- a/sys/net/if_slvar.h +++ b/sys/net/if_slvar.h @@ -32,7 +32,7 @@ * * @(#)if_slvar.h 8.3 (Berkeley) 2/1/94 * - * $Id: if_slvar.h,v 1.9 1996/01/30 22:57:52 mpp Exp $ + * $Id: if_slvar.h,v 1.10 1996/02/06 18:51:15 wollman Exp $ */ #ifndef _NET_IF_SLVAR_H_ @@ -67,6 +67,7 @@ struct sl_softc { #define SC_ERROR 0x0001 /* had an input error */ #define SC_OUTWAIT 0x0002 /* waiting for output fill */ #define SC_KEEPALIVE 0x0004 /* input keepalive */ +#define SC_STATIC 0x0008 /* it is static unit */ /* visible flags */ #define SC_COMPRESS IFF_LINK0 /* compress TCP traffic */ |