Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Dec 2012 22:48:12 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r244569 - stable/9/sys/netpfil/ipfw
Message-ID:  <201212212248.qBLMmCuN053570@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Fri Dec 21 22:48:12 2012
New Revision: 244569
URL: http://svnweb.freebsd.org/changeset/base/244569

Log:
  Merge r241908, r242632
  
  Remove unnecessary chain read lock in ipfw nat 'global' code.
  Document case when ipfw chain lock must be held while calling ipfw_nat().

Modified:
  stable/9/sys/netpfil/ipfw/ip_fw_nat.c
  stable/9/sys/netpfil/ipfw/ip_fw_private.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netpfil/ipfw/ip_fw_nat.c
==============================================================================
--- stable/9/sys/netpfil/ipfw/ip_fw_nat.c	Fri Dec 21 22:20:59 2012	(r244568)
+++ stable/9/sys/netpfil/ipfw/ip_fw_nat.c	Fri Dec 21 22:48:12 2012	(r244569)
@@ -202,6 +202,13 @@ add_redir_spool_cfg(char *buf, struct cf
 	}
 }
 
+/*
+ * ipfw_nat - perform mbuf header translation.
+ *
+ * Note V_layer3_chain has to be locked while calling ipfw_nat() in
+ * 'global' operation mode (t == NULL).
+ *
+ */
 static int
 ipfw_nat(struct ip_fw_args *args, struct cfg_nat *t, struct mbuf *m)
 {
@@ -269,7 +276,7 @@ ipfw_nat(struct ip_fw_args *args, struct
 
 		found = 0;
 		chain = &V_layer3_chain;
-		IPFW_RLOCK(chain);
+		IPFW_RLOCK_ASSERT(chain);
 		/* Check every nat entry... */
 		LIST_FOREACH(t, &chain->nat, _next) {
 			if ((t->mode & PKT_ALIAS_SKIP_GLOBAL) != 0)
@@ -282,7 +289,6 @@ ipfw_nat(struct ip_fw_args *args, struct
 				break;
 			}
 		}
-		IPFW_RUNLOCK(chain);
 		if (found != 1) {
 			/* No instance found, return ignore */
 			args->m = mcl;

Modified: stable/9/sys/netpfil/ipfw/ip_fw_private.h
==============================================================================
--- stable/9/sys/netpfil/ipfw/ip_fw_private.h	Fri Dec 21 22:20:59 2012	(r244568)
+++ stable/9/sys/netpfil/ipfw/ip_fw_private.h	Fri Dec 21 22:48:12 2012	(r244569)
@@ -251,6 +251,7 @@ struct sockopt;	/* used by tcp_var.h */
 	rw_destroy(&(_chain)->uh_lock);			\
 	} while (0)
 
+#define	IPFW_RLOCK_ASSERT(_chain)	rw_assert(&(_chain)->rwmtx, RA_RLOCKED)
 #define	IPFW_WLOCK_ASSERT(_chain)	rw_assert(&(_chain)->rwmtx, RA_WLOCKED)
 
 #define IPFW_RLOCK(p) rw_rlock(&(p)->rwmtx)



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