* Detach bpf from an interface. This involves detaching each descriptor * associated with the interface. Notify each descriptor as it's detached * so that any sleepers wake up and get ENXIO. */
| 2743 | * so that any sleepers wake up and get ENXIO. |
| 2744 | */ |
| 2745 | void |
| 2746 | bpfdetach(struct ifnet *ifp) |
| 2747 | { |
| 2748 | struct bpf_if *bp, *bp_temp; |
| 2749 | struct bpf_d *d; |
| 2750 | |
| 2751 | BPF_LOCK(); |
| 2752 | /* Find all bpf_if struct's which reference ifp and detach them. */ |
| 2753 | CK_LIST_FOREACH_SAFE(bp, &bpf_iflist, bif_next, bp_temp) { |
| 2754 | if (ifp != bp->bif_ifp) |
| 2755 | continue; |
| 2756 | |
| 2757 | CK_LIST_REMOVE(bp, bif_next); |
| 2758 | *bp->bif_bpf = (struct bpf_if *)&dead_bpf_if; |
| 2759 | |
| 2760 | CTR4(KTR_NET, |
| 2761 | "%s: sheduling free for encap %d (%p) for if %p", |
| 2762 | __func__, bp->bif_dlt, bp, ifp); |
| 2763 | |
| 2764 | /* Detach common descriptors */ |
| 2765 | while ((d = CK_LIST_FIRST(&bp->bif_dlist)) != NULL) { |
| 2766 | bpf_detachd_locked(d, true); |
| 2767 | } |
| 2768 | |
| 2769 | /* Detach writer-only descriptors */ |
| 2770 | while ((d = CK_LIST_FIRST(&bp->bif_wlist)) != NULL) { |
| 2771 | bpf_detachd_locked(d, true); |
| 2772 | } |
| 2773 | bpfif_rele(bp); |
| 2774 | } |
| 2775 | BPF_UNLOCK(); |
| 2776 | } |
| 2777 | |
| 2778 | /* |
| 2779 | * Get a list of available data link type of the interface. |
no test coverage detected