Skip to content

Ethernet doesn't work with IPV6 #6283

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

Closed
1 task done
copercini opened this issue Feb 14, 2022 · 11 comments
Closed
1 task done

Ethernet doesn't work with IPV6 #6283

copercini opened this issue Feb 14, 2022 · 11 comments
Labels

Comments

@copercini
Copy link
Contributor

Board

ESP32 dev module + LAN8720A

Device Description

ESP32 dev module + LAN8720A

Hardware Configuration

I think the hardware is fine, LAN8720A is working flawless with IPV4

Version

v2.0.2

IDE Name

Arduino IDE

Operating System

Ubuntu 20.04

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

It seems that IPV6 is not working with ethernet interface, I'm trying to add ETH.enableIpV6(); inside ARDUINO_EVENT_ETH_CONNECTED event, but it seems to produce no results, and ARDUINO_EVENT_ETH_GOT_IP6 is never called (check attached code). It's working fine with IPV4

I also checked with Wi-FI STA interface and IPV6 works as expected

Sketch

#include <ETH.h>

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event)
{
  Serial.printf("Event: %d\n", event);
  switch (event) {
    case ARDUINO_EVENT_ETH_START:
      Serial.println("ETH Started");
      //set eth hostname here
      ETH.setHostname("esp32-ethernet");
      break;
    case ARDUINO_EVENT_ETH_CONNECTED:
      Serial.println("ETH Connected");

      ////I'm trying to enable IPV6 here
      delay(10);
      ETH.enableIpV6();
      delay(10);
      /////

      break;
    case ARDUINO_EVENT_ETH_GOT_IP:
      Serial.print("ETH MAC: ");
      Serial.print(ETH.macAddress());
      Serial.print(", IPv4: ");
      Serial.print(ETH.localIP());
      if (ETH.fullDuplex()) {
        Serial.print(", FULL_DUPLEX");
      }
      Serial.print(", ");
      Serial.print(ETH.linkSpeed());
      Serial.println("Mbps");
      eth_connected = true;
      break;
    case ARDUINO_EVENT_ETH_DISCONNECTED:
      Serial.println("ETH Disconnected");
      eth_connected = false;
      break;
    case ARDUINO_EVENT_ETH_STOP:
      Serial.println("ETH Stopped");
      eth_connected = false;
      break;

    ////Expecting this IPV6 event, but it never happens
    case ARDUINO_EVENT_ETH_GOT_IP6:
      Serial.println("Ethernet IPv6 is preferred");
      break;
    ////



    default:
      break;
  }
}

void testClient(const char * host, uint16_t port)
{
  Serial.print("\nconnecting to ");
  Serial.println(host);

  WiFiClient client;
  if (!client.connect(host, port)) {
    Serial.println("connection failed");
    return;
  }
  client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
  while (client.connected() && !client.available());
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("closing connection\n");
  client.stop();
}

void setup()
{
  Serial.begin(115200);
  WiFi.onEvent(WiFiEvent);
  ETH.begin(1, 32, 2, 4, ETH_PHY_LAN8720); //ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE
}


void loop()
{
  if (eth_connected) {
    testClient("google.com", 80);
  }
  delay(10000);
}

Debug Message

Event: 18
ETH Started
Event: 20
ETH Connected
Event: 22
ETH MAC: 24:0A:C4:E3:26:4B, IPv4: 192.168.31.52, FULL_DUPLEX, 100Mbps

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@copercini copercini added the Status: Awaiting triage Issue is waiting for triage label Feb 14, 2022
@lbernstone
Copy link
Contributor

ARDUINO_EVENT_ETH_GOT_IP6 would mean that an address is assigned. How are you expecting to get your ipv6 address? SLAAC and DHCPv6 are not enabled in sdkconfig.

@copercini
Copy link
Contributor Author

