Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{bp-15287} tcp_recvfrom.c:resolve issue in tcp_recvhandler #15362

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions net/tcp/tcp_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ static uint16_t tcp_recvhandler(FAR struct net_driver_s *dev,
FAR void *pvpriv, uint16_t flags)
{
FAR struct tcp_recvfrom_s *pstate = pvpriv;
FAR struct iob_s *iob = NULL;

ninfo("flags: %04x\n", flags);

Expand All @@ -408,12 +409,37 @@ static uint16_t tcp_recvhandler(FAR struct net_driver_s *dev,

tcp_sender(dev, pstate);

if ((flags & TCP_ACKDATA) != 0)
{
iob = iob_tryalloc(false);
if (iob == NULL)
{
nerr("ERROR: IOB alloc failed !\n");
return flags;
}

iob_reserve(iob, CONFIG_NET_LL_GUARDSIZE);
int ret = iob_clone_partial(dev->d_iob, dev->d_iob->io_pktlen,
0, iob, 0, false, false);
if (ret < 0)
{
iob_free_chain(iob);
nerr("ERROR: IOB clone failed ret=%d!\n", ret);
return flags;
}
}

/* Copy the data from the packet (saving any unused bytes from the
* packet in the read-ahead buffer).
*/

flags = tcp_newdata(dev, pstate, flags);

if (iob != NULL)
{
netdev_iob_replace(dev, iob);
}

/* Indicate that the data has been consumed and that an ACK
* should be sent.
*/
Expand Down
Loading