Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Oct 2006 19:15:12 GMT
From:      Paolo Pisati <piso@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 108035 for review
Message-ID:  <200610171915.k9HJFCVF071510@repoman.freebsd.org>

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

Change 108035 by piso@piso_newluxor on 2006/10/17 19:14:29

	Make IPFW compiles again with _no_ nat support
	in case LIBALIAS is not defined.

Affected files ...

.. //depot/projects/soc2005/libalias/sys/conf/options#8 edit
.. //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#23 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/conf/options#8 (text+ko) ====

@@ -375,7 +375,7 @@
 IPXIP			opt_ipx.h
 LIBMBPOOL
 LIBMCHAIN
-LIBALIAS
+LIBALIAS		opt_net.h
 MBUF_STRESS_TEST
 NCP
 NETATALK		opt_atalk.h

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

@@ -137,7 +137,9 @@
 struct ip_fw_chain {
 	struct ip_fw	*rules;		/* list of rules */
 	struct ip_fw	*reap;		/* list of rules to reap */
+#ifdef LIBALIAS
 	LIST_HEAD(, cfg_nat) nat;       /* list of nat entries */
+#endif
 	struct radix_node_head *tables[IPFW_TABLES_MAX];
 	struct rwlock	rwmtx;
 };
@@ -154,8 +156,6 @@
 #define IPFW_WLOCK(p) rw_wlock(&(p)->rwmtx)
 #define IPFW_WUNLOCK(p) rw_wunlock(&(p)->rwmtx)
 
-static eventhandler_tag ifaddr_event_tag;
-
 /*
  * list of rules for layer 3
  */
@@ -2031,6 +2031,35 @@
 	return match;
 }
 
+#ifdef LIBALIAS 
+static eventhandler_tag ifaddr_event_tag;
+
+static void 
+ifaddr_change(void *arg __unused, struct ifnet *ifp) {
+	struct cfg_nat *ptr;
+	struct ifaddr *ifa;
+
+	IPFW_WLOCK(&layer3_chain);			
+	/* Check every nat entry... */
+	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);
+			TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
+				if (ifa->ifa_addr == NULL)
+					continue;
+				if (ifa->ifa_addr->sa_family != AF_INET)
+					continue;
+				ptr->ip = ((struct sockaddr_in *) 
+					   (ifa->ifa_addr))->sin_addr;
+				LibAliasSetAddress(ptr->lib, ptr->ip);				    
+			}
+			mtx_unlock(&ifp->if_addr_mtx);
+		}
+	}
+	IPFW_WUNLOCK(&layer3_chain);	
+}
+
 static void
 flush_nat_ptrs(const int i) {
 	struct ip_fw *rule;
@@ -2197,6 +2226,7 @@
 	/* something really bad happened: panic! */
 	panic("%s\n", panic_err);
 }
+#endif
 
 /*
  * The main check routine for the firewall.
@@ -3420,7 +3450,7 @@
 				retval = (cmd->opcode == O_NETGRAPH) ?
 				    IP_FW_NETGRAPH : IP_FW_NGTEE;
 				goto done;
-
+#ifdef LIBALIAS
 			case O_NAT: {
 				struct cfg_nat *t;
 				struct mbuf *mcl;
@@ -3567,7 +3597,7 @@
 				retval = IP_FW_NAT; 
 				goto done;
 			}
-
+#endif
 			default:
 				panic("-- unknown opcode %d\n", cmd->opcode);
 			} /* end of switch() on opcodes */
@@ -4293,33 +4323,6 @@
 	return (bp - (char *)buf);
 }
 
-
-static void 
-ifaddr_change(void *arg __unused, struct ifnet *ifp) {
-	struct cfg_nat *ptr;
-	struct ifaddr *ifa;
-
-	IPFW_WLOCK(&layer3_chain);			
-	/* Check every nat entry... */
-	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);
-			TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
-				if (ifa->ifa_addr == NULL)
-					continue;
-				if (ifa->ifa_addr->sa_family != AF_INET)
-					continue;
-				ptr->ip = ((struct sockaddr_in *) 
-					   (ifa->ifa_addr))->sin_addr;
-				LibAliasSetAddress(ptr->lib, ptr->ip);				    
-			}
-			mtx_unlock(&ifp->if_addr_mtx);
-		}
-	}
-	IPFW_WUNLOCK(&layer3_chain);	
-}
-
 /**
  * {set|get}sockopt parser.
  */
@@ -4541,7 +4544,7 @@
 			free(tbl, M_TEMP);
 		}
 		break;
-
+#ifdef LIBALIAS
 	case IP_FW_NAT_CFG:
 	{
 		struct cfg_nat *ptr, *ser_n;
@@ -4710,7 +4713,7 @@
 		free(data, M_IPFW);
 	}
 	break;
-
+#endif
 	default:
 		printf("ipfw: ipfw_ctl invalid option %d\n", sopt->sopt_name);
 		error = EINVAL;
@@ -4883,9 +4886,11 @@
 	ip_fw_ctl_ptr = ipfw_ctl;
 	ip_fw_chk_ptr = ipfw_chk;
 	callout_reset(&ipfw_timeout, hz, ipfw_tick, NULL);	
+#ifdef LIBALIAS
 	LIST_INIT(&layer3_chain.nat);
 	ifaddr_event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_change, 
 					 NULL, EVENTHANDLER_PRI_ANY);
+#endif
 	return (0);
 }
 
@@ -4893,13 +4898,16 @@
 ipfw_destroy(void)
 {
 	struct ip_fw *reap;
+#ifdef LIBALIAS
 	struct cfg_nat *ptr, *ptr_temp;
+#endif
 
 	ip_fw_chk_ptr = NULL;
 	ip_fw_ctl_ptr = NULL;
 	callout_drain(&ipfw_timeout);
 	IPFW_WLOCK(&layer3_chain);
 	flush_tables(&layer3_chain);
+#ifdef LIBALIAS
 	LIST_FOREACH_SAFE(ptr, &layer3_chain.nat, _next, ptr_temp) {
 		LIST_REMOVE(ptr, _next);
 		del_redir_spool_cfg(ptr, &ptr->redir_chain);
@@ -4907,6 +4915,7 @@
 		free(ptr, M_IPFW);
 	}
 	EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_event_tag);
+#endif
 	layer3_chain.reap = NULL;
 	free_chain(&layer3_chain, 1 /* kill default rule */);
 	reap = layer3_chain.reap, layer3_chain.reap = NULL;



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