summaryrefslogtreecommitdiff
path: root/Kernel/Net/Routing.cpp
diff options
context:
space:
mode:
authorbrapru <brapru@pm.me>2022-04-29 21:49:00 -0400
committerAndreas Kling <kling@serenityos.org>2022-04-30 16:24:33 +0200
commit0866a0cd1e81600776d034334950390b3c07a734 (patch)
tree521a85a5f6e97088d509b371613d2ee884ce326c /Kernel/Net/Routing.cpp
parent863c14c4f4f2c8d91db0935f668629f331da1b57 (diff)
downloadserenity-0866a0cd1e81600776d034334950390b3c07a734.zip
Kernel+route: Support global routing table deletion
Diffstat (limited to 'Kernel/Net/Routing.cpp')
-rw-r--r--Kernel/Net/Routing.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index feba06a32b..8c2396b3ad 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -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 {};
}));