Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jun 2020 09:52:43 +0000 (UTC)
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r362648 - stable/12/sys/net
Message-ID:  <202006260952.05Q9qhZx013619@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kp
Date: Fri Jun 26 09:52:43 2020
New Revision: 362648
URL: https://svnweb.freebsd.org/changeset/base/362648

Log:
  MFC r358325:
  
  bridge: Move locking defines into if_bridge.c
  
  The locking defines for if_bridge used to live in if_bridgevar.h, but
  they're only ever used by the bridge implementation itself (in
  if_bridge.c). Moving them into the .c file.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/12/sys/net/if_bridge.c
  stable/12/sys/net/if_bridgevar.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/if_bridge.c
==============================================================================
--- stable/12/sys/net/if_bridge.c	Fri Jun 26 09:46:03 2020	(r362647)
+++ stable/12/sys/net/if_bridge.c	Fri Jun 26 09:52:43 2020	(r362648)
@@ -185,6 +185,47 @@ extern void	nd6_setmtu(struct ifnet *);
 #define	BRIDGE_IFCAPS_STRIP		IFCAP_LRO
 
 /*
+ * Bridge locking
+ */
+#define BRIDGE_LOCK_INIT(_sc)		do {			\
+	mtx_init(&(_sc)->sc_mtx, "if_bridge", NULL, MTX_DEF);	\
+	cv_init(&(_sc)->sc_cv, "if_bridge_cv");			\
+} while (0)
+#define BRIDGE_LOCK_DESTROY(_sc)	do {	\
+	mtx_destroy(&(_sc)->sc_mtx);		\
+	cv_destroy(&(_sc)->sc_cv);		\
+} while (0)
+#define BRIDGE_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
+#define BRIDGE_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
+#define BRIDGE_LOCK_ASSERT(_sc)		mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
+#define BRIDGE_UNLOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED)
+#define	BRIDGE_LOCK2REF(_sc, _err)	do {	\
+	mtx_assert(&(_sc)->sc_mtx, MA_OWNED);	\
+	if ((_sc)->sc_iflist_xcnt > 0)		\
+		(_err) = EBUSY;			\
+	else					\
+		(_sc)->sc_iflist_ref++;		\
+	mtx_unlock(&(_sc)->sc_mtx);		\
+} while (0)
+#define	BRIDGE_UNREF(_sc)		do {				\
+	mtx_lock(&(_sc)->sc_mtx);					\
+	(_sc)->sc_iflist_ref--;						\
+	if (((_sc)->sc_iflist_xcnt > 0) && ((_sc)->sc_iflist_ref == 0))	\
+		cv_broadcast(&(_sc)->sc_cv);				\
+	mtx_unlock(&(_sc)->sc_mtx);					\
+} while (0)
+#define	BRIDGE_XLOCK(_sc)		do {		\
+	mtx_assert(&(_sc)->sc_mtx, MA_OWNED);		\
+	(_sc)->sc_iflist_xcnt++;			\
+	while ((_sc)->sc_iflist_ref > 0)		\
+		cv_wait(&(_sc)->sc_cv, &(_sc)->sc_mtx);	\
+} while (0)
+#define	BRIDGE_XDROP(_sc)		do {	\
+	mtx_assert(&(_sc)->sc_mtx, MA_OWNED);	\
+	(_sc)->sc_iflist_xcnt--;		\
+} while (0)
+
+/*
  * Bridge interface list entry.
  */
 struct bridge_iflist {

Modified: stable/12/sys/net/if_bridgevar.h
==============================================================================
--- stable/12/sys/net/if_bridgevar.h	Fri Jun 26 09:46:03 2020	(r362647)
+++ stable/12/sys/net/if_bridgevar.h	Fri Jun 26 09:52:43 2020	(r362648)
@@ -271,44 +271,6 @@ struct ifbpstpconf {
 
 #ifdef _KERNEL
 
-#define BRIDGE_LOCK_INIT(_sc)		do {			\
-	mtx_init(&(_sc)->sc_mtx, "if_bridge", NULL, MTX_DEF);	\
-	cv_init(&(_sc)->sc_cv, "if_bridge_cv");			\
-} while (0)
-#define BRIDGE_LOCK_DESTROY(_sc)	do {	\
-	mtx_destroy(&(_sc)->sc_mtx);		\
-	cv_destroy(&(_sc)->sc_cv);		\
-} while (0)
-#define BRIDGE_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
-#define BRIDGE_UNLOCK(_sc)		mtx_unlock(&(_sc)->sc_mtx)
-#define BRIDGE_LOCK_ASSERT(_sc)		mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
-#define BRIDGE_UNLOCK_ASSERT(_sc)	mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED)
-#define	BRIDGE_LOCK2REF(_sc, _err)	do {	\
-	mtx_assert(&(_sc)->sc_mtx, MA_OWNED);	\
-	if ((_sc)->sc_iflist_xcnt > 0)		\
-		(_err) = EBUSY;			\
-	else					\
-		(_sc)->sc_iflist_ref++;		\
-	mtx_unlock(&(_sc)->sc_mtx);		\
-} while (0)
-#define	BRIDGE_UNREF(_sc)		do {				\
-	mtx_lock(&(_sc)->sc_mtx);					\
-	(_sc)->sc_iflist_ref--;						\
-	if (((_sc)->sc_iflist_xcnt > 0) && ((_sc)->sc_iflist_ref == 0))	\
-		cv_broadcast(&(_sc)->sc_cv);				\
-	mtx_unlock(&(_sc)->sc_mtx);					\
-} while (0)
-#define	BRIDGE_XLOCK(_sc)		do {		\
-	mtx_assert(&(_sc)->sc_mtx, MA_OWNED);		\
-	(_sc)->sc_iflist_xcnt++;			\
-	while ((_sc)->sc_iflist_ref > 0)		\
-		cv_wait(&(_sc)->sc_cv, &(_sc)->sc_mtx);	\
-} while (0)
-#define	BRIDGE_XDROP(_sc)		do {	\
-	mtx_assert(&(_sc)->sc_mtx, MA_OWNED);	\
-	(_sc)->sc_iflist_xcnt--;		\
-} while (0)
-
 #define BRIDGE_INPUT(_ifp, _m)		do {			\
 		KASSERT((_ifp)->if_bridge_input != NULL,		\
 	    ("%s: if_bridge not loaded!", __func__));	\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006260952.05Q9qhZx013619>