diff --git a/sys/net/if.c b/sys/net/if.c index 050798493836..28d1cddbed6f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1428,7 +1428,6 @@ ifa_alloc(size_t size, int flags) if (ifa == NULL) return (NULL); - mtx_init(&ifa->ifa_mtx, "ifaddr", NULL, MTX_DEF); refcount_init(&ifa->ifa_refcnt, 1); ifa->if_data.ifi_datalen = sizeof(ifa->if_data); @@ -1447,7 +1446,6 @@ ifa_free(struct ifaddr *ifa) { if (refcount_release(&ifa->ifa_refcnt)) { - mtx_destroy(&ifa->ifa_mtx); free(ifa, M_IFADDR); } } @@ -2244,9 +2242,9 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) log(LOG_INFO, "%s: changing name to '%s'\n", ifp->if_xname, new_name); + IF_ADDR_WLOCK(ifp); strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname)); ifa = ifp->if_addr; - IFA_LOCK(ifa); sdl = (struct sockaddr_dl *)ifa->ifa_addr; namelen = strlen(new_name); onamelen = sdl->sdl_nlen; @@ -2265,7 +2263,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) bzero(sdl->sdl_data, onamelen); while (namelen != 0) sdl->sdl_data[--namelen] = 0xff; - IFA_UNLOCK(ifa); + IF_ADDR_WUNLOCK(ifp); EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); /* Announce the return of the interface. */ diff --git a/sys/net/if_var.h b/sys/net/if_var.h index b7a3c695c401..a65f6a730417 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -805,7 +805,6 @@ struct ifaddr { int ifa_metric; /* cost of going out this interface */ int (*ifa_claim_addr) /* check if an addr goes to this if */ (struct ifaddr *, struct sockaddr *); - struct mtx ifa_mtx; }; #endif @@ -816,9 +815,6 @@ struct ifaddr { #define ifa_list ifa_link #ifdef _KERNEL -#define IFA_LOCK(ifa) mtx_lock(&(ifa)->ifa_mtx) -#define IFA_UNLOCK(ifa) mtx_unlock(&(ifa)->ifa_mtx) - struct ifaddr * ifa_alloc(size_t size, int flags); void ifa_free(struct ifaddr *ifa); void ifa_ref(struct ifaddr *ifa);