diff options
47 files changed, 111 insertions, 215 deletions
diff --git a/sys/alpha/tc/am7990.c b/sys/alpha/tc/am7990.c index 5c102ddeb77d..ef907829c82b 100644 --- a/sys/alpha/tc/am7990.c +++ b/sys/alpha/tc/am7990.c @@ -221,10 +221,7 @@ am7990_config(sc) printf("%s: address %s\n", device_get_nameunit(sc->sc_dev), ether_sprintf(sc->sc_enaddr)); - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); switch (sc->sc_memsize) { case 8192: diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 883a02623186..3622632b061a 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -370,12 +370,10 @@ int an_attach(sc, unit, flags) bzero((char *)&sc->an_stats, sizeof(sc->an_stats)); /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc->an_stat_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); return(0); } diff --git a/sys/dev/an/if_an_isa.c b/sys/dev/an/if_an_isa.c index ae79a3ea1bb1..1e887c07073a 100644 --- a/sys/dev/an/if_an_isa.c +++ b/sys/dev/an/if_an_isa.c @@ -132,7 +132,7 @@ an_detach_isa(device_t dev) struct ifnet *ifp = &sc->arpcom.ac_if; an_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); an_release_resources(dev); diff --git a/sys/dev/an/if_an_pccard.c b/sys/dev/an/if_an_pccard.c index 4f2b961d3289..dbaf9f49f7c6 100644 --- a/sys/dev/an/if_an_pccard.c +++ b/sys/dev/an/if_an_pccard.c @@ -105,7 +105,7 @@ an_pccard_detach(device_t dev) } an_stop(sc); ifp->if_flags &= ~IFF_RUNNING; - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); sc->an_gone = 1; bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); an_release_resources(dev); diff --git a/sys/dev/an/if_an_pci.c b/sys/dev/an/if_an_pci.c index c114afb91dda..f95dd01ecced 100644 --- a/sys/dev/an/if_an_pci.c +++ b/sys/dev/an/if_an_pci.c @@ -199,7 +199,7 @@ an_detach_pci(device_t dev) struct ifnet *ifp = &sc->arpcom.ac_if; an_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); an_release_resources(dev); diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index ebeee1726b55..44b714c5d969 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -1644,8 +1644,7 @@ ed_attach(sc, unit, flags) /* * Attach the interface */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); } /* device attach does transition from UNCONFIGURED to IDLE state */ @@ -1671,10 +1670,6 @@ ed_attach(sc, unit, flags) (sc->vendor == ED_VENDOR_HP)) && (ifp->if_flags & IFF_ALTPHYS)) ? " tranceiver disabled" : ""); - /* - * If BPF is in the kernel, call the attach for it - */ - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); return (0); } diff --git a/sys/dev/ed/if_ed_pccard.c b/sys/dev/ed/if_ed_pccard.c index 63b0e7bb8f18..9d5fb7f239d4 100644 --- a/sys/dev/ed/if_ed_pccard.c +++ b/sys/dev/ed/if_ed_pccard.c @@ -91,7 +91,7 @@ ed_pccard_detach(device_t dev) } ed_stop(sc); ifp->if_flags &= ~IFF_RUNNING; - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); sc->gone = 1; bus_teardown_intr(dev, sc->irq_res, sc->irq_handle); ed_release_resources(dev); diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index f10e36e1e8d3..b4a0eb785563 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -318,11 +318,8 @@ ep_attach(sc) ep_ifmedia_upd(ifp); } - if (!attached) { - if_attach(ifp); - ether_ifattach(ifp); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - } + if (!attached) + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); #ifdef EP_LOCAL_STATS sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc = diff --git a/sys/dev/ep/if_ep_pccard.c b/sys/dev/ep/if_ep_pccard.c index 30eefb203111..85092b74f35f 100644 --- a/sys/dev/ep/if_ep_pccard.c +++ b/sys/dev/ep/if_ep_pccard.c @@ -48,6 +48,7 @@ #include <machine/resource.h> #include <sys/rman.h> +#include <net/ethernet.h> #include <net/if.h> #include <net/if_arp.h> #include <net/if_media.h> @@ -227,7 +228,7 @@ ep_pccard_detach(device_t dev) return (0); } sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING; - if_detach(&sc->arpcom.ac_if); + ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); sc->gone = 1; bus_teardown_intr(dev, sc->irq, sc->ep_intrhand); ep_free(dev); diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c index 754c63cd1cdd..54eca7bfeabc 100644 --- a/sys/dev/ex/if_ex.c +++ b/sys/dev/ex/if_ex.c @@ -450,16 +450,11 @@ ex_isa_attach(device_t dev) /* * Attach the interface. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); device_printf(sc->dev, "Ethernet address %6D\n", sc->arpcom.ac_enaddr, ":"); - /* - * If BPF is in the kernel, call the attach for it - */ - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); DODEBUG(Start_End, printf("ex_isa_attach%d: finish\n", unit);); return(0); diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index 2b0143e046e4..4d3c9fbfbc97 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -830,10 +830,7 @@ ieattach(struct isa_device *dvp) EVENTHANDLER_REGISTER(shutdown_post_sync, ee16_shutdown, ie, SHUTDOWN_PRI_DEFAULT); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); return (1); } diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c index e0f4c7bc225d..01395e63d011 100644 --- a/sys/dev/sn/if_sn.c +++ b/sys/dev/sn/if_sn.c @@ -224,8 +224,7 @@ sn_attach(device_t dev) ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; ifp->if_timer = 0; - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); /* * Fill the hardware address into ifa_addr if we find an AF_LINK @@ -245,8 +244,6 @@ sn_attach(device_t dev) bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); } - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - return 0; } diff --git a/sys/dev/sn/if_sn_pccard.c b/sys/dev/sn/if_sn_pccard.c index 018646ededdf..4220deaf1ece 100644 --- a/sys/dev/sn/if_sn_pccard.c +++ b/sys/dev/sn/if_sn_pccard.c @@ -90,7 +90,7 @@ sn_pccard_detach(device_t dev) struct sn_softc *sc = device_get_softc(dev); sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING; - if_detach(&sc->arpcom.ac_if); + ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); sn_deactivate(dev); return 0; } diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index ea505ce5d6a5..6e46a4dd7581 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -734,12 +734,10 @@ USB_ATTACH(aue) aue_qdat.if_rxstart = aue_rxstart; /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc->aue_stat_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); usb_register_netisr(); sc->aue_gone = 0; @@ -761,8 +759,7 @@ Static int aue_detach(dev) sc->aue_gone = 1; untimeout(aue_tick, sc, sc->aue_stat_ch); - bpfdetach(ifp); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); if (sc->aue_ep[AUE_ENDPT_TX] != NULL) usbd_abort_pipe(sc->aue_ep[AUE_ENDPT_TX]); diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c index 6681517f84db..3de43640b4e3 100644 --- a/sys/dev/usb/if_cue.c +++ b/sys/dev/usb/if_cue.c @@ -555,12 +555,10 @@ USB_ATTACH(cue) cue_qdat.if_rxstart = cue_rxstart; /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc->cue_stat_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); usb_register_netisr(); sc->cue_gone = 0; @@ -582,8 +580,7 @@ Static int cue_detach(dev) sc->cue_gone = 1; untimeout(cue_tick, sc, sc->cue_stat_ch); - bpfdetach(ifp); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); if (sc->cue_ep[CUE_ENDPT_TX] != NULL) usbd_abort_pipe(sc->cue_ep[CUE_ENDPT_TX]); diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c index cb6a03c46350..780c42bbcbf1 100644 --- a/sys/dev/usb/if_kue.c +++ b/sys/dev/usb/if_kue.c @@ -500,11 +500,9 @@ USB_ATTACH(kue) kue_qdat.if_rxstart = kue_rxstart; /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); usb_register_netisr(); sc->kue_gone = 0; @@ -526,10 +524,8 @@ Static int kue_detach(dev) sc->kue_gone = 1; - if (ifp != NULL) { - bpfdetach(ifp); - if_detach(ifp); - } + if (ifp != NULL) + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); if (sc->kue_ep[KUE_ENDPT_TX] != NULL) usbd_abort_pipe(sc->kue_ep[KUE_ENDPT_TX]); diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index 303cd9454783..da8dcb0c81b2 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -210,10 +210,7 @@ vxattach(sc) ifp->if_watchdog = vxwatchdog; ifp->if_softc = sc; - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); sc->tx_start_thresh = 20; /* probably a good starting point. */ diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c index 63cbb7627750..2bde25c91b76 100644 --- a/sys/dev/xe/if_xe.c +++ b/sys/dev/xe/if_xe.c @@ -478,7 +478,7 @@ xe_detach(device_t dev) { struct xe_softc *sc = device_get_softc(dev); sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING; - if_detach(&sc->arpcom.ac_if); + ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); xe_deactivate(dev); return 0; } @@ -577,14 +577,7 @@ xe_attach (device_t dev) { device_printf(dev, "Ethernet address %6D\n", scp->arpcom.ac_enaddr, ":"); /* Attach the interface */ - if_attach(scp->ifp); - ether_ifattach(scp->ifp); - - /* BPF is in the kernel, call the attach for it */ -#if XE_DEBUG > 1 - device_printf(dev, "BPF listener attached\n"); -#endif - bpfattach(scp->ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(scp->ifp, ETHER_BPF_SUPPORTED); /* Done */ return 0; diff --git a/sys/i386/isa/if_cs.c b/sys/i386/isa/if_cs.c index b255d5da7006..b9e8afe0ac7d 100644 --- a/sys/i386/isa/if_cs.c +++ b/sys/i386/isa/if_cs.c @@ -609,16 +609,14 @@ cs_attach(struct cs_softc *sc, int unit, int flags) ifmedia_set(&sc->media, media); cs_mediaset(sc, media); - if_attach(ifp); cs_stop( sc ); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); } if (bootverbose) printf(CS_NAME"%d: ethernet address %6D\n", ifp->if_unit, sc->arpcom.ac_enaddr, ":"); - bpfattach(ifp, DLT_EN10MB, sizeof (struct ether_header)); return 1; } diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c index bbe09409469e..41583bc20e49 100644 --- a/sys/i386/isa/if_el.c +++ b/sys/i386/isa/if_el.c @@ -192,17 +192,12 @@ el_attach(struct isa_device *idev) /* Now we can attach the interface */ dprintf(("Attaching interface...\n")); - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); /* Print out some information for the user */ printf("el%d: 3c501 address %6D\n",idev->id_unit, sc->arpcom.ac_enaddr, ":"); - /* Finally, attach to bpf filter if it is present. */ - dprintf(("Attaching to BPF...\n")); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - dprintf(("el_attach() finished.\n")); return(1); } diff --git a/sys/i386/isa/if_fe.c b/sys/i386/isa/if_fe.c index 821c80bb82bd..71532475b60c 100644 --- a/sys/i386/isa/if_fe.c +++ b/sys/i386/isa/if_fe.c @@ -2841,14 +2841,13 @@ fe_attach ( struct isa_device * dev ) /* Attach and stop the interface. */ #if NCARD > 0 if (already_ifattach[dev->id_unit] != 1) { - if_attach(&sc->sc_if); + ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED); already_ifattach[dev->id_unit] = 1; } #else - if_attach(&sc->sc_if); + ether_ifattach(&sc->sc_if, ETHER_BPF_SUPPORTED); #endif fe_stop(sc); - ether_ifattach(&sc->sc_if); /* Print additional info when attached. */ printf("fe%d: address %6D, type %s%s\n", sc->sc_unit, @@ -2897,8 +2896,6 @@ fe_attach ( struct isa_device * dev ) sc->sc_unit); } - /* If BPF is in the kernel, call the attach for it. */ - bpfattach(&sc->sc_if, DLT_EN10MB, sizeof(struct ether_header)); return 1; } diff --git a/sys/i386/isa/if_le.c b/sys/i386/isa/if_le.c index 8c5df1123ef1..451df1f9d1bc 100644 --- a/sys/i386/isa/if_le.c +++ b/sys/i386/isa/if_le.c @@ -352,10 +352,7 @@ le_attach( ifp->if_addrlen = 6; ifp->if_hdrlen = 14; - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); return 1; } diff --git a/sys/i386/isa/if_lnc.c b/sys/i386/isa/if_lnc.c index 6784f6f825f8..ef5d4bd25734 100644 --- a/sys/i386/isa/if_lnc.c +++ b/sys/i386/isa/if_lnc.c @@ -1232,12 +1232,7 @@ lnc_attach_sc(struct lnc_softc *sc, int unit) sc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN; sc->arpcom.ac_if.if_snd.ifq_maxlen = IFQ_MAXLEN; - /* - * XXX -- should check return status of if_attach - */ - - if_attach(&sc->arpcom.ac_if); - ether_ifattach(&sc->arpcom.ac_if); + ether_ifattach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); printf("lnc%d: ", unit); if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE) @@ -1247,8 +1242,6 @@ lnc_attach_sc(struct lnc_softc *sc, int unit) printf("%s", ic_ident[sc->nic.ic]); printf(" address %6D\n", sc->arpcom.ac_enaddr, ":"); - bpfattach(&sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header)); - return (1); } diff --git a/sys/i386/isa/if_rdp.c b/sys/i386/isa/if_rdp.c index b11ec1c092af..663ef18602ba 100644 --- a/sys/i386/isa/if_rdp.c +++ b/sys/i386/isa/if_rdp.c @@ -608,8 +608,7 @@ rdp_attach(struct isa_device *isa_dev) /* * Attach the interface */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); } /* @@ -623,10 +622,6 @@ rdp_attach(struct isa_device *isa_dev) printf("%s%d: address %6D\n", ifp->if_name, ifp->if_unit, sc->arpcom.ac_enaddr, ":"); - /* - * If BPF is in the kernel, call the attach for it - */ - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); return 1; } diff --git a/sys/i386/isa/if_wi.c b/sys/i386/isa/if_wi.c index ff50139f1ee2..101d45aef0a2 100644 --- a/sys/i386/isa/if_wi.c +++ b/sys/i386/isa/if_wi.c @@ -216,7 +216,7 @@ static int wi_pccard_detach(dev) } wi_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_teardown_intr(dev, sc->irq, sc->wi_intrhand); wi_free(dev); sc->wi_gone = 1; @@ -326,12 +326,10 @@ static int wi_pccard_attach(device_t dev) wi_stop(sc); /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc->wi_stat_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); return(0); } diff --git a/sys/i386/isa/if_wl.c b/sys/i386/isa/if_wl.c index 44f2849d9bbe..e42f62c4e31f 100644 --- a/sys/i386/isa/if_wl.c +++ b/sys/i386/isa/if_wl.c @@ -505,10 +505,7 @@ wlattach(struct isa_device *id) ifp->if_done ifp->if_reset */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); bcopy(&sc->wl_addr[0], sc->wl_ac.ac_enaddr, WAVELAN_ADDR_SIZE); printf("%s%d: address %6D, NWID 0x%02x%02x", ifp->if_name, ifp->if_unit, diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 619a2e9b6f24..6d1c82e19fbf 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -82,6 +82,12 @@ struct ether_addr { #ifdef _KERNEL +/* + * For device drivers to specify whether they support BPF or not + */ +#define ETHER_BPF_UNSUPPORTED 0 +#define ETHER_BPF_SUPPORTED 1 + struct ifnet; struct mbuf; diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c index 97d93c89f18f..e2ede0882e6e 100644 --- a/sys/net/if_ef.c +++ b/sys/net/if_ef.c @@ -128,9 +128,7 @@ ef_attach(struct efnet *sc) /* * Attach the interface */ - if_attach(ifp); - ether_ifattach(ifp); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); ifp->if_resolvemulti = 0; ifp->if_type = IFT_XETHER; diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 7ae976e0f65c..d7c410b0c814 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -646,12 +646,14 @@ ether_demux(ifp, eh, m) * Perform common duties while attaching to interface list */ void -ether_ifattach(ifp) +ether_ifattach(ifp, bpf) register struct ifnet *ifp; + int bpf; { register struct ifaddr *ifa; register struct sockaddr_dl *sdl; + if_attach(ifp); ifp->if_type = IFT_ETHER; ifp->if_addrlen = 6; ifp->if_hdrlen = 14; @@ -660,18 +662,32 @@ ether_ifattach(ifp) if (ifp->if_baudrate == 0) ifp->if_baudrate = 10000000; ifa = ifnet_addrs[ifp->if_index - 1]; - if (ifa == 0) { - printf("ether_ifattach: no lladdr!\n"); - return; - } + KASSERT(ifa != NULL, ("%s: no lladdr!\n", __FUNCTION__)); sdl = (struct sockaddr_dl *)ifa->ifa_addr; sdl->sdl_type = IFT_ETHER; sdl->sdl_alen = ifp->if_addrlen; bcopy((IFP2AC(ifp))->ac_enaddr, LLADDR(sdl), ifp->if_addrlen); + if (bpf) + bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); if (ng_ether_attach_p != NULL) (*ng_ether_attach_p)(ifp); } +/* + * Perform common duties while detaching an Ethernet interface + */ +void +ether_ifdetach(ifp, bpf) + struct ifnet *ifp; + int bpf; +{ + if (ng_ether_detach_p != NULL) + (*ng_ether_detach_p)(ifp); + if (bpf) + bpfdetach(ifp); + if_detach(ifp); +} + SYSCTL_DECL(_net_link); SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet"); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 79b1ff6287d9..e6f07853622e 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -323,7 +323,8 @@ extern struct ifnet loif[]; extern int if_index; extern struct ifaddr **ifnet_addrs; -void ether_ifattach __P((struct ifnet *)); +void ether_ifattach __P((struct ifnet *, int)); +void ether_ifdetach __P((struct ifnet *, int)); void ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *)); void ether_demux __P((struct ifnet *, struct ether_header *, struct mbuf *)); int ether_output __P((struct ifnet *, diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index dce3be83c813..db51ac329680 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -170,9 +170,7 @@ vlaninit(void *dummy) ifp->if_ioctl = vlan_ioctl; ifp->if_output = ether_output; ifp->if_snd.ifq_maxlen = ifqmaxlen; - if_attach(ifp); - ether_ifattach(ifp); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); /* Now undo some of the damage... */ ifp->if_data.ifi_type = IFT_8021_VLAN; ifp->if_data.ifi_hdrlen = EVL_ENCAPLEN; diff --git a/sys/pc98/pc98/if_ed.c b/sys/pc98/pc98/if_ed.c index 2f594bca26f7..253a829faec2 100644 --- a/sys/pc98/pc98/if_ed.c +++ b/sys/pc98/pc98/if_ed.c @@ -2471,8 +2471,7 @@ ed_attach(sc, unit, flags) /* * Attach the interface */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); } /* device attach does transition from UNCONFIGURED to IDLE state */ @@ -2498,10 +2497,6 @@ ed_attach(sc, unit, flags) (sc->vendor == ED_VENDOR_HP)) && (ifp->if_flags & IFF_ALTPHYS)) ? " tranceiver disabled" : ""); - /* - * If BPF is in the kernel, call the attach for it - */ - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); return 1; } diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c index 55a2cadfe86e..eb84838b9094 100644 --- a/sys/pci/if_dc.c +++ b/sys/pci/if_dc.c @@ -1748,14 +1748,11 @@ static int dc_attach(dev) } /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc->dc_stat_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - #ifdef __alpha__ sc->dc_srm_media = 0; @@ -1802,7 +1799,7 @@ static int dc_detach(dev) ifp = &sc->arpcom.ac_if; dc_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_generic_detach(dev); device_delete_child(dev, sc->dc_miibus); diff --git a/sys/pci/if_de.c b/sys/pci/if_de.c index 81b70e00e970..29ee192124c2 100644 --- a/sys/pci/if_de.c +++ b/sys/pci/if_de.c @@ -4870,11 +4870,8 @@ tulip_attach( tulip_reset(sc); - if_attach(ifp); + ether_ifattach(&(sc)->tulip_if, ETHER_BPF_SUPPORTED); ifp->if_snd.ifq_maxlen = ifqmaxlen; - ether_ifattach(&(sc)->tulip_if); - - bpfattach(&sc->tulip_if, DLT_EN10MB, sizeof(struct ether_header)); } #if defined(TULIP_BUS_DMA) diff --git a/sys/pci/if_fxp.c b/sys/pci/if_fxp.c index a9060e303411..408ec5de2adf 100644 --- a/sys/pci/if_fxp.c +++ b/sys/pci/if_fxp.c @@ -598,14 +598,12 @@ fxp_attach(device_t dev) /* * Attach the interface. */ - if_attach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); /* * Let the system queue as many packets as we have available * TX descriptors. */ ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1; - ether_ifattach(ifp); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); splx(s); return 0; @@ -629,7 +627,7 @@ fxp_detach(device_t dev) /* * Close down routes etc. */ - if_detach(&sc->arpcom.ac_if); + ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); /* * Stop DMA and drop transmit queue. diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c index 0e98cbdfed34..05e33d15f313 100644 --- a/sys/pci/if_rl.c +++ b/sys/pci/if_rl.c @@ -954,12 +954,9 @@ static int rl_attach(dev) ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -978,7 +975,7 @@ static int rl_detach(dev) sc = device_get_softc(dev); ifp = &sc->arpcom.ac_if; - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); rl_stop(sc); bus_generic_detach(dev); diff --git a/sys/pci/if_sf.c b/sys/pci/if_sf.c index df269c426281..aae6d4892253 100644 --- a/sys/pci/if_sf.c +++ b/sys/pci/if_sf.c @@ -827,12 +827,9 @@ static int sf_attach(dev) ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1; /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -851,7 +848,7 @@ static int sf_detach(dev) sc = device_get_softc(dev); ifp = &sc->arpcom.ac_if; - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); sf_stop(sc); bus_generic_detach(dev); diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c index 7745001c8498..f36e384c8dcb 100644 --- a/sys/pci/if_sis.c +++ b/sys/pci/if_sis.c @@ -695,14 +695,11 @@ static int sis_attach(dev) } /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc->sis_stat_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); - fail: splx(s); return(error); @@ -722,7 +719,7 @@ static int sis_detach(dev) sis_reset(sc); sis_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_generic_detach(dev); device_delete_child(dev, sc->sis_miibus); diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c index be1695a80b1e..7b4cbee38c3e 100644 --- a/sys/pci/if_sk.c +++ b/sys/pci/if_sk.c @@ -1219,12 +1219,10 @@ static int sk_attach_xmac(dev) } /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); callout_handle_init(&sc_if->sk_tick_ch); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); return(0); } @@ -1429,7 +1427,7 @@ static int sk_detach_xmac(dev) sc_if = device_get_softc(dev); ifp = &sc_if->arpcom.ac_if; sk_stop(sc_if); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_generic_detach(dev); if (sc_if->sk_miibus != NULL) device_delete_child(dev, sc_if->sk_miibus); diff --git a/sys/pci/if_ste.c b/sys/pci/if_ste.c index f63e7f0296ba..3efee77dfb2b 100644 --- a/sys/pci/if_ste.c +++ b/sys/pci/if_ste.c @@ -1066,13 +1066,9 @@ static int ste_attach(dev) ifp->if_snd.ifq_maxlen = STE_TX_LIST_CNT - 1; /* - * Call MI attach routines. + * Call MI attach routine. */ - - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -1092,7 +1088,7 @@ static int ste_detach(dev) ifp = &sc->arpcom.ac_if; ste_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_generic_detach(dev); device_delete_child(dev, sc->ste_miibus); diff --git a/sys/pci/if_ti.c b/sys/pci/if_ti.c index a495cf6a6e20..c85d323ed233 100644 --- a/sys/pci/if_ti.c +++ b/sys/pci/if_ti.c @@ -1734,12 +1734,9 @@ static int ti_attach(dev) ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO); /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -1759,7 +1756,7 @@ static int ti_detach(dev) sc = device_get_softc(dev); ifp = &sc->arpcom.ac_if; - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); ti_stop(sc); bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand); diff --git a/sys/pci/if_tl.c b/sys/pci/if_tl.c index e73b892f0b4f..5b4e4643c8e3 100644 --- a/sys/pci/if_tl.c +++ b/sys/pci/if_tl.c @@ -1333,12 +1333,9 @@ static int tl_attach(dev) } /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -1358,7 +1355,7 @@ static int tl_detach(dev) ifp = &sc->arpcom.ac_if; tl_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_generic_detach(dev); device_delete_child(dev, sc->tl_miibus); diff --git a/sys/pci/if_tx.c b/sys/pci/if_tx.c index 1eec12b990b4..f79b4f6a66e5 100644 --- a/sys/pci/if_tx.c +++ b/sys/pci/if_tx.c @@ -573,12 +573,7 @@ epic_freebsd_attach( SHUTDOWN_PRI_DEFAULT); /* Attach to if manager */ - if_attach(ifp); - ether_ifattach(ifp); - -#if NBPF > 0 - bpfattach(ifp,DLT_EN10MB, sizeof(struct ether_header)); -#endif + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); splx(s); diff --git a/sys/pci/if_vr.c b/sys/pci/if_vr.c index 266a66cf5750..4d0dac19b776 100644 --- a/sys/pci/if_vr.c +++ b/sys/pci/if_vr.c @@ -798,12 +798,9 @@ static int vr_attach(dev) callout_handle_init(&sc->vr_stat_ch); /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -823,7 +820,7 @@ static int vr_detach(dev) ifp = &sc->arpcom.ac_if; vr_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); bus_generic_detach(dev); device_delete_child(dev, sc->vr_miibus); diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c index 2be3f2f91411..d640af655cf9 100644 --- a/sys/pci/if_wb.c +++ b/sys/pci/if_wb.c @@ -965,12 +965,9 @@ static int wb_attach(dev) } /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: if (error) @@ -993,7 +990,7 @@ static int wb_detach(dev) ifp = &sc->arpcom.ac_if; wb_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); /* Delete any miibus and phy devices attached to this interface */ bus_generic_detach(dev); diff --git a/sys/pci/if_wx.c b/sys/pci/if_wx.c index 5fd2b2853486..c509f588d193 100644 --- a/sys/pci/if_wx.c +++ b/sys/pci/if_wx.c @@ -629,10 +629,8 @@ wx_attach(device_t dev) ifp->if_ioctl = wx_ioctl; ifp->if_start = wx_start; ifp->if_watchdog = wx_txwatchdog; - if_attach(ifp); ifp->if_snd.ifq_maxlen = WX_MAX_TDESC - 1; - ether_ifattach(ifp); - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); tmp = wxlist; if (tmp) { while (tmp->wx_next) @@ -651,7 +649,7 @@ wx_detach(device_t dev) { wx_softc_t *sc = device_get_softc(dev); int s = splimp(); - if_detach(&sc->w.arpcom.ac_if); + ether_ifdetach(&sc->w.arpcom.ac_if, ETHER_BPF_SUPPORTED); wx_stop(sc); bus_teardown_intr(dev, sc->w.irq, sc->w.ih); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->w.irq); diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c index 489bc4c4aac6..486570855c20 100644 --- a/sys/pci/if_xl.c +++ b/sys/pci/if_xl.c @@ -1489,12 +1489,9 @@ static int xl_attach(dev) done: /* - * Call MI attach routines. + * Call MI attach routine. */ - if_attach(ifp); - ether_ifattach(ifp); - - bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); + ether_ifattach(ifp, ETHER_BPF_SUPPORTED); fail: splx(s); @@ -1515,7 +1512,7 @@ static int xl_detach(dev) xl_reset(sc); xl_stop(sc); - if_detach(ifp); + ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); /* Delete any miibus and phy devices attached to this interface */ if (sc->xl_miibus != NULL) { |
