qdisc: expose traffic shaping info via netcfg and LinkDevice trait

LinkDevice gains qdisc_info() → String defaulting to 'none'.
EthernetLink reports current qdisc configuration:
  none  /  token_bucket rate=N burst=N tokens=N  /  priority_queue len=N max=N

TokenBucket and PriorityQueue gain public accessor methods:
  rate(), burst(), tokens() / max_len()

netcfg exposes at /scheme/netcfg/ifaces/eth0/qdisc:
  cat /scheme/netcfg/ifaces/eth0/qdisc  →  'none' (default)

Enables monitoring tools to discover current traffic shaping.
Future: wo node for configuring qdisc type + parameters.
This commit is contained in:
Red Bear OS
2026-07-08 17:50:31 +03:00
parent 7abd45bf2e
commit c1cfee3bea
4 changed files with 30 additions and 12 deletions
+6 -12
View File
@@ -25,13 +25,11 @@ pub struct TokenBucket {
impl TokenBucket {
pub fn new(rate_bps: u64, burst_bytes: u64) -> Self {
Self {
rate: rate_bps,
burst: burst_bytes.max(1500),
tokens: burst_bytes.max(1500),
last_update: Instant::from_millis(0),
}
Self { rate: rate_bps, burst: burst_bytes.max(1500), tokens: burst_bytes.max(1500), last_update: Instant::from_millis(0) }
}
pub fn rate(&self) -> u64 { self.rate }
pub fn burst(&self) -> u64 { self.burst }
pub fn tokens(&self) -> u64 { self.tokens }
pub fn set_rate(&mut self, rate_bps: u64) {
self.rate = rate_bps;
@@ -67,12 +65,8 @@ pub struct PriorityQueue {
}
impl PriorityQueue {
pub fn new(max_len: usize) -> Self {
Self {
bands: [VecDeque::new(), VecDeque::new(), VecDeque::new()],
max_len,
}
}
pub fn new(max_len: usize) -> Self { Self { bands: [VecDeque::new(), VecDeque::new(), VecDeque::new()], max_len } }
pub fn max_len(&self) -> usize { self.max_len }
fn classify(packet: &[u8]) -> usize {
if packet.len() < 2 || packet[0] >> 4 != 4 {