net/netdev: a valid netdev for ipv4 should have ipv4 addr configured

It's not a valid netdev if without ipv4 address.

Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
This commit is contained in:
shichunma
2026-01-28 21:35:22 +08:00
committed by Xiang Xiao
parent 5b978a7f9b
commit 3fb776e45c

View File

@@ -347,7 +347,15 @@ FAR struct net_driver_s *netdev_findby_ripv4addr(in_addr_t lipaddr,
* about that here.
*/
return netdev_default();
dev = netdev_default();
if (dev && net_ipv4addr_cmp(dev->d_ipaddr, INADDR_ANY))
{
return NULL;
}
else
{
return dev;
}
}
else
{
@@ -393,7 +401,15 @@ FAR struct net_driver_s *netdev_findby_ripv4addr(in_addr_t lipaddr,
* try the default network device.
*/
return netdev_default();
dev = netdev_default();
if (dev && net_ipv4addr_cmp(dev->d_ipaddr, INADDR_ANY))
{
return NULL;
}
else
{
return dev;
}
}
#endif /* CONFIG_NET_IPv4 */