Lines Matching refs:ifp
104 struct ifnet *ifp;
188 static int dlil_event_internal(struct ifnet *ifp, struct kev_msg *msg);
203 void dlil_input_packet_list(struct ifnet *ifp, struct mbuf *m);
333 find_attached_proto(struct ifnet *ifp, u_long protocol_family)
337 if (ifp->if_proto_hash) {
338 proto = SLIST_FIRST(&ifp->if_proto_hash[i]);
366 __unused struct ifnet *ifp,
377 lck_mtx_assert(ifp->if_lock, what);
383 struct ifnet *ifp)
386 lck_rw_lock_shared(ifp->if_lock);
388 lck_mtx_assert(ifp->if_lock, LCK_MTX_ASSERT_NOTOWNED);
389 lck_mtx_lock(ifp->if_lock);
395 struct ifnet *ifp)
398 lck_rw_lock_exclusive(ifp->if_lock);
400 lck_mtx_assert(ifp->if_lock, LCK_MTX_ASSERT_NOTOWNED);
401 lck_mtx_lock(ifp->if_lock);
407 struct ifnet *ifp)
410 lck_rw_done(ifp->if_lock);
412 lck_mtx_assert(ifp->if_lock, LCK_MTX_ASSERT_OWNED);
413 lck_mtx_unlock(ifp->if_lock);
435 static int dlil_ifp_proto_count(struct ifnet * ifp)
440 if (ifp->if_proto_hash != NULL) {
443 SLIST_FOREACH(proto, &ifp->if_proto_hash[i], next_hash) {
453 dlil_post_msg(struct ifnet *ifp, u_long event_subclass, u_long event_code,
475 strncpy(&event_data->if_name[0], ifp->if_name, IFNAMSIZ);
476 event_data->if_family = ifp->if_family;
477 event_data->if_unit = (unsigned long) ifp->if_unit;
483 dlil_event_internal(ifp, &ev_msg);
488 ifnet_t ifp, struct dlil_threading_info *inputthread)
493 // loopback ifp may not be configured at dlil_init time.
494 if (ifp == lo_ifp)
497 snprintf(inputthread->input_name, 32, "dlil_input_%s%d_mtx", ifp->if_name, ifp->if_unit);
603 struct ifnet *ifp,
616 filter->filt_ifp = ifp;
631 TAILQ_INSERT_TAIL(&ifp->if_flt_head, filter, filt_next);
645 ifnet_t ifp = NULL;
661 TAILQ_FOREACH(ifp, &ifnet_head, if_link) {
662 TAILQ_FOREACH(entry, &ifp->if_flt_head, filt_next) {
688 TAILQ_REMOVE(&ifp->if_flt_head, filter, filt_next);
822 ifnet_t ifp,
833 if (ifp == NULL || m_head == NULL) {
849 (ifp->if_type != IFT_LOOP && rcvif != ifp) ||
860 inp = ifp->if_input_thread;
889 * Because of loopbacked multicast we cannot stuff the ifp in
894 if (inp == dlil_lo_thread_ptr && ifp->if_type == IFT_LOOP) {
933 ifp->if_data.ifi_ipackets += stats->packets_in;
934 ifp->if_data.ifi_ibytes += stats->bytes_in;
935 ifp->if_data.ifi_ierrors += stats->errors_in;
937 ifp->if_data.ifi_opackets += stats->packets_out;
938 ifp->if_data.ifi_obytes += stats->bytes_out;
939 ifp->if_data.ifi_oerrors += stats->errors_out;
941 ifp->if_data.ifi_collisions += stats->collisions;
942 ifp->if_data.ifi_iqdrops += stats->dropped;
951 dlil_interface_filters_input(struct ifnet * ifp, struct mbuf * * m_p,
957 TAILQ_FOREACH(filter, &ifp->if_flt_head, filt_next) {
964 ifp, protocol_family,
989 error = (*ifproto->kpi.v1.input)(ifproto->ifp,
999 error = (*ifproto->kpi.v2.input)(ifproto->ifp,
1015 ifnet_t ifp = ifp_param;
1029 ifp = m->m_pkthdr.rcvif;
1039 error = (*ifp->if_demux)(ifp, m, frame_header,
1050 ifp->if_imcasts++;
1056 filter_result = dlil_interface_filters_input(ifp, &m,
1076 && last_ifproto->ifp == ifp
1082 ifproto = find_attached_proto(ifp, protocol_family);
1132 dlil_event_internal(struct ifnet *ifp, struct kev_msg *event)
1136 if (ifp_use(ifp, kIfNetUseCount_MustNotBeZero) == 0) {
1140 TAILQ_FOREACH(filter, &ifp->if_flt_head, filt_next) {
1142 filter->filt_event(filter->filt_cookie, ifp, filter->filt_protocol, event);
1145 if (ifp->if_proto_hash) {
1151 SLIST_FOREACH(proto, &ifp->if_proto_hash[i], next_hash) {
1156 eventp(ifp, proto->protocol_family, event);
1164 if (ifp->if_event)
1165 ifp->if_event(ifp, event);
1167 if (ifp_unuse(ifp))
1168 ifp_use_reached_zero(ifp);
1176 ifnet_t ifp,
1182 if (ifp == NULL || event == NULL) return EINVAL;
1192 result = dlil_event_internal(ifp, &kev_msg);
1241 struct ifnet* ifp,
1267 proto = find_attached_proto(ifp, proto_family);
1286 retval = preoutp(ifp, proto_family, &m, dest, route, frame_type, dst_linkaddr);
1300 retval = mac_ifnet_check_transmit(ifp, m, proto_family,
1308 if (raw == 0 && ifp->if_framer) {
1309 retval = ifp->if_framer(ifp, &m, dest, dst_linkaddr, frame_type);
1331 ifp = bridge_dst_lookup(eh);
1332 bdg_forward(&m0, ifp);
1345 TAILQ_FOREACH(filter, &ifp->if_flt_head, filt_next) {
1348 retval = filter->filt_output(filter->filt_cookie, ifp, proto_family, &m);
1362 if ((ifp->if_eflags & IFEF_SENDLIST) != 0) {
1368 retval = ifp->if_output(ifp, m);
1386 retval = ifp->if_output(ifp, send_head);
1415 * because a protocol is likely to interact with an ifp while it
1420 ifnet_t ifp,
1446 proto = find_attached_proto(ifp, proto_family);
1465 retval = preoutp(ifp, proto_family, &m, dest, route, frame_type, dst_linkaddr);
1478 retval = mac_ifnet_check_transmit(ifp, m, proto_family,
1487 if (raw == 0 && ifp->if_framer) {
1488 retval = ifp->if_framer(ifp, &m, dest, dst_linkaddr, frame_type);
1510 ifp = bridge_dst_lookup(eh);
1511 bdg_forward(&m0, ifp);
1524 TAILQ_FOREACH(filter, &ifp->if_flt_head, filt_next) {
1527 retval = filter->filt_output(filter->filt_cookie, ifp, proto_family, &m);
1545 if (!(ifp->if_hwassist & IFNET_MULTIPAGES)) {
1554 if ((ifp->if_eflags & IFEF_SENDLIST) != 0) {
1560 retval = ifp->if_output(ifp, m);
1578 retval = ifp->if_output(ifp, send_head);
1598 ifnet_t ifp,
1608 if (ifp == NULL || ioctl_code == 0)
1611 /* Attempt to increment the use count. If it's zero, bail out, the ifp is invalid */
1612 result = ifp_use(ifp, kIfNetUseCount_MustNotBeZero);
1623 TAILQ_FOREACH(filter, &ifp->if_flt_head, filt_next) {
1626 result = filter->filt_ioctl(filter->filt_cookie, ifp, proto_fam, ioctl_code, ioctl_arg);
1641 struct if_proto *proto = find_attached_proto(ifp, proto_fam);
1648 result = ioctlp(ifp, proto_fam, ioctl_code, ioctl_arg);
1663 * Since we have incremented the use count on the ifp, we are guaranteed
1664 * that the ifp will not go away (the function pointers may not be changed).
1679 if (ifp->if_ioctl)
1680 result = (*ifp->if_ioctl)(ifp, ioctl_code, ioctl_arg);
1695 if (ifp_unuse(ifp))
1696 ifp_use_reached_zero(ifp);
1705 ifnet_t ifp,
1712 if (ifp->if_set_bpf_tap)
1713 error = ifp->if_set_bpf_tap(ifp, mode, callback);
1721 struct ifnet *ifp,
1736 proto = find_attached_proto(ifp, proto_addr->sa_family);
1741 result = resolvep(ifp, proto_addr,(struct sockaddr_dl*)ll_addr,
1746 if ((result == EOPNOTSUPP || result == 0) && ifp->if_check_multi) {
1751 result = ifp->if_check_multi(ifp, verify);
1761 ifnet_t ifp,
1773 proto = find_attached_proto(ifp, target_proto->sa_family);
1784 result = arpp(ifp, arpop, sender_hw, sender_proto, target_hw,
1805 ifnet_t ifp,
1893 result = dlil_send_arp_internal(ifp, arpop, sender_hw, sender_proto,
1902 struct ifnet *ifp,
1909 old_value = ifp->if_usecnt;
1911 retval = ENXIO; // ifp is invalid
1914 } while (!OSCompareAndSwap((UInt32)old_value, (UInt32)old_value + 1, (UInt32*)&ifp->if_usecnt));
1930 struct ifnet *ifp)
1936 if (ifp->if_usecnt != 0)
1937 panic("ifp_use_reached_zero: ifp->if_usecnt != 0");
1940 ifnet_lock_exclusive(ifp);
1943 TAILQ_REMOVE(&ifnet_head, ifp, if_link);
1944 ifnet_addrs[ifp->if_index - 1] = NULL;
1946 /* ifp should be removed from the interface list */
1947 while (ifp->if_multiaddrs.lh_first) {
1948 struct ifmultiaddr *ifma = ifp->if_multiaddrs.lh_first;
1962 ifp->if_eflags &= ~IFEF_DETACHING; // clear the detaching flag
1963 ifnet_lock_done(ifp);
1965 free_func = ifp->if_free;
1967 dlil_post_msg(ifp, KEV_DL_SUBCLASS, KEV_DL_IF_DETACHED, NULL, 0);
1970 free_func(ifp);
1975 struct ifnet *ifp)
1978 oldval = OSDecrementAtomic((SInt32*)&ifp->if_usecnt);
1980 panic("ifp_unuse: ifp(%s%d)->if_usecnt was zero\n", ifp->if_name, ifp->if_unit);
1985 if ((ifp->if_eflags & IFEF_DETACHING) == 0)
2000 struct ifnet *ifp = proto->ifp;
2024 ifnet_lock_shared(ifp);
2025 if ((ifp->if_eflags & IFEF_DETACHING) != 0) {
2026 ifnet_lock_done(ifp);
2030 ifnet_lock_done(ifp);
2032 if (find_attached_proto(ifp, proto->protocol_family) != NULL) {
2041 retval = ifp->if_add_proto(ifp, proto->protocol_family, demux_list, demux_count);
2051 ifp_use(ifp, kIfNetUseCount_MustNotBeZero);
2057 struct if_proto* prev_proto = SLIST_FIRST(&ifp->if_proto_hash[hash_value]);
2063 SLIST_INSERT_HEAD(&ifp->if_proto_hash[hash_value], proto, next_hash);
2074 ev_pr_data.proto_remaining_count = dlil_ifp_proto_count(ifp);
2075 dlil_post_msg(ifp, KEV_DL_SUBCLASS, KEV_DL_PROTO_ATTACHED,
2080 ifp->if_name, ifp->if_unit, retval);
2086 ifnet_attach_protocol(ifnet_t ifp, protocol_family_t protocol,
2092 if (ifp == NULL || protocol == 0 || proto_details == NULL)
2103 ifproto->ifp = ifp;
2124 ifnet_attach_protocol_v2(ifnet_t ifp, protocol_family_t protocol,
2130 if (ifp == NULL || protocol == 0 || proto_details == NULL)
2141 ifproto->ifp = ifp;
2161 extern void if_rtproto_del(struct ifnet *ifp, int protocol);
2167 struct ifnet *ifp = proto->ifp;
2173 proto->kpi.v1.detached(ifp, proto->protocol_family);
2177 proto->kpi.v2.detached(ifp, proto->protocol_family);
2185 if_rtproto_del(ifp, proto_family);
2189 ev_pr_data.proto_remaining_count = dlil_ifp_proto_count(ifp);
2190 dlil_post_msg(ifp, KEV_DL_SUBCLASS, KEV_DL_PROTO_DETACHED,
2197 ifnet_detach_protocol(ifnet_t ifp, protocol_family_t proto_family)
2203 if (ifp == NULL || proto_family == 0) return EINVAL;
2209 proto = find_attached_proto(ifp, proto_family);
2223 proto = find_attached_proto(ifp, proto_family);
2235 if (ifp->if_del_proto)
2236 ifp->if_del_proto(ifp, proto->protocol_family);
2238 SLIST_REMOVE(&ifp->if_proto_hash[proto_hash_value(proto_family)], proto, if_proto, next_hash);
2243 use_reached_zero = ifp_unuse(ifp);
2255 ifp_use_reached_zero(ifp);
2293 struct ifnet *ifp;
2310 TAILQ_FOREACH(ifp, &ifnet_head, if_link) {
2315 struct if_proto **prev_nextptr = &SLIST_FIRST(&ifp->if_proto_hash[i]);
2320 if (ifp->if_del_proto)
2321 ifp->if_del_proto(ifp, proto->protocol_family);
2324 reached_zero = ifp_unuse(ifp);
2337 for (filt = TAILQ_FIRST(&ifp->if_flt_head); filt; filt = next_filt) {
2341 TAILQ_REMOVE(&ifp->if_flt_head, filt, filt_next);
2348 if (ifp->if_delayed_detach) {
2349 ifp->if_delayed_detach = 0;
2350 reached_zero = ifp_unuse(ifp);
2375 ifp_use_reached_zero(ifp);
2401 ifnet_t ifp,
2409 if (ifp == NULL) return EINVAL;
2410 if (ll_addr && ifp->if_addrlen == 0) {
2411 ifp->if_addrlen = ll_addr->sdl_alen;
2413 else if (ll_addr && ll_addr->sdl_alen != ifp->if_addrlen) {
2417 interface_family = ifp->if_family;
2423 if (tmp_if == ifp) {
2431 if ((ifp->if_eflags & IFEF_REUSE) == 0 || ifp->if_lock == 0)
2433 ifp->if_lock = lck_rw_alloc_init(ifnet_lock_group, ifnet_lock_attr);
2435 ifp->if_lock = lck_mtx_alloc_init(ifnet_lock_group, ifnet_lock_attr);
2438 if (ifp->if_lock == 0) {
2447 if (ifp->if_add_proto == 0 || ifp->if_del_proto == 0) {
2453 if ((ifp->if_eflags & IFEF_REUSE) == 0 || ifp->if_proto_hash == NULL) {
2465 TAILQ_INIT(&ifp->if_flt_head);
2470 ifp->if_proto_hash = new_proto_list;
2480 if (ifp->if_snd.ifq_maxlen == 0)
2481 ifp->if_snd.ifq_maxlen = ifqmaxlen;
2482 TAILQ_INIT(&ifp->if_prefixhead);
2483 LIST_INIT(&ifp->if_multiaddrs);
2484 ifnet_touch_lastchange(ifp);
2487 ifp_use(ifp, kIfNetUseCount_MayBeZero);
2491 ifnet_lock_exclusive(ifp);
2493 if ((ifp->if_eflags & IFEF_REUSE) == 0 || ifp->if_index == 0)
2494 ifp->if_index = if_next_index();
2496 ifa = TAILQ_FIRST(&ifp->if_addrhead);
2498 namelen = snprintf(workbuf, sizeof(workbuf), "%s%d", ifp->if_name, ifp->if_unit);
2501 socksize = masklen + ifp->if_addrlen;
2514 if_detach_ifa(ifp, ifa);
2520 ifnet_addrs[ifp->if_index - 1] = ifa;
2526 sdl->sdl_index = ifp->if_index;
2527 sdl->sdl_type = ifp->if_type;
2530 if (ll_addr->sdl_alen != ifp->if_addrlen)
2531 panic("ifnet_attach - ll_addr->sdl_alen != ifp->if_addrlen");
2534 ifa->ifa_ifp = ifp;
2544 TAILQ_INIT(&ifp->if_addrhead);
2545 ifa = ifnet_addrs[ifp->if_index - 1];
2554 TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link);
2557 mac_ifnet_label_associate(ifp);
2560 TAILQ_INSERT_TAIL(&ifnet_head, ifp, if_link);
2561 ifindex2ifnet[ifp->if_index] = ifp;
2574 if (ifp->if_type == IFT_ETHER) {
2578 ifp->if_input_thread = _MALLOC(sizeof(struct dlil_threading_info), M_NKE, M_WAITOK);
2579 if (ifp->if_input_thread == NULL)
2580 panic("ifnet_attach ifp=%p couldn't alloc threading\n", ifp);
2581 if ((err = dlil_create_input_thread(ifp, ifp->if_input_thread)) != 0)
2582 panic("ifnet_attach ifp=%p couldn't get a thread. err=%x\n", ifp, err);
2584 printf("ifnet_attach: dlil thread for ifp=%p if_index=%x\n", ifp, ifp->if_index);
2589 ifnet_lock_done(ifp);
2591 dlil_post_msg(ifp, KEV_DL_SUBCLASS, KEV_DL_IF_ATTACHED, NULL, 0);
2598 ifnet_t ifp)
2607 if (ifp == NULL) return EINVAL;
2609 ifnet_lock_exclusive(ifp);
2611 if ((ifp->if_eflags & IFEF_DETACHING) != 0) {
2613 ifnet_lock_done(ifp);
2624 ifp->if_eflags |= IFEF_DETACHING;
2625 ifnet_lock_done(ifp);
2627 dlil_post_msg(ifp, KEV_DL_SUBCLASS, KEV_DL_IF_DETACHING, NULL, 0);
2630 bpfdetach(ifp);
2637 ifp->if_delayed_detach = 1;
2645 fhead = ifp->if_flt_head;
2646 TAILQ_INIT(&ifp->if_flt_head);
2649 zeroed = ifp_unuse(ifp);
2656 if ((inputthread = ifp->if_input_thread) != NULL) {
2684 /* cleanup ifp dlil input thread, if any */
2685 ifp->if_input_thread = NULL;
2711 ifp_use_reached_zero(ifp);
2743 __unused ifnet_t ifp,
2756 struct ifnet **ifp)
2782 panic("ifp's lock is gone\n");
2786 *ifp = ifp1;
2822 *ifp = ifp1;
2832 ifnet_t ifp)
2834 struct dlil_ifnet *dlifp = (struct dlil_ifnet *)ifp;
2837 if (ifp->if_lock)
2838 ifnet_lock_exclusive(ifp);
2839 ifp->if_eflags &= ~IFEF_INUSE;
2840 ifp->if_ioctl = dlil_recycle_ioctl;
2841 ifp->if_output = dlil_recycle_output;
2842 ifp->if_free = dlil_recycle_free;
2843 ifp->if_set_bpf_tap = dlil_recycle_set_bpf_tap;
2845 strncpy(dlifp->if_namestorage, ifp->if_name, IFNAMSIZ);
2846 ifp->if_name = dlifp->if_namestorage;
2851 * still has a handle on ifp will now see it as unlabeled.
2854 mac_ifnet_label_recycle(ifp);
2856 if (ifp->if_lock)
2857 ifnet_lock_done(ifp);
2862 dlil_proto_unplumb_all(struct ifnet *ifp)
2873 (void) proto_unplumb(PF_INET, ifp);
2875 (void) proto_unplumb(PF_INET6, ifp);
2878 (void) proto_unplumb(PF_APPLETALK, ifp);