-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Address translation doesn't work correctly with non-reused ephemeral ports #5820
Comments
Additional context for why the port is not reused — this happens due to a secondary connection being established to the same
This happens due to concurrent dial and some nodes providing multiple addresses (e.g. DNS + IP) that resolve to the same |
This issue is also triggered without a secondary connection (concurrent dial disabled) to the same For example, if the node listens on a TCP address(e.g. |
Thank you for the detailed bug report and for elaborating a possible solution! Sorry for the late reply.
Yes that would solve it I think. However, it would require us to touch I was wondering if we could instead solve the issue in the identify protocol. I am not super familiar with the port-reuse logic in different transports, so apologies if I am missing something very obvious. |
Summary
In
libp2p-0.54.1
whenhandle_established_outbound_connection()
ofIdentify
protocol is called it seemsport_use
argument is not set toPortUse::New
at least in some cases when ephemeral port was actually used.This is what comment in
ConnectedPoint::Dialer
says:This leads to
Identify
mistakenly thinking that we reused the port, not taking this branch inemit_new_external_addr_candidate_event()
and emitting such ephemeral address without translation inToSwarm::NewExternalAddrCandidate(observed.clone())
.This issue was originally reported in paritytech/polkadot-sdk#7207. It leads to ephemeral addresses being discovered as external in
polkadot
. For the context,polkadot
does not use AutoNAT protocol and eagerly confirms all external address candidates provided byIdentify
behavior.To obtain the logs below additional logging was added to
Identify
: dmitry-markin@4205675Expected behavior
Only listen addresses reported by
Identify
for connections with actually reused port are emitted without address translation.Actual behavior
Ephemeral addresses with not reused ports are emitted without address translation.
Relevant log output
Possible Solution
Transport::Dial
to yield bothTransport::Output
andPortUse
.dial()
to return the actualPortUse
of the outbound socket created.pool::task::PendingConnectionEvent::ConnectionEstablished
to includePortUse
; updatepool::PoolEvent
to yield correctPortUse
inConnectedPoint
.AndThenFuture
and the such.Version
0.54.1
Would you like to work on fixing this bug?
Maybe
The text was updated successfully, but these errors were encountered: