int pflog_clone_destroy(struct ifnet *ifp) #endif { struct pflog_softc *pflogif = ifp->if_softc; int s; s = splnet(); #ifdef __FreeBSD__ PF_LOCK(); #endif pflogifs[pflogif->sc_unit] = NULL; LIST_REMOVE(pflogif, sc_list); #ifdef __FreeBSD__ PF_UNLOCK(); #endif splx(s); #if NBPFILTER > 0 bpfdetach(ifp); #endif if_detach(ifp); #ifdef __FreeBSD__ if_free(ifp); #endif free(pflogif, M_DEVBUF); #ifndef __FreeBSD__ return (0); #endif }
static int usie_detach(device_t self) { struct usie_softc *sc = device_get_softc(self); uint8_t x; /* detach ifnet */ if (sc->sc_ifp != NULL) { usie_if_stop(sc); usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER); bpfdetach(sc->sc_ifp); if_detach(sc->sc_ifp); if_free(sc->sc_ifp); sc->sc_ifp = NULL; } /* detach ucom */ if (sc->sc_nucom > 0) ucom_detach(&sc->sc_super_ucom, sc->sc_ucom); /* stop all USB transfers */ usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER); for (x = 0; x != USIE_UCOM_MAX; x++) usbd_transfer_unsetup(sc->sc_uc_xfer[x], USIE_UC_N_XFER); mtx_destroy(&sc->sc_mtx); return (0); }
static int ipfw_log_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) { int unit; if (ifp == NULL) return (0); LOGIF_WLOCK(); if (log_if != NULL && ifp == log_if) log_if = NULL; else { LOGIF_WUNLOCK(); return (EINVAL); } LOGIF_WUNLOCK(); unit = ifp->if_dunit; bpfdetach(ifp); if_detach(ifp); if_free(ifp); ifc_free_unit(ifc, unit); return (0); }
static int loop_clone_destroy(struct ifnet *ifp) { if (ifp == lo0ifp) return (EPERM); #ifdef MBUFTRACE #ifdef T2EX if ( ifp->if_mowner != NULL ) { #endif MOWNER_DETACH(ifp->if_mowner); free(ifp->if_mowner, M_DEVBUF); #ifdef T2EX } #endif #endif #if NBPFILTER > 0 bpfdetach(ifp); #endif if_detach(ifp); free(ifp, M_DEVBUF); return (0); }
static int ipfwlog_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct ifnet *ifp; ifp = if_alloc(IFT_PFLOG); if (ifp == NULL) return (ENOSPC); if_initname(ifp, ipfwlogname, unit); ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_mtu = 65536; ifp->if_ioctl = ipfw_bpf_ioctl; ifp->if_output = ipfw_bpf_output; ifp->if_hdrlen = PFLOG_HDRLEN; if_attach(ifp); bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); LOGIF_WLOCK(); if (V_pflog_if != NULL) { LOGIF_WUNLOCK(); bpfdetach(ifp); if_detach(ifp); if_free(ifp); return (EEXIST); } V_pflog_if = ifp; LOGIF_WUNLOCK(); return (0); }
int pppdetach() { struct ppp_softc *sc; int i; IOLog("Removing PPP on Line Discipline %d\n", PPPDISC); if (!tty_ld_remove(PPPDISC)) IOLog("ppp: Could not remove line discipline\n"); IOLog("Removing interfaces:\n"); for (sc = ppp_softc, i = 0; i < NUM_PPP; sc++, i++) { nbq_free(&sc->sc_freeq); nbq_free(&sc->sc_rawq); nbq_free(&sc->sc_fastq); nbq_free(&sc->sc_slowq); nbq_free(&sc->sc_inq); nbq_free(&sc->sc_npq); nbq_free(&sc->sc_compq); if_detach(sc->sc_if); /* no idea why we need this, but... */ bzero(sc->sc_if, sizeof(netif_t)); IOLog(" ppp%d successfully detached.\n", i); } IOLog("PPP-2.3 Successfully Removed.\n\n"); return 0; }
static int gre_clone_destroy(struct ifnet *ifp) { struct gre_softc *sc = ifp->if_softc; int cpu; #ifdef INET if (sc->encap != NULL) encap_detach(sc->encap); #endif LIST_REMOVE(sc, sc_list); bpfdetach(ifp); if_detach(ifp); for (cpu = 0; cpu < netisr_ncpus; ++cpu) { if (sc->route_pcpu[cpu].ro_rt != NULL) { rtfree_async(sc->route_pcpu[cpu].ro_rt); sc->route_pcpu[cpu].ro_rt = NULL; } } kfree(sc->route_pcpu, M_GRE); kfree(sc, M_GRE); return 0; }
int ugl_detach(struct device *self, int flags) { struct ugl_softc *sc = (struct ugl_softc *)self; struct ifnet *ifp = GET_IFP(sc); int s; DPRINTFN(2,("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); s = splusb(); if (ifp->if_flags & IFF_RUNNING) ugl_stop(sc); if (ifp->if_softc != NULL) if_detach(ifp); #ifdef DIAGNOSTIC if (sc->sc_ep[UGL_ENDPT_TX] != NULL || sc->sc_ep[UGL_ENDPT_RX] != NULL || sc->sc_ep[UGL_ENDPT_INTR] != NULL) printf("%s: detach has active endpoints\n", sc->sc_dev.dv_xname); #endif splx(s); return (0); }
int vte_detach(struct device *self, int flags) { struct vte_softc *sc = (struct vte_softc *)self; struct ifnet *ifp = &sc->sc_arpcom.ac_if; int s; s = splnet(); vte_stop(sc); splx(s); mii_detach(&sc->sc_miibus, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete all remaining media. */ ifmedia_delete_instance(&sc->sc_miibus.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); vte_dma_free(sc); if (sc->sc_irq_handle != NULL) { pci_intr_disestablish(sc->sc_pct, sc->sc_irq_handle); sc->sc_irq_handle = NULL; } return (0); }
/* * Cardbus detach function: deallocate all resources */ int re_cardbus_detach(struct device *self, int flags) { struct re_cardbus_softc *csc = (void *)self; struct rl_softc *sc = &csc->sc_rl; struct cardbus_devfunc *ct = csc->ct; struct ifnet *ifp = &sc->sc_arpcom.ac_if; /* Remove timeout handler */ timeout_del(&sc->timer_handle); /* Detach PHY */ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete media stuff */ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); /* Disable interrupts */ if (csc->sc_ih != NULL) cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih); /* Free cardbus resources */ Cardbus_mapreg_unmap(ct, csc->sc_bar_reg, sc->rl_btag, sc->rl_bhandle, csc->sc_mapsize); return (0); }
static int ipfw_log_clone_destroy(struct ifnet *ifp) { int unit; if (ifp == NULL) return (0); unit = ifp->if_dunit; if (unit < 0 || unit >= LOG_IF_MAX) { return EINVAL; } if (log_if_table[unit] == NULL) { return EINVAL; } LOGIF_WLOCK(); log_if_table[unit] = NULL; bpfdetach(ifp); if_detach(ifp); if_free(ifp); log_if_count--; LOGIF_WUNLOCK(); return (0); }
static int shmif_unclone(struct ifnet *ifp) { struct shmif_sc *sc = ifp->if_softc; shmif_stop(ifp, 1); if_down(ifp); finibackend(sc); mutex_enter(&sc->sc_mtx); sc->sc_dying = true; cv_broadcast(&sc->sc_cv); mutex_exit(&sc->sc_mtx); if (sc->sc_rcvl) kthread_join(sc->sc_rcvl); sc->sc_rcvl = NULL; vmem_xfree(shmif_units, sc->sc_unit+1, 1); ether_ifdetach(ifp); if_detach(ifp); cv_destroy(&sc->sc_cv); mutex_destroy(&sc->sc_mtx); kmem_free(sc, sizeof(*sc)); return 0; }
/* * Detach net80211 state on device detach. Tear down * all vap's and reclaim all common state prior to the * device state going away. Note we may call back into * driver; it must be prepared for this. */ void ieee80211_ifdetach(struct ieee80211com *ic) { struct ifnet *ifp = ic->ic_ifp; struct ieee80211vap *vap; if_detach(ifp); while ((vap = TAILQ_FIRST(&ic->ic_vaps)) != NULL) ieee80211_vap_destroy(vap); ieee80211_waitfor_parent(ic); ieee80211_sysctl_detach(ic); ieee80211_dfs_detach(ic); ieee80211_regdomain_detach(ic); ieee80211_scan_detach(ic); #ifdef IEEE80211_SUPPORT_SUPERG ieee80211_superg_detach(ic); #endif ieee80211_ht_detach(ic); /* NB: must be called before ieee80211_node_detach */ ieee80211_proto_detach(ic); ieee80211_crypto_detach(ic); ieee80211_power_detach(ic); ieee80211_node_detach(ic); ifmedia_removeall(&ic->ic_media); taskqueue_free(ic->ic_tq); }
int ueagle_detach(struct device *self, int flags) { struct ueagle_softc *sc = (struct ueagle_softc *)self; struct ifnet *ifp = &sc->sc_if; if (sc->fw != NULL) return 0; /* shortcut for pre-firmware devices */ ueagle_stop(ifp, 1); /* wait for stat thread to exit properly */ if (sc->stat_thread != NULL) { DPRINTFN(3, ("%s: waiting for stat thread to exit\n", sc->sc_dev.dv_xname)); tsleep(sc->stat_thread, PZERO, "ueaglestat", 0); DPRINTFN(3, ("%s: stat thread exited properly\n", sc->sc_dev.dv_xname)); } if (ifp->if_softc != NULL) if_detach(ifp); return 0; }
int re_pci_detach(struct device *self, int flags) { struct re_pci_softc *psc = (struct re_pci_softc *)self; struct rl_softc *sc = &psc->sc_rl; struct ifnet *ifp = &sc->sc_arpcom.ac_if; /* Remove timeout handler */ timeout_del(&sc->timer_handle); /* Detach PHY */ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); /* Delete media stuff */ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); /* Disable interrupts */ if (psc->sc_ih != NULL) pci_intr_disestablish(psc->sc_pc, psc->sc_ih); /* Free pci resources */ bus_space_unmap(sc->rl_btag, sc->rl_bhandle, psc->sc_iosize); return (0); }
static void enc_clone_destroy(struct ifnet *ifp) { KASSERT(ifp != encif, ("%s: destroying encif", __func__)); bpfdetach(ifp); if_detach(ifp); if_free(ifp); }
static void disc_destroy(struct disc_softc *sc) { bpfdetach(&sc->sc_if); if_detach(&sc->sc_if); free(sc, M_DISC); }
void wanpipe_generic_unregister(struct ifnet *ifp) { log(LOG_INFO, "%s: Unregister interface!\n", ifp->if_xname); sppp_detach(ifp); if_free_sadl(ifp); if_detach(ifp); }
/* * Common stuff for detaching an ATM interface */ void atm_ifdetach(struct ifnet *ifp) { if (atm_harp_detach_p) (*atm_harp_detach_p)(ifp); if(ng_atm_detach_p) (*ng_atm_detach_p)(ifp); if_detach(ifp); }
int faith_clone_destroy(struct ifnet *ifp) { bpf_detach(ifp); if_detach(ifp); if_free(ifp); return (0); }
static int 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); sn_deactivate(dev); return 0; }
/* * Delete a mif from the mif table */ static int del_m6if(mifi_t *mifip) { struct mif6 *mifp = mif6table + *mifip; mifi_t mifi; struct ifnet *ifp; struct sockaddr_in6 sin6; int s; if (*mifip >= nummifs) return EINVAL; if (mifp->m6_ifp == NULL) return EINVAL; s = splsoftnet(); if (!(mifp->m6_flags & MIFF_REGISTER)) { /* * XXX: what if there is yet IPv4 multicast daemon * using the interface? */ ifp = mifp->m6_ifp; sin6.sin6_family = AF_INET6; sin6.sin6_addr = in6addr_any; if_mcast_op(ifp, SIOCDELMULTI, sin6tosa(&sin6)); } else { if (reg_mif_num != (mifi_t)-1) { if_detach(&multicast_register_if6); reg_mif_num = (mifi_t)-1; } } #ifdef notyet memset((void *)qtable[*mifip], 0, sizeof(qtable[*mifip])); memset((void *)mifp->m6_tbf, 0, sizeof(*(mifp->m6_tbf))); #endif memset((void *)mifp, 0, sizeof (*mifp)); /* Adjust nummifs down */ for (mifi = nummifs; mifi > 0; mifi--) if (mif6table[mifi - 1].m6_ifp) break; nummifs = mifi; splx(s); #ifdef MRT6DEBUG if (mrt6debug) log(LOG_DEBUG, "del_m6if %d, nummifs %d\n", *mifip, nummifs); #endif return 0; }
int loop_clone_destroy(struct ifnet *ifp) { if (ifp == lo0ifp) return (EPERM); if_detach(ifp); free(ifp, M_DEVBUF); return (0); }
int loop_clone_destroy(struct ifnet *ifp) { if (ifp->if_index == lo0ifidx) return (EPERM); if_detach(ifp); free(ifp, M_DEVBUF, sizeof(*ifp)); return (0); }
/* detach */ int url_detach(device_t self, int flags) { struct url_softc *sc = device_private(self); struct ifnet *ifp = GET_IFP(sc); int s; DPRINTF(("%s: %s: enter\n", device_xname(sc->sc_dev), __func__)); /* Detached before attached finished */ if (!sc->sc_attached) return (0); callout_stop(&sc->sc_stat_ch); /* Remove any pending tasks */ usb_rem_task(sc->sc_udev, &sc->sc_tick_task); usb_rem_task(sc->sc_udev, &sc->sc_stop_task); s = splusb(); if (--sc->sc_refcnt >= 0) { /* Wait for processes to go away */ usb_detach_waitold(sc->sc_dev); } if (ifp->if_flags & IFF_RUNNING) url_stop(GET_IFP(sc), 1); rnd_detach_source(&sc->rnd_source); mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY); ether_ifdetach(ifp); if_detach(ifp); #ifdef DIAGNOSTIC if (sc->sc_pipe_tx != NULL) aprint_debug_dev(self, "detach has active tx endpoint.\n"); if (sc->sc_pipe_rx != NULL) aprint_debug_dev(self, "detach has active rx endpoint.\n"); if (sc->sc_pipe_intr != NULL) aprint_debug_dev(self, "detach has active intr endpoint.\n"); #endif sc->sc_attached = 0; splx(s); rw_destroy(&sc->sc_mii_rwlock); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); return (0); }
static int ex_pccard_detach(device_t dev) { struct ex_softc *sc = device_get_softc(dev); struct ifnet *ifp = &sc->arpcom.ac_if; ex_stop(sc); ifp->if_flags &= ~IFF_RUNNING; if_detach(ifp); ex_release_resources(dev); return (0); }
static void disc_clone_destroy(struct ifnet *ifp) { struct disc_softc *sc; sc = ifp->if_softc; bpfdetach(ifp); if_detach(ifp); if_free(ifp); free(sc, M_DISC); }
static void lo_clone_destroy(struct ifnet *ifp) { #ifndef VIMAGE /* XXX: destroying lo0 will lead to panics. */ KASSERT(V_loif != ifp, ("%s: destroying lo0", __func__)); #endif bpfdetach(ifp); if_detach(ifp); if_free(ifp); }
int faith_clone_destroy(struct ifnet *ifp) { struct faith_softc *sc = (struct faith_softc *) ifp; LIST_REMOVE(sc, sc_list); bpfdetach(ifp); if_detach(ifp); kfree(sc, M_FAITH); return 0; }
static void pflog_clone_destroy(struct ifnet *ifp) { int i; for (i = 0; i < PFLOGIFS_MAX; i++) if (pflogifs[i] == ifp) pflogifs[i] = NULL; bpfdetach(ifp); if_detach(ifp); if_free(ifp); }