mtu: per-interface MTU configuration via netcfg

LinkDevice trait gains set_mtu(mtu) with default no-op.
EthernetLink stores mtu in field, clamped to 576-9000 (RFC 791 min/max).

netcfg/ifaces/eth0/mtu becomes rw:
  cat /scheme/netcfg/ifaces/eth0/mtu  →  '1500' (default)
  echo 1400 > .../mtu  →  VPN MTU
  echo 9000 > .../mtu  →  jumbo frames

Clamped to [576, 9000]:
- 576: minimum for IPv4 (RFC 791)
- 9000: standard jumbo frame MTU

Useful for VPNs (MTU 1400 to avoid fragmentation through tunnel overhead),
jumbo frames (MTU 9000 on datacenter networks), and constrained paths.
This commit is contained in:
Red Bear OS
2026-07-08 17:57:16 +03:00
parent c1cfee3bea
commit c015a375b1
3 changed files with 26 additions and 1 deletions
+10
View File
@@ -86,6 +86,7 @@ pub struct EthernetLink {
hardware_address: Option<EthernetAddress>,
ip_address: Option<IpCidr>,
qdisc_config: QdiscConfig,
mtu: usize,
stats: Stats,
arp_requests: u64,
arp_replies: u64,
@@ -121,6 +122,7 @@ impl EthernetLink {
ndp_state: Default::default(),
slaac_state: Default::default(),
qdisc_config: QdiscConfig::default(),
mtu: Self::MTU,
stats: Stats::default(),
neighbor_cache: Default::default(),
arp_requests: 0,
@@ -894,5 +896,13 @@ impl LinkDevice for EthernetLink {
}
}
}
fn mtu(&self) -> usize {
self.mtu
}
fn set_mtu(&mut self, mtu: usize) {
self.mtu = mtu.clamp(576, 9000);
}
}
+2
View File
@@ -57,6 +57,8 @@ pub trait LinkDevice {
1500
}
fn set_mtu(&mut self, _mtu: usize) {}
fn link_state(&self) -> &'static str {
"unknown"
}