From owner-svn-src-user@FreeBSD.ORG Tue Oct 15 10:01:16 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 507B153C; Tue, 15 Oct 2013 10:01:16 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2E90821B1; Tue, 15 Oct 2013 10:01:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9FA1GaN088621; Tue, 15 Oct 2013 10:01:16 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9FA1FcZ088610; Tue, 15 Oct 2013 10:01:15 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201310151001.r9FA1FcZ088610@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 15 Oct 2013 10:01:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256513 - in user/ae/inet6/sys: netinet netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2013 10:01:16 -0000 Author: ae Date: Tue Oct 15 10:01:15 2013 New Revision: 256513 URL: http://svnweb.freebsd.org/changeset/base/256513 Log: Simplify tcp6_connect(). Also make in6_pcblookup_hash_locked() and in6_pcbladdr() functions static. Modified: user/ae/inet6/sys/netinet/tcp_usrreq.c user/ae/inet6/sys/netinet6/in6_pcb.c user/ae/inet6/sys/netinet6/in6_pcb.h Modified: user/ae/inet6/sys/netinet/tcp_usrreq.c ============================================================================== --- user/ae/inet6/sys/netinet/tcp_usrreq.c Tue Oct 15 09:55:07 2013 (r256512) +++ user/ae/inet6/sys/netinet/tcp_usrreq.c Tue Oct 15 10:01:15 2013 (r256513) @@ -1168,10 +1168,7 @@ out: static int tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) { - struct inpcb *inp = tp->t_inpcb, *oinp; - struct socket *so = inp->inp_socket; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; - struct in6_addr addr6; + struct inpcb *inp = tp->t_inpcb; int error; INP_WLOCK_ASSERT(inp); @@ -1182,39 +1179,9 @@ tcp6_connect(struct tcpcb *tp, struct so if (error) goto out; } - - /* - * Cannot simply call in_pcbconnect, because there might be an - * earlier incarnation of this same connection still in - * TIME_WAIT state, creating an ADDRINUSE error. - * in6_pcbladdr() also handles scope zone IDs. - * - * XXXRW: We wouldn't need to expose in6_pcblookup_hash_locked() - * outside of in6_pcb.c if there were an in6_pcbconnect_setup(). - */ - error = in6_pcbladdr(inp, nam, &addr6); - if (error) - goto out; - oinp = in6_pcblookup_hash_locked(inp->inp_pcbinfo, - &sin6->sin6_addr, sin6->sin6_port, - IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) - ? &addr6 - : &inp->in6p_laddr, - inp->inp_lport, 0, NULL); - if (oinp) { - error = EADDRINUSE; + error = in6_pcbconnect(inp, nam, td->td_ucred); + if (error != 0) goto out; - } - if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) - inp->in6p_laddr = addr6; - inp->in6p_faddr = sin6->sin6_addr; - inp->inp_fport = sin6->sin6_port; - /* update flowinfo - draft-itojun-ipv6-flowlabel-api-00 */ - inp->inp_flow &= ~IPV6_FLOWLABEL_MASK; - if (inp->inp_flags & IN6P_AUTOFLOWLABEL) - inp->inp_flow |= - (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); - in_pcbrehash(inp); INP_HASH_WUNLOCK(&V_tcbinfo); /* Compute window scaling to request. */ @@ -1222,7 +1189,7 @@ tcp6_connect(struct tcpcb *tp, struct so (TCP_MAXWIN << tp->request_r_scale) < sb_max) tp->request_r_scale++; - soisconnecting(so); + soisconnecting(inp->inp_socket); TCPSTAT_INC(tcps_connattempt); tcp_state_change(tp, TCPS_SYN_SENT); tp->iss = tcp_new_isn(tp); Modified: user/ae/inet6/sys/netinet6/in6_pcb.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_pcb.c Tue Oct 15 09:55:07 2013 (r256512) +++ user/ae/inet6/sys/netinet6/in6_pcb.c Tue Oct 15 10:01:15 2013 (r256513) @@ -106,6 +106,9 @@ __FBSDID("$FreeBSD$"); #include #include +static struct inpcb *in6_pcblookup_hash_locked(struct inpcbinfo *, + struct in6_addr *, u_int, struct in6_addr *, u_int, int, struct ifnet *); + int in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) @@ -302,7 +305,7 @@ in6_pcbbind(register struct inpcb *inp, * a bit of a kludge, but cleaning up the internal interfaces would * have forced minor changes in every protocol). */ -int +static int in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam, struct in6_addr *plocal_addr6) { @@ -975,7 +978,7 @@ found: /* * Lookup PCB in hash list. */ -struct inpcb * +static struct inpcb * in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_int fport_arg, struct in6_addr *laddr, u_int lport_arg, int lookupflags, struct ifnet *ifp) Modified: user/ae/inet6/sys/netinet6/in6_pcb.h ============================================================================== --- user/ae/inet6/sys/netinet6/in6_pcb.h Tue Oct 15 09:55:07 2013 (r256512) +++ user/ae/inet6/sys/netinet6/in6_pcb.h Tue Oct 15 10:01:15 2013 (r256513) @@ -86,7 +86,6 @@ int in6_pcbconnect(struct inpcb *, struc int in6_pcbconnect_mbuf(struct inpcb *, struct sockaddr *, struct ucred *, struct mbuf *); void in6_pcbdisconnect(struct inpcb *); -int in6_pcbladdr(struct inpcb *, struct sockaddr *, struct in6_addr *); struct inpcb * in6_pcblookup_local(struct inpcbinfo *, struct in6_addr *, u_short, int, @@ -96,10 +95,6 @@ struct inpcb * u_int, struct in6_addr *, u_int, int, struct ifnet *); struct inpcb * - in6_pcblookup_hash_locked(struct inpcbinfo *, struct in6_addr *, - u_int, struct in6_addr *, u_int, int, - struct ifnet *); -struct inpcb * in6_pcblookup_mbuf(struct inpcbinfo *, struct in6_addr *, u_int, struct in6_addr *, u_int, int, struct ifnet *ifp, struct mbuf *);