n0-computer / n0-computer/noq

Make it possible to pass around `&mut <path related state>`

Open
#313 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

multipath refactor
Dominant language
Rust
Stars
413
Forks
63
Avg merge
4d 14m
Merged PRs (30d)
4

Description

Problem

Currently, we call .get(&path_id) and .get_mut(&path_id) again and again.
We do so with Connection::paths, Connection::rem_cids, Connection::local_cid_state, Connection::path_stats, and PacketSpace::number_spaces.

We don't re-use the results from .get or .get_mut, because these end up borrowing &mut Connection, during their lifetime we can't call functions that operate on the connection.

Proposed solution

Ideally, we separate out the all the non-path-specific state in Connection from the path-specific state, so that these borrows don't get into each other's way.

Notes

In the past, when we've tried to make this refactor, we found some parts that make this hard, e.g. the pto_max_path that needs to traverse all paths, thus we can't hold a borrow of a path at the same time.
Another issue is when we need to operate on two paths at the same time. That can be required e.g. when we want to send PATH_ABANDONs. We both need access to the path that we're currently abandoning, as well as another open path that we actually send the PATH_ABANDON on. There exists HashMap::get_disjoint_mut, but there's no equivalent for BTreeMap, unfortunately.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the .get and .get_mut call sites involving Connection::paths, rem_cids, local_cid_state, path_stats, and PacketSpace::number_spaces. Read the handling of pto_max_path and PATH_ABANDON operations to understand the cross-path borrowing constraints. Done means path-specific and connection-wide state can be borrowed independently without breaking multi-path operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.