diff options
-rw-r--r-- | Kernel/API/POSIX/net/route.h | 1 | ||||
-rw-r--r-- | Kernel/GlobalProcessExposed.cpp | 1 | ||||
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 6 | ||||
-rw-r--r-- | Kernel/Net/Routing.cpp | 4 | ||||
-rw-r--r-- | Kernel/Net/Routing.h | 8 |
5 files changed, 12 insertions, 8 deletions
diff --git a/Kernel/API/POSIX/net/route.h b/Kernel/API/POSIX/net/route.h index 8c3c6b8bfa..92c9bfb7f0 100644 --- a/Kernel/API/POSIX/net/route.h +++ b/Kernel/API/POSIX/net/route.h @@ -24,6 +24,7 @@ struct rtentry { #define RTF_UP 0x1 /* do not delete the route */ #define RTF_GATEWAY 0x2 /* the route is a gateway and not an end host */ +#define RTF_HOST 0x4 /* host entry (net otherwise) */ #ifdef __cplusplus } diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index 3ae1ecb008..01bdb5f2d9 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -114,6 +114,7 @@ private: TRY(obj.add("gateway", gateway->view())); auto netmask = TRY(it.netmask.to_string()); TRY(obj.add("genmask", netmask->view())); + TRY(obj.add("flags", it.flags)); TRY(obj.add("interface", it.adapter->name())); TRY(obj.finish()); } diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 76f851899b..e9305a5adb 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -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; diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp index 8c2396b3ad..a96a201a5c 100644 --- a/Kernel/Net/Routing.cpp +++ b/Kernel/Net/Routing.cpp @@ -135,9 +135,9 @@ SpinlockProtected<Route::RouteList>& routing_table() return *s_routing_table; } -ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, RefPtr<NetworkAdapter> adapter, UpdateTable update) +ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, u16 flags, RefPtr<NetworkAdapter> adapter, UpdateTable update) { - auto route_entry = adopt_ref_if_nonnull(new (nothrow) Route { destination, gateway, netmask, adapter.release_nonnull() }); + auto route_entry = adopt_ref_if_nonnull(new (nothrow) Route { destination, gateway, netmask, flags, adapter.release_nonnull() }); if (!route_entry) return ENOMEM; diff --git a/Kernel/Net/Routing.h b/Kernel/Net/Routing.h index b0db0baf2e..3d68a0f34c 100644 --- a/Kernel/Net/Routing.h +++ b/Kernel/Net/Routing.h @@ -15,22 +15,24 @@ namespace Kernel { struct Route : public RefCounted<Route> { - Route(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, NonnullRefPtr<NetworkAdapter> adapter) + Route(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, u16 flags, NonnullRefPtr<NetworkAdapter> adapter) : destination(destination) , gateway(gateway) , netmask(netmask) + , flags(flags) , adapter(adapter) { } bool operator==(Route const& other) const { - return destination == other.destination && gateway == other.gateway && netmask == other.netmask && adapter.ptr() == other.adapter.ptr(); + return destination == other.destination && gateway == other.gateway && netmask == other.netmask && flags == other.flags && adapter.ptr() == other.adapter.ptr(); } const IPv4Address destination; const IPv4Address gateway; const IPv4Address netmask; + const u16 flags; NonnullRefPtr<NetworkAdapter> adapter; IntrusiveListNode<Route, RefPtr<Route>> route_list_node {}; @@ -50,7 +52,7 @@ enum class UpdateTable { }; void update_arp_table(IPv4Address const&, MACAddress const&, UpdateTable update); -ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, RefPtr<NetworkAdapter> const adapter, UpdateTable update); +ErrorOr<void> update_routing_table(IPv4Address const& destination, IPv4Address const& gateway, IPv4Address const& netmask, u16 flags, RefPtr<NetworkAdapter> const adapter, UpdateTable update); enum class AllowUsingGateway { Yes, |