svn commit: r324525 - stable/10/sys/ofed/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Oct 11 10:20:54 UTC 2017
Author: hselasky
Date: Wed Oct 11 10:20:53 2017
New Revision: 324525
URL: https://svnweb.freebsd.org/changeset/base/324525
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/10/sys/ofed/include/linux/inetdevice.h
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/ofed/include/linux/inetdevice.h
==============================================================================
--- stable/10/sys/ofed/include/linux/inetdevice.h Wed Oct 11 10:12:22 2017 (r324524)
+++ stable/10/sys/ofed/include/linux/inetdevice.h Wed Oct 11 10:20:53 2017 (r324525)
@@ -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
@@ -25,6 +25,7 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
*/
#ifndef _LINUX_INETDEVICE_H_
@@ -51,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);
}
More information about the svn-src-all
mailing list