From 1dd22582da24d02adca114b42062a1cbfda71eb1 Mon Sep 17 00:00:00 2001 From: brapru Date: Sun, 17 Apr 2022 12:02:21 -0400 Subject: [PATCH] Kernel: Ignore interfaces without an IP address when updating ARP For the same reason we ignore interfaces without an IP address when choosing where to send a route, we should also ignore interfaces without IP addresses when updating the ARP table on incoming packets from local addresses. On an interface with a null address, the mask checking would always result in zero, which resulted in the system updating the ARP table on almost every incoming packet from any address (private or public). This patch fixes this behavior by only applying this check to interfaces with valid addresses and now the ARP table won't get constantly hammered. Closes #13713 --- Kernel/Net/NetworkTask.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 128b62fe0eb..d5996e0e6e2 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -201,12 +201,13 @@ void handle_ipv4(EthernetFrameHeader const& eth, size_t frame_size, Time const& dbgln_if(IPV4_DEBUG, "handle_ipv4: source={}, destination={}", packet.source(), packet.destination()); NetworkingManagement::the().for_each([&](auto& adapter) { - if (adapter.link_up()) { - auto my_net = adapter.ipv4_address().to_u32() & adapter.ipv4_netmask().to_u32(); - auto their_net = packet.source().to_u32() & adapter.ipv4_netmask().to_u32(); - if (my_net == their_net) - update_arp_table(packet.source(), eth.source(), UpdateTable::Set); - } + if (adapter.ipv4_address().is_zero() || !adapter.link_up()) + return; + + auto my_net = adapter.ipv4_address().to_u32() & adapter.ipv4_netmask().to_u32(); + auto their_net = packet.source().to_u32() & adapter.ipv4_netmask().to_u32(); + if (my_net == their_net) + update_arp_table(packet.source(), eth.source(), UpdateTable::Set); }); switch ((IPv4Protocol)packet.protocol()) {