From owner-svn-src-all@freebsd.org Thu Mar 16 10:02:47 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 109FFD0DE16; Thu, 16 Mar 2017 10:02:47 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D14081142; Thu, 16 Mar 2017 10:02:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2GA2jEQ070304; Thu, 16 Mar 2017 10:02:45 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2GA2jk4070303; Thu, 16 Mar 2017 10:02:45 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201703161002.v2GA2jk4070303@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 16 Mar 2017 10:02:45 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Mar 2017 10:02:47 -0000 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_ */