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:
@@ -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;
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -478,8 +478,9 @@ fn mk_root_node(
|
||||
match devices.borrow().get("eth0") {
|
||||
Some(dev) => {
|
||||
let s = dev.statistics();
|
||||
format!("rx_bytes={} rx_packets={} tx_bytes={} tx_packets={} mtu={} link={}\n",
|
||||
format!("rx_bytes={} rx_packets={} tx_bytes={} tx_packets={} rx_errors={} tx_errors={} rx_dropped={} tx_dropped={} mtu={} link={}\n",
|
||||
s.rx_bytes, s.rx_packets, s.tx_bytes, s.tx_packets,
|
||||
s.rx_errors, s.tx_errors, s.rx_dropped, s.tx_dropped,
|
||||
dev.mtu(), dev.link_state())
|
||||
}
|
||||
None => "Device not found\n".into(),
|
||||
@@ -591,8 +592,9 @@ fn mk_root_node(
|
||||
match devices.borrow().get("loopback") {
|
||||
Some(dev) => {
|
||||
let s = dev.statistics();
|
||||
format!("rx_bytes={} rx_packets={} tx_bytes={} tx_packets={} mtu={} link={}\n",
|
||||
format!("rx_bytes={} rx_packets={} tx_bytes={} tx_packets={} rx_errors={} tx_errors={} rx_dropped={} tx_dropped={} mtu={} link={}\n",
|
||||
s.rx_bytes, s.rx_packets, s.tx_bytes, s.tx_packets,
|
||||
s.rx_errors, s.tx_errors, s.rx_dropped, s.tx_dropped,
|
||||
dev.mtu(), dev.link_state())
|
||||
}
|
||||
None => "Device not found\n".into(),
|
||||
|
||||
Reference in New Issue
Block a user