From b34e34d2239b253107ecb3243b24a3e5f79ed8f0 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 5 Jun 2024 15:17:00 +0200 Subject: [PATCH] net: l2: ethernet: arp: Simplify ACD case In case of ACD Probe/Announcement, all we need is to generate ARP packet, we don't really want any cache entries to be created or searched for. There was a bug, that a cache entry was created for the Announcement sent, resulting in skipped ARP packet generation and malformed packet being sent by the ACD module. Therefore, simplify all this, by simply returning early in case of conflict detection packets. Signed-off-by: Robert Lubos --- subsys/net/l2/ethernet/arp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/subsys/net/l2/ethernet/arp.c b/subsys/net/l2/ethernet/arp.c index a166e304f4244e2..07066472da964f7 100644 --- a/subsys/net/l2/ethernet/arp.c +++ b/subsys/net/l2/ethernet/arp.c @@ -355,6 +355,11 @@ struct net_pkt *net_arp_prepare(struct net_pkt *pkt, return NULL; } + if (net_pkt_ipv4_acd(pkt)) { + return arp_prepare(net_pkt_iface(pkt), request_ip, NULL, + pkt, current_ip); + } + if (IS_ENABLED(CONFIG_NET_IPV4_AUTO)) { is_ipv4_ll_used = net_ipv4_is_ll_addr((struct in_addr *) &NET_IPV4_HDR(pkt)->src) || @@ -406,8 +411,7 @@ struct net_pkt *net_arp_prepare(struct net_pkt *pkt, * in the pending list and if so, resend the request, otherwise just * append the packet to the request fifo list. */ - if (!net_pkt_ipv4_acd(pkt) && - k_queue_unique_append(&entry->pending_queue._queue, + if (k_queue_unique_append(&entry->pending_queue._queue, net_pkt_ref(pkt))) { NET_DBG("Pending ARP request for %s, queuing pkt %p", net_sprint_ipv4_addr(addr), pkt);