-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ipv4 packet not forwarded between SLIP and WIFI STA interfaces. (IDFGH-5517) #7246
Comments
@clementfumey-inventhys Do you really enable the napt for that interface? Didn't see a call to |
You are right, I forgot it on both STA interface and SLIP. But I still have the same problem, when for example pinging from my computer (through the SLIP interface) to the wifi router. on wich the ESP32 STA is connected. Anyway this seems not related to any bug or issue in esp-idf, but more of my lack of knowledge in lwip routing. I will thus close the issue. Sorry for the inconvenience. |
TBH, the SLIP interface is a little different from standard netifs of lwip (it is very simple and uses predefined addresses) so I'm not sure if the address translation would work here (I've never tried). Alternatively you can use PPP netif, as the setup |
Here is an update of the case, if anyone is interested in SLIP/STA forwarding : To make IP Forwarding worked with SLIP, I added a netmask and a gateway to the SLIP interface.
It get rid of the previous log message Next problem is that it correctly forward my ICMP ping request from the SLIP to Wifi but on the ICMP ping reply from the Wifi router, it never enter the NAPT receive function and never forward back to the SLIP. Here is the lines of code I do not understands in
Why |
The interface with inp->napt set is the interface that is "hidden" behind the NAPT. Outgoing packets here are mapped in ip_forward(). This pice of code handles packet incoming packets on other interfaces (no inp->napt) , that are checked here, whether they have to be rewritten to be forwarded back into "hidden" network. |
Thank you @martin-ger , I definitely misunderstood this napt part. My mistake was to enable NAPT on the wrong interfaces. @david-cermak I found a small bug in esp-netif that prevent the SLIP interface to be set as default. On the esp32 with Wifi AP and SLIP interface, the default interface should be SLIP (prio 16 > prio 10). Here is the snippet I use to fix it in
I just added the SLIP_LWIP_NETIF condition where the lwip netif is not store in netif_handle like the default case for wifi but in lwip_netif. Now I am able to have an ESP-MESH with internal ip adressing, connected to an internet router, where some nodes are connected to an other esp32 via SLIP. The other node provide an AP to a smartphone or computer to access internet through the Mesh. It is very slow for now but there is place for improvements. |
@clementfumey-inventhys Thanks for pointing out this bug and suggesting the fix! I would prefer using the --- a/components/esp_netif/lwip/esp_netif_lwip.c
+++ b/components/esp_netif/lwip/esp_netif_lwip.c
@@ -178,7 +178,7 @@ static void esp_netif_set_default_netif(esp_netif_t *esp_netif)
esp_netif_ppp_set_default_netif(esp_netif->netif_handle);
#endif
} else {
- netif_set_default(esp_netif->netif_handle);
+ netif_set_default(esp_netif->lwip_netif);
}
} Could we close this issue with this |
Environment
Problem Description
Goal: I am trying to give access to internet to a node (computer or esp32 for example) through an ESP32 that act as router through a SLIP connection and MESH STA.
My current work is based on esp-idf branch v4.3
The idea is to an ESP32 that is connected using UART through a SLIP interface with static IP addresses (slip-modem example in esp-idf) to an computer (or an another ESP32). The ESP32 is also connected to internet throught its Wifi Sta.
On the node, IP_FORWARDING and NAPT is enable.
On the node, the incoming packet on the SLIP interface is not forwarded to the wifi interface. It seems lwip do not know what is the default gw for ip addresses he doesn't know.
I have tested a similar configuration with ESP32 acting Wifi AP and forwarding Wifi traffic to a SLIP interface and it works.
Expected Behavior
lwip should forward ip packets from slip interface to esp-mesh wifi interface
Actual Behavior
Code to reproduce this issue
slip-modem example with this main : https://gist.github.com/clementfumey-inventhys/d19b30f109f3bcaf6e93b22e86e96624
CONFIG_LWIP_L2_TO_L3_COPY, CONFIG_LWIP_IP_FORWARD and CONFIG_LWIP_IPV4_NAPT should be enable in sdkconfig
The text was updated successfully, but these errors were encountered: