stats: add rx_errors, tx_errors, rx_dropped, tx_dropped counters

Stats struct gains 4 new u64 fields per RFC 1213 (MIB-II):
- rx_errors: incoming packets with errors
- tx_errors: outgoing packets with errors
- rx_dropped: incoming packets dropped (buffer full, etc.)
- tx_dropped: outgoing packets dropped (qdisc dropped, buffer full)

EthernetLink tx path now increments tx_dropped when qdisc returns None
(qdisc decided to drop the packet, e.g., TokenBucket rate exceeded).

netcfg stats output now exposes all 8 counters:
  rx_bytes=N rx_packets=N tx_bytes=N tx_packets=N
  rx_errors=N tx_errors=N rx_dropped=N tx_dropped=N
  mtu=N link=up

Aggregate fields work for bridge/bond via existing sum logic.
This commit is contained in:
Red Bear OS
2026-07-08 18:35:22 +03:00
parent f3c18f410c
commit 82d8a049cc
3 changed files with 9 additions and 2 deletions
+1
View File
@@ -711,6 +711,7 @@ impl LinkDevice for EthernetLink {
let owned = self.qdisc_config.enqueue_and_dequeue(packet.to_vec(), now);
let Some(packet) = owned else {
self.stats.tx_dropped += 1;
return;
};
self.stats.tx_packets += 1;
+4
View File
@@ -84,6 +84,10 @@ pub struct Stats {
pub rx_packets: u64,
pub tx_bytes: u64,
pub tx_packets: u64,
pub rx_errors: u64,
pub tx_errors: u64,
pub rx_dropped: u64,
pub tx_dropped: u64,
}
#[derive(Default)]