libmill icon indicating copy to clipboard operation
libmill copied to clipboard

IPv6 Link Local Addresses

Open shehzadkhawar opened this issue 8 years ago • 4 comments

While testing libmill on to my IPv6 enabled cluster, I noticed the following.

My cluster uses IPv6 Link Local Addresses (fe80:: network prefixes). There is no consideration (correct me if i am wrong) on setting the link-local sin6_scope_id [1] in the libmill. So libmill does only work with global IPv6 addresses and does not work with link local addresses.

Similarly if one sets IPv6 link local address like this, they will get nothing

./test fe80::230:48ff:fefc:eb00 5555 ipaddr raddr = ipremote(, atoi(argv[2]), IPADDR_IPV6, -1); ERROR: Network is unreachable

./test fe80::230:48ff:fefc:eb00**/64** 5555 ipaddr raddr = ipremote(, atoi(argv[2]), IPADDR_IPV6, -1); NOTE: ipremote stucks

./test fe80::230:48ff:fefc:eb00**%eth0** 5555 ipaddr raddr = ipremote(, atoi(argv[2]), IPADDR_IPV6, -1); NOTE: ipremote stucks

In the code there is no such parameter which sets the link local scope. Even if I do that, I don't pass through the ipremote function call.

References:

1- http://man7.org/linux/man-pages/man7/ipv6.7.html 2- see comment section, especially in the middle and at the end http://www.electronicsfaq.com/2012/12/simple-tcp-client-server-sockets.html

shehzadkhawar avatar Jul 22 '16 11:07 shehzadkhawar

Yes, it sucks. The whole IPv6/string conversion business sucks.

Feel free to propose a solution. IIRC there is an RFC with best practices for this...

sustrik avatar Jul 22 '16 11:07 sustrik

Just updated this on my system (ip.c) and it works like a charm in my tests

https://gist.github.com/shehzadkhawar/cebdfc01659030fb7dedb6eb6601c6a4

If you think that is good enough, can you kindly push it, I am unable to do since I have many fragments which I don't want to be pushed here for now

shehzadkhawar avatar Aug 09 '16 17:08 shehzadkhawar

Can you please send a pull request and state that it's submitted under MIT/X11 license?

sustrik avatar Aug 09 '16 17:08 sustrik

I've re-read RFC 4007, specifically section 11. It turns out it's not that easy. If the node has two interfaces, both can have the same link-local address. To disambiguate zone index should be added (e.g. fe80::1234%1). Picking the first one as in your patch may lead to non-deterministic name resolution. The rfc even suggest disambiguation based on interface names (e.g. fe80::1234%eth0).

inet_pton is not able to parse that kind of address string.

However, at least in theory, getaddrinfo() should be able to parse IP addresses with zone IDs. I haven't tested it though.

sustrik avatar Aug 10 '16 05:08 sustrik