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:
Zhe Weng
2025-01-14 17:02:57 +08:00
committed by Alan C. Assis
parent 3c0309e0ed
commit b2db3a6430
3 changed files with 34 additions and 12 deletions
+2 -9
View File
@@ -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