route: flush node — clear entire routing table

New /scheme/netcfg/route/flush clears all routes at once:
  echo > /scheme/netcfg/route/flush

Mirrors Linux 'ip route flush all'.

Replaces the route table with a new empty RouteTable. All
existing Rc shares see the change immediately. Useful for
bulk route management (clear and re-add). Notifies route/list
subscribers after flush.

All 31 tests pass.
This commit is contained in:
Red Bear OS
2026-07-09 11:16:33 +03:00
parent 6864302cdb
commit 9dcd809778
+15 -4
View File
@@ -128,7 +128,7 @@ fn mk_root_node(
nat — NAT bindings (bindings / stats)\n\
capture — packet capture (enable/read/filter/count)\n\
sysctl — kernel tunables (net/ipv4/ip_forward)\n\
route — routing table (list/add/rm/count/gateway)\n\
route — routing table (list/add/rm/flush/count/gateway)\n\
resolv — DNS configuration (nameserver/nameserver6)\n\
ifaces — per-interface config/stats (eth0/lo/...)\n\
version — netstack version info\n"
@@ -566,9 +566,20 @@ fn mk_root_node(
notifier.borrow_mut().schedule_notify("route/list");
}
Ok(())
}
},
},
}
},
"flush" => {
wo [route_table, notifier] (Option<()>, None)
|_cur_value, _line| {
Ok(())
}
|_cur_value| {
*route_table.borrow_mut() = RouteTable::default();
notifier.borrow_mut().schedule_notify("route/list");
Ok(())
}
},
},
"arp" => {
"list" => {
ro [devices] || {