Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Mar 2017 10:02:45 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315405 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201703161002.v2GA2jk4070303@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703161002.v2GA2jk4070303>