From owner-svn-src-user@FreeBSD.ORG Thu Oct 24 00:53:10 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 89F4A5C2; Thu, 24 Oct 2013 00:53:10 +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 5E5922D3B; Thu, 24 Oct 2013 00:53:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9O0rAlQ025952; Thu, 24 Oct 2013 00:53:10 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9O0rAqo025951; Thu, 24 Oct 2013 00:53:10 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201310240053.r9O0rAqo025951@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 24 Oct 2013 00:53:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r257032 - user/ae/inet6/sys/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: Thu, 24 Oct 2013 00:53:10 -0000 Author: ae Date: Thu Oct 24 00:53:09 2013 New Revision: 257032 URL: http://svnweb.freebsd.org/changeset/base/257032 Log: Scope related cleanup in rip6_connect(): * remove sa6_embedscope() and in6_setscope() calls; * use sa6_checkzone() to check sin6_scope_id for correctness; * when laddr or faddr is from link-local scope, initialize in6p_zoneid. Modified: user/ae/inet6/sys/netinet6/raw_ip6.c Modified: user/ae/inet6/sys/netinet6/raw_ip6.c ============================================================================== --- user/ae/inet6/sys/netinet6/raw_ip6.c Thu Oct 24 00:48:31 2013 (r257031) +++ user/ae/inet6/sys/netinet6/raw_ip6.c Thu Oct 24 00:53:09 2013 (r257032) @@ -763,7 +763,7 @@ rip6_connect(struct socket *so, struct s struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; struct in6_addr in6a; struct ifnet *ifp = NULL; - int error = 0, scope_ambiguous = 0; + int error = 0; inp = sotoinpcb(so); KASSERT(inp != NULL, ("rip6_connect: inp == NULL")); @@ -774,18 +774,8 @@ rip6_connect(struct socket *so, struct s return (EADDRNOTAVAIL); if (addr->sin6_family != AF_INET6) return (EAFNOSUPPORT); - - /* - * Application should provide a proper zone ID or the use of default - * zone IDs should be enabled. Unfortunately, some applications do - * not behave as it should, so we need a workaround. Even if an - * appropriate ID is not determined, we'll see if we can determine - * the outgoing interface. If we can, determine the zone ID based on - * the interface below. - */ - if (addr->sin6_scope_id == 0 && !V_ip6_use_defzone) - scope_ambiguous = 1; - if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) + error = sa6_checkzone(addr); + if (error != 0) return (error); INP_INFO_WLOCK(&V_ripcbinfo); @@ -798,16 +788,12 @@ rip6_connect(struct socket *so, struct s INP_INFO_WUNLOCK(&V_ripcbinfo); return (error); } - - /* XXX: see above */ - if (ifp && scope_ambiguous && - (error = in6_setscope(&addr->sin6_addr, ifp, NULL)) != 0) { - INP_WUNLOCK(inp); - INP_INFO_WUNLOCK(&V_ripcbinfo); - return (error); - } inp->in6p_faddr = addr->sin6_addr; inp->in6p_laddr = in6a; + if (IN6_IS_ADDR_LINKLOCAL(&inp->in6p_faddr) || + IN6_IS_ADDR_LINKLOCAL(&inp->in6p_laddr)) + inp->in6p_zoneid = in6_getscopezone(ifp, + IPV6_ADDR_SCOPE_LINKLOCAL); soisconnected(so); INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_ripcbinfo);