From 1fad3ab869321c2c8304739087fff00ca27ef39a Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Wed, 8 Jul 2026 18:44:55 +0300 Subject: [PATCH] route: add /scheme/netcfg/route/gateway read-only node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reads the default gateway from the route table: cat /scheme/netcfg/route/gateway → 'default via 192.168.1.1\n' or 'no default route\n' if no default gateway configured. Looks up the route for 0.0.0.0 (the default route CIDR) and returns its 'via' address. Mirrors Linux 'ip route show default'. --- netstack/src/scheme/netcfg/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/netstack/src/scheme/netcfg/mod.rs b/netstack/src/scheme/netcfg/mod.rs index 0b00a33d6b..9963497519 100644 --- a/netstack/src/scheme/netcfg/mod.rs +++ b/netstack/src/scheme/netcfg/mod.rs @@ -266,6 +266,17 @@ fn mk_root_node( format!("routes: {}\n", count) } }, + "gateway" => { + ro [route_table] || { + let table = route_table.borrow(); + let zero: IpAddress = IpAddress::v4(0, 0, 0, 0); + let gw = table.lookup_gateway(&zero); + match gw { + Some(addr) => format!("default via {}\n", addr), + None => "no default route\n".to_string(), + } + } + }, "add" => { wo [iface, notifier, route_table] (Option, None) |cur_value, line| {