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

Kernel+route: Support global routing table deletion

This commit is contained in:
brapru 2022-04-29 21:49:00 -04:00 committed by Andreas Kling
parent 863c14c4f4
commit 0866a0cd1e
3 changed files with 21 additions and 8 deletions

View file

@ -142,7 +142,6 @@ ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address c
return ENOMEM;
TRY(routing_table().with([&](auto& table) -> ErrorOr<void> {
// TODO: Add support for deleting routing entries
if (update == UpdateTable::Set) {
for (auto const& route : table) {
if (route == *route_entry)
@ -150,6 +149,15 @@ ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address c
}
table.append(*route_entry);
}
if (update == UpdateTable::Delete) {
for (auto& route : table) {
if (route == *route_entry) {
table.remove(route);
return {};
}
}
return ESRCH;
}
return {};
}));