napt: Fix PBUF_REF type to clone the pbuf before forwarding

Picked from espressif/esp-idf@39068263
Ref IDF-4800
This commit is contained in:
xueyunfei
2021-04-25 17:19:23 +08:00
committed by David Cermak
parent 8a5a30dd5d
commit 4a05f3979d
+16
View File
@@ -370,7 +370,23 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
return;
}
/* transmit pbuf on chosen interface */
#if ESP_LWIP && IP_NAPT
if (p->type_internal == PBUF_REF)
{
struct pbuf *q = pbuf_clone(PBUF_LINK, PBUF_RAM, p);
if (q != NULL) {
netif->output(netif, q, ip4_current_dest_addr());
pbuf_free(q);
} else {
MIB2_STATS_INC(mib2.ipinaddrerrors);
MIB2_STATS_INC(mib2.ipindiscards);
}
} else {
netif->output(netif, p, ip4_current_dest_addr());
}
#else
netif->output(netif, p, ip4_current_dest_addr());
#endif /* ESP_LWIP && IP_NAPT */
return;
return_noroute:
MIB2_STATS_INC(mib2.ipoutnoroutes);