Skip to content

fix(iroh): Always update the best addr after changes #3422

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

Merged
merged 3 commits into from
Aug 1, 2025

Conversation

matheus23
Copy link
Member

@matheus23 matheus23 commented Jul 31, 2025

Description

There was a bug where in NodeMap::add_node_addr wouldn't cause an update to the NodeUdpState::best addr, because we wouldn't call NodeUdpState::udpate_best_addr after changes in NodeState::update_from_node_addr.

In an effort to fix this class of bugs once and for all, I've made NodeUdpState::paths private and added guarded access. The access guard has a Drop implementation that calls update_best_addr.

We originally saw this bug as an error message in iroh-blobs tests:
image


While making NodeUdpState's fields private, I noticed that NodeUdpState::best was sometimes accessed instead of NodeUdpState::send_addr. This is now fixed, but required passing through the have_ipv6 boolean quite a bit, so that's why the diff is slightly bigger.
Feel free to look at commits in isolation instead.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.

Copy link

github-actions bot commented Jul 31, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3422/docs/iroh/

Last updated: 2025-07-31T14:00:22Z

Copy link

github-actions bot commented Jul 31, 2025

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 062bef3

@matheus23 matheus23 marked this pull request as ready for review July 31, 2025 13:58
@n0bot n0bot bot added this to iroh Jul 31, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Jul 31, 2025
best_ipv4: UdpSendAddr,
}

pub(super) struct MutAccess<'a> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool. Have you considered moving all the logic that needs to have access to the internals here to be methods on the NodeUdpPaths itself and protecting access and ensuring updating of best addr that way? I think it's what I would have gone for, or at least tried. I appreciate this is less changes.

I'm also aware that all these changes interact with the changes needed for multipath... and I haven't wrapped my head around what those are yet so don't know if more or less cleaning up here is helpful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had considered that. Would've been substantially more changes I guess

@matheus23 matheus23 added this pull request to the merge queue Aug 1, 2025
Merged via the queue into main with commit 36842d5 Aug 1, 2025
29 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Aug 1, 2025
@matheus23 matheus23 deleted the matheus23/always-update-best-addr branch August 1, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants