napt: Fix PBUF_REF type to clone the pbuf before forwarding

This commit is contained in:
xueyunfei
2022-03-08 07:28:03 +00:00
committed by David Čermák
parent 2b922919a1
commit 39068263f0
2 changed files with 18 additions and 0 deletions
+16
View File
@@ -421,7 +421,23 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
return;
}
/* transmit pbuf on chosen interface */
#if ESP_IP_FORWARD
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_IP_FORWARD */
return;
return_noroute:
MIB2_STATS_INC(mib2.ipoutnoroutes);
+2
View File
@@ -110,6 +110,8 @@
#define ESP_THREAD_PROTECTION 0
#define ESP_DHCP_DISABLE_CLIENT_ID 0
#define ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER 0
#define ESP_IP_FORWARD 1
#ifdef IP_NAPT
#define IP_NAPT_MAX 16