From a707fc77ef2d80ce5f4bed6e5c9bdd6bc0cc3912 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 11 Sep 2023 17:54:13 +0300 Subject: [PATCH] [nrf fromtree] net: arp: Directly send the queued pkt We must send the packet without queueing it. The pkt has already been queued for sending, once by net_if and second time in the ARP queue. We must not queue it twice in net_if so that the statistics of the pkt are not counted twice and the packet filter callbacks are only called once. Fixes #62483 Signed-off-by: Jukka Rissanen (cherry picked from commit 0e5016e5026fb1f83bd32c1255a9edb2bdf53127) --- subsys/net/l2/ethernet/arp.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/subsys/net/l2/ethernet/arp.c b/subsys/net/l2/ethernet/arp.c index f26c2f7ba96..35a2ec63a64 100644 --- a/subsys/net/l2/ethernet/arp.c +++ b/subsys/net/l2/ethernet/arp.c @@ -514,6 +514,8 @@ static void arp_update(struct net_if *iface, sys_slist_prepend(&arp_table, &entry->node); while (!k_fifo_is_empty(&entry->pending_queue)) { + int ret; + pkt = k_fifo_get(&entry->pending_queue, K_FOREVER); /* Set the dst in the pending packet */ @@ -525,7 +527,17 @@ static void arp_update(struct net_if *iface, net_sprint_ipv4_addr(&entry->ip), pkt, pkt->frags); - net_if_queue_tx(iface, pkt); + /* We directly send the packet without first queueing it. + * The pkt has already been queued for sending, once by + * net_if and second time in the ARP queue. We must not + * queue it twice in net_if so that the statistics of + * the pkt are not counted twice and the packet filter + * callbacks are only called once. + */ + ret = net_if_l2(iface)->send(iface, pkt); + if (ret < 0) { + net_pkt_unref(pkt); + } } k_mutex_unlock(&arp_mutex);