net: protect the older network cards driver's tx and rx process

Add netdev_lock in xxx_input and txavail to adapt to drivers that do not
use upperhalf.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-08-22 12:03:02 +08:00
committed by Xiang Xiao
parent 6b625dfdf2
commit c8713a1b48
5 changed files with 27 additions and 4 deletions
+5 -1
View File
@@ -1045,9 +1045,12 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
FAR uint8_t *buf;
int bstop;
netdev_lock(dev);
if (dev->d_buf == NULL)
{
return devif_iob_poll(dev, callback);
bstop = devif_iob_poll(dev, callback);
netdev_unlock(dev);
return bstop;
}
buf = dev->d_buf;
@@ -1102,6 +1105,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
/* Restore the flat buffer */
dev->d_buf = buf;
netdev_unlock(dev);
return bstop;
}
+6 -1
View File
@@ -503,6 +503,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
FAR uint8_t *buf;
int ret;
netdev_lock(dev);
/* Store reception timestamp if enabled and not provided by hardware. */
#if defined(CONFIG_NET_TIMESTAMP) && !defined(CONFIG_ARCH_HAVE_NETDEV_TIMESTAMP)
@@ -520,10 +522,13 @@ int ipv4_input(FAR struct net_driver_s *dev)
dev->d_buf = buf;
netdev_unlock(dev);
return ret;
}
return netdev_input(dev, ipv4_in, true);
ret = netdev_input(dev, ipv4_in, true);
netdev_unlock(dev);
return ret;
}
#endif /* CONFIG_NET_IPv4 */
+6 -1
View File
@@ -675,6 +675,8 @@ int ipv6_input(FAR struct net_driver_s *dev)
FAR uint8_t *buf;
int ret;
netdev_lock(dev);
/* Store reception timestamp if enabled and not provided by hardware. */
#if defined(CONFIG_NET_TIMESTAMP) && !defined(CONFIG_ARCH_HAVE_NETDEV_TIMESTAMP)
@@ -692,9 +694,12 @@ int ipv6_input(FAR struct net_driver_s *dev)
dev->d_buf = buf;
netdev_unlock(dev);
return ret;
}
return netdev_input(dev, ipv6_in, true);
ret = netdev_input(dev, ipv6_in, true);
netdev_unlock(dev);
return ret;
}
#endif /* CONFIG_NET_IPv6 */