Date: Wed, 11 Oct 2017 10:12:22 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324524 - stable/11/sys/compat/linuxkpi/common/include/linux Message-ID: <201710111012.v9BACMvK012041@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710111012.v9BACMvK012041>