summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2003-12-13 10:01:17 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2003-12-13 10:01:17 +0000
commiteb44ab8f06e509496e0fac097e6075641ace5524 (patch)
treee2b49f6fcad0815f99be2bb89c51f57d8d874b86 /sys/net
parent1e9a3e001c114ae01cfe4b27637c6fb261e2ef68 (diff)
initial support ifconfig destroy; ok deraadt@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_ppp.c30
-rw-r--r--sys/net/if_sl.c27
2 files changed, 51 insertions, 6 deletions
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 69904704b64..f4e1bd5be29 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ppp.c,v 1.38 2003/12/10 07:22:42 itojun Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.39 2003/12/13 10:01:16 markus Exp $ */
/* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */
/*
@@ -167,6 +167,8 @@ static void pppdumpm(struct mbuf *m0);
#ifdef ALTQ
static void ppp_ifstart(struct ifnet *ifp);
#endif
+int ppp_clone_create(struct if_clone *, int);
+void ppp_clone_destroy(struct ifnet *);
/*
* Some useful mbuf macros not in mbuf.h.
@@ -210,11 +212,9 @@ struct compressor *ppp_compressors[8] = {
};
#endif /* PPP_COMPRESS */
-int ppp_clone_create(struct if_clone *, int);
-
LIST_HEAD(, ppp_softc) ppp_softc_list;
struct if_clone ppp_cloner =
- IF_CLONE_INITIALIZER("ppp", ppp_clone_create, NULL);
+ IF_CLONE_INITIALIZER("ppp", ppp_clone_create, ppp_clone_destroy);
/*
* Called from boot code to establish ppp interfaces.
@@ -270,6 +270,28 @@ ppp_clone_create(ifc, unit)
return (0);
}
+void
+ppp_clone_destroy(ifp)
+ struct ifnet *ifp;
+{
+ struct ppp_softc *sc = ifp->if_softc;
+ int s;
+
+ if (sc->sc_devp != NULL)
+ return;
+
+ s = splimp();
+ LIST_REMOVE(sc, sc_list);
+ splx(s);
+
+#if NBPFILTER > 0
+ bpfdetach(ifp);
+#endif
+ if_detach(ifp);
+
+ free(sc, M_DEVBUF);
+}
+
/*
* Allocate a ppp interface unit and initialize it.
*/
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 604cfc7939d..7cd01bbb346 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sl.c,v 1.24 2003/12/12 12:54:57 hshoexer Exp $ */
+/* $OpenBSD: if_sl.c,v 1.25 2003/12/13 10:01:16 markus Exp $ */
/* $NetBSD: if_sl.c,v 1.39.4.1 1996/06/02 16:26:31 thorpej Exp $ */
/*
@@ -184,10 +184,11 @@ static int slinit(struct sl_softc *);
static struct mbuf *sl_btom(struct sl_softc *, int);
int sl_clone_create(struct if_clone *, int);
+void sl_clone_destroy(struct ifnet *);
LIST_HEAD(, sl_softc) sl_softc_list;
struct if_clone sl_cloner =
- IF_CLONE_INITIALIZER("sl", sl_clone_create, NULL);
+ IF_CLONE_INITIALIZER("sl", sl_clone_create, sl_clone_destroy);
/*
* Called from boot code to establish sl interfaces.
@@ -238,6 +239,28 @@ sl_clone_create(ifc, unit)
return (0);
}
+void
+sl_clone_destroy(ifp)
+ struct ifnet *ifp;
+{
+ struct sl_softc *sc = ifp->if_softc;
+ int s;
+
+ if (sc->sc_ttyp != NULL)
+ return;
+
+ s = splimp();
+ LIST_REMOVE(sc, sc_list);
+ splx(s);
+
+#if NBPFILTER > 0
+ bpfdetach(ifp);
+#endif
+ if_detach(ifp);
+
+ free(sc, M_DEVBUF);
+}
+
static int
slinit(sc)
struct sl_softc *sc;