svn commit: r195023 - in head/sys/netinet: . ipfw

Robert Watson rwatson at FreeBSD.org
Fri Jun 26 00:46:50 UTC 2009


Author: rwatson
Date: Fri Jun 26 00:46:50 2009
New Revision: 195023
URL: http://svn.freebsd.org/changeset/base/195023

Log:
  Update various IPFW-related modules to use if_addr_rlock()/
  if_addr_runlock() rather than IF_ADDR_LOCK()/IF_ADDR_UNLOCK().
  
  MFC after:	6 weeks

Modified:
  head/sys/netinet/ip_divert.c
  head/sys/netinet/ipfw/ip_fw2.c
  head/sys/netinet/ipfw/ip_fw_nat.c

Modified: head/sys/netinet/ip_divert.c
==============================================================================
--- head/sys/netinet/ip_divert.c	Fri Jun 26 00:45:20 2009	(r195022)
+++ head/sys/netinet/ip_divert.c	Fri Jun 26 00:46:50 2009	(r195023)
@@ -254,7 +254,7 @@ divert_packet(struct mbuf *m, int incomi
 
 		/* Find IP address for receive interface */
 		ifp = m->m_pkthdr.rcvif;
-		IF_ADDR_LOCK(ifp);
+		if_addr_rlock(ifp);
 		TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
 			if (ifa->ifa_addr->sa_family != AF_INET)
 				continue;
@@ -262,7 +262,7 @@ divert_packet(struct mbuf *m, int incomi
 			    ((struct sockaddr_in *) ifa->ifa_addr)->sin_addr;
 			break;
 		}
-		IF_ADDR_UNLOCK(ifp);
+		if_addr_runlock(ifp);
 	}
 	/*
 	 * Record the incoming interface name whenever we have one.

Modified: head/sys/netinet/ipfw/ip_fw2.c
==============================================================================
--- head/sys/netinet/ipfw/ip_fw2.c	Fri Jun 26 00:45:20 2009	(r195022)
+++ head/sys/netinet/ipfw/ip_fw2.c	Fri Jun 26 00:46:50 2009	(r195023)
@@ -475,17 +475,17 @@ iface_match(struct ifnet *ifp, ipfw_insn
 	} else {
 		struct ifaddr *ia;
 
-		IF_ADDR_LOCK(ifp);
+		if_addr_rlock(ifp);
 		TAILQ_FOREACH(ia, &ifp->if_addrhead, ifa_link) {
 			if (ia->ifa_addr->sa_family != AF_INET)
 				continue;
 			if (cmd->p.ip.s_addr == ((struct sockaddr_in *)
 			    (ia->ifa_addr))->sin_addr.s_addr) {
-				IF_ADDR_UNLOCK(ifp);
+				if_addr_runlock(ifp);
 				return(1);	/* match */
 			}
 		}
-		IF_ADDR_UNLOCK(ifp);
+		if_addr_runlock(ifp);
 	}
 	return(0);	/* no match, fail ... */
 }
@@ -588,7 +588,7 @@ search_ip6_addr_net (struct in6_addr * i
 	struct in6_addr copia;
 
 	TAILQ_FOREACH(mdc, &V_ifnet, if_link) {
-		IF_ADDR_LOCK(mdc);
+		if_addr_rlock(mdc);
 		TAILQ_FOREACH(mdc2, &mdc->if_addrhead, ifa_link) {
 			if (mdc2->ifa_addr->sa_family == AF_INET6) {
 				fdm = (struct in6_ifaddr *)mdc2;
@@ -596,12 +596,12 @@ search_ip6_addr_net (struct in6_addr * i
 				/* need for leaving scope_id in the sock_addr */
 				in6_clearscope(&copia);
 				if (IN6_ARE_ADDR_EQUAL(ip6_addr, &copia)) {
-					IF_ADDR_UNLOCK(mdc);
+					if_addr_runlock(mdc);
 					return 1;
 				}
 			}
 		}
-		IF_ADDR_UNLOCK(mdc);
+		if_addr_runlock(mdc);
 	}
 	return 0;
 }

Modified: head/sys/netinet/ipfw/ip_fw_nat.c
==============================================================================
--- head/sys/netinet/ipfw/ip_fw_nat.c	Fri Jun 26 00:45:20 2009	(r195022)
+++ head/sys/netinet/ipfw/ip_fw_nat.c	Fri Jun 26 00:46:50 2009	(r195023)
@@ -92,7 +92,7 @@ ifaddr_change(void *arg __unused, struct
 	LIST_FOREACH(ptr, &V_layer3_chain.nat, _next) {
 		/* ...using nic 'ifp->if_xname' as dynamic alias address. */
 		if (strncmp(ptr->if_name, ifp->if_xname, IF_NAMESIZE) == 0) {
-			IF_ADDR_LOCK(ifp);
+			if_addr_rlock(ifp);
 			TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
 				if (ifa->ifa_addr == NULL)
 					continue;
@@ -102,7 +102,7 @@ ifaddr_change(void *arg __unused, struct
 				    (ifa->ifa_addr))->sin_addr;
 				LibAliasSetAddress(ptr->lib, ptr->ip);
 			}
-			IF_ADDR_UNLOCK(ifp);
+			if_addr_runlock(ifp);
 		}
 	}
 	IPFW_WUNLOCK(&V_layer3_chain);	


More information about the svn-src-all mailing list