-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Issue with Auto-IP and Multicast/socket connection #53587
Comments
It's not clear to me either. The logic behind address selection in case I can see however another potential issue with IPv4 autoconf - it does not seem to set the subnet mask on the interface when the address is configured (
Have you seen those? The subnet issue should likely be fixed in the IPv4 autoconf module itself, i. e. when autoconf address is set, the subnet mask on the interface should also be updated, @jukkar do you agree? I see the limitation though, that it's not possible to have IPv4 addresses configured with different sub masks on a single interface, not sure if that's a big problem though. |
@rlubos : I did see
@rlubos , @carlescufi : #53666 does not fix the issue. |
@bonetor Just to clarify, what is the destination address in this scenario? |
The serverAddr in
The client software running on a PC sending and receiving Multicasts via UDP is in a network with IP starting with 10.x.x.x. |
Ok, then I've got confused by your previous statement, which suggested that the destination address is also IPv4 link-local:
But it seems that you want to send a packet to a non-link-local destination address, having only a link-local one, and this is simply not supported by Zephyr. In such case, the link-local source addresses are explicitly ignored: I think this approach is justifiable in simple implementations, given that LL addresses are not routable and should only be considered for link-local communication. RFC3927 however does mention a possibility of sending a packet to a host that does not have a LL address:
@jukkar What's your opinion, shall we introduce such a possibility? I think it should be possible to introduce a final fall-back, in case there's really no other address, to try to choose LL address here (only if autoconf is enabled): It'd still be needed however to register a valid gateway address (peer address in such case), otherwise ARP module will get confused, as from its perspective the IP packet is within different subnet, so it'll try to send it via gateway. |
@jukkar Any opinion on the above? |
Typically auto link local addresses are meant to point-to-point connection to a host with similar auto ip address, and have limited functionality (no routing etc). I would say that what we have implemented now is ok and fine, but I have no big objections if someone implements it and proposes patch, the review will then tell whether it should be accepted or not. |
@rlubos In regard to your comment
The statement
actually says, that the destination address is a link-local address. But in the mentioned case we want to send the package from the device with a link-local address to the destination address which is the Multicast IP address.
But why does the function returns true if |
I've now noticed that Anyway, fixing this doesn't fix the issue, as LL source would still be ignored for multicast destinations. Please give this branch a try, where I've implemented a fallback to LL address in case no better match is found: I've tested it briefly with the autoconf sample, and I was able to sucessfully send packets to mutlicast address or non-LL peers on the same local network. If you can confirm that this helps in your case as well, I can send a PR out of it for further review. |
I did a first test and with the changes on your branch it works also on my side. I will so some further tests with my setup and provide you more feedback. |
@bonetor Did you have a chance to do some more tests? |
Sorry for the late feedback. The described behavior is solved with the implementations on https://github.com/rlubos/zephyr/commits/net/use-ll-addr-as-last-resort. This issue can be closed. |
We still need to open a PR :) I'll send one. |
Hello together.
I am using the STM32H747-DISCO board with Zephyr v3.1 .
I configured a socket to receive Multicasts send via UDP by a client software running on a PC and I send back UDP packages to the client software as an answer to the received packages.
The socket is configured in the following way:
The socket is polled within a thread to receive the UDP packages and send back answers to the received packages via:
If a static IP is configured,
zsock_recvfrom
receives the Multicast andzsock_sendto
sends an answer to the client software.If the IP settings are changed during running my application from static to DHCP and a DHCP is available
zsock_recvfrom
receives the Multicast andzsock_sendto
sends an answer to the client software.If the IP settings are changed during running the application from static to DHCP and a DHCP is not available, Auto-IP is used and Zephyr sets an IP automatically. In that case and
zsock_recvfrom
receives the Multicast butzsock_sendto
does not send an answer to the client software and returns an error, -EINVAL.When debugging the issue I found out that in the function
net_if_ipv4_select_src_addr
in line 3215 of zephyr/subsys/net/ip/net_if.c the variablesrc
is not set and stays NULL.In case of Auto-IP the function call to
net_ipv4_is_ll_addr(dst)
in the if statement in line 3223 returns true as the Auto-IP address is a local-link address. Therefore the else statement in line 3254 is executed. Within that statement src is not set. That's why the if statement in line 3258 is executed. Within this statementnet_if_ipv4_get_global_addr
returns NULL andnet_ipv4_unspecified_address
returns NULL. That's why at the endzsock_sendto
fails.I do not understand why
src
is not set to a valid value in case of switching from static IP to Auto-IP. Why issrc
not set andzsock_sendto
fails at the end?In case of static IP the function call to
net_ipv4_is_ll_addr(dst)
in the if statement in line 3223 returns false and the if statement is executed. In that case line 3227 with the function callnet_if_ipv4_get_best_match
is executed andsrc
is set to the static IP address.The text was updated successfully, but these errors were encountered: