From 9712942caa1c8b432af347b2ab2a516a914da26b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 14 Nov 2024 02:34:17 +0000 Subject: [PATCH] chore(connlib): add logs and error handling on bad stride (#7339) In order to narrow down #7332, we are now checking the stride length and report oddities such as `string > len` as an error to the event-loop. --- rust/socket-factory/src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rust/socket-factory/src/lib.rs b/rust/socket-factory/src/lib.rs index eb02cf8ef..8ccefe116 100644 --- a/rust/socket-factory/src/lib.rs +++ b/rust/socket-factory/src/lib.rs @@ -236,6 +236,24 @@ impl UdpSocket { continue; }; + match meta.stride.cmp(&meta.len) { + std::cmp::Ordering::Equal => {} + std::cmp::Ordering::Less => { + let num_packets = meta.len / meta.stride; + + tracing::trace!(%num_packets, size = %meta.stride, "Read packets using GRO"); + } + std::cmp::Ordering::Greater => { + return Poll::Ready(Err(io::Error::new( + io::ErrorKind::InvalidData, + format!( + "stride ({}) is larger than buffer len ({})", + meta.stride, meta.len + ), + ))) + } + } + let local = SocketAddr::new(local_ip, *port); let iter = buffer[..meta.len]