PERFORCE change 144332 for review
Julian Elischer
julian at FreeBSD.org
Mon Jun 30 05:13:24 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144332
Change 144332 by julian at julian_trafmon1 on 2008/06/30 05:12:55
revert IFC. we need this
Affected files ...
.. //depot/projects/vimage/src/sys/net/if_loop.c#21 edit
Differences ...
==== //depot/projects/vimage/src/sys/net/if_loop.c#21 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)if_loop.c 8.2 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/net/if_loop.c,v 1.117 2008/06/29 13:17:01 ed Exp $
+ * $FreeBSD: src/sys/net/if_loop.c,v 1.116 2008/05/09 20:38:25 rwatson Exp $
*/
/*
@@ -43,6 +43,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
#include <machine/bus.h>
@@ -91,6 +92,13 @@
#define LOMTU 16384
#endif
+#define LONAME "lo"
+
+struct lo_softc {
+ struct ifnet *sc_ifp;
+ 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,
@@ -107,6 +115,8 @@
static LIST_HEAD(lo_list, lo_softc) lo_list;
#endif /* !VIMAGE */
+static MALLOC_DEFINE(M_LO, LONAME, "Loopback Interface");
+
static struct mtx lo_mtx;
IFC_SIMPLE_DECLARE(lo, 1);
@@ -114,18 +124,23 @@
static void
lo_clone_destroy(struct ifnet *ifp)
{
+ struct lo_softc *sc;
#ifdef INVARIANTS
INIT_VNET_NET(ifp->if_vnet);
#endif
+ sc = ifp->if_softc;
+
/* XXX: destroying lo0 will lead to panics. */
KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__));
mtx_lock(&lo_mtx);
+ LIST_REMOVE(sc, sc_next);
mtx_unlock(&lo_mtx);
bpfdetach(ifp);
if_detach(ifp);
if_free(ifp);
+ free(sc, M_LO);
}
static int
@@ -133,10 +148,14 @@
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
+ struct lo_softc *sc;
- ifp = if_alloc(IFT_LOOP);
- if (ifp == NULL)
+ MALLOC(sc, struct lo_softc *, sizeof(*sc), M_LO, M_WAITOK | M_ZERO);
+ ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
+ if (ifp == NULL) {
+ free(sc, M_LO);
return (ENOSPC);
+ }
if (V_loif == NULL)
V_loif = ifp;
@@ -146,6 +165,7 @@
ifp->if_ioctl = loioctl;
ifp->if_output = looutput;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
+ ifp->if_softc = sc;
if_attach(ifp);
bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
mtx_lock(&lo_mtx);
More information about the p4-projects
mailing list