From owner-svn-src-all@freebsd.org Sat Sep 9 12:50:14 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30339E14D53; Sat, 9 Sep 2017 12:50:14 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F346967CA6; Sat, 9 Sep 2017 12:50:13 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v89CoDN6015760; Sat, 9 Sep 2017 12:50:13 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v89CoDeF015759; Sat, 9 Sep 2017 12:50:13 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201709091250.v89CoDeF015759@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 9 Sep 2017 12:50:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323364 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 323364 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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 Sep 2017 12:50:14 -0000 Author: hselasky Date: Sat Sep 9 12:50:12 2017 New Revision: 323364 URL: https://svnweb.freebsd.org/changeset/base/323364 Log: Only search the scope ID in ip6_find_dev() for IPv6 addresses which have a scope ID. Change size of the searched scope ID to the full 16-bits. There can typically be more than 255 interfaces. Suggested by: ae @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/inetdevice.h Modified: head/sys/compat/linuxkpi/common/include/linux/inetdevice.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/inetdevice.h Sat Sep 9 11:56:48 2017 (r323363) +++ head/sys/compat/linuxkpi/common/include/linux/inetdevice.h Sat Sep 9 12:50:12 2017 (r323364) @@ -61,7 +61,7 @@ static inline struct net_device * ip6_dev_find(struct vnet *vnet, struct in6_addr addr) { struct sockaddr_in6 sin6; - struct ifaddr *ifa; + struct ifaddr *ifa = NULL; struct ifnet *ifp = NULL; int x; @@ -70,16 +70,22 @@ ip6_dev_find(struct vnet *vnet, struct in6_addr addr) sin6.sin6_len = sizeof(sin6); sin6.sin6_family = AF_INET6; CURVNET_SET_QUIET(vnet); - /* XXX need to search all scope ID's */ - for (x = 0; x <= V_if_index; x++) { - sin6.sin6_addr.s6_addr[3] = x; - ifa = ifa_ifwithaddr((struct sockaddr *)&sin6); - if (ifa != NULL) { - ifp = ifa->ifa_ifp; - if_ref(ifp); - ifa_free(ifa); - break; + if (IN6_IS_SCOPE_LINKLOCAL(&addr) || + IN6_IS_ADDR_MC_INTFACELOCAL(&addr)) { + /* XXX need to search all scope ID's */ + for (x = 0; x <= V_if_index && x < 65536; x++) { + sin6.sin6_addr.s6_addr16[1] = htons(x); + ifa = ifa_ifwithaddr((struct sockaddr *)&sin6); + if (ifa != NULL) + break; } + } else { + ifa = ifa_ifwithaddr((struct sockaddr *)&sin6); + } + if (ifa != NULL) { + ifp = ifa->ifa_ifp; + if_ref(ifp); + ifa_free(ifa); } CURVNET_RESTORE(); return (ifp);