Author: hselasky
Date: Thu Mar 16 10:02:45 2017
New Revision: 315405
URL: https://svnweb.freebsd.org/changeset/base/315405

Log:
  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

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  Thu Mar 16 
09:59:35 2017        (r315404)
+++ head/sys/compat/linuxkpi/common/include/linux/inetdevice.h  Thu Mar 16 
10:02:45 2017        (r315405)
@@ -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 
        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_ */
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to