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.
This commit is contained in:
Red Bear OS
2026-07-08 18:42:57 +03:00
parent 22d05e5f89
commit 649ba27669
+3
View File
@@ -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;
};