From c950063f73ae11dd304b672b26aadb8d3c37296d Mon Sep 17 00:00:00 2001 From: yuanjm Date: Thu, 16 Jun 2022 16:03:54 +0800 Subject: [PATCH] napt: Fix IP forwarding when forward netif enable NAPT * Fix communication between different netifs fails if NAPT is enabled * Fixes IDF-4896 --- src/core/ipv4/ip4.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index c616f73ff..738c94dd0 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -383,8 +383,11 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) #if ESP_LWIP #if IP_NAPT - if (ip_napt_forward(p, iphdr, inp, netif) != ERR_OK) - return; + /* If the output netif uses NAPT, we will not perform NAPT forwarding (because NAPT netif will not search the NAPT table on ip4_input) */ + if (!netif->napt) { + if (ip_napt_forward(p, iphdr, inp, netif) != ERR_OK) + return; + } #endif #endif /* ESP_LWIP */