1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 23:07:34 +00:00

NetworkServer: Disable interface if Enabled = false

We now remove default route and set IP address to 0.0.0.0 (Kernel
interprets this as "link down") for all disabled interfaces, so that
a reboot is no longer needed.
This commit is contained in:
Maciej 2022-07-10 17:55:34 +02:00 committed by Andreas Kling
parent 211ced3b65
commit b5708a084b

View file

@ -83,8 +83,14 @@ ErrorOr<int> serenity_main(Main::Arguments)
MUST(Core::command("route"sv, { "add", "-n", "0.0.0.0", "-m", "0.0.0.0", "-g", config.ipv4_gateway, "-i", ifname }, {}));
}
}
} else {
// FIXME: Propagate errors
dbgln("Disabling interface {}", ifname);
MUST(Core::command("route", { "del", "-n", "0.0.0.0", "-m", "0.0.0.0", "-i", ifname }, {}));
MUST(Core::command("ifconfig", { "-a", ifname.characters(), "-i", "0.0.0.0", "-m", "0.0.0.0" }, {}));
}
});
if (!interfaces_with_dhcp_enabled.is_empty()) {
dbgln("Running DHCPClient for interfaces: {}", interfaces_with_dhcp_enabled);
Vector<char*> args;