Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Sep 2017 14:10:09 +0300
From:      "Andrey V. Elsukov" <bu7cher@yandex.ru>
To:        Hans Petter Selasky <hselasky@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r323351 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <1b752f11-2ec8-4c07-d53a-9e32a5fcf56c@yandex.ru>
In-Reply-To: <201709090721.v897LRWA084296@repo.freebsd.org>
References:  <201709090721.v897LRWA084296@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--uM0Lw8OWixNWN3KGnXXfo8EBDuLuhWhFV
Content-Type: multipart/mixed; boundary="6sld1W72nU0TTXlieE9kjsANimh2dWr46";
 protected-headers="v1"
From: "Andrey V. Elsukov" <bu7cher@yandex.ru>
To: Hans Petter Selasky <hselasky@FreeBSD.org>, src-committers@freebsd.org,
 svn-src-all@freebsd.org, svn-src-head@freebsd.org
Message-ID: <1b752f11-2ec8-4c07-d53a-9e32a5fcf56c@yandex.ru>
Subject: Re: svn commit: r323351 -
 head/sys/compat/linuxkpi/common/include/linux
References: <201709090721.v897LRWA084296@repo.freebsd.org>
In-Reply-To: <201709090721.v897LRWA084296@repo.freebsd.org>

--6sld1W72nU0TTXlieE9kjsANimh2dWr46
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

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
>=20
> Log:
>   Resolve IPv6 scope ID issues when using ip6_find_dev() in the LinuxKP=
I.
>  =20
>   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.
>  =20
>   MFC after:		1 week
>   Sponsored by:		Mellanox Technologies
>=20
> Modified:
>   head/sys/compat/linuxkpi/common/include/linux/inetdevice.h
>=20
> Modified: head/sys/compat/linuxkpi/common/include/linux/inetdevice.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- 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 add=
r)
>  {
>  	struct sockaddr_in6 sin6;
>  	struct ifaddr *ifa;
> -	struct ifnet *ifp;
> +	struct ifnet *ifp =3D NULL;
> +	int x;
> =20
>  	memset(&sin6, 0, sizeof(sin6));
>  	sin6.sin6_addr =3D addr;
>  	sin6.sin6_len =3D sizeof(sin6);
>  	sin6.sin6_family =3D AF_INET6;
>  	CURVNET_SET_QUIET(vnet);
> -	ifa =3D ifa_ifwithaddr((struct sockaddr *)&sin6);
> -	CURVNET_RESTORE();
> -	if (ifa) {
> -		ifp =3D ifa->ifa_ifp;
> -		if_ref(ifp);
> -		ifa_free(ifa);
> -	} else {
> -	  	ifp =3D NULL;
> +	/* XXX need to search all scope ID's */
> +	for (x =3D 0; x <=3D V_if_index; x++) {
> +		sin6.sin6_addr.s6_addr[3] =3D 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.

--=20
WBR, Andrey V. Elsukov


--6sld1W72nU0TTXlieE9kjsANimh2dWr46--

--uM0Lw8OWixNWN3KGnXXfo8EBDuLuhWhFV
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlmzzBEACgkQAcXqBBDI
oXqS1gf/XUB8rlcPl7LxzAUBeSsiOhKkBOLWsPvmhrZnvjzjOwtau7hmqb5h8Ofg
U/aXp4StREcM8pV4bodObDWI6MCmwriDFgCAUhaTDjufi/WdWruBwEkNQCTM6az7
XVEV2CwktjayckbE19usPVHo8V9JR1fmiOUiiAYhr5NUYp1Xf/QwKzKYVb1YWUJG
PCpIjMXdWQduRRreBLKJsI6nLfOwdQ1E+ISTMlsX6HU5NWWFA3O0+E6PVm5J63Rb
TVR9Fka3eAO/yqM2RssvwrX60yNQmiq1XU2aC2AFr97VMaF06X3ASXUR2JRV6znV
rOncsFmAt/KODRXc8bfEikAaYC4O1Q==
=mqOK
-----END PGP SIGNATURE-----

--uM0Lw8OWixNWN3KGnXXfo8EBDuLuhWhFV--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1b752f11-2ec8-4c07-d53a-9e32a5fcf56c>