Skip to content

Commit de8161f

Browse files
committed
net: Reset pbuf length when re-queueing on error.
I recently pulled a NXP crash fix for their ethernet driver which will requeue a pbuf to the ethernet driver rather than sending it to the lwip stack if it can't allocate a new pbuf to keep the ethernet hardware primed with available packet buffers. While recently reviewing this code I noticed that the full size of the pbuf wasn't used on this re-queueing operation but the size of the last received packet. I now reset the pbuf size back to its originally allocated size before doing this requeue operation.
1 parent acb3578 commit de8161f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libraries/net/eth/lwip-eth/arch/lpc17_emac.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
346346
struct lpc_enetdata *lpc_enetif = netif->state;
347347
struct pbuf *p = NULL;
348348
u32_t idx, length;
349+
u16_t origLength;
349350

350351
#ifdef LOCK_RX_THREAD
351352
#if NO_SYS == 0
@@ -428,6 +429,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
428429

429430
/* Zero-copy */
430431
p = lpc_enetif->rxb[idx];
432+
origLength = p->len;
431433
p->len = (u16_t) length;
432434

433435
/* Free pbuf from descriptor */
@@ -440,6 +442,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
440442
LINK_STATS_INC(link.drop);
441443

442444
/* Re-queue the pbuf for receive */
445+
p->len = origLength;
443446
lpc_rxqueue_pbuf(lpc_enetif, p);
444447

445448
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,

0 commit comments

Comments
 (0)