mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:47:35 +00:00
Kernel: Add support for route flags
Previously the routing table did not store the route flags. This adds basic support and exposes them in the /proc directory so that a userspace caller can query the route and identify the type of each route.
This commit is contained in:
parent
210c3f24cd
commit
7a4e41f8f8
5 changed files with 12 additions and 8 deletions
|
@ -629,14 +629,14 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
|
|||
return EPERM;
|
||||
if (route.rt_gateway.sa_family != AF_INET)
|
||||
return EAFNOSUPPORT;
|
||||
if ((route.rt_flags & (RTF_UP | RTF_GATEWAY)) != (RTF_UP | RTF_GATEWAY))
|
||||
if (!(route.rt_flags & RTF_UP))
|
||||
return EINVAL; // FIXME: Find the correct value to return
|
||||
|
||||
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::Set);
|
||||
return update_routing_table(destination, gateway, genmask, route.rt_flags, adapter, UpdateTable::Set);
|
||||
}
|
||||
case SIOCDELRT:
|
||||
if (!Process::current().is_superuser())
|
||||
|
@ -648,7 +648,7 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
|
|||
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 update_routing_table(destination, gateway, genmask, route.rt_flags, adapter, UpdateTable::Delete);
|
||||
}
|
||||
|
||||
return EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue