Skip to content

Commit

Permalink
Ignore normal errors (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle authored Feb 26, 2025
1 parent d4733c5 commit 057ae5b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
42 changes: 39 additions & 3 deletions src/net/xdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,24 +447,60 @@ fn io_loop(

// Ensure the fill ring doesn't get starved, which could drop packets
if let Err(error) = fill.enqueue(&mut umem, BATCH_SIZE * 2 - recvd, true) {
tracing::error!(%error, "RX kick failed");
// This is shoehorning an error that isn't attributable to a particular packet
crate::metrics::errors_total(
crate::metrics::Direction::Read,
&io_error_to_discriminant(error),
&crate::metrics::EMPTY,
)
.inc();
}

// Process each of the packets that we received, potentially queuing
// packets to be sent
process::process_packets(&mut rx_slab, &mut umem, &mut tx_slab, &mut state);

let before = tx_slab.len();
let enqueued_sends = match tx.send(&mut tx_slab, true) {
Ok(es) => es,
Err(error) => {
tracing::error!(%error, "TX kick failed");
// These are all temporary errors that can occur during normal
// operation
// if !matches!(
// error.raw_os_error(),
// Some(libc::EBUSY | libc::ENOBUFS | libc::EAGAIN | libc::ENETDOWN)
// ) {
// This is shoehorning an error that isn't attributable to a particular packet
crate::metrics::errors_total(
crate::metrics::Direction::Read,
&io_error_to_discriminant(error),
&crate::metrics::EMPTY,
)
.inc();
//}

before - tx_slab.len()
}
};

// Return frames that have completed sending
pending_sends -= completion.dequeue(&mut umem, pending_sends);
pending_sends += enqueued_sends;
pending_sends -= completion.dequeue(&mut umem, pending_sends);
}
}
}

#[inline]
fn io_error_to_discriminant(error: std::io::Error) -> std::borrow::Cow<'static, str> {
let Some(code) = error.raw_os_error() else {
return error.to_string().into();
};

match code {
libc::EBUSY => "EBUSY".into(),
libc::ENOBUFS => "ENOBUFS".into(),
libc::EAGAIN => "EAGAIN".into(),
libc::ENETDOWN => "ENETDOWN".into(),
other => format!("{other}").into(),
}
}
7 changes: 7 additions & 0 deletions src/net/xdp/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ pub fn process_packets(
metrics::WRITE
};

// This indicates a packet that is split, which we don't handle _at all_ right now
if inner.is_continued() {
metrics::packets_dropped_total(direction, "split packet", &metrics::EMPTY).inc();
umem.free_packet(inner);
continue;
}

let packet = PacketWrapper { inner, udp };

let res = {
Expand Down

0 comments on commit 057ae5b

Please sign in to comment.