Skip to content

Commit

Permalink
Allow v3 responses to v4 client requests
Browse files Browse the repository at this point in the history
  • Loading branch information
rnijveld authored and davidv1992 committed Jun 26, 2024
1 parent 8dc8cdf commit 42d6f75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions ntp-proto/src/algorithm/kalman/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::config::SynchronizationConfig;

use super::{config::AlgorithmConfig, SourceSnapshot};

#[derive(Debug)]
enum BoundType {
Start,
End,
Expand Down
18 changes: 13 additions & 5 deletions ntp-proto/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ pub enum ProtocolVersion {
}

impl ProtocolVersion {
pub fn expected_incoming_version(&self) -> u8 {
pub fn is_expected_incoming_version(&self, incoming_version: u8) -> bool {
match self {
ProtocolVersion::V4 => 4,
ProtocolVersion::V4 => incoming_version == 4 || incoming_version == 3,
#[cfg(feature = "ntpv5")]
ProtocolVersion::V4UpgradingToV5 { .. } => 4,
ProtocolVersion::V4UpgradingToV5 { .. } => incoming_version == 4,
#[cfg(feature = "ntpv5")]
ProtocolVersion::V5 => 5,
ProtocolVersion::V5 => incoming_version == 5,
}
}
}
Expand Down Expand Up @@ -619,7 +619,15 @@ impl<Controller: SourceController> NtpSource<Controller> {
}
};

if message.version() != self.protocol_version.expected_incoming_version() {
if !self
.protocol_version
.is_expected_incoming_version(message.version())
{
warn!(
incoming_version = message.version(),
expected_version = ?self.protocol_version,
"Received packet with unexpected version from source"
);
return actions!();
}

Expand Down

0 comments on commit 42d6f75

Please sign in to comment.