mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
Kernel/Net: Support removing route entries with unknown gateway
If you specify gateway as 0.0.0.0, the SIOCDELRT ioctl will remove all route entries that match all the other arguments.
This commit is contained in:
parent
36676a1604
commit
bea1668159
2 changed files with 11 additions and 2 deletions
|
@ -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 {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue