From 49abe218ab79140b233d21a1c8097a727f9a5950 Mon Sep 17 00:00:00 2001 From: Steffen Butzer Date: Tue, 26 Nov 2024 19:02:21 +0000 Subject: [PATCH] Respond only to ARP requests addressed to device via either broadcast or unicast Previous behavior would reply to other IPs that only match the subnet with our (IP, MAC) pair but not respond to unicast requests addressed with an unknown (all zeroes) MAC or broadcast requests. --- src/smolnetd/link/ethernet.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/smolnetd/link/ethernet.rs b/src/smolnetd/link/ethernet.rs index 111569aee9..4f3a2dfb3a 100644 --- a/src/smolnetd/link/ethernet.rs +++ b/src/smolnetd/link/ethernet.rs @@ -124,7 +124,9 @@ impl EthernetLink { target_hardware_addr, target_protocol_addr, } => { - if hardware_address != target_hardware_addr { + let is_unicast_mac = target_hardware_addr != EMPTY_MAC && !target_hardware_addr.is_broadcast(); + + if is_unicast_mac && hardware_address != target_hardware_addr { // Only process packet that are for us return; } @@ -137,7 +139,7 @@ impl EthernetLink { return; } - if !ip_addr.contains_addr(&target_protocol_addr) { + if ip_addr.address() != target_protocol_addr { return; }