Kernel: Ignore interfaces without an IP address when routing packages

Let's not route packages through interfaces which don't have an address
yet unless we're explicitly asked to (e.g. by DHCPClient).
This commit is contained in:
Gunnar Beutner 2021-05-21 21:47:26 +02:00 committed by Andreas Kling
commit 7cd49ba2a2
Notes: sideshowbarker 2024-07-18 17:36:38 +09:00

View file

@ -152,7 +152,7 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
RefPtr<NetworkAdapter> local_adapter = nullptr;
RefPtr<NetworkAdapter> gateway_adapter = nullptr;
NetworkAdapter::for_each([source_addr, &target_addr, &local_adapter, &gateway_adapter, &matches](auto& adapter) {
NetworkAdapter::for_each([source_addr, &target_addr, &local_adapter, &gateway_adapter, &matches, &through](auto& adapter) {
auto adapter_addr = adapter.ipv4_address().to_u32();
auto adapter_mask = adapter.ipv4_netmask().to_u32();
@ -161,6 +161,9 @@ RoutingDecision route_to(const IPv4Address& target, const IPv4Address& source, c
return;
}
if (!adapter.link_up() || (adapter_addr == 0 && !through))
return;
if (source_addr != 0 && source_addr != adapter_addr)
return;