diff options
author | Maciej <sppmacd@pm.me> | 2022-07-10 17:55:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-14 23:26:47 +0200 |
commit | b5708a084b5c615dce4bf3ae6d79c563d69cd812 (patch) | |
tree | b8704509c469f35f2d0e88415542929b12881827 /Userland/Services | |
parent | 211ced3b65085632a1eb2c3a6346232f5df6b35f (diff) | |
download | serenity-b5708a084b5c615dce4bf3ae6d79c563d69cd812.zip |
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.
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/NetworkServer/main.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Services/NetworkServer/main.cpp b/Userland/Services/NetworkServer/main.cpp index db93a076ec..14ea3e1aad 100644 --- a/Userland/Services/NetworkServer/main.cpp +++ b/Userland/Services/NetworkServer/main.cpp @@ -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; |