Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix/routing: ensure messages are backloged when not yet elder
Browse files Browse the repository at this point in the history
Messages were still dropped when not in Elder state.
Ensure the message are backlogged, and trace appropriatly.

Also improve error logging.

Test:
Clippy + soak test
  • Loading branch information
Jean-Philippe DUFRAIGNE committed Oct 25, 2019
1 parent 7fffc81 commit eb1653b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/states/adult.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,25 @@ impl Base for Adult {
) -> Result<Transition, RoutingError> {
let HopMessage { content: msg, .. } = msg;

if self
if !self
.routing_msg_filter
.filter_incoming(msg.routing_message())
.is_new()
&& self.in_authority(&msg.routing_message().dst)
{
trace!(
"{} Known message: {:?} - not handling further",
self,
msg.routing_message()
);
return Ok(Transition::Stay);
}

if self.in_authority(&msg.routing_message().dst) {
self.check_signed_message_integrity(&msg)?;
self.dispatch_routing_message(msg, outbox)?;
} else {
self.msg_backlog.push(msg);
}

Ok(Transition::Stay)
}

Expand Down
13 changes: 11 additions & 2 deletions src/states/joining_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,24 @@ impl Base for JoiningPeer {
) -> Result<Transition, RoutingError> {
let HopMessage { content: msg, .. } = msg;

if self
if !self
.routing_msg_filter
.filter_incoming(msg.routing_message())
.is_new()
&& self.in_authority(&msg.routing_message().dst)
{
trace!(
"{} Known message: {:?} - not handling further",
self,
msg.routing_message()
);
return Ok(Transition::Stay);
}

if self.in_authority(&msg.routing_message().dst) {
self.check_signed_message_integrity(&msg)?;
self.dispatch_routing_message(msg, outbox)
} else {
self.msg_backlog.push(msg);
Ok(Transition::Stay)
}
}
Expand Down
7 changes: 4 additions & 3 deletions tests/mock_network/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ pub fn verify_section_invariants_for_node(node: &TestNode, min_section_size: usi
{
panic!(
"Our prefix is compatible with one of the neighbour prefixes:\
us: {:?} / neighbour: {:?}",
our_prefix, compatible_prefix,
us: {:?} / neighbour: {:?}, neighbour_prefixes: {:?}",
our_prefix, compatible_prefix, neighbour_prefixes,
);
}

Expand All @@ -667,11 +667,12 @@ pub fn verify_section_invariants_for_node(node: &TestNode, min_section_size: usi
.find(|prefix| node.inner.section_elders(prefix).len() < min_section_size)
{
panic!(
"A section is below the minimum size: size({:?}) = {}; For ({:?}: {:?})",
"A section is below the minimum size: size({:?}) = {}; For ({:?}: {:?}), neighbour_prefixes: {:?}",
prefix,
node.inner.section_elders(prefix).len(),
our_name,
our_prefix,
neighbour_prefixes,
);
}

Expand Down

0 comments on commit eb1653b

Please sign in to comment.