diff --git a/controller/src/handler.rs b/controller/src/handler.rs index ab66722c9..3afb94de5 100644 --- a/controller/src/handler.rs +++ b/controller/src/handler.rs @@ -263,7 +263,7 @@ impl InnerProtocol for Handler { PacketHandlerResult::NotHandled } - fn should_communicate_with(&self, _: &Identity) -> bool { + fn should_respond_to(&self, _: &Identity) -> bool { true } } diff --git a/network-hypervisor/src/vl1/node.rs b/network-hypervisor/src/vl1/node.rs index d642a97d9..a32f397c4 100644 --- a/network-hypervisor/src/vl1/node.rs +++ b/network-hypervisor/src/vl1/node.rs @@ -93,15 +93,23 @@ pub trait NodeStorage: Sync + Send { /// Trait to be implemented to provide path hints and a filter to approve physical paths. pub trait PathFilter: Sync + Send { /// Called to check and see if a physical address should be used for ZeroTier traffic to a node. + /// + /// The default implementation always returns true. + #[allow(unused_variables)] fn should_use_physical_path( &self, id: &Identity, endpoint: &Endpoint, local_socket: Option<&HostSystemImpl::LocalSocket>, local_interface: Option<&HostSystemImpl::LocalInterface>, - ) -> bool; + ) -> bool { + true + } /// Called to look up any statically defined or memorized paths to known nodes. + /// + /// The default implementation always returns None. + #[allow(unused_variables)] fn get_path_hints( &self, id: &Identity, @@ -111,7 +119,9 @@ pub trait PathFilter: Sync + Send { Option, Option, )>, - >; + > { + None + } } /// Result of a packet handler. @@ -177,8 +187,8 @@ pub trait InnerProtocol: Sync + Send { cursor: &mut usize, ) -> PacketHandlerResult; - /// Check if this peer should communicate with another at all. - fn should_communicate_with(&self, id: &Identity) -> bool; + /// Check if this node should respond to messages from a given peer. + fn should_respond_to(&self, id: &Identity) -> bool; } /// How often to check the root cluster definitions against the root list and update. @@ -945,7 +955,7 @@ impl Node { let mut whois_queue = self.whois_queue.lock().unwrap(); if let Some(qi) = whois_queue.get_mut(&received_identity.address) { let address = received_identity.address; - if inner.should_communicate_with(&received_identity) { + if inner.should_respond_to(&received_identity) { let mut peers = self.peers.write().unwrap(); if let Some(peer) = peers.get(&address).cloned().or_else(|| { Peer::new(&self.identity, received_identity, time_ticks) @@ -1122,7 +1132,7 @@ impl InnerProtocol for DummyInnerProtocol { } #[inline(always)] - fn should_communicate_with(&self, _id: &Identity) -> bool { + fn should_respond_to(&self, _id: &Identity) -> bool { true } } @@ -1131,29 +1141,4 @@ impl InnerProtocol for DummyInnerProtocol { #[derive(Default)] pub struct DummyPathFilter; -impl PathFilter for DummyPathFilter { - #[inline(always)] - fn should_use_physical_path( - &self, - _id: &Identity, - _endpoint: &Endpoint, - _local_socket: Option<&::LocalSocket>, - _local_interface: Option<&::LocalInterface>, - ) -> bool { - true - } - - #[inline(always)] - fn get_path_hints( - &self, - _id: &Identity, - ) -> Option< - Vec<( - Endpoint, - Option<::LocalSocket>, - Option<::LocalInterface>, - )>, - > { - None - } -} +impl PathFilter for DummyPathFilter {} diff --git a/network-hypervisor/src/vl1/peer.rs b/network-hypervisor/src/vl1/peer.rs index 43d1a28aa..15bcf1c8b 100644 --- a/network-hypervisor/src/vl1/peer.rs +++ b/network-hypervisor/src/vl1/peer.rs @@ -603,7 +603,7 @@ impl Peer { source_path: &Arc, payload: &PacketBuffer, ) -> PacketHandlerResult { - if !(inner.should_communicate_with(&self.identity) || node.this_node_is_root() || node.is_peer_root(self)) { + if !(inner.should_respond_to(&self.identity) || node.this_node_is_root() || node.is_peer_root(self)) { debug_event!( host_system, "[vl1] dropping HELLO from {} due to lack of trust relationship", @@ -800,7 +800,7 @@ impl Peer { message_id: MessageId, payload: &PacketBuffer, ) -> PacketHandlerResult { - if node.this_node_is_root() || inner.should_communicate_with(&self.identity) { + if node.this_node_is_root() || inner.should_respond_to(&self.identity) { let mut addresses = payload.as_bytes(); while addresses.len() >= ADDRESS_SIZE { if !self @@ -846,7 +846,7 @@ impl Peer { message_id: MessageId, payload: &PacketBuffer, ) -> PacketHandlerResult { - if inner.should_communicate_with(&self.identity) || node.is_peer_root(self) { + if inner.should_respond_to(&self.identity) || node.is_peer_root(self) { self.send(host_system, node, None, time_ticks, |packet| { let mut f: &mut OkHeader = packet.append_struct_get_mut().unwrap(); f.verb = verbs::VL1_OK; diff --git a/network-hypervisor/src/vl2/switch.rs b/network-hypervisor/src/vl2/switch.rs index 5372b2b88..9be3dbd10 100644 --- a/network-hypervisor/src/vl2/switch.rs +++ b/network-hypervisor/src/vl2/switch.rs @@ -58,7 +58,7 @@ impl InnerProtocol for Switch { PacketHandlerResult::NotHandled } - fn should_communicate_with(&self, id: &Identity) -> bool { + fn should_respond_to(&self, id: &Identity) -> bool { true } }