netcfg: interface enable/disable control (ip link set eth0 down/up)

LinkDevice trait gains is_enabled() and set_enabled() with defaults.
EthernetLink stores enabled flag (default: true). When disabled,
link_state() reports 'down' regardless of hardware_address presence.

netcfg/ifaces/eth0/enabled is rw:
  cat /scheme/netcfg/ifaces/eth0/enabled  →  'up' or 'down'
  echo up   > .../enabled  →  bring interface up
  echo down > .../enabled  →  bring interface down
  echo on/off/1/0/yes/no  →  also accepted

Mirrors Linux 'ip link set dev <state>'.

Pre-existing link state (hardware_address Some/None) unchanged;
the enabled flag adds a software override layer that can be
toggled without restarting the netstack.
This commit is contained in:
Red Bear OS
2026-07-08 18:24:02 +03:00
parent 89083a25f9
commit 9bab466704
4 changed files with 58 additions and 2 deletions
+6
View File
@@ -59,6 +59,12 @@ pub trait LinkDevice {
fn set_mtu(&mut self, _mtu: usize) {}
fn is_enabled(&self) -> bool {
true
}
fn set_enabled(&mut self, _enabled: bool) {}
fn link_state(&self) -> &'static str {
"unknown"
}