svn commit: r323351 - head/sys/compat/linuxkpi/common/include/linux

Andrey V. Elsukov bu7cher at yandex.ru
Sat Sep 9 11:14:00 UTC 2017


On 09.09.2017 10:21, Hans Petter Selasky wrote:
> Author: hselasky
> Date: Sat Sep  9 07:21:27 2017
> New Revision: 323351
> URL: https://svnweb.freebsd.org/changeset/base/323351
> 
> Log:
>   Resolve IPv6 scope ID issues when using ip6_find_dev() in the LinuxKPI.
>   
>   Workaround problem that ifa_ifwithaddr() also matches the scope ID of
>   the IPv6 address when searching for a maching IPv6 address. For now
>   simply try all valid scope IDs until a match is found.
>   
>   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	Sat Sep  9 06:34:20 2017	(r323350)
> +++ head/sys/compat/linuxkpi/common/include/linux/inetdevice.h	Sat Sep  9 07:21:27 2017	(r323351)
> @@ -62,22 +62,26 @@ ip6_dev_find(struct vnet *vnet, struct in6_addr addr)
>  {
>  	struct sockaddr_in6 sin6;
>  	struct ifaddr *ifa;
> -	struct ifnet *ifp;
> +	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);
> -	ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
> -	CURVNET_RESTORE();
> -	if (ifa) {
> -		ifp = ifa->ifa_ifp;
> -		if_ref(ifp);
> -		ifa_free(ifa);
> -	} else {
> -	  	ifp = NULL;
> +	/* XXX need to search all scope ID's */
> +	for (x = 0; x <= V_if_index; x++) {
> +		sin6.sin6_addr.s6_addr[3] = x;

This doesn't look right. We use s6_addr16[1] to keep scope zone id.
And if_index value should be converted into network byte order. It is
quite usual to have more that 255 interfaces.

And what is more important, you must not use this code for global IPv6
addresses.

-- 
WBR, Andrey V. Elsukov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 553 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20170909/c46c533e/attachment.sig>


More information about the svn-src-head mailing list