- TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
- oia = ia;
- TAILQ_REMOVE(&in_ifaddrhead, oia, ia_link);
- IFAFREE(&oia->ia_ifa);
-
- /*
- * If the interface supports multicast, and no address is left,
- * remove the "all hosts" multicast group from that interface.
- */
- if (ifp->if_flags & IFF_MULTICAST) {
- struct in_addr addr;
- struct in_multi *inm;
-
- TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
- if (ifa->ifa_addr->sa_family == AF_INET)
- break;
-
- if (ifa == 0) {
- addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP);
- IN_LOOKUP_MULTI(addr, ifp, inm);
- if (inm)
- in_delmulti(inm);
- }
- }
- splx(s);
+ lck_mtx_unlock(rt_mtx);
+ ifnet_lock_exclusive(ifp);
+ if_detach_ifa(ifp, ifa);
+ ifafree(&ia->ia_ifa);
+
+#ifdef __APPLE__
+ /*
+ * If the interface supports multicast, and no address is left,
+ * remove the "all hosts" multicast group from that interface.
+ */
+ if (ifp->if_flags & IFF_MULTICAST) {
+ struct in_addr addr;
+ struct in_multi *inm;
+
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
+ if (ifa->ifa_addr->sa_family == AF_INET)
+ break;
+
+ if (ifa == 0) {
+ addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP);
+ IN_LOOKUP_MULTI(addr, ifp, inm);
+ }
+ ifnet_lock_done(ifp);
+ if (inm)
+ in_delmulti(&inm);
+ } else
+ ifnet_lock_done(ifp);
+#endif
+
+ /* Post the kernel event */
+ kev_post_msg(&ev_msg);