From owner-svn-src-user@FreeBSD.ORG Wed Oct 23 23:40:49 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 BDEECE23; Wed, 23 Oct 2013 23:40:49 +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 91DD02947; Wed, 23 Oct 2013 23:40:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9NNenX6001395; Wed, 23 Oct 2013 23:40:49 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9NNene7001394; Wed, 23 Oct 2013 23:40:49 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201310232340.r9NNene7001394@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 23 Oct 2013 23:40:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r257022 - 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: Wed, 23 Oct 2013 23:40:49 -0000 Author: ae Date: Wed Oct 23 23:40:49 2013 New Revision: 257022 URL: http://svnweb.freebsd.org/changeset/base/257022 Log: Scope related cleanup in nd6_is_new_addr_neighbor(): * since we assume that addresses doesn't contains embedded zone ids, link-local addresses are always neighbors. So, remove sa6_recoverscope() and in6_setscope() calls; * use in6_localip() to check that address matches one of our addresses; * use in6ifa_ifpwithdstaddr() instead of ifa_ifwithdstaddr(). Modified: user/ae/inet6/sys/netinet6/nd6.c Modified: user/ae/inet6/sys/netinet6/nd6.c ============================================================================== --- user/ae/inet6/sys/netinet6/nd6.c Wed Oct 23 23:21:11 2013 (r257021) +++ user/ae/inet6/sys/netinet6/nd6.c Wed Oct 23 23:40:49 2013 (r257022) @@ -874,34 +874,20 @@ static int nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) { struct nd_prefix *pr; - struct ifaddr *dstaddr; + struct in6_ifaddr *ia6; /* * A link-local address is always a neighbor. - * XXX: a link does not necessarily specify a single interface. */ - if (IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr)) { - struct sockaddr_in6 sin6_copy; - u_int32_t zone; - - /* - * We need sin6_copy since sa6_recoverscope() may modify the - * content (XXX). - */ - sin6_copy = *addr; - if (sa6_recoverscope(&sin6_copy)) - return (0); /* XXX: should be impossible */ - if (in6_setscope(&sin6_copy.sin6_addr, ifp, &zone)) - return (0); - if (sin6_copy.sin6_scope_id == zone) - return (1); - else - return (0); - } - + if (IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr)) + return (1); /* * If the address matches one of our addresses, * it should be a neighbor. + */ + if (in6_localip(&addr->sin6_addr)) + return (1); + /* * If the address matches one of our on-link prefixes, it should be a * neighbor. */ @@ -944,13 +930,10 @@ nd6_is_new_addr_neighbor(struct sockaddr * If the address is assigned on the node of the other side of * a p2p interface, the address should be a neighbor. */ - dstaddr = ifa_ifwithdstaddr((struct sockaddr *)addr); - if (dstaddr != NULL) { - if (dstaddr->ifa_ifp == ifp) { - ifa_free(dstaddr); - return (1); - } - ifa_free(dstaddr); + ia6 = in6ifa_ifpwithdstaddr(ifp, &addr->sin6_addr); + if (ia6 != NULL) { + ifa_free(&ia6->ia_ifa); + return (1); } /*