From 649ba27669d3858223dd8b154bb6e2c46e8ad85f Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Wed, 8 Jul 2026 18:42:57 +0300 Subject: [PATCH] stats: track rx_errors (malformed ARP/frame) + tx_errors (network write fail) All 4 RFC 1213 counters now wired to real events: - rx_errors: malformed Ethernet frame or ARP packet - tx_errors: network_file.write_all() failed - rx_dropped: ARP/NDP neighbor resolution failed or queue full - tx_dropped: qdisc returned None (rate-limit kicked in) Stats output now reflects actual error/drop conditions. Mirrors Linux's ifconfig/sar 'errors' and 'dropped' fields. --- netstack/src/link/ethernet.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/netstack/src/link/ethernet.rs b/netstack/src/link/ethernet.rs index c10f504552..d53ea1849d 100644 --- a/netstack/src/link/ethernet.rs +++ b/netstack/src/link/ethernet.rs @@ -156,6 +156,7 @@ impl EthernetLink { f(frame.payload_mut()); if let Err(_) = self.network_file.write_all(&self.output_buffer) { + self.stats.tx_errors += 1; error!( "Dropped outboud packet on {} (failed to write to network file)", self.name @@ -175,6 +176,7 @@ impl EthernetLink { let Ok(repr) = ArpPacket::new_checked(packet).and_then(|packet| ArpRepr::parse(&packet)) else { debug!("Dropped incomming arp packet on {} (Malformed)", self.name); + self.stats.rx_errors += 1; return; }; @@ -787,6 +789,7 @@ impl LinkDevice for EthernetLink { let packet = EthernetFrame::new_unchecked(&input_buffer[..]); let Ok(repr) = EthernetRepr::parse(&packet) else { debug!("Dropped incomming frame on {} (Malformed)", self.name); + self.stats.rx_errors += 1; continue; };