Date: Wed, 23 Oct 2013 23:40:49 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r257022 - user/ae/inet6/sys/netinet6 Message-ID: <201310232340.r9NNene7001394@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310232340.r9NNene7001394>