svn commit: r190197 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet netinet6

Bjoern A. Zeeb bz at FreeBSD.org
Sat Mar 21 04:19:00 PDT 2009


Author: bz
Date: Sat Mar 21 11:18:59 2009
New Revision: 190197
URL: http://svn.freebsd.org/changeset/base/190197

Log:
  MFC r185370:
  
    Merge in6_pcbfree() into in_pcbfree() which after the previous
    IPsec change in r185366 (r185366 for stable/7) only differed in
    two additonal IPv6 lines.
    Rather than splattering conditional code everywhere add the v6
    check centrally at this single place.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/netinet/in_pcb.c
  stable/7/sys/netinet/tcp_timewait.c
  stable/7/sys/netinet/tcp_usrreq.c
  stable/7/sys/netinet6/in6_pcb.c
  stable/7/sys/netinet6/in6_pcb.h
  stable/7/sys/netinet6/raw_ip6.c
  stable/7/sys/netinet6/udp6_usrreq.c

Modified: stable/7/sys/netinet/in_pcb.c
==============================================================================
--- stable/7/sys/netinet/in_pcb.c	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet/in_pcb.c	Sat Mar 21 11:18:59 2009	(r190197)
@@ -901,10 +901,17 @@ in_pcbfree(struct inpcb *inp)
 	INP_WLOCK_ASSERT(inp);
 
 #ifdef IPSEC
-	ipsec_delete_pcbpolicy(inp);
+	if (inp->inp_sp != NULL)
+		ipsec_delete_pcbpolicy(inp);
 #endif /* IPSEC */
 	inp->inp_gencnt = ++ipi->ipi_gencnt;
 	in_pcbremlists(inp);
+#ifdef INET6
+	if (inp->inp_vflag & INP_IPV6PROTO) {
+		ip6_freepcbopts(inp->in6p_outputopts);
+		ip6_freemoptions(inp->in6p_moptions);
+	}
+#endif
 	if (inp->inp_options)
 		(void)m_free(inp->inp_options);
 	if (inp->inp_moptions != NULL)

Modified: stable/7/sys/netinet/tcp_timewait.c
==============================================================================
--- stable/7/sys/netinet/tcp_timewait.c	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet/tcp_timewait.c	Sat Mar 21 11:18:59 2009	(r190197)
@@ -501,14 +501,8 @@ tcp_twclose(struct tcptw *tw, int reuse)
 			 */
 			INP_WUNLOCK(inp);
 		}
-	} else {
-#ifdef INET6
-		if (inp->inp_vflag & INP_IPV6PROTO)
-			in6_pcbfree(inp);
-		else
-#endif
-			in_pcbfree(inp);
-	}
+	} else
+		in_pcbfree(inp);
 	tcpstat.tcps_closed++;
 	crfree(tw->tw_cred);
 	tw->tw_cred = NULL;

Modified: stable/7/sys/netinet/tcp_usrreq.c
==============================================================================
--- stable/7/sys/netinet/tcp_usrreq.c	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet/tcp_usrreq.c	Sat Mar 21 11:18:59 2009	(r190197)
@@ -155,9 +155,6 @@ static void
 tcp_detach(struct socket *so, struct inpcb *inp)
 {
 	struct tcpcb *tp;
-#ifdef INET6
-	int isipv6 = INP_CHECK_SOCKAF(so, AF_INET6) != 0;
-#endif
 
 	INP_INFO_WLOCK_ASSERT(&tcbinfo);
 	INP_WLOCK_ASSERT(inp);
@@ -184,12 +181,7 @@ tcp_detach(struct socket *so, struct inp
 			KASSERT(tp == NULL, ("tcp_detach: INP_TIMEWAIT && "
 			    "INP_DROPPED && tp != NULL"));
 			in_pcbdetach(inp);
-#ifdef INET6
-			if (isipv6)
-				in6_pcbfree(inp);
-			else
-#endif
-				in_pcbfree(inp);
+			in_pcbfree(inp);
 		} else {
 			in_pcbdetach(inp);
 			INP_WUNLOCK(inp);
@@ -208,15 +200,9 @@ tcp_detach(struct socket *so, struct inp
 		    tp->t_state < TCPS_SYN_SENT) {
 			tcp_discardcb(tp);
 			in_pcbdetach(inp);
-#ifdef INET6
-			if (isipv6)
-				in6_pcbfree(inp);
-			else
-#endif
-				in_pcbfree(inp);
-		} else {
-				in_pcbdetach(inp);
-		}
+			in_pcbfree(inp);
+		} else
+			in_pcbdetach(inp);
 	}
 }
 
