Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jun 2018 18:33:24 +0000
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        "Andrey V. Elsukov" <bu7cher@yandex.ru>, Rick Macklem <rmacklem@FreeBSD.org>, FreeBSD Net <freebsd-net@freebsd.org>
Subject:   IPv6 scope handling, was Re: svn commit: r335806 - projects/pnfs-planb-server/usr.sbin/nfsd
Message-ID:  <YTOPR0101MB09532F60F2905ECA610DF86DDD4D0@YTOPR0101MB0953.CANPRD01.PROD.OUTLOOK.COM>
In-Reply-To: <0c85d229-3b8f-3b4c-ba3c-34ec06728455@yandex.ru>
References:  <201806292207.w5TM7QX9052770@repo.freebsd.org>, <0c85d229-3b8f-3b4c-ba3c-34ec06728455@yandex.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Andrey V. Elsukov wrote:
>On 30.06.2018 01:07, Rick Macklem wrote:
>> Author: rmacklem
>> Date: Fri Jun 29 22:07:25 2018
>> New Revision: 335806
>> URL: https://svnweb.freebsd.org/changeset/base/335806
>>
>> Log:
>>   Add support for IPv6 addresses to the "-p" option for the pNFS server =
DS
>>   specifications.
>>
>> +     char *mdspath, *mdsp, ip6[INET6_ADDRSTRLEN];
>> +     const char *ad;
>>       int ecode;
>> +             hints.ai_flags =3D AI_CANONNAME | AI_ADDRCONFIG;
>> +             hints.ai_family =3D PF_UNSPEC;
>>               hints.ai_socktype =3D SOCK_STREAM;
>>               hints.ai_protocol =3D IPPROTO_TCP;
>>               ecode =3D getaddrinfo(cp, NULL, &hints, &ai_tcp);
>>               if (ecode !=3D 0)
>>                       err(1, "getaddrinfo pnfs: %s %s", cp,
>>                           gai_strerror(ecode));
>> +                             memcpy(&sin6, res->ai_addr, sizeof(sin6));
>> +                             ad =3D inet_ntop(AF_INET6, &sin6.sin6_addr=
, ip6,
>> +                                 sizeof(ip6));
>
>Hi,
>
>I'm unaware of applicability of IPv6 addresses with restricted scope in
>this area, but when you use inet_ntop() to get IPv6 address text
>representation, you can lost IPv6 scope zone id. getaddrinfo() can
>return sockaddr structure with properly filled sin6_scope_id field. It
>is better to use getnameinfo() with NI_NUMERICHOST flag. Also the size
>of ip6 buffer should be enough to keep scope specifier.
Thanks for mentioning this. First off, you could write what I know about IP=
v6
addresses on a very small postage stamp...

Are you referring to the 4bits in the second octet of the address or the st=
uff that
can end up as a suffix starting with"%"?

In this case, the address string is put "on the wire" for the client to use=
 to connect
to a data server (DS). I'm not sure if the "%..." stuff is useful in this c=
ase and,
when it gets to the client, it will be translated to an address via the ker=
nel
version of inet_pton(), which does not parse "%..." as far as I can see.

So maybe others can clarify if it would be better to use getnameinfo() for =
this
use case?

Thanks, rick
ps: I changed the mailing list to freebsd-nat@ so hopefully the net folks w=
ill notice.




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