diff options
author | brapru <brapru@pm.me> | 2022-04-29 21:49:00 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-30 16:24:33 +0200 |
commit | 0866a0cd1e81600776d034334950390b3c07a734 (patch) | |
tree | 521a85a5f6e97088d509b371613d2ee884ce326c /Kernel/Net/IPv4Socket.cpp | |
parent | 863c14c4f4f2c8d91db0935f668629f331da1b57 (diff) | |
download | serenity-0866a0cd1e81600776d034334950390b3c07a734.zip |
Kernel+route: Support global routing table deletion
Diffstat (limited to 'Kernel/Net/IPv4Socket.cpp')
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 264c7a34f5..76f851899b 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -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; |