svn commit: r256521 - head/sys/net

Gleb Smirnoff glebius at FreeBSD.org
Tue Oct 15 10:41:23 UTC 2013


Author: glebius
Date: Tue Oct 15 10:41:22 2013
New Revision: 256521
URL: http://svnweb.freebsd.org/changeset/base/256521

Log:
    Remove ifa_mtx. It was used only in one place in kernel, and ifnet's
  ifaddr lock can substitute it there.
  
  Discussed with:	melifaro, ae
  Sponsored by:	Netflix
  Sponsored by:	Nginx, Inc.

Modified:
  head/sys/net/if.c
  head/sys/net/if_var.h

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Tue Oct 15 10:37:50 2013	(r256520)
+++ head/sys/net/if.c	Tue Oct 15 10:41:22 2013	(r256521)
@@ -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,
 		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,
 		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. */

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Tue Oct 15 10:37:50 2013	(r256520)
+++ head/sys/net/if_var.h	Tue Oct 15 10:41:22 2013	(r256521)
@@ -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);


More information about the svn-src-all mailing list