forked from nuttx/nuttx-update
net/ipfwd: fix devif_forward
after IOB offload.
Problem: - `iob_copyout` to `d_buf` doesn't set `io_len` of the IOB, so `devif_poll` failed to copy the data into `buf` by `iob_copyout` Modification: - Just Move the IOB in `devif_forward`. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
813dfe9756
commit
2a780e0467
3 changed files with 43 additions and 13 deletions
|
@ -895,6 +895,20 @@ int netdev_lladdrsize(FAR struct net_driver_s *dev);
|
|||
int netdev_iob_prepare(FAR struct net_driver_s *dev, bool throttled,
|
||||
unsigned int timeout);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_iob_replace
|
||||
*
|
||||
* Description:
|
||||
* Replace buffer resources for a given NIC
|
||||
*
|
||||
* Assumptions:
|
||||
* The caller has locked the network and new iob is prepared with
|
||||
* l2 gruard size as offset.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void netdev_iob_replace(FAR struct net_driver_s *dev, FAR struct iob_s *iob);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_iob_clear
|
||||
*
|
||||
|
|
|
@ -60,24 +60,14 @@
|
|||
|
||||
void devif_forward(FAR struct forward_s *fwd)
|
||||
{
|
||||
unsigned int offset;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL);
|
||||
offset = NET_LL_HDRLEN(fwd->f_dev);
|
||||
|
||||
/* Copy the IOB chain that contains the L3L3 headers and any data payload */
|
||||
/* Move the IOB chain that contains the L3 header and any data payload */
|
||||
|
||||
DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NETDEV_PKTSIZE(fwd->f_dev));
|
||||
ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob,
|
||||
fwd->f_iob->io_pktlen, 0);
|
||||
|
||||
DEBUGASSERT(ret == fwd->f_iob->io_pktlen);
|
||||
netdev_iob_replace(fwd->f_dev, fwd->f_iob);
|
||||
|
||||
fwd->f_dev->d_sndlen = 0;
|
||||
fwd->f_dev->d_len = fwd->f_iob->io_pktlen;
|
||||
|
||||
UNUSED(ret);
|
||||
fwd->f_iob = NULL;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IPFORWARD */
|
||||
|
|
|
@ -84,6 +84,32 @@ int netdev_iob_prepare(FAR struct net_driver_s *dev, bool throttled,
|
|||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_iob_replace
|
||||
*
|
||||
* Description:
|
||||
* Replace buffer resources for a given NIC
|
||||
*
|
||||
* Assumptions:
|
||||
* The caller has locked the network and new iob is prepared with
|
||||
* l2 gruard size as offset.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void netdev_iob_replace(FAR struct net_driver_s *dev, FAR struct iob_s *iob)
|
||||
{
|
||||
/* Release previous buffer */
|
||||
|
||||
netdev_iob_release(dev);
|
||||
|
||||
/* Set new buffer */
|
||||
|
||||
dev->d_iob = iob;
|
||||
dev->d_buf = &dev->d_iob->io_data[CONFIG_NET_LL_GUARDSIZE -
|
||||
NET_LL_HDRLEN(dev)];
|
||||
dev->d_len = iob->io_pktlen;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_iob_clear
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue