summaryrefslogtreecommitdiffstats
path: root/sys/net/if_sl.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-05-13 14:09:34 +0000
committerache <ache@FreeBSD.org>1996-05-13 14:09:34 +0000
commitb4272ea59ba9378df0a091cc4b4cd4870dabe230 (patch)
tree657fb556942f7f9b61330a82c893ce0c999642d9 /sys/net/if_sl.c
parentbde67b9082eadd157b58a9ecf59c6b81c731a15e (diff)
downloadFreeBSD-src-b4272ea59ba9378df0a091cc4b4cd4870dabe230.zip
FreeBSD-src-b4272ea59ba9378df0a091cc4b4cd4870dabe230.tar.gz
Prevent mixing of static and dynamic unit allocation strategies
Diffstat (limited to 'sys/net/if_sl.c')
-rw-r--r--sys/net/if_sl.c27
1 files changed, 21 insertions, 6 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:
OpenPOWER on IntegriCloud