Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On a Google Cloud node, listening on an IPv6 address triggers a lot of listener errors #1552

Closed
tomaka opened this issue Apr 20, 2020 · 2 comments
Labels

Comments

@tomaka
Copy link
Member

tomaka commented Apr 20, 2020

When listening for example on /ip6/::/tcp/30333, there seems to be a periodic ListenerError whose message is something like:

::ffff:10.128.0.9 does not match any listen address

let msg = format!("{} does not match any listen address", socket_addr.ip());

This only happens on my Google Cloud node, and not on my local machine.

@tomaka
Copy link
Member Author

tomaka commented Apr 20, 2020

I logged the output of calling the host_addresses function:

2020-04-20 08:54:53.207 tokio-runtime-worker DEBUG libp2p_tcp  host_addresses = [(V4(127.0.0.1), 127.0.0.1/8, "/ip4/127.0.0.1/tcp/30333"), (V4(10.128.0.9), 10.128.0.9/32, "/ip4/10.128.0.9/tcp/30333"), (V4(172.17.0.1), 172.17.0.1/16, "/ip4/172.17.0.1/tcp/30333"), (V6(::1), ::1/128, "/ip6/::1/tcp/30333")]
... (unrelevant logs here) ...
2020-04-20 08:54:55.611 tokio-runtime-worker DEBUG libp2p_tcp  host_addresses = [(V4(127.0.0.1), 127.0.0.1/8, "/ip4/127.0.0.1/tcp/30333"), (V4(10.128.0.9), 10.128.0.9/32, "/ip4/10.128.0.9/tcp/30333"), (V4(172.17.0.1), 172.17.0.1/16, "/ip4/172.17.0.1/tcp/30333"), (V6(::1), ::1/128, "/ip6/::1/tcp/30333")]
2020-04-20 08:54:55.611 tokio-runtime-worker ERROR sub-libp2p  Error on libp2p listener ListenerId(1): ::ffff:10.128.0.9 does not match any listen address

The problem just seems to be that V4(10.128.0.9) doesn't compare equal to IpV6Addr(::ffff:10.128.0.9), but there might be a smarter way to fix that than adding a custom equality function.

twittner added a commit to twittner/rust-libp2p that referenced this issue Apr 23, 2020
The current behaviour of listening on an IPv6 address varies depending
on the operating system's IP address stack implementation. Some support
IPv4-mapped IPv6 addresses (e.g. Linux and newer versions of Windows)
so a single IPv6 address would support IPv4-mapped addresses too.
Others do not (e.g. OpenBSD). If they do, then some support them by
default (e.g. Linux) and some do not (e.g. Windows).

This PR attempts to implement the same behaviour accross operating
systems. The strategy is as follows:

Disable IPv4-mapped IPv6 addresses, hence the socket option IPV6_V6ONLY
is always set to true.

This allows binding two sockets to the same port and also avoids the
problem of comparing mixed addresses which leads issues such as libp2p#1552.
twittner added a commit that referenced this issue Apr 24, 2020
* tcp: Set IPV6_V6ONLY for IPv6 listeners.

The current behaviour of listening on an IPv6 address varies depending
on the operating system's IP address stack implementation. Some support
IPv4-mapped IPv6 addresses (e.g. Linux and newer versions of Windows)
so a single IPv6 address would support IPv4-mapped addresses too.
Others do not (e.g. OpenBSD). If they do, then some support them by
default (e.g. Linux) and some do not (e.g. Windows).

This PR attempts to implement the same behaviour accross operating
systems. The strategy is as follows:

Disable IPv4-mapped IPv6 addresses, hence the socket option IPV6_V6ONLY
is always set to true.

This allows binding two sockets to the same port and also avoids the
problem of comparing mixed addresses which leads issues such as #1552.

* Update CHANGELOG and address review concerns.

* Update CHANGELOG.md

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
@twittner
Copy link
Contributor

#1555 separates IPv4 and IPv6 listeners, so this mixed comparison should not happen anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants