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.
pull/46/head
Adam Green 2013-08-24 14:48:12 -07:00
parent acb35785c9
commit de8161fde1
1 changed files with 3 additions and 0 deletions

View File

@ -346,6 +346,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
struct lpc_enetdata *lpc_enetif = netif->state;
struct pbuf *p = NULL;
u32_t idx, length;
u16_t origLength;
#ifdef LOCK_RX_THREAD
#if NO_SYS == 0
@ -428,6 +429,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
/* Zero-copy */
p = lpc_enetif->rxb[idx];
origLength = p->len;
p->len = (u16_t) length;
/* Free pbuf from descriptor */
@ -440,6 +442,7 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
LINK_STATS_INC(link.drop);
/* Re-queue the pbuf for receive */
p->len = origLength;
lpc_rxqueue_pbuf(lpc_enetif, p);
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,