diff options
author | brapru <brapru@pm.me> | 2022-04-17 12:02:21 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-31 10:22:46 +0100 |
commit | 1dd22582da24d02adca114b42062a1cbfda71eb1 (patch) | |
tree | 8cf4d3dfd0a5a73ec870ce0d6c0ee4c69086987c /Kernel/Net/NetworkTask.cpp | |
parent | a3a6ee9865dde0c8b0ce4287d010029f1be511dc (diff) | |
download | serenity-1dd22582da24d02adca114b42062a1cbfda71eb1.zip |
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
Diffstat (limited to 'Kernel/Net/NetworkTask.cpp')
-rw-r--r-- | Kernel/Net/NetworkTask.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 128b62fe0e..d5996e0e6e 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()) { |