[systemd-devel] [PATCH 1/2] Ignore IPv6 link-local addresses
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Mon Feb 4 07:40:12 PST 2013
On Mon, Feb 04, 2013 at 03:56:25PM +0100, Eelco Dolstra wrote:
> Returning IPv6 link-local addresses is a bad idea, because they only
> work if an application connects specifically over the corresponding
> interface.
Isn't this a responsibility of the application to deal with that?
> So you get errors like:
>
> $ curl -6 http://my-machine/
> curl: (7) Failed to connect to fe80::d6be:d9ff:fe1b:8477: Invalid argument
$ hostnamectl set-hostname bupkis-tmp
$ curl -6v bupkis-tmp
* About to connect() to bupkis-tmp port 80 (#0)
* Trying fe80::a60:6eff:fe00:6241...
* Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
So here everything is working as expected (I don't have an http server).
Zbyszek
> To prevent this, this patch filters out link-local addresses. So if
> you don't have a routable IPv6 address, nss-myhostname will fall back
> to returning ::1.
> ---
> src/nss-myhostname/netlink.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/nss-myhostname/netlink.c b/src/nss-myhostname/netlink.c
> index 53c3b50..621ca1d 100644
> --- a/src/nss-myhostname/netlink.c
> +++ b/src/nss-myhostname/netlink.c
> @@ -155,6 +155,10 @@ int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) {
> ifaddrmsg->ifa_scope == RT_SCOPE_NOWHERE)
> continue;
>
> + if (ifaddrmsg->ifa_family == AF_INET6 &&
> + ifaddrmsg->ifa_scope == RT_SCOPE_LINK)
> + continue;
> +
> if (ifaddrmsg->ifa_flags & IFA_F_DEPRECATED)
> continue;
>
> --
> 1.8.1
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
More information about the systemd-devel
mailing list