1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57: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

@ -639,8 +639,16 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
return update_routing_table(destination, gateway, genmask, adapter, UpdateTable::Set);
}
case SIOCDELRT:
// FIXME: Support gateway deletion
return {};
if (!Process::current().is_superuser())
return EPERM;
if (route.rt_gateway.sa_family != AF_INET)
return EAFNOSUPPORT;
auto destination = IPv4Address(((sockaddr_in&)route.rt_dst).sin_addr.s_addr);
auto gateway = IPv4Address(((sockaddr_in&)route.rt_gateway).sin_addr.s_addr);
auto genmask = IPv4Address(((sockaddr_in&)route.rt_genmask).sin_addr.s_addr);
return update_routing_table(destination, gateway, genmask, adapter, UpdateTable::Delete);
}
return EINVAL;