Skip to content

Commit

Permalink
chore: share only incrementing errors if not a filter packet drops be…
Browse files Browse the repository at this point in the history
…tween XDP and io-uring (#1103)
  • Loading branch information
XAMPPRocky authored Feb 6, 2025
1 parent 3052f2a commit e646693
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
16 changes: 16 additions & 0 deletions src/components/proxy/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ pub enum PipelineError {
}

impl PipelineError {
/// We only want to mark potential I/O errors as errors, as they
/// can indicate something wrong with the system, error variants
/// from packets being bad aren't errors from quilkin's perspective.
pub(crate) fn inc_system_errors_total(
&self,
direction: crate::metrics::Direction,
asn_info: &crate::metrics::AsnInfo,
) {
if matches!(
self,
PipelineError::Io(_) | PipelineError::Filter(crate::filters::FilterError::Io(_))
) {
crate::metrics::errors_total(direction, &self.to_string(), asn_info).inc();
}
}

pub fn discriminant(&self) -> &'static str {
match self {
Self::NoUpstreamEndpoints => "no upstream endpoints",
Expand Down
10 changes: 1 addition & 9 deletions src/components/proxy/packet_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,7 @@ impl<P: PacketMut> DownstreamPacket<P> {
if let Err(error) = self.process_inner(config, sessions, destinations) {
let discriminant = error.discriminant();

// We only want to mark potential I/O errors as errors, as they
// can indicate something wrong with the system, error variants
// from packets being bad aren't errors from quilkin's perspective.
if matches!(
error,
PipelineError::Io(_) | PipelineError::Filter(crate::filters::FilterError::Io(_))
) {
metrics::errors_total(metrics::READ, discriminant, &metrics::EMPTY).inc();
}
error.inc_system_errors_total(metrics::READ, &metrics::EMPTY);
metrics::packets_dropped_total(metrics::READ, discriminant, &metrics::EMPTY).inc();
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/xdp/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ pub fn process_packets(
}
Err((error, packet)) => {
let discriminant = error.discriminant();
metrics::errors_total(direction, discriminant, &metrics::EMPTY).inc();
error.inc_system_errors_total(direction, &metrics::EMPTY);
metrics::packets_dropped_total(direction, discriminant, &metrics::EMPTY).inc();

umem.free_packet(packet);
Expand Down

0 comments on commit e646693

Please sign in to comment.