@lbernstone Thanks for your reply, it's a bit weird because using Wi-Fi in the exactly same sdkconfig it's able to get at least a local IPV6, and event ARDUINO_EVENT_WIFI_STA_GOT_IP6 is called when it happens. I've tested with this example https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino

I'm also testing using IDF v4.4, the event appears but the IPV6 doesn't work using ethernet, only using Wi-Fi. Enabling SLAAC and DHCPv6 there, it gets a public IPV6, but I'm also not able to access ESP32 webserver from it

So far:
Arduino 2.0.2:
WiFi IPv4 works and I'm able to access webserver locally
WiFi IPv6 works and I'm able to access webserver locally
Ethernet IPv4 works and I'm able to access webserver locally
Ethernet IPv6 doesn't even call the event and doesn't work

IDF v4.4:
WiFi IPv4 works and I'm able to access webserver locally
WiFi IPv6 works and I'm able to access webserver locally
Ethernet IPv4 works and I'm able to access webserver locally
Ethernet IPv6 calls the event with an IPv6, but I'm not able to access webserver from it

@me-no-dev
Copy link
Member

so in both cases IPv6 does not work? With any option in menuconfig? That is rather strange... it used to work before :) Maybe regression in ETH in IDF?

@copercini
Copy link
Contributor Author

yes, in both cases it doesn't work, so I think it's an IDF bug, not in arduino layer. I'll open an issue there (and close this one?)

@me-no-dev
Copy link
Member

maybe leave it open to be closed when fixed there? It is still possible that something in the API has changed and requires changes here, but I doubt it.

@ewpa
Copy link

ewpa commented Feb 15, 2022

Confirming I had this issue for some time and I applied a fix in commit e205fedbe8522a5fbf84f5853c214c930bc4be42 for my fork of ewpa/esp-lwip. @copercini perhaps try to recreate the issue in my fork of ewpa/esp32-arduino under branch 2.0.2+dev and test the effectiveness of the below fix?

Always process Neighbor Solicitation messages. This fixes IPv6 Neighbor Discovery not finding the ESP32 on Ethernet interfaces.

@VojtechBartoska VojtechBartoska added Area: ESP-IDF related ESP-IDF related issues Status: Pending and removed Status: Awaiting triage Issue is waiting for triage labels Feb 16, 2022
@copercini
Copy link
Contributor Author

@ewpa it worked like magic!

Arduino 2.0.2 as IDF component with @ewpa fix from here:
ARDUINO_EVENT_ETH_GOT_IP6 event is not being triggered yet, but calling ETH.localIPv6() after a while it gets the correct IPv6 for ethernet and it's possible to access webserver from it

IDF v4.4:
It's working as expected now, I'm able to access webserver from local IPv6 printed on UART and even from global IPv6 when SLAAC and DHCPv6 are enabled in menuconfig 😄

@stale stale bot added the wontfix label Apr 18, 2022
@espressif espressif deleted a comment from stale bot Apr 20, 2022
nuclearcat added a commit to nuclearcat/esp32-arduino-lib-builder that referenced this issue May 7, 2022
To use IPv6 we need proper SLAAC support which is not possible without this option.
Compile tested on esp32, esp32s2, esp32s3, esp32c3
Functionality tested in esp32 BasicHttpClient with some minor patches, IPv6 start to work.

No significant sketch size increase (probably within rounding bounds):
Before:
Wrote 875328 bytes (558896 compressed) at 0x00010000 in 9.0 seconds (effective 779.4 kbit/s)...
After:
Wrote 875328 bytes (558942 compressed) at 0x00010000 in 9.0 seconds (effective 779.8 kbit/s)...

This patch part of the efforts mentioned in espressif/arduino-esp32#6242

Proper IPv6 support also was requested in:
espressif/arduino-esp32#6626
espressif/arduino-esp32#6590
espressif/arduino-esp32#6283
espressif/arduino-esp32#6703
espressif/arduino-esp32#5624
espressif/arduino-esp32#1261
And many others.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
nuclearcat added a commit to nuclearcat/esp32-arduino-lib-builder that referenced this issue May 10, 2022
To use IPv6 we need proper SLAAC support which is not possible without this option.
Compile tested on esp32, esp32s2, esp32s3, esp32c3
Functionality tested in esp32 BasicHttpClient with some minor patches, IPv6 start to work.

No significant sketch size increase (probably within rounding bounds):
Before:
Wrote 875328 bytes (558896 compressed) at 0x00010000 in 9.0 seconds (effective 779.4 kbit/s)...
After:
Wrote 875328 bytes (558942 compressed) at 0x00010000 in 9.0 seconds (effective 779.8 kbit/s)...

This patch part of the efforts mentioned in espressif/arduino-esp32#6242

Proper IPv6 support also was requested in:
espressif/arduino-esp32#6626
espressif/arduino-esp32#6590
espressif/arduino-esp32#6283
espressif/arduino-esp32#6703
espressif/arduino-esp32#5624
espressif/arduino-esp32#1261
And many others.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
nuclearcat added a commit to nuclearcat/esp32-arduino-lib-builder that referenced this issue May 23, 2022
To use IPv6 we need proper SLAAC support which is not possible without this option.
Compile tested on esp32, esp32s2, esp32s3, esp32c3
Functionality tested in esp32 BasicHttpClient with some minor patches, IPv6 start to work.

No significant sketch size increase (probably within rounding bounds):
Before:
Wrote 875328 bytes (558896 compressed) at 0x00010000 in 9.0 seconds (effective 779.4 kbit/s)...
After:
Wrote 875328 bytes (558942 compressed) at 0x00010000 in 9.0 seconds (effective 779.8 kbit/s)...

This patch part of the efforts mentioned in espressif/arduino-esp32#6242

Proper IPv6 support also was requested in:
espressif/arduino-esp32#6626
espressif/arduino-esp32#6590
espressif/arduino-esp32#6283
espressif/arduino-esp32#6703
espressif/arduino-esp32#5624
espressif/arduino-esp32#1261
And many others.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
me-no-dev pushed a commit to espressif/esp32-arduino-lib-builder that referenced this issue Jun 12, 2022
To use IPv6 we need proper SLAAC support which is not possible without this option.
Compile tested on esp32, esp32s2, esp32s3, esp32c3
Functionality tested in esp32 BasicHttpClient with some minor patches, IPv6 start to work.

No significant sketch size increase (probably within rounding bounds):
Before:
Wrote 875328 bytes (558896 compressed) at 0x00010000 in 9.0 seconds (effective 779.4 kbit/s)...
After:
Wrote 875328 bytes (558942 compressed) at 0x00010000 in 9.0 seconds (effective 779.8 kbit/s)...

This patch part of the efforts mentioned in espressif/arduino-esp32#6242

Proper IPv6 support also was requested in:
espressif/arduino-esp32#6626
espressif/arduino-esp32#6590
espressif/arduino-esp32#6283
espressif/arduino-esp32#6703
espressif/arduino-esp32#5624
espressif/arduino-esp32#1261
And many others.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
@VojtechBartoska
Copy link
Contributor

@copercini Please check merged PR which can solve your issue.

espressif/esp32-arduino-lib-builder#67

It will be available in next release 2.0.4.

@VojtechBartoska
Copy link
Contributor

still valid @copercini?

@VojtechBartoska
Copy link
Contributor

This is supposed to be fixed, can you please retest under v2.0.4 @copercini? Thanks.

@VojtechBartoska
Copy link
Contributor

Closing as solved, if needed please reopen the issue.

Repository owner moved this from In Review to Done in Arduino ESP32 Core Project Roadmap Aug 23, 2022
@VojtechBartoska VojtechBartoska added Status: Solved and removed Resolution: Awaiting response Waiting for response of author labels Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

5 participants