svn commit: r324524 - stable/11/sys/compat/linuxkpi/common/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Oct 11 10:12:24 UTC 2017
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);
}
More information about the svn-src-stable-11
mailing list