diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index c4a0bd09..88a4503a 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -207,10 +207,9 @@ pppos_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) err_t err; LWIP_UNUSED_ARG(ppp); - /* Grab an output buffer. Using PBUF_POOL here for tx is ok since the pbuf - gets freed by 'pppos_output_last' before this function returns and thus - cannot starve rx. */ - nb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); + /* Grab an output buffer. Assume PBUF_POOL_BUFSIZE is an acceptable + * chunk size for Tx as well. */ + nb = pbuf_alloc(PBUF_RAW, PBUF_POOL_BUFSIZE, PBUF_RAM); if (nb == NULL) { PPPDEBUG(LOG_WARNING, ("pppos_write[%d]: alloc fail\n", ppp->netif->num)); LINK_STATS_INC(link.memerr); @@ -220,6 +219,8 @@ pppos_write(ppp_pcb *ppp, void *ctx, struct pbuf *p) return ERR_MEM; } + /* Empty the buffer */ + nb->len = 0; /* Set nb->tot_len to actual payload length */ nb->tot_len = p->len; @@ -258,10 +259,9 @@ pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u16_t protocol) err_t err; LWIP_UNUSED_ARG(ppp); - /* Grab an output buffer. Using PBUF_POOL here for tx is ok since the pbuf - gets freed by 'pppos_output_last' before this function returns and thus - cannot starve rx. */ - nb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); + /* Grab an output buffer. Assume PBUF_POOL_BUFSIZE is an acceptable + * chunk size for Tx as well. */ + nb = pbuf_alloc(PBUF_RAW, PBUF_POOL_BUFSIZE, PBUF_RAM); if (nb == NULL) { PPPDEBUG(LOG_WARNING, ("pppos_netif_output[%d]: alloc fail\n", ppp->netif->num)); LINK_STATS_INC(link.memerr); @@ -270,6 +270,8 @@ pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u16_t protocol) return ERR_MEM; } + /* Empty the buffer */ + nb->len = 0; /* Set nb->tot_len to actual payload length */ nb->tot_len = pb->tot_len;