summaryrefslogtreecommitdiffstats
path: root/sys/net/if_sl.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-03-31 22:59:56 +0000
committerrwatson <rwatson@FreeBSD.org>2004-03-31 22:59:56 +0000
commit5ef02cd175cbb3fe1ffe24d5beac82d3d60240b2 (patch)
tree5efb77bb93951efdfbb534e3b3d0aede4ce82a7d /sys/net/if_sl.c
parentf1e67ce243be5a22142dbe20d35dd7c1711d70a8 (diff)
downloadFreeBSD-src-5ef02cd175cbb3fe1ffe24d5beac82d3d60240b2.zip
FreeBSD-src-5ef02cd175cbb3fe1ffe24d5beac82d3d60240b2.tar.gz
Abstract "is a particular SLIP unit free" check behind slisunitfree(),
and use that instead of manual list searches in a couple of places.
Diffstat (limited to 'sys/net/if_sl.c')
-rw-r--r--sys/net/if_sl.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 39fce74..4632bfb 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -224,6 +224,18 @@ static int *st_unit_list;
static size_t st_unit_max = 0;
static int
+slisunitfree(int unit)
+{
+ struct sl_softc *nc;
+
+ LIST_FOREACH(nc, &sl_list, sl_next) {
+ if (nc->sc_if.if_dunit == unit)
+ return (0);
+ }
+ return (1);
+}
+
+static int
slisstatic(unit)
int unit;
{
@@ -260,7 +272,7 @@ slmarkstatic(unit)
static struct sl_softc *
slcreate()
{
- struct sl_softc *sc, *nc;
+ struct sl_softc *sc;
int unit;
struct mbuf *m;
@@ -310,10 +322,8 @@ slcreate()
for (unit=0; ; unit++) {
if (slisstatic(unit))
continue;
- LIST_FOREACH(nc, &sl_list, sl_next) {
- if (nc->sc_if.if_dunit == unit)
- continue;
- }
+ if (!slisunitfree(unit))
+ continue;
break;
}
if_initname(&sc->sc_if, "sl", unit);
@@ -443,7 +453,7 @@ sltioctl(tp, cmd, data, flag, td)
int flag;
struct thread *td;
{
- struct sl_softc *sc = (struct sl_softc *)tp->t_sc, *nc;
+ struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
int s, unit, wasup;
s = splimp();
@@ -459,12 +469,8 @@ sltioctl(tp, cmd, data, flag, td)
return (ENXIO);
}
if (sc->sc_if.if_dunit != unit) {
- LIST_FOREACH(nc, &sl_list, sl_next) {
- if (nc->sc_if.if_dunit == *(u_int *)data) {
- splx(s);
- return (ENXIO);
- }
- }
+ if (!slisunitfree(unit))
+ return (ENXIO);
wasup = sc->sc_if.if_flags & IFF_UP;
bpfdetach(&sc->sc_if);
OpenPOWER on IntegriCloud