IPv6 scope handling, was Re: svn commit: r335806 - projects/pnfs-planb-server/usr.sbin/nfsd

Rick Macklem rmacklem at uoguelph.ca
Sun Jul 1 17:25:43 UTC 2018


Andrey V. Elsukov wrote:
[stuff snipped]
>>
>> I think what you are saying above is that a Link-local address won't work
>> and that the address must be a global one?
>> Should the code check for "fe8" at the start and skip over those ones?
>
>It is possible that all hosts are in the same scope zone, e.g. they are
>connected in the one broadcast domain through the switch.
>In this case it is possible to use link-local addresses and they all
>will be reachable.
>
>> The "on-the-wire" address sent to HostC is specified in standard string form
>> (can't remember the RFC#, but it is referenced by RFC5661), so I can't send
>> any more than that to HostC.
>
>So if I understand correctly, after formatting you are sending this
>address string to the some foreign host?
Yes, that is what happens.

>The scope zone id specifier is only does matter for the host where it is
>used. I.e. there is no sense to send "%ifname" to the foreign host,
>because it can have different ifname for the link and that address
>specification won't work.
That is what I thought.

>I think for now we can leave the code as is (put some XXX with comment
>here), and then in the future, if it will be needed, add better handling
>for that :)
How about this patch? (Basically use the link local address if it is the only one
returned by getaddrinfo().)
--- nfsd.c	2018-06-30 08:16:51.771742000 -0400
+++ /tmp/nfsd.c	2018-07-01 13:01:30.243285000 -0400
@@ -1309,7 +1309,17 @@ parse_dsserver(const char *optionarg, st
 				memcpy(&sin6, res->ai_addr, sizeof(sin6));
 				ad = inet_ntop(AF_INET6, &sin6.sin6_addr, ip6,
 				    sizeof(ip6));
-				break;
+
+				/*
+				 * XXX
+				 * Since a link local address will only
+				 * work if the client and DS are in the
+				 * same scope zone, only use it if it is
+				 * the only address.
+				 */
+				if (ad != NULL &&
+				    !IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
+					break;
 			}
 		}
 		if (ad == NULL)
[more stuff snipped]

Thanks for the comments, rick


More information about the freebsd-net mailing list