Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Dec 2008 00:41:41 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r185726 - user/kmacy/HEAD_fast_multi_xmit/sys/net
Message-ID:  <200812070041.mB70ff82009445@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Sun Dec  7 00:41:40 2008
New Revision: 185726
URL: http://svn.freebsd.org/changeset/base/185726

Log:
  - fix need for conditional runlock
  - style changes
  - add comment

Modified:
  user/kmacy/HEAD_fast_multi_xmit/sys/net/radix.h
  user/kmacy/HEAD_fast_multi_xmit/sys/net/route.c

Modified: user/kmacy/HEAD_fast_multi_xmit/sys/net/radix.h
==============================================================================
--- user/kmacy/HEAD_fast_multi_xmit/sys/net/radix.h	Sat Dec  6 23:55:29 2008	(r185725)
+++ user/kmacy/HEAD_fast_multi_xmit/sys/net/radix.h	Sun Dec  7 00:41:40 2008	(r185726)
@@ -157,6 +157,7 @@ struct radix_node_head {
 
 #define	RADIX_NODE_HEAD_DESTROY(rnh)	rw_destroy(&(rnh)->rnh_lock)
 #define	RADIX_NODE_HEAD_LOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_LOCKED)
+#define	RADIX_NODE_HEAD_WLOCK_ASSERT(rnh) rw_assert(&(rnh)->rnh_lock, RA_WLOCKED)
 #endif /* _KERNEL */
 
 void	 rn_init(void);

Modified: user/kmacy/HEAD_fast_multi_xmit/sys/net/route.c
==============================================================================
--- user/kmacy/HEAD_fast_multi_xmit/sys/net/route.c	Sat Dec  6 23:55:29 2008	(r185725)
+++ user/kmacy/HEAD_fast_multi_xmit/sys/net/route.c	Sun Dec  7 00:41:40 2008	(r185726)
@@ -289,6 +289,10 @@ rtalloc1_fib(struct sockaddr *dst, int r
 retry:
 	if (needlock)
 		RADIX_NODE_HEAD_RLOCK(rnh);
+#ifdef INVARIANTS	
+	else
+		RADIX_NODE_HEAD_LOCK_ASSERT(rnh);
+#endif
 	rn = rnh->rnh_matchaddr(dst, rnh);
 	if (rn && ((rn->rn_flags & RNF_ROOT) == 0)) {
 
@@ -313,26 +317,25 @@ retry:
 		} else {
 			RT_LOCK(newrt);
 			RT_ADDREF(newrt);
-			RADIX_NODE_HEAD_RUNLOCK(rnh);
+			if (needlock)
+				RADIX_NODE_HEAD_RUNLOCK(rnh);
 			goto done;
 		}
 	}
-	
+	/*
+	 * if needresolve is set then we have the exclusive lock
+	 *  and we need to keep it held for the benefit of rtrequest_fib
+	 */
 	if (!needresolve && needlock)
 		RADIX_NODE_HEAD_RUNLOCK(rnh);
 	
-
 	if (needresolve) {
-		
+		RADIX_NODE_HEAD_WLOCK_ASSERT(rnh);
 		/*
-		 * If we find it and it's not the root node, then
-		 * get a reference on the rtentry associated.
+		 * We are apparently adding (report = 0 in delete).
+		 * If it requires that it be cloned, do so.
+		 * (This implies it wasn't a HOST route.)
 		 */
-			/*
-			 * We are apparently adding (report = 0 in delete).
-			 * If it requires that it be cloned, do so.
-			 * (This implies it wasn't a HOST route.)
-			 */
 		err = rtrequest_fib(RTM_RESOLVE, dst, NULL,
 		    NULL, RTF_RNH_LOCKED, &newrt, fibnum);
 		if (err) {
@@ -560,16 +563,16 @@ rtredirect_fib(struct sockaddr *dst,
 			info.rti_info[RTAX_NETMASK] = netmask;
 			info.rti_ifa = ifa;
 			info.rti_flags = flags;
-			if (rt0)
+			if (rt0 != NULL)
 				RT_UNLOCK(rt0);	/* drop lock to avoid LOR with RNH */
 			error = rtrequest1_fib(RTM_ADD, &info, &rt, fibnum);
-			if (rt) {
+			if (rt != NULL) {
 				RT_LOCK(rt);
-				if (rt0)
+				if (rt0 != NULL)
 					EVENTHANDLER_INVOKE(route_redirect_event, rt0, rt, dst);
 				flags = rt->rt_flags;
 			}
-			if (rt0)
+			if (rt0 != NULL)
 				RTFREE(rt0);
 			
 			stat = &V_rtstat.rts_dynamic;



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