mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user