Index: if.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if.c,v
retrieving revision 1.129
diff -u -r1.129 if.c
--- if.c	26 Feb 2002 01:11:08 -0000	1.129
+++ if.c	26 Feb 2002 08:21:10 -0000
@@ -579,6 +579,7 @@
 	int len;
 {
 	struct if_clone *ifc;
+	struct ifnet *ifp;
 	char *dp;
 	int wildcard;
 	int unit;
@@ -592,8 +593,24 @@
 		return (EEXIST);
 
 	wildcard = (unit < 0);
+	if (wildcard) {
+		/*
+		 * Find a free unit.
+		 */ 
+		unit = -1;
+next_unit:
+		unit++;
+		TAILQ_FOREACH(ifp, &ifnet, if_link) {
+			if ((ifp->if_unit == unit) &&
+			    (strcmp(name, ifp->if_name) == 0))
+				goto next_unit;
+		}
+	}
 
-	err = (*ifc->ifc_create)(ifc, &unit);
+	if (unit > IF_MAXUNIT)
+		return (ENXIO);
+
+	err = (*ifc->ifc_create)(ifc, unit);
 	if (err != 0)
 		return (err);
 
@@ -636,8 +653,7 @@
 	if (ifc->ifc_destroy == NULL)
 		return (EOPNOTSUPP);
 
-	(*ifc->ifc_destroy)(ifp);
-	return (0);
+	return ((*ifc->ifc_destroy)(ifp));
 }
 
 /*
Index: if.h
===================================================================
RCS file: /home/ncvs/src/sys/net/if.h,v
retrieving revision 1.68
diff -u -r1.68 if.h
--- if.h	18 Jan 2002 14:33:03 -0000	1.68
+++ if.h	21 Feb 2002 01:39:20 -0000
@@ -55,6 +55,7 @@
  */
 #define		IFNAMSIZ	16
 #define		IF_NAMESIZE	IFNAMSIZ
+#define		IF_MAXUNIT	0x7fff	/* ifp->if_unit is only 15 bits */
 
 /*
  * Structure describing a `cloning' interface.
@@ -64,8 +65,8 @@
 	const char *ifc_name;		/* name of device, e.g. `gif' */
 	size_t ifc_namelen;		/* length of name */
 
-	int	(*ifc_create)(struct if_clone *, int *);
-	void	(*ifc_destroy)(struct ifnet *);
+	int	(*ifc_create)(struct if_clone *, int);
+	int	(*ifc_destroy)(struct ifnet *);
 };
 
 #define IF_CLONE_INITIALIZER(name, create, destroy)			\
Index: if_faith.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_faith.c,v
retrieving revision 1.10
diff -u -r1.10 if_faith.c
--- if_faith.c	8 Jan 2002 10:30:09 -0000	1.10
+++ if_faith.c	21 Feb 2002 18:40:55 -0000
@@ -57,8 +57,6 @@
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/malloc.h>
-#include <machine/bus.h>	/* XXX: Shouldn't really be required! */
-#include <sys/rman.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
@@ -85,11 +83,9 @@
 #include <net/net_osdep.h>
 
 #define FAITHNAME	"faith"
-#define FAITH_MAXUNIT	0x7fff	/* ifp->if_unit is only 15 bits */
 
 struct faith_softc {
 	struct ifnet sc_if;	/* must be first */
-	struct resource *r_unit;
 	LIST_ENTRY(faith_softc) sc_list;
 };
 
@@ -102,11 +98,10 @@
 static int faithmodevent __P((module_t, int, void *));
 
 static MALLOC_DEFINE(M_FAITH, FAITHNAME, "Firewall Assisted Tunnel Interface");
-static struct rman faithunits[1];
 static LIST_HEAD(, faith_softc) faith_softc_list;
 
-int	faith_clone_create __P((struct if_clone *, int *));
-void	faith_clone_destroy __P((struct ifnet *));
+int	faith_clone_create __P((struct if_clone *, int));
+int	faith_clone_destroy __P((struct ifnet *));
 
 struct if_clone faith_cloner =
     IF_CLONE_INITIALIZER(FAITHNAME, faith_clone_create, faith_clone_destroy);
