From owner-svn-src-all@FreeBSD.ORG Thu Nov 27 12:04:35 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AFCD61065670; Thu, 27 Nov 2008 12:04:35 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B4A58FC1C; Thu, 27 Nov 2008 12:04:35 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mARC4Z5N086594; Thu, 27 Nov 2008 12:04:35 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mARC4Zdd086587; Thu, 27 Nov 2008 12:04:35 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200811271204.mARC4Zdd086587@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Thu, 27 Nov 2008 12:04:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185370 - in head/sys: netinet netinet6 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Nov 2008 12:04:35 -0000 Author: bz Date: Thu Nov 27 12:04:35 2008 New Revision: 185370 URL: http://svn.freebsd.org/changeset/base/185370 Log: Merge in6_pcbfree() into in_pcbfree() which after the previous IPsec change in r185366 only differed in two additonal IPv6 lines. Rather than splattering conditional code everywhere add the v6 check centrally at this single place. Reviewed by: rwatson (as part of a larger changset) MFC after: 6 weeks (*) (*) possibly need to leave a stub wrapper in 7 to keep the symbol. Modified: head/sys/netinet/in_pcb.c head/sys/netinet/tcp_timewait.c head/sys/netinet/tcp_usrreq.c head/sys/netinet6/in6_pcb.c head/sys/netinet6/in6_pcb.h head/sys/netinet6/raw_ip6.c head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet/in_pcb.c Thu Nov 27 12:04:35 2008 (r185370) @@ -899,10 +899,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: head/sys/netinet/tcp_timewait.c ============================================================================== --- head/sys/netinet/tcp_timewait.c Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet/tcp_timewait.c Thu Nov 27 12:04:35 2008 (r185370) @@ -514,14 +514,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); V_tcpstat.tcps_closed++; crfree(tw->tw_cred); tw->tw_cred = NULL; Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet/tcp_usrreq.c Thu Nov 27 12:04:35 2008 (r185370) @@ -156,9 +156,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 #ifdef INVARIANTS INIT_VNET_INET(so->so_vnet); #endif @@ -188,12 +185,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); @@ -212,15 +204,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); } } @@ -1479,12 +1465,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(&V_tcbinfo); return (ENOBUFS); } Modified: head/sys/netinet6/in6_pcb.c ============================================================================== --- head/sys/netinet6/in6_pcb.c Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet6/in6_pcb.c Thu Nov 27 12:04:35 2008 (r185370) @@ -103,12 +103,6 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef IPSEC -#include -#include -#include -#endif /* IPSEC */ - #include struct in6_addr zeroin6_addr; @@ -410,39 +404,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_inpcb_destroy(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: head/sys/netinet6/in6_pcb.h ============================================================================== --- head/sys/netinet6/in6_pcb.h Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet6/in6_pcb.h Thu Nov 27 12:04:35 2008 (r185370) @@ -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: head/sys/netinet6/raw_ip6.c ============================================================================== --- head/sys/netinet6/raw_ip6.c Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet6/raw_ip6.c Thu Nov 27 12:04:35 2008 (r185370) @@ -605,7 +605,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(&V_ripcbinfo); } Modified: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Thu Nov 27 11:27:59 2008 (r185369) +++ head/sys/netinet6/udp6_usrreq.c Thu Nov 27 12:04:35 2008 (r185370) @@ -901,7 +901,7 @@ udp6_detach(struct socket *so) INP_INFO_WLOCK(&V_udbinfo); INP_WLOCK(inp); in_pcbdetach(inp); - in6_pcbfree(inp); + in_pcbfree(inp); INP_INFO_WUNLOCK(&V_udbinfo); }