Skip to content

Commit

Permalink
fix: correct "unset" value for latency metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mlegner committed Nov 22, 2023
1 parent ac1f2c1 commit bfe1728
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
3 changes: 2 additions & 1 deletion crates/scion-grpc/proto/daemon/v1/daemon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ message Path {
// Latency lists the latencies between any two consecutive interfaces.
// Entry i describes the latency between interface i and i+1.
// Consequently, there are N-1 entries for N interfaces.
// A 0-value indicates that the AS did not announce a latency for this hop.
// A negative value indicates that the AS did not announce a latency for
// this hop.
repeated google.protobuf.Duration latency = 6;
// Bandwidth lists the bandwidth between any two consecutive interfaces, in
// Kbit/s.
Expand Down
10 changes: 2 additions & 8 deletions crates/scion-proto/src/path/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub struct PathMetadata {
/// Latencies between any two consecutive interfaces.
/// Entry i describes the latency between interface i and i+1.
/// Consequently, there are N-1 entries for N interfaces.
/// A 0-value indicates that the AS did not announce a latency for this hop.
pub latency: Option<Vec<Option<Duration>>>,
/// The bandwidth between any two consecutive interfaces, in kbps.
/// Entry i describes the bandwidth between interfaces i and i+1.
Expand Down Expand Up @@ -108,15 +107,10 @@ impl TryFrom<daemon_grpc::Path> for PathMetadata {
let latency = some_if_length_matches!(
(grpc_path.latency, expected_count_links) =>
into_iter()
.map(|mut d| {
d.normalize();
if d.seconds < 0 {
warn!("negative path latency");
None
} else {
.map(|d| {
Duration::seconds(d.seconds)
.checked_add(&Duration::nanoseconds(d.nanos.into()))
}
.filter(|d| d >= &Duration::zero())
})
.collect()
);
Expand Down

0 comments on commit bfe1728

Please sign in to comment.