From owner-svn-src-all@FreeBSD.ORG Sat Apr 9 12:38:09 2011 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 C8444106566B; Sat, 9 Apr 2011 12:38:09 +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 9A2078FC0C; Sat, 9 Apr 2011 12:38:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39Cc9Ft014070; Sat, 9 Apr 2011 12:38:09 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39Cc9ko014066; Sat, 9 Apr 2011 12:38:09 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201104091238.p39Cc9ko014066@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sat, 9 Apr 2011 12:38:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220490 - stable/7/sys/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: Sat, 09 Apr 2011 12:38:09 -0000 Author: bz Date: Sat Apr 9 12:38:09 2011 New Revision: 220490 URL: http://svn.freebsd.org/changeset/base/220490 Log: MFC r219570: Push a possible "unbind" in some situation from in6_pcbsetport() to callers. This also fixes a problem when the prison call could set the inp->in6p_laddr (laddr) and a following priv_check_cred() call would return an error and will allow us to merge the IPv4 and IPv6 implementation. Modified: stable/7/sys/netinet6/in6_pcb.c stable/7/sys/netinet6/in6_src.c stable/7/sys/netinet6/udp6_usrreq.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/netinet6/in6_pcb.c ============================================================================== --- stable/7/sys/netinet6/in6_pcb.c Sat Apr 9 12:35:08 2011 (r220489) +++ stable/7/sys/netinet6/in6_pcb.c Sat Apr 9 12:38:09 2011 (r220490) @@ -252,8 +252,11 @@ in6_pcbbind(register struct inpcb *inp, inp->in6p_laddr = sin6->sin6_addr; } if (lport == 0) { - if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) + if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) { + /* Undo an address bind that may have occurred. */ + inp->in6p_laddr = in6addr_any; return (error); + } } else { inp->inp_lport = lport; if (in_pcbinshash(inp) != 0) { Modified: stable/7/sys/netinet6/in6_src.c ============================================================================== --- stable/7/sys/netinet6/in6_src.c Sat Apr 9 12:35:08 2011 (r220489) +++ stable/7/sys/netinet6/in6_src.c Sat Apr 9 12:38:09 2011 (r220490) @@ -858,11 +858,8 @@ in6_pcbsetport(struct in6_addr *laddr, s count = last - first; do { - if (count-- < 0) { /* completely used? */ - /* Undo an address bind that may have occurred. */ - inp->in6p_laddr = in6addr_any; + if (count-- < 0) /* completely used? */ return (EADDRNOTAVAIL); - } ++*lastport; if (*lastport < first || *lastport > last) *lastport = first; Modified: stable/7/sys/netinet6/udp6_usrreq.c ============================================================================== --- stable/7/sys/netinet6/udp6_usrreq.c Sat Apr 9 12:35:08 2011 (r220489) +++ stable/7/sys/netinet6/udp6_usrreq.c Sat Apr 9 12:38:09 2011 (r220490) @@ -597,8 +597,11 @@ udp6_output(struct inpcb *inp, struct mb goto release; } if (inp->inp_lport == 0 && - (error = in6_pcbsetport(laddr, inp, td->td_ucred)) != 0) + (error = in6_pcbsetport(laddr, inp, td->td_ucred)) != 0) { + /* Undo an address bind that may have occurred. */ + inp->in6p_laddr = in6addr_any; goto release; + } } else { if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { error = ENOTCONN;