@@ -119,22 +114,9 @@
 	int type;
 	void *data;
 {
-	int err;
 
 	switch (type) {
 	case MOD_LOAD:
-		faithunits->rm_type = RMAN_ARRAY;
-		faithunits->rm_descr = "configurable if_faith units";
-		err = rman_init(faithunits);
-		if (err != 0)
-			return (err);
-		err = rman_manage_region(faithunits, 0, FAITH_MAXUNIT);
-		if (err != 0) {
-			printf("%s: faithunits: rman_manage_region: "
-			    "Failed %d\n", FAITHNAME, err);
-			rman_fini(faithunits);
-			return (err);
-		}
 		LIST_INIT(&faith_softc_list);
 		if_clone_attach(&faith_cloner);
 
@@ -154,10 +136,6 @@
 			faith_clone_destroy(
 			    &LIST_FIRST(&faith_softc_list)->sc_if);
 
-		err = rman_fini(faithunits);
-		if (err != 0)
-			return (err);
-
 		break;
 	}
 	return 0;
@@ -175,34 +153,16 @@
 int
 faith_clone_create(ifc, unit)
 	struct if_clone *ifc;
-	int *unit;
+	int unit;
 {
-	struct resource *r;
 	struct faith_softc *sc;
 
-	if (*unit > FAITH_MAXUNIT)
-		return (ENXIO);
-
-	if (*unit < 0) {
-		r = rman_reserve_resource(faithunits, 0, FAITH_MAXUNIT, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			return (ENOSPC);
-		*unit = rman_get_start(r);
-	} else {
-		r = rman_reserve_resource(faithunits, *unit, *unit, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			return (ENOSPC);
-	}
-
 	sc = malloc(sizeof(struct faith_softc), M_FAITH, M_WAITOK);
 	bzero(sc, sizeof(struct faith_softc));
 
 	sc->sc_if.if_softc = sc;
 	sc->sc_if.if_name = FAITHNAME;
-	sc->sc_if.if_unit = *unit;
-	sc->r_unit = r;
+	sc->sc_if.if_unit = unit;
 
 	sc->sc_if.if_mtu = FAITHMTU;
 	/* Change to BROADCAST experimentaly to announce its prefix. */
@@ -219,21 +179,18 @@
 	return (0);
 }
 
-void
+int
 faith_clone_destroy(ifp)
 	struct ifnet *ifp;
 {
-	int err;
 	struct faith_softc *sc = (void *) ifp;
 
 	LIST_REMOVE(sc, sc_list);
 	bpfdetach(ifp);
 	if_detach(ifp);
 
-	err = rman_release_resource(sc->r_unit);
-	KASSERT(err == 0, ("Unexpected error freeing resource"));
-
 	free(sc, M_FAITH);
+	return (0);
 }
 
 int
Index: if_gif.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_gif.c,v
retrieving revision 1.18
diff -u -r1.18 if_gif.c
--- if_gif.c	26 Feb 2002 01:56:56 -0000	1.18
+++ if_gif.c	26 Feb 2002 08:13:37 -0000
@@ -46,8 +46,6 @@
 #include <sys/syslog.h>
 #include <sys/protosw.h>
 #include <sys/conf.h>
-#include <machine/bus.h>	/* XXX: Shouldn't really be required! */
-#include <sys/rman.h>
 #include <machine/cpu.h>
 
 #include <net/if.h>
@@ -82,10 +80,8 @@
 #include <net/net_osdep.h>
 
 #define GIFNAME		"gif"
-#define GIF_MAXUNIT	0x7fff	/* ifp->if_unit is only 15 bits */
 
 static MALLOC_DEFINE(M_GIF, "gif", "Generic Tunnel Interface");
-static struct rman gifunits[1];
 static LIST_HEAD(, gif_softc) gif_softc_list;
 
 void	(*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp, int af);
@@ -93,8 +89,8 @@
 void	(*ng_gif_attach_p)(struct ifnet *ifp);
 void	(*ng_gif_detach_p)(struct ifnet *ifp);
 
-int	gif_clone_create __P((struct if_clone *, int *));
-void	gif_clone_destroy __P((struct ifnet *));
+int	gif_clone_create __P((struct if_clone *, int));
+int	gif_clone_destroy __P((struct ifnet *));
 
 struct if_clone gif_cloner =
     IF_CLONE_INITIALIZER("gif", gif_clone_create, gif_clone_destroy);
@@ -158,34 +154,16 @@
 int
 gif_clone_create(ifc, unit)
 	struct if_clone *ifc;
-	int *unit;
+	int unit;
 {
-	struct resource *r;
 	struct gif_softc *sc;
 
-	if (*unit > GIF_MAXUNIT)
-		return (ENXIO);
-
-	if (*unit < 0) {
-		r = rman_reserve_resource(gifunits, 0, GIF_MAXUNIT, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			return (ENOSPC);
-		*unit = rman_get_start(r);
-	} else {
-		r = rman_reserve_resource(gifunits, *unit, *unit, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			return (EEXIST);
-	}
-	
 	sc = malloc (sizeof(struct gif_softc), M_GIF, M_WAITOK);
 	bzero(sc, sizeof(struct gif_softc));
 
 	sc->gif_if.if_softc = sc;
 	sc->gif_if.if_name = GIFNAME;
-	sc->gif_if.if_unit = *unit;
-	sc->r_unit = r;
+	sc->gif_if.if_unit = unit;
 
 	sc->encap_cookie4 = sc->encap_cookie6 = NULL;
 #ifdef INET
@@ -229,7 +207,7 @@
 	return (0);
 }
 
-void
+int
 gif_clone_destroy(ifp)
 	struct ifnet *ifp;
 {
@@ -252,10 +230,8 @@
 	bpfdetach(ifp);
 	if_detach(ifp);
 
-	err = rman_release_resource(sc->r_unit);
-	KASSERT(err == 0, ("Unexpected error freeing resource"));
-
 	free(sc, M_GIF);
+	return (0);
 }
 
 static int
@@ -264,22 +240,9 @@
 	int type;
 	void *data;
 {
-	int err;
 
 	switch (type) {
 	case MOD_LOAD:
-		gifunits->rm_type = RMAN_ARRAY;
-		gifunits->rm_descr = "configurable if_gif units";
-		err = rman_init(gifunits);
-		if (err != 0)
-			return (err);
-		err = rman_manage_region(gifunits, 0, GIF_MAXUNIT);
-		if (err != 0) {
-			printf("%s: gifunits: rman_manage_region: Failed %d\n",
-			    GIFNAME, err);
-			rman_fini(gifunits);
-			return (err);
-		}
 		LIST_INIT(&gif_softc_list);
 		if_clone_attach(&gif_cloner);
 
@@ -294,9 +257,6 @@
 		while (!LIST_EMPTY(&gif_softc_list))
 			gif_clone_destroy(&LIST_FIRST(&gif_softc_list)->gif_if);
 
-		err = rman_fini(gifunits);
-		if (err != 0)
-			return (err);
 #ifdef INET6
 		ip6_gif_hlim = 0;
 #endif
Index: if_gif.h
===================================================================
RCS file: /home/ncvs/src/sys/net/if_gif.h,v
retrieving revision 1.8
diff -u -r1.8 if_gif.h
--- if_gif.h	27 Sep 2001 03:14:16 -0000	1.8
+++ if_gif.h	21 Feb 2002 02:07:39 -0000
@@ -68,7 +68,6 @@
 	int		gif_flags;
 	const struct encaptab *encap_cookie4;
 	const struct encaptab *encap_cookie6;
-	struct resource *r_unit;	/* resource allocated for this unit */
 	void		*gif_netgraph;	/* ng_gif(4) netgraph node info */
 	LIST_ENTRY(gif_softc) gif_link; /* all gif's are linked */
 };
Index: if_loop.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_loop.c,v
retrieving revision 1.67
diff -u -r1.67 if_loop.c
--- if_loop.c	29 Dec 2001 08:45:17 -0000	1.67
+++ if_loop.c	21 Feb 2002 18:42:39 -0000
@@ -88,12 +88,6 @@
 #include <netatalk/at_var.h>
 #endif
 
-int loioctl __P((struct ifnet *, u_long, caddr_t));
-static void lortrequest __P((int, struct rtentry *, struct rt_addrinfo *));
-
-int looutput __P((struct ifnet *ifp,
-		struct mbuf *m, struct sockaddr *dst, struct rtentry *rt));
-
 #ifdef TINY_LOMTU
 #define	LOMTU	(1024+512)
 #elif defined(LARGE_LOMTU)
@@ -102,26 +96,39 @@
 #define LOMTU	16384
 #endif
 
-static int nloop = 1;
-
-struct ifnet *loif;			/* Used externally */
-
-static MALLOC_DEFINE(M_LO, "lo", "Loopback Interface");
+#define LONAME	"lo"
 
 struct lo_softc {
 	struct	ifnet sc_if;		/* network-visible interface */
 	LIST_ENTRY(lo_softc) sc_next;
 };
+
+int		loioctl(struct ifnet *, u_long, caddr_t);
+static void	lortrequest(int, struct rtentry *, struct rt_addrinfo *);
+int		looutput(struct ifnet *ifp, struct mbuf *m,
+		    struct sockaddr *dst, struct rtentry *rt);
+int		lo_clone_create(struct if_clone *, int);
+int		lo_clone_destroy(struct ifnet *);
+
+struct ifnet *loif = NULL;			/* Used externally */
+
+static MALLOC_DEFINE(M_LO, LONAME, "Loopback Interface");
+
 static LIST_HEAD(lo_list, lo_softc) lo_list;
 
-static void
-locreate(int unit)
+struct if_clone lo_cloner =
+    IF_CLONE_INITIALIZER(LONAME, lo_clone_create, lo_clone_destroy);
+
+int
+lo_clone_create(ifc, unit)
+	struct if_clone *ifc;
+	int unit;
 {
 	struct lo_softc *sc;
 
 	MALLOC(sc, struct lo_softc *, sizeof(*sc), M_LO, M_WAITOK | M_ZERO);
 
-	sc->sc_if.if_name = "lo";
+	sc->sc_if.if_name = LONAME;
 	sc->sc_if.if_unit = unit;
 	sc->sc_if.if_mtu = LOMTU;
 	sc->sc_if.if_flags = IFF_LOOPBACK | IFF_MULTICAST;
@@ -129,62 +136,50 @@
 	sc->sc_if.if_output = looutput;
 	sc->sc_if.if_type = IFT_LOOP;
 	sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen;
+	sc->sc_if.if_softc = sc;
 	if_attach(&sc->sc_if);
 	bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
 	LIST_INSERT_HEAD(&lo_list, sc, sc_next);
 	if (loif == NULL)
 		loif = &sc->sc_if;
-}
 
-static void
-lodestroy(struct lo_softc *sc)
-{
-	bpfdetach(&sc->sc_if);
-	if_detach(&sc->sc_if);
-	LIST_REMOVE(sc, sc_next);
-	FREE(sc, M_LO);
+	return (0);
 }
 
-
-static int
-sysctl_net_nloop(SYSCTL_HANDLER_ARGS)
+int
+lo_clone_destroy(ifp)
+	struct ifnet *ifp;
 {
-	int newnloop;
-	int error;
-
-	newnloop = nloop;
-
-	error = sysctl_handle_opaque(oidp, &newnloop, sizeof newnloop, req);
-	if (error || !req->newptr)
-		return (error);
+	struct lo_softc *sc;
+	
+	sc = ifp->if_softc;
 
-	if (newnloop < 1)
+	/*
+	 * Prevent lo0 from being destroyed.
+	 */
+	if (loif == ifp)
 		return (EINVAL);
-	while (newnloop > nloop) {
-		locreate(nloop);
-		nloop++;
-	}
-	while (newnloop < nloop) {
-		lodestroy(LIST_FIRST(&lo_list));
-		nloop--;
-	}
+
+	bpfdetach(ifp);
+	if_detach(ifp);
+	LIST_REMOVE(sc, sc_next);
+	FREE(sc, M_LO);
 	return (0);
 }
-SYSCTL_PROC(_net, OID_AUTO, nloop, CTLTYPE_INT | CTLFLAG_RW,
-	    0, 0, sysctl_net_nloop, "I", "");
 
 static int
 loop_modevent(module_t mod, int type, void *data) 
 { 
-	int i;
+	int err;
 
 	switch (type) { 
 	case MOD_LOAD: 
-		TUNABLE_INT_FETCH("net.nloop", &nloop);
-		if (nloop < 1)			/* sanity check */
-			nloop = 1;
-		for (i = 0; i < nloop; i++)
-			locreate(i);
+		LIST_INIT(&lo_list);
+		if_clone_attach(&lo_cloner);
+
+		/* Create lo0 */
+		err = lo_clone_create(&lo_cloner, 0);
+		KASSERT(err == 0, ("%s: can't create lo0", __func__));
 		break; 
 	case MOD_UNLOAD: 
 		printf("loop module unload - not possible for this module type\n"); 
Index: if_stf.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_stf.c,v
retrieving revision 1.16
diff -u -r1.16 if_stf.c
--- if_stf.c	8 Jan 2002 10:30:09 -0000	1.16
+++ if_stf.c	21 Feb 2002 18:41:12 -0000
@@ -86,8 +86,6 @@
 #include <sys/kernel.h>
 #include <sys/protosw.h>
 #include <sys/queue.h>
-#include <machine/bus.h>	/* XXX: Shouldn't really be required! */ 
-#include <sys/rman.h>
 #include <machine/cpu.h>
 
 #include <sys/malloc.h>
@@ -118,7 +116,6 @@
 #include <net/bpf.h>
 
 #define STFNAME		"stf"
-#define STF_MAXUNIT	0	/* only one is currently allowed */
 
 #define IN6_IS_ADDR_6TO4(x)	(ntohs((x)->s6_addr16[0]) == 0x2002)
 #define GET_V4(x)	((struct in_addr *)(&(x)->s6_addr16[1]))
@@ -131,14 +128,12 @@
 	} __sc_ro46;
 #define sc_ro	__sc_ro46.__sc_ro4
 	const struct encaptab *encap_cookie;
-	struct resource *r_unit;	/* resource allocated for this unit */
 	LIST_ENTRY(stf_softc) sc_list;	/* all stf's are linked */
 };
 
 static LIST_HEAD(, stf_softc) stf_softc_list;
 
 static MALLOC_DEFINE(M_STF, STFNAME, "6to4 Tunnel Interface");
-static struct rman stfunits[1];
 static int ip_stf_ttl = 40;
 
 extern  struct domain inetdomain;
@@ -162,8 +157,8 @@
 static void stf_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *));
 static int stf_ioctl __P((struct ifnet *, u_long, caddr_t));
 
-int	stf_clone_create __P((struct if_clone *, int *));
-void	stf_clone_destroy __P((struct ifnet *));
+int	stf_clone_create __P((struct if_clone *, int));
+int	stf_clone_destroy __P((struct ifnet *));
 
 struct if_clone stf_cloner =
     IF_CLONE_INITIALIZER(STFNAME, stf_clone_create, stf_clone_destroy);
@@ -171,31 +166,17 @@
 int
 stf_clone_create(ifc, unit)
 	struct if_clone *ifc;
-	int *unit;
+	int unit;
 {
-	struct resource *r;
 	struct stf_softc *sc;
 
-	if (*unit > STF_MAXUNIT)
+	/* only one clone is currently allowed */
+	if (!LIST_EMPTY(&stf_softc_list))
 		return (ENXIO);
 
-	if (*unit < 0) {
-		 r = rman_reserve_resource(stfunits, 0, STF_MAXUNIT, 1,
-		     RF_ALLOCATED | RF_ACTIVE, NULL);
-		 if (r == NULL)
-			return (ENOSPC);
-		 *unit = rman_get_start(r);
-	} else {
-		r = rman_reserve_resource(stfunits, *unit, *unit, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			 return (EEXIST);
-	}
-
 	sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO);
 	sc->sc_if.if_name = STFNAME;
-	sc->sc_if.if_unit = *unit;
-	sc->r_unit = r;
+	sc->sc_if.if_unit = unit;
 
 	sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6,
 	    stf_encapcheck, &in_stf_protosw, sc);
@@ -216,7 +197,7 @@
 	return (0);
 }
 
-void
+int
 stf_clone_destroy(ifp)
 	struct ifnet *ifp;
 {
@@ -229,10 +210,8 @@
 	bpfdetach(ifp);
 	if_detach(ifp);
 
-	err = rman_release_resource(sc->r_unit);
-	KASSERT(err == 0, ("Unexpected error freeing resource"));
-
 	free(sc, M_STF);
+	return (0);
 }
 
 static int
@@ -241,35 +220,17 @@
 	int type;
 	void *data;
 {
-	int err;
 
 	switch (type) {
 	case MOD_LOAD:
-		stfunits->rm_type = RMAN_ARRAY;
-		stfunits->rm_descr = "configurable if_stf units";
-		err = rman_init(stfunits);
-		if (err != 0)
-			return (err);
-		err = rman_manage_region(stfunits, 0, STF_MAXUNIT);
-		if (err != 0) {
-			printf("%s: stfunits: rman_manage_region: Failed %d\n",
-			    STFNAME, err);
-			rman_fini(stfunits);
-			return (err);
-		}
 		LIST_INIT(&stf_softc_list);
 		if_clone_attach(&stf_cloner);
-
 		break;
 	case MOD_UNLOAD:
 		if_clone_detach(&stf_cloner);
 
 		while (!LIST_EMPTY(&stf_softc_list))
 			stf_clone_destroy(&LIST_FIRST(&stf_softc_list)->sc_if);
-
-		err = rman_fini(stfunits);
-		KASSERT(err == 0, ("Unexpected error freeing resource"));
-
 		break;
 	}
 
Index: if_vlan.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_vlan.c,v
retrieving revision 1.37
diff -u -r1.37 if_vlan.c
--- if_vlan.c	26 Feb 2002 02:19:33 -0000	1.37
+++ if_vlan.c	26 Feb 2002 08:13:37 -0000
@@ -66,8 +66,6 @@
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <machine/bus.h>	/* XXX: Shouldn't really be required! */
-#include <sys/rman.h>
 
 #include <net/bpf.h>
 #include <net/ethernet.h>
@@ -83,18 +81,16 @@
 #endif
 
 #define VLANNAME	"vlan"
-#define VLAN_MAXUNIT	0x7fff	/* ifp->if_unit is only 15 bits */
 
 SYSCTL_DECL(_net_link);
 SYSCTL_NODE(_net_link, IFT_L2VLAN, vlan, CTLFLAG_RW, 0, "IEEE 802.1Q VLAN");
 SYSCTL_NODE(_net_link_vlan, PF_LINK, link, CTLFLAG_RW, 0, "for consistency");
 
 static MALLOC_DEFINE(M_VLAN, "vlan", "802.1Q Virtual LAN Interface");
-static struct rman vlanunits[1];
 static LIST_HEAD(, ifvlan) ifv_list;
 
-static	int vlan_clone_create(struct if_clone *, int *);
-static	void vlan_clone_destroy(struct ifnet *);
+static	int vlan_clone_create(struct if_clone *, int);
+static	int vlan_clone_destroy(struct ifnet *);
 static	void vlan_start(struct ifnet *ifp);
 static	void vlan_ifinit(void *foo);
 static	int vlan_input(struct ether_header *eh, struct mbuf *m);
@@ -176,22 +172,9 @@
 static int
 vlan_modevent(module_t mod, int type, void *data) 
 { 
-	int err;
 
 	switch (type) { 
 	case MOD_LOAD: 
-		vlanunits->rm_type = RMAN_ARRAY;
-		vlanunits->rm_descr = "configurable if_vlan units";
-		err = rman_init(vlanunits);
-		if (err != 0)
-			return (err);
-		err = rman_manage_region(vlanunits, 0, VLAN_MAXUNIT);
-		if (err != 0) {
-			printf("%s: vlanunits: rman_manage_region: Failed %d\n",
-			    VLANNAME, err);
-			rman_fini(vlanunits);
-			return (err);
-		}
 		LIST_INIT(&ifv_list);
 		vlan_input_p = vlan_input;
 		vlan_input_tag_p = vlan_input_tag;
@@ -203,9 +186,6 @@
 		vlan_input_tag_p = NULL;
 		while (!LIST_EMPTY(&ifv_list))
 			vlan_clone_destroy(&LIST_FIRST(&ifv_list)->ifv_if);
-		err = rman_fini(vlanunits);
-		if (err != 0)
-			 return (err);
 		break;
 	} 
 	return 0; 
@@ -220,29 +200,12 @@
 DECLARE_MODULE(if_vlan, vlan_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 
 static int
-vlan_clone_create(struct if_clone *ifc, int *unit)
+vlan_clone_create(struct if_clone *ifc, int unit)
 {
-	struct resource *r;
 	struct ifvlan *ifv;
 	struct ifnet *ifp;
 	int s;
 
-	if (*unit > VLAN_MAXUNIT)
-		return (ENXIO);
-
-	if (*unit < 0) {
-		r  = rman_reserve_resource(vlanunits, 0, VLAN_MAXUNIT, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			return (ENOSPC);
-		*unit = rman_get_start(r);
-	} else {
-		r  = rman_reserve_resource(vlanunits, *unit, *unit, 1,
-		    RF_ALLOCATED | RF_ACTIVE, NULL);
-		if (r == NULL)
-			return (EEXIST);
-	}
-
 	ifv = malloc(sizeof(struct ifvlan), M_VLAN, M_WAITOK | M_ZERO);
 	ifp = &ifv->ifv_if;
 	SLIST_INIT(&ifv->vlan_mc_listhead);
@@ -253,8 +216,7 @@
 
 	ifp->if_softc = ifv;
 	ifp->if_name = "vlan";
-	ifp->if_unit = *unit;
-	ifv->r_unit = r;
+	ifp->if_unit = unit;
 	/* NB: flags are not set here */
 	ifp->if_linkmib = &ifv->ifv_mib;
 	ifp->if_linkmiblen = sizeof ifv->ifv_mib;
@@ -274,12 +236,11 @@
 	return (0);
 }
 
-static void
+static int
 vlan_clone_destroy(struct ifnet *ifp)
 {
 	struct ifvlan *ifv = ifp->if_softc;
 	int s;
-	int err;
 
 	s = splnet();
 	LIST_REMOVE(ifv, ifv_list);
@@ -288,9 +249,8 @@
 
 	ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
 
-	err = rman_release_resource(ifv->r_unit);
-	KASSERT(err == 0, ("Unexpected error freeing resource"));
 	free(ifv, M_VLAN);
+	return (0);
 }
 
 static void
Index: if_vlan_var.h
===================================================================
RCS file: /home/ncvs/src/sys/net/if_vlan_var.h,v
retrieving revision 1.10
diff -u -r1.10 if_vlan_var.h
--- if_vlan_var.h	5 Sep 2001 21:10:28 -0000	1.10
+++ if_vlan_var.h	21 Feb 2002 02:09:34 -0000
@@ -48,7 +48,6 @@
 	}	ifv_mib;
 	SLIST_HEAD(__vlan_mchead, vlan_mc_entry)	vlan_mc_listhead;
 	LIST_ENTRY(ifvlan) ifv_list;
-	struct resource *r_unit;	/* resource allocated for this unit */
 };
 #define	ifv_if	ifv_ac.ac_if
 #define	ifv_tag	ifv_mib.ifvm_tag
