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.
This commit is contained in:
Thomas Eizinger
2024-11-14 02:34:17 +00:00
committed by GitHub
parent 3cf5cbb989
commit 9712942caa

View File

@@ -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]