net/arp: Skip ARP request if ip address is invalid

Supports no ARP reply for invalid routing addresses in cross-segment communication

Signed-off-by: zhangkai25 <zhangkai25@xiaomi.com>
This commit is contained in:
zhangkai25 2025-05-29 19:23:30 +08:00 committed by Xiang Xiao
parent 0a381a3ff7
commit 711c58767a
2 changed files with 10 additions and 0 deletions

View file

@ -224,6 +224,12 @@ void arp_out(FAR struct net_driver_s *dev)
net_ipv4addr_copy(ipaddr, dev->d_draddr);
#endif
if (ipaddr == INADDR_ANY)
{
dev->d_len = 0;
return;
}
}
/* The destination address is on the local network. Check if it is

View file

@ -254,6 +254,10 @@ int arp_send(in_addr_t ipaddr)
net_ipv4addr_copy(dripaddr, dev->d_draddr);
#endif
ipaddr = dripaddr;
if (ipaddr == INADDR_ANY)
{
return -EHOSTUNREACH;
}
}
/* The destination address is on the local network. Check if it is