-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/net/sock_util: don't require interface for link-local addr if there is only a single interface #17927
Conversation
int _get_default_netif(sock_udp_ep_t *ep_out) | ||
{ | ||
netif_t *netif = netif_iter(NULL); | ||
if (netif == NULL || netif_iter(netif) != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why checking again for netif_iter(netif) != NULL
? According to doc netif_iter
returns NULL, if there is no interface after @p last
, which would be already true for the first call of netif_iter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
netif_iter(NULL)
gives the first interfacenetif_iter(netif_iter(NULL))
gives the second interface- and so on
This should only set the interface if there is a first, but not a second interface. (to mirror the behavior of netutils_get_ipv6()
)
a208497
to
1971855
Compare
1971855
to
4aca39c
Compare
When the sock_tl_str2ep() function is supplied with a link-local address but no interface, if there is only a single interface use that instead of not setting the interface.
46dd6b2
to
cf3cbce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current behavior isn't to not set the interface but it is set to 0
(as it is done for IPv4) the same is happening for non link-local addresses. (this behavior is currently untested for IPv6, but tested for IPv4 in unittests/sock_util
)
With this PR non link-local addresses without interface return EINVAL (they did not before).
0
seems a sane choice to me, if there is just one interface (tell me if I am wrong).
Just to repeat the current behavior is [fe80::90a7:a6ff:fe4b:2e32]
-> ep.netif=0, ep.port=0, ep.addr set value
huh, that would be a bug - this PR only applies to IPv6 link-local addresses, behavior for all other address types remains unchanged. |
oops that wasn't the cause when i tested with |
superseded by #18065 |
Contribution description
When the
sock_tl_str2ep()
function is supplied with a link-local address but no interface, if there is only a single interface use that instead of not setting the interface.This is to match the behavior of the
ping
command.Testing procedure
tests/nanocoap_cli
is a user of this API.still works but now you can also do
If there is only a single interface.
Issues/PRs references