Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions quest/m2/cluster-routes/mount-scope.md

This file was deleted.

3 changes: 2 additions & 1 deletion rs/moq-net/src/route/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,8 @@ impl Stream {
tag,
node: state.router.hop_of(self.key),
};
// A mount hears nothing, so it asks for nothing and files nothing.
// A mount hears nothing, so it asks for nothing and files nothing; it closes under
// its session's scope (`Router::disconnect`), which a permit may change.
let link = Link {
scope: None,
interest: BTreeSet::new(),
Expand Down
29 changes: 29 additions & 0 deletions rs/moq-net/src/route/node/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,35 @@ fn a_closed_session_takes_its_mounts() {
assert_eq!(relay.lock().router.neighbors(), 0);
}

/// A scoped session's close doubts no node, since a scoped peer names itself as it likes,
/// and an unscoped one doubts the Node ID it declared, whether or not a mount of it is
/// open. A mount closes under the scope its session holds then, here one set after the
/// mount opened.
#[test]
fn a_session_closing_with_its_mounts_doubts_only_if_unscoped() {
for scoped in [false, true] {
for mounted in [false, true] {
let relay = Node::new(2, 2, clock());
let session = relay.answer(peer(1, 10), Link::default(), p("other")).unwrap();
let mount = mounted.then(|| session.mount(p("live")).unwrap());
let scope = scoped.then(|| crate::route::Scope {
regions: vec![p("live")],
qualify: crate::route::qualifier([7; 32]),
});
let link = Link {
scope,
interest: Default::default(),
..Default::default()
};
session.relink(link, false).unwrap();
drop(session);
drop(mount);
let doubt = relay.lock().router.retained().doubt;
assert_eq!(doubt, usize::from(!scoped), "scoped {scoped}, mounted {mounted}");
}
}
}

/// The origin declares its hop id, without the qualified marker, or a random
/// identity when nothing is left of it.
#[test]
Expand Down
13 changes: 11 additions & 2 deletions rs/moq-net/src/route/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,9 +1117,18 @@ impl<N: Key, A: Item> Router<N, A> {
/// goes, and each names its hop to the others.
pub fn disconnect(&mut self, neighbors: impl IntoIterator<Item = N>, now: Instant) {
self.clock(now);
// A mount speaks for the session it answers, so it closes under that session's
// scope, read before any of them go.
let neighbors: Vec<(N, bool)> = (neighbors.into_iter())
.map(|neighbor| {
let scoped =
(self.sessions.get(&self.listen(neighbor))).is_some_and(|session| session.link.scope.is_some());
(neighbor, scoped)
})
.collect();
let mut ids = BTreeSet::new();
let mut hops = Vec::new();
for neighbor in neighbors {
for (neighbor, scoped) in neighbors {
let Some(session) = self.sessions.remove(&neighbor) else {
continue;
};
Expand All @@ -1144,7 +1153,7 @@ impl<N: Key, A: Item> Router<N, A> {
ids.extend(self.fail(hop, session.hop, None, Vec::new(), false, now));
// A scoped peer names itself as it likes, so its close neither doubts that node
// nor names it to the neighbours: the routes it sent end one by one instead.
if session.link.scope.is_none() {
if !scoped {
ids.extend(self.suspect(session.hop, now));
hops.push(Report::Closed(hop));
}
Expand Down