svn commit: r356712 - stable/11/sys/netinet

Alexander Motin mav at FreeBSD.org
Tue Jan 14 00:51:36 UTC 2020


Author: mav
Date: Tue Jan 14 00:51:35 2020
New Revision: 356712
URL: https://svnweb.freebsd.org/changeset/base/356712

Log:
  MFC r356240: Relax locking of carp_forus().
  
  This fixes deadlock between CARP and bridge.  Bridge calls this function
  taking CARP lock while holding bridge lock.  Same time CARP tries to send
  its announcements via the bridge while holding CARP lock.
  
  Use of CARP_LOCK() here does not solve anything, since sc_addr is constant
  while race on sc_state is harmless and use of the lock does not close it.

Modified:
  stable/11/sys/netinet/ip_carp.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/ip_carp.c
==============================================================================
--- stable/11/sys/netinet/ip_carp.c	Tue Jan 14 00:50:30 2020	(r356711)
+++ stable/11/sys/netinet/ip_carp.c	Tue Jan 14 00:51:35 2020	(r356712)
@@ -1136,14 +1136,15 @@ carp_forus(struct ifnet *ifp, u_char *dhost)
 
 	CIF_LOCK(ifp->if_carp);
 	IFNET_FOREACH_CARP(ifp, sc) {
-		CARP_LOCK(sc);
+		/*
+		 * CARP_LOCK() is not here, since would protect nothing, but
+		 * cause deadlock with if_bridge, calling this under its lock.
+		 */
 		if (sc->sc_state == MASTER && !bcmp(dhost, LLADDR(&sc->sc_addr),
 		    ETHER_ADDR_LEN)) {
-			CARP_UNLOCK(sc);
 			CIF_UNLOCK(ifp->if_carp);
 			return (1);
 		}
-		CARP_UNLOCK(sc);
 	}
 	CIF_UNLOCK(ifp->if_carp);
 


More information about the svn-src-all mailing list