mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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
This commit is contained in:
parent
a3a6ee9865
commit
1dd22582da
Notes:
sideshowbarker
2024-07-17 10:33:28 +09:00
Author: https://github.com/brapru Commit: https://github.com/SerenityOS/serenity/commit/1dd22582da Pull-request: https://github.com/SerenityOS/serenity/pull/13722 Issue: https://github.com/SerenityOS/serenity/issues/13713 Reviewed-by: https://github.com/IdanHo
1 changed files with 7 additions and 6 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue