mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 18:56:10 +08:00
net/netdev: Add netdev_iob_replace_l2 for netdev to avoid misuse
And fix wrong `d_len` for IOBs from `upper->txq` in TX. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
@@ -182,15 +182,8 @@ static void netpkt_put(FAR struct net_driver_s *dev, FAR netpkt_t *pkt,
|
||||
|
||||
DEBUGASSERT(dev && pkt);
|
||||
|
||||
/* TODO: Using netdev_iob_release instead of netdev_iob_replace now,
|
||||
* because netdev_iob_replace sets d_len = L3_LEN and d_buf,
|
||||
* but we don't want these changes.
|
||||
*/
|
||||
|
||||
atomic_fetch_add(&upper->lower->quota[type], 1);
|
||||
netdev_iob_release(dev);
|
||||
dev->d_iob = pkt;
|
||||
dev->d_len = netpkt_getdatalen(upper->lower, pkt);
|
||||
netdev_iob_replace_l2(dev, pkt);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -344,7 +337,7 @@ static int netdev_upper_tx(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Put the packet back to the device */
|
||||
|
||||
netdev_iob_replace(dev, iob_remove_queue(&upper->txq));
|
||||
netdev_iob_replace_l2(dev, iob_remove_queue(&upper->txq));
|
||||
return netdev_upper_txpoll(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user