From 5ca7ae458577ebd4988cff1d1d12af182e6b1359 Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Sat, 28 Dec 2019 10:59:52 +1100 Subject: [PATCH] Kernel: Route all loopback traffic through the loopback adapter --- Kernel/Net/NetworkAdapter.cpp | 3 +++ Kernel/Net/Routing.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp index 5db9d5c286..3666f8f265 100644 --- a/Kernel/Net/NetworkAdapter.cpp +++ b/Kernel/Net/NetworkAdapter.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,8 @@ WeakPtr NetworkAdapter::from_ipv4_address(const IPv4Address& add if (adapter->ipv4_address() == address) return adapter->make_weak_ptr(); } + if (address[0] == 127) + return LoopbackAdapter::the().make_weak_ptr(); return nullptr; } diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp index befbaf7bb5..eaf5c40d3f 100644 --- a/Kernel/Net/Routing.cpp +++ b/Kernel/Net/Routing.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -18,6 +19,9 @@ bool RoutingDecision::is_zero() const RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source) { + if (target[0] == 127) + return { LoopbackAdapter::the().make_weak_ptr(), {} }; + auto target_addr = target.to_u32(); auto source_addr = source.to_u32();