Skip to content

Commit

Permalink
Remove explicit peer address from trace log
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonbaeten committed Oct 24, 2023
1 parent 087f3ff commit 89312cc
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions ntpd/src/daemon/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ impl<C: 'static + NtpClock + Send> ServerTask<C> {
}
Ok((length, peer_addr, opt_timestamp)) => {
// FIXME: maybe perform min length and '%4' checks here to reduce work for those packets?

let request_buf = &buf[..length];
let mut response_buf = [0; MAX_PACKET_SIZE];
let response_buf = response_buf.as_mut_slice();
Expand Down Expand Up @@ -379,7 +378,7 @@ impl<C: 'static + NtpClock + Send> ServerTask<C> {
return None;
}

let accept_result = self.accept_packet(request_buf, peer_addr, timestamp, filter_result);
let accept_result = self.accept_packet(request_buf, timestamp, filter_result);

self.stats.update_from(&accept_result);

Expand Down Expand Up @@ -506,12 +505,11 @@ impl<C: 'static + NtpClock + Send> ServerTask<C> {
fn accept_packet<'a>(
&self,
buf: &'a [u8],
peer_addr: SocketAddr,
recv_timestamp: NtpTimestamp,
filter_result: Result<(), FilterReason>,
) -> AcceptResult<'a> {
// actually parse the packet
let accept_data = self.accept_data(buf, peer_addr, recv_timestamp);
let accept_data = self.accept_data(buf, recv_timestamp);

match filter_result {
Ok(_) => accept_data,
Expand All @@ -525,29 +523,20 @@ impl<C: 'static + NtpClock + Send> ServerTask<C> {
/// - check if the packet can even be deserialized
/// - check if it was successfully decrypted (and authenticated)
/// - check if it was a request packet (`Client` prior to NTPv5)
fn accept_data<'a>(
&self,
buf: &'a [u8],
peer_addr: SocketAddr,
recv_timestamp: NtpTimestamp,
) -> AcceptResult<'a> {
fn accept_data<'a>(&self, buf: &'a [u8], recv_timestamp: NtpTimestamp) -> AcceptResult<'a> {
let keyset = self.keyset.borrow().clone();
match NtpPacket::deserialize(buf, keyset.as_ref()) {
Ok((packet, decoded_cookie)) => match packet.mode() {
NtpAssociationMode::Client => {
trace!("NTP client request accepted from {}", peer_addr); // TODO: move peer_addr to a tracing::span
trace!("NTP client request accepted");
AcceptResult::Accept {
packet,
decoded_cookie,
recv_timestamp,
}
}
_ => {
trace!(
"NTP packet with unknown mode {:?} ignored from {}",
packet.mode(),
peer_addr
);
trace!("NTP packet with unknown mode {:?} ignored", packet.mode());
AcceptResult::Ignore
}
},
Expand Down

0 comments on commit 89312cc

Please sign in to comment.