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

p2p/nat: fix UPnP port reset #31566

Merged
merged 11 commits into from
Apr 9, 2025
Merged

Conversation

cskiraly
Copy link
Collaborator

@cskiraly cskiraly commented Apr 4, 2025

Make UPnP more robust

  • Once a random port was mapped, we try to stick to it even if a UPnP refresh fails. Previously we were immediately moving back to try the default port, leading to frequent ENR changes.

  • We were deleting port mappings before refresh as a possible workaround. This created issues in some UPnP servers. The UPnP (and PMP) specification is explicit about the refresh requirements, and delete is clearly not needed (see p2p/nat: remove forceful port mapping in upnp #30265 (comment)). From now on we only delete when closing.

  • We were trying to add port mappings only once, and then moved on to random ports. Now we insist a bit more, so that a simple failed request won't lead to ENR changes.

Fixes #31418

@cskiraly cskiraly requested review from fjl and zsfelfoldi as code owners April 4, 2025 13:00
@cskiraly cskiraly marked this pull request as draft April 4, 2025 13:03
@cskiraly cskiraly marked this pull request as ready for review April 7, 2025 11:22
Signed-off-by: Csaba Kiraly <[email protected]>
@fjl fjl changed the title p2p/nat: Fix UPnP port reset p2p/nat: fix UPnP port reset Apr 8, 2025
Signed-off-by: Csaba Kiraly <[email protected]>
@fjl fjl merged commit a7f24c2 into ethereum:master Apr 9, 2025
3 of 4 checks passed
@fjl fjl added this to the 1.15.8 milestone Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NAT UPnP continuously remapping port
2 participants