summaryrefslogtreecommitdiffstats
path: root/sys/net/if_disc.c
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
committerbrooks <brooks@FreeBSD.org>2005-06-10 16:49:24 +0000
commit567ba9b00a248431e7c1147c4e079fd7a11b9ecf (patch)
treef65b6d7834b40dfcd48534829a0a1e9529ab87ee /sys/net/if_disc.c
parent3eaa67c3ad947d85be5350e0e184cd6ee5b93a52 (diff)
downloadFreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.zip
FreeBSD-src-567ba9b00a248431e7c1147c4e079fd7a11b9ecf.tar.gz
Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have been replaced with a struct ifnet pointer to be filled by a call to the new function, if_alloc(). The layer 2 common structure is also allocated via if_alloc() based on the interface type. It is hung off the new struct ifnet member, if_l2com. This change removes the size of these structures from the kernel ABI and will allow us to better manage them as interfaces come and go. Other changes of note: - Struct arpcom is no longer referenced in normal interface code. Instead the Ethernet address is accessed via the IFP2ENADDR() macro. To enforce this ac_enaddr has been renamed to _ac_enaddr. - The second argument to ether_ifattach is now always the mac address from driver private storage rather than sometimes being ac_enaddr. Reviewed by: sobomax, sam
Diffstat (limited to 'sys/net/if_disc.c')
-rw-r--r--sys/net/if_disc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 3068b44..7789b29 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -62,7 +62,7 @@
#define DISCNAME "disc"
struct disc_softc {
- struct ifnet sc_if; /* must be first */
+ struct ifnet *sc_ifp; /* must be first */
LIST_ENTRY(disc_softc) sc_list;
};
@@ -86,8 +86,11 @@ disc_clone_create(struct if_clone *ifc, int unit)
struct disc_softc *sc;
sc = malloc(sizeof(struct disc_softc), M_DISC, M_WAITOK | M_ZERO);
-
- ifp = &sc->sc_if;
+ ifp = sc->sc_ifp = if_alloc(IFT_LOOP);
+ if (ifp == NULL) {
+ free(sc, M_DISC);
+ return (ENOSPC);
+ }
ifp->if_softc = sc;
if_initname(ifp, ifc->ifc_name, unit);
@@ -95,7 +98,6 @@ disc_clone_create(struct if_clone *ifc, int unit)
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
ifp->if_ioctl = discioctl;
ifp->if_output = discoutput;
- ifp->if_type = IFT_LOOP;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
ifp->if_snd.ifq_maxlen = 20;
@@ -112,8 +114,9 @@ static void
disc_destroy(struct disc_softc *sc)
{
- bpfdetach(&sc->sc_if);
- if_detach(&sc->sc_if);
+ bpfdetach(sc->sc_ifp);
+ if_detach(sc->sc_ifp);
+ if_free(sc->sc_ifp);
free(sc, M_DISC);
}
OpenPOWER on IntegriCloud