Skip to content

Commit

Permalink
net: ipv4: Fix ARP probe check in address conflict detection
Browse files Browse the repository at this point in the history
The second condition needs to check ARP probes only

The ACD is not properly implemented as described in RFC5227 ch. 2.1.1
The implementation incorrectly detects an IP conflict, if an ARP request is received for the target IP.
The reason is that the current implementation checks for ARP requests instead of ARP probes.
  • Loading branch information
anhuba authored and andy committed Oct 28, 2024
1 parent 95cc5f5 commit e0cefd7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions subsys/net/ip/ipv4_acd.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,18 @@ enum net_verdict net_ipv4_acd_input(struct net_if *iface, struct net_pkt *pkt)
ll_addr = net_if_get_link_addr(addr_iface);

/* RFC 5227, ch. 2.1.1 Probe Details:
* - Sender IP address match OR,
* - Target IP address match with different sender HW address,
* - ARP Request/Reply with Sender IP address match OR,
* - ARP Probe where Target IP address match with different sender HW address,
* indicate a conflict.
* ARP Probe has an all-zero sender IP address
*/
if (net_ipv4_addr_cmp_raw(arp_hdr->src_ipaddr,
(uint8_t *)&ifaddr->address.in_addr) ||
(net_ipv4_addr_cmp_raw(arp_hdr->dst_ipaddr,
(uint8_t *)&ifaddr->address.in_addr) &&
memcmp(&arp_hdr->src_hwaddr, ll_addr->addr, ll_addr->len) != 0)) {
(memcmp(&arp_hdr->src_hwaddr, ll_addr->addr, ll_addr->len) != 0) &&
(net_ipv4_addr_cmp_raw(arp_hdr->src_ipaddr,
(uint8_t *)&(struct in_addr)INADDR_ANY_INIT)))) {
NET_DBG("Conflict detected from %s for %s",
net_sprint_ll_addr((uint8_t *)&arp_hdr->src_hwaddr,
arp_hdr->hwlen),
Expand Down

0 comments on commit e0cefd7

Please sign in to comment.