From 98777343bdf0101b5eb366e4625d5a22381ebfe3 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 17 Mar 2023 09:18:38 +0100 Subject: [PATCH] lwip:esp_netif: Send Periodic Gratuitous ARP only on valid IPv4 It was possible that the device would send a Gratuitous ARP before acquiring a valid address, advertising it has 0.0.0.0 address. --- components/esp_netif/lwip/esp_netif_lwip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index c84d3217c5..a6fe43f6a1 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -174,7 +174,9 @@ static void dns_clear_servers(bool keep_fallback) static void netif_send_garp(void *arg) { struct netif *netif = arg; - etharp_gratuitous(netif); + if (!ip4_addr_cmp(netif_ip4_addr(netif), IP4_ADDR_ANY4)) { // Send GARP requests only if we have a valid IP + etharp_gratuitous(netif); + } sys_timeout(CONFIG_LWIP_GARP_TMR_INTERVAL*1000, netif_send_garp, netif); }