summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/Routing.cpp6
-rw-r--r--Kernel/Net/Routing.h7
2 files changed, 11 insertions, 2 deletions
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 77c314acd2..a98fc9b80a 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -137,6 +137,8 @@ SpinlockProtected<Route::RouteList>& routing_table()
ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, u16 flags, RefPtr<NetworkAdapter> adapter, UpdateTable update)
{
+ dbgln_if(ROUTING_DEBUG, "update_routing_table {} {} {} {} {} {}", destination, gateway, netmask, flags, adapter, update == UpdateTable::Set ? "Set" : "Delete");
+
auto route_entry = adopt_ref_if_nonnull(new (nothrow) Route { destination, gateway, netmask, flags, adapter.release_nonnull() });
if (!route_entry)
return ENOMEM;
@@ -151,7 +153,9 @@ ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address c
}
if (update == UpdateTable::Delete) {
for (auto& route : table) {
- if (route == *route_entry) {
+ dbgln("candidate: {} {} {} {} {}", route.destination, route.gateway, route.netmask, route.flags, route.adapter);
+ if (route.matches(*route_entry)) {
+ // FIXME: Remove all entries, not only the first one.
table.remove(route);
return {};
}
diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h
index 3d68a0f34c..ba7f06f2d2 100644
--- a/Kernel/Net/Routing.h
+++ b/Kernel/Net/Routing.h
@@ -26,7 +26,12 @@ struct Route : public RefCounted<Route> {
bool operator==(Route const& other) const
{
- return destination == other.destination && gateway == other.gateway && netmask == other.netmask && flags == other.flags && adapter.ptr() == other.adapter.ptr();
+ return destination == other.destination && netmask == other.netmask && flags == other.flags && adapter.ptr() == other.adapter.ptr();
+ }
+
+ bool matches(Route const& other) const
+ {
+ return destination == other.destination && (gateway == other.gateway || other.gateway.is_zero()) && netmask == other.netmask && flags == other.flags && adapter.ptr() == other.adapter.ptr();
}
const IPv4Address destination;