Skip to content

Commit

Permalink
NetworkServer: Disable interface if Enabled = false
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sppmacd authored and awesomekling committed Jul 14, 2022
1 parent 211ced3 commit b5708a0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Userland/Services/NetworkServer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b5708a0

Please sign in to comment.