mirror of
https://github.com/apache/nuttx.git
synced 2026-09-24 00:42:03 +08:00
netdev_upperhalf: avoid recursion during transmission
to avoid uncontrollable stack overhead, we actively avoid scenarios where recursion occurs. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
@@ -86,6 +86,8 @@ struct netdev_upperhalf_s
|
||||
struct netdev_vlan_entry_s vlan[CONFIG_NET_VLAN_COUNT];
|
||||
#endif
|
||||
|
||||
bool txing;
|
||||
|
||||
/* Deferring process to work queue or thread */
|
||||
|
||||
union
|
||||
@@ -381,11 +383,13 @@ static void netdev_upper_txavail_work(FAR struct netdev_upperhalf_s *upper)
|
||||
/* Ignore the notification if the interface is not yet up */
|
||||
|
||||
net_lock();
|
||||
if (IFF_IS_UP(dev->d_flags))
|
||||
if (IFF_IS_UP(dev->d_flags) && !upper->txing)
|
||||
{
|
||||
DEBUGASSERT(dev->d_buf == NULL); /* Make sure: IOB only. */
|
||||
upper->txing = true;
|
||||
while (netdev_upper_can_tx(upper) &&
|
||||
netdev_upper_tx(dev) == NETDEV_TX_CONTINUE);
|
||||
upper->txing = false;
|
||||
}
|
||||
|
||||
net_unlock();
|
||||
@@ -1408,6 +1412,8 @@ int netdev_lower_register(FAR struct netdev_lowerhalf_s *dev,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
upper->txing = false;
|
||||
|
||||
dev->netdev.d_ifup = netdev_upper_ifup;
|
||||
dev->netdev.d_ifdown = netdev_upper_ifdown;
|
||||
dev->netdev.d_txavail = netdev_upper_txavail;
|
||||
|
||||
Reference in New Issue
Block a user