From owner-svn-src-stable-11@freebsd.org Wed Oct 11 10:12:24 2017 Return-Path: Delivered-To: svn-src-stable-11@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 139D3E27409; Wed, 11 Oct 2017 10:12:24 +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 CB01B2ADC; Wed, 11 Oct 2017 10:12:23 +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 v9BACMkB012042; Wed, 11 Oct 2017 10:12:22 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9BACMvK012041; Wed, 11 Oct 2017 10:12:22 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710111012.v9BACMvK012041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 11 Oct 2017 10:12:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324524 - stable/11/sys/compat/linuxkpi/common/include/linux X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 324524 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 10:12:24 -0000 Author: hselasky Date: Wed Oct 11 10:12:22 2017 New Revision: 324524 URL: https://svnweb.freebsd.org/changeset/base/324524 Log: MFC r315405, r323351 and r323364: Add helper function similar to ip_dev_find() to the LinuxKPI to lookup a network device by its IPv6 address in the given VNET. Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h Wed Oct 11 10:04:17 2017 (r324523) +++ stable/11/sys/compat/linuxkpi/common/include/linux/inetdevice.h Wed Oct 11 10:12:22 2017 (r324524) @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2017 Mellanox Technologies, Ltd. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,40 @@ ip_dev_find(struct net *net, uint32_t addr) if_ref(ifp); ifa_free(ifa); } + return (ifp); +} + +static inline struct net_device * +ip6_dev_find(struct vnet *vnet, struct in6_addr addr) +{ + struct sockaddr_in6 sin6; + struct ifaddr *ifa = NULL; + struct ifnet *ifp = NULL; + int x; + + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_addr = addr; + sin6.sin6_len = sizeof(sin6); + sin6.sin6_family = AF_INET6; + CURVNET_SET_QUIET(vnet); + 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); }