diff --git a/sys/net/if.c b/sys/net/if.c index a658384509e..8e5de9493cc 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1423,7 +1423,6 @@ void ifa_init(struct ifaddr *ifa) { - mtx_init(&ifa->ifa_mtx, "ifaddr", NULL, MTX_DEF); refcount_init(&ifa->ifa_refcnt, 1); ifa->if_data.ifi_datalen = sizeof(ifa->if_data); } @@ -1440,7 +1439,6 @@ ifa_free(struct ifaddr *ifa) { if (refcount_release(&ifa->ifa_refcnt)) { - mtx_destroy(&ifa->ifa_mtx); free(ifa, M_IFADDR); } } @@ -2255,9 +2253,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; @@ -2276,7 +2274,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 677a688e415..ae41aebbe29 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -804,7 +804,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; }; #define IFA_ROUTE RTF_UP /* route installed */ #define IFA_RTSELF RTF_HOST /* loopback route to self installed */ @@ -813,8 +812,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) void ifa_free(struct ifaddr *ifa); void ifa_init(struct ifaddr *ifa);