Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Oct 2006 21:15:10 GMT
From:      Paolo Pisati <piso@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 107999 for review
Message-ID:  <200610162115.k9GLFAkg084562@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107999

Change 107999 by piso@piso_newluxor on 2006/10/16 21:14:16

	Start moving nat_chain under layer3_chain.

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#20 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#20 (text+ko) ====

@@ -137,6 +137,7 @@
 struct ip_fw_chain {
 	struct ip_fw	*rules;		/* list of rules */
 	struct ip_fw	*reap;		/* list of rules to reap */
+	LIST_HEAD(, cfg_nat) nat;       /* list of nat entries */
 	struct radix_node_head *tables[IPFW_TABLES_MAX];
 	struct rwlock	rwmtx;
 };
@@ -305,7 +306,6 @@
 MODULE_DEPEND(ipfw, libalias, 1, 1, 1);
 
 struct rwlock   nat_chain_rwl; 
-LIST_HEAD(nat_chain, cfg_nat) nat_chain = LIST_HEAD_INITIALIZER(foo);
 
 #define	NAT_LOCK_INIT(_chain) \
 	rw_init(_chain, "NAT instances")
@@ -2066,7 +2066,7 @@
 lookup_nat(const int i) {
 	struct cfg_nat *ptr;
 
-	LIST_FOREACH(ptr, &nat_chain, _next)
+	LIST_FOREACH(ptr, &layer3_chain.nat, _next)
 		if (ptr->id == i) 
 			return(ptr);
 	return (NULL);
@@ -4321,7 +4321,7 @@
 
 	NAT_WLOCK(&nat_chain_rwl);			
 	/* Check every nat entry... */
-	LIST_FOREACH(ptr, &nat_chain, _next) {
+	LIST_FOREACH(ptr, &layer3_chain.nat, _next) {
 		/* ...using nic 'ifp->if_xname' as dynamic alias address. */
 		if (strncmp(ptr->if_name, ifp->if_xname, IF_NAMESIZE) == 0) {
 			mtx_lock(&ifp->if_addr_mtx);
@@ -4624,7 +4624,7 @@
 				    ptr);                               /* Add new entries. */
 		free(buf, M_IPFW);
 		NAT_WLOCK(&nat_chain_rwl);
-		HOOK_NAT(&nat_chain, ptr);
+		HOOK_NAT(&layer3_chain.nat, ptr);
 		NAT_WUNLOCK(&nat_chain_rwl);
 	}
 	break;
@@ -4667,7 +4667,7 @@
 			return (ENOSPC);
 		NAT_RLOCK(&nat_chain_rwl);
 		/* Serialize all the data. */
-		LIST_FOREACH(n, &nat_chain, _next) {
+		LIST_FOREACH(n, &layer3_chain.nat, _next) {
 			nat_cnt++;
 			if (off + sof_nat < NAT_BUF_LEN) {
 				bcopy(n, &data[off], sof_nat);
@@ -4710,7 +4710,7 @@
 
 		NAT_RLOCK(&nat_chain_rwl);
 		size = i = 0;
-		LIST_FOREACH(ptr, &nat_chain, _next) {
+		LIST_FOREACH(ptr, &layer3_chain.nat, _next) {
 			if (ptr->lib->logDesc == NULL) 
 				continue;
 			cnt++;
@@ -4903,6 +4903,7 @@
 	ip_fw_ctl_ptr = ipfw_ctl;
 	ip_fw_chk_ptr = ipfw_chk;
 	callout_reset(&ipfw_timeout, hz, ipfw_tick, NULL);	
+	LIST_INIT(&layer3_chain.nat);
 	NAT_LOCK_INIT(&nat_chain_rwl);
 	ifaddr_event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_change, 
 					 NULL, EVENTHANDLER_PRI_ANY);
@@ -4921,7 +4922,7 @@
 	IPFW_WLOCK(&layer3_chain);
 	flush_tables(&layer3_chain);
 	NAT_WLOCK(&nat_chain_rwl);
-	LIST_FOREACH_SAFE(ptr, &nat_chain, _next, ptr_temp) {
+	LIST_FOREACH_SAFE(ptr, &layer3_chain.nat, _next, ptr_temp) {
 		LIST_REMOVE(ptr, _next);
 		del_redir_spool_cfg(ptr, &ptr->redir_chain);
 		LibAliasUninit(ptr->lib);



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