@@ -1464,12 +1450,7 @@ tcp_attach(struct socket *so)
 	tp = tcp_newtcpcb(inp);
 	if (tp == NULL) {
 		in_pcbdetach(inp);
-#ifdef INET6
-		if (isipv6)
-			in6_pcbfree(inp);
-		else
-#endif
-			in_pcbfree(inp);
+		in_pcbfree(inp);
 		INP_INFO_WUNLOCK(&tcbinfo);
 		return (ENOBUFS);
 	}

Modified: stable/7/sys/netinet6/in6_pcb.c
==============================================================================
--- stable/7/sys/netinet6/in6_pcb.c	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet6/in6_pcb.c	Sat Mar 21 11:18:59 2009	(r190197)
@@ -101,12 +101,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet6/in6_pcb.h>
 #include <netinet6/scope6_var.h>
 
-#ifdef IPSEC
-#include <netipsec/ipsec.h>
-#include <netipsec/ipsec6.h>
-#include <netipsec/key.h>
-#endif /* IPSEC */
-
 #include <security/mac/mac_framework.h>
 
 struct	in6_addr zeroin6_addr;
@@ -412,39 +406,6 @@ in6_pcbdisconnect(struct inpcb *inp)
 	in_pcbrehash(inp);
 }
 
-void
-in6_pcbfree(struct inpcb *inp)
-{
-	struct inpcbinfo *ipi = inp->inp_pcbinfo;
-
-	KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__));
-
-	INP_INFO_WLOCK_ASSERT(ipi);
-	INP_WLOCK_ASSERT(inp);
-
-#ifdef IPSEC
-	if (inp->in6p_sp != NULL)
-		ipsec_delete_pcbpolicy(inp);
-#endif /* IPSEC */
-	inp->inp_gencnt = ++ipi->ipi_gencnt;
-	in_pcbremlists(inp);
-	ip6_freepcbopts(inp->in6p_outputopts);
-	ip6_freemoptions(inp->in6p_moptions);
-	/* Check and free IPv4 related resources in case of mapped addr */
-	if (inp->inp_options)
-		(void)m_free(inp->inp_options);
-	if (inp->inp_moptions != NULL)
-		inp_freemoptions(inp->inp_moptions);
-	inp->inp_vflag = 0;
-	crfree(inp->inp_cred);
-
-#ifdef MAC
-	mac_destroy_inpcb(inp);
-#endif
-	INP_WUNLOCK(inp);
-	uma_zfree(ipi->ipi_zone, inp);
-}
-
 struct sockaddr *
 in6_sockaddr(in_port_t port, struct in6_addr *addr_p)
 {

Modified: stable/7/sys/netinet6/in6_pcb.h
==============================================================================
--- stable/7/sys/netinet6/in6_pcb.h	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet6/in6_pcb.h	Sat Mar 21 11:18:59 2009	(r190197)
@@ -74,7 +74,6 @@ void	in6_losing __P((struct inpcb *));
 int	in6_pcbbind __P((struct inpcb *, struct sockaddr *, struct ucred *));
 int	in6_pcbconnect __P((struct inpcb *, struct sockaddr *, struct ucred *));
 void	in6_pcbdisconnect __P((struct inpcb *));
-void	in6_pcbfree __P((struct inpcb *));
 int	in6_pcbladdr __P((struct inpcb *, struct sockaddr *,
 			  struct in6_addr **));
 struct	inpcb *

Modified: stable/7/sys/netinet6/raw_ip6.c
==============================================================================
--- stable/7/sys/netinet6/raw_ip6.c	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet6/raw_ip6.c	Sat Mar 21 11:18:59 2009	(r190197)
@@ -601,7 +601,7 @@ rip6_detach(struct socket *so)
 	INP_WLOCK(inp);
 	FREE(inp->in6p_icmp6filt, M_PCB);
 	in_pcbdetach(inp);
-	in6_pcbfree(inp);
+	in_pcbfree(inp);
 	INP_INFO_WUNLOCK(&ripcbinfo);
 }
 

Modified: stable/7/sys/netinet6/udp6_usrreq.c
==============================================================================
--- stable/7/sys/netinet6/udp6_usrreq.c	Sat Mar 21 10:10:33 2009	(r190196)
+++ stable/7/sys/netinet6/udp6_usrreq.c	Sat Mar 21 11:18:59 2009	(r190197)
@@ -890,7 +890,7 @@ udp6_detach(struct socket *so)
 	INP_INFO_WLOCK(&udbinfo);
 	INP_WLOCK(inp);
 	in_pcbdetach(inp);
-	in6_pcbfree(inp);
+	in_pcbfree(inp);
 	INP_INFO_WUNLOCK(&udbinfo);
 }
 


More information about the svn-src-all mailing list