From 993d18e8734f081720dc7e5730af3588bec64f4f Mon Sep 17 00:00:00 2001 From: Rayhaan Jaufeerally Date: Wed, 17 Jul 2024 17:00:42 +0000 Subject: [PATCH] Remove another SystemTime reference --- crates/server/src/data_structures.rs | 7 ++++--- crates/server/src/peer.rs | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/server/src/data_structures.rs b/crates/server/src/data_structures.rs index a684c8a..deb341f 100644 --- a/crates/server/src/data_structures.rs +++ b/crates/server/src/data_structures.rs @@ -14,7 +14,8 @@ use bgp_packet::nlri::NLRI; use bgp_packet::path_attributes::PathAttribute; -use std::time::SystemTime; + +use chrono::{DateTime, Utc}; /// RouteInfo encapsulates information received about a particular BGP route. #[derive(Clone, Debug)] @@ -30,9 +31,9 @@ pub struct RouteInfo { pub rejection_reason: Option, /// Time at which this path was learned from the peer. - pub learned: SystemTime, + pub learned: DateTime, /// Time at which this path was last updated by the peer. - pub updated: SystemTime, + pub updated: DateTime, /// The current path attributes from the UPDATE message where this path /// was learned. diff --git a/crates/server/src/peer.rs b/crates/server/src/peer.rs index 3ea7ed2..7f0dbd9 100644 --- a/crates/server/src/peer.rs +++ b/crates/server/src/peer.rs @@ -45,13 +45,12 @@ use bgp_packet::path_attributes::{ }; use bgp_packet::traits::ParserContext; use bytes::BytesMut; -use chrono::{DateTime, NaiveDateTime, Offset, TimeZone, Utc}; +use chrono::{DateTime, Utc}; use eyre::{bail, eyre}; use ip_network_table_deps_treebitmap::address::Address; use ip_network_table_deps_treebitmap::IpLookupTable; use std::convert::TryFrom; use std::convert::TryInto; -use std::io::ErrorKind; use std::net::IpAddr; use std::net::SocketAddr; use std::sync::Arc; @@ -297,10 +296,12 @@ pub struct PeerStateMachine { // server_config is the server wide config that we use here for // reading global options. server_config: ServerConfig, + /// The current configuration for this peer. // To apply a new configuration the peer must be shutdown and // restarted so that the new configuration can take effect. config: PeerConfig, + // Store the peer's open message so we can reference it. peer_open_msg: Option, @@ -813,7 +814,7 @@ where // Update the route_info, we need to clone it then reassign. let mut new_route_info: RouteInfo = route_info.clone(); new_route_info.path_attributes = route_update.path_attributes.clone(); - new_route_info.updated = std::time::SystemTime::now(); + new_route_info.updated = Utc::now(); self.prefixes_in .insert(addr, announcement.prefixlen.into(), new_route_info); } @@ -825,8 +826,8 @@ where nlri: announcement.clone(), accepted, rejection_reason, - learned: std::time::SystemTime::now(), - updated: std::time::SystemTime::now(), + learned: Utc::now(), + updated: Utc::now(), path_attributes: route_update.path_attributes.clone(), }; self.prefixes_in