Skip to content
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

Fix UDP send to IPv6 link local addresses #6541

Merged
merged 2 commits into from
Apr 11, 2020

Conversation

nomis
Copy link
Contributor

@nomis nomis commented Sep 20, 2019

lwIP's tcp/udp_connect() and tcp/udp_bind() functions automatically
set the zone if it is required but missing, but udp_connect() is not
used so this doesn't happen.

Explicitly set the zone to the default network interface if it is
required for the type of address being used. Otherwise there is no
zone set and packets to a link local destination don't go anywhere.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 20, 2019

Thanks !
What about a comment with your explanation ?
Did you try to simply call udp_connect() instead ?

lwIP's tcp/udp_connect() and tcp/udp_bind() functions automatically
set the zone if it is required but missing, but udp_connect() is not
used so this doesn't happen.

Explicitly set the zone to the default network interface if it is
required for the type of address being used. Otherwise there is no
zone set and packets to a link local destination don't go anywhere.
@nomis
Copy link
Contributor Author

nomis commented Sep 20, 2019

I've just tried using udp_connect() and lwIP isn't selecting the zone for a link local address because it tries to route to it and no source address has been provided... so it looks like TCP to link-local address won't currently work either.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 20, 2019

I had been testing TCP with fe80: and I remember it worked. Did you try ?

edit: didn't work after dedicated test (I might have tried the other way around)

@nomis
Copy link
Contributor Author

nomis commented Sep 20, 2019

No, I've not tested TCP at all. Did you set or bind a source address explicitly?

If it works without specifying a source address then it would be reasonable to apply this fix so that UDP works too.

@d-a-v
Copy link
Collaborator

d-a-v commented Sep 20, 2019

No, I've not tested TCP at all. Did you set or bind a source address explicitly?

No.
I'd have to retry testing. You can too: take any tcp/http client example and change the address to your link-local IPv6 server address.

I assume this issue would exist only for client not server, but it can also be tried with server examples. Under linux, link-local server addresses must be extended with %intfname like fe80::%eth0.

@devyte
Copy link
Collaborator

devyte commented Nov 8, 2019

What is the status here?

@devyte
Copy link
Collaborator

devyte commented Nov 20, 2019

@nomis ping

@devyte devyte added this to the 2.7.0 milestone Nov 20, 2019
Copy link
Collaborator

@d-a-v d-a-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change, IPv6 UDP packets to fe80:: do not leave esp (Udp.endPacket() == 0).
With this change, I can see them with tcpdump on my router.

@d-a-v
Copy link
Collaborator

d-a-v commented Apr 11, 2020

This change is also necessary for TCP (credit will be given).
Merging for UDP.

@d-a-v d-a-v merged commit ee619d3 into esp8266:master Apr 11, 2020
d-a-v added a commit to d-a-v/Arduino that referenced this pull request Apr 11, 2020
d-a-v added a commit that referenced this pull request Apr 11, 2020
credit: Simon Arlott @nomis - similar to #6541 for TCP (#7207)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants