aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-03-16 10:02:45 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-03-16 10:02:45 +0000
commit8300fb13dd92854b48c421b02850c0693d3d74f6 (patch)
tree53e3c7c22f0a093757dbcd8b13d3e6c7d1c87a97 /sys/compat/linuxkpi/common/include
parent404027276b0f858b2870ccb1535c3f70d8b89622 (diff)
downloadsrc-8300fb13dd92854b48c421b02850c0693d3d74f6.tar.gz
src-8300fb13dd92854b48c421b02850c0693d3d74f6.zip
Add helper function similar to ip_dev_find() to the LinuxKPI to lookup
a network device by its IPv6 address in the given VNET. MFC after: 1 week Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=315405
Diffstat (limited to 'sys/compat/linuxkpi/common/include')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/inetdevice.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/inetdevice.h b/sys/compat/linuxkpi/common/include/linux/inetdevice.h
index 36517fb9d28b..33f12277ec66 100644
--- a/sys/compat/linuxkpi/common/include/linux/inetdevice.h
+++ b/sys/compat/linuxkpi/common/include/linux/inetdevice.h
@@ -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
@@ -57,4 +57,28 @@ ip_dev_find(struct vnet *vnet, uint32_t addr)
return (ifp);
}
+static inline struct net_device *
+ip6_dev_find(struct vnet *vnet, struct in6_addr addr)
+{
+ struct sockaddr_in6 sin6;
+ struct ifaddr *ifa;
+ struct ifnet *ifp;
+
+ memset(&sin6, 0, sizeof(sin6));
+ sin6.sin6_addr = addr;
+ sin6.sin6_len = sizeof(sin6);
+ sin6.sin6_family = AF_INET6;
+ CURVNET_SET_QUIET(vnet);
+ ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
+ CURVNET_RESTORE();
+ if (ifa) {
+ ifp = ifa->ifa_ifp;
+ if_ref(ifp);
+ ifa_free(ifa);
+ } else {
+ ifp = NULL;
+ }
+ return (ifp);
+}
+
#endif /* _LINUX_INETDEVICE_H_ */