-
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
fix DNS resolution in ping6 #13450
fix DNS resolution in ping6 #13450
Conversation
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.
tests/gnrc_sock_udp
is failing with this PR. On master
it still works.
I restored the test to use The test is passing now again on |
I've marked it as an API change due to the doc change. However, since the doc is just adopted to the behavior, I don't think we need two ACKs here. |
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.
Tested on native
and samr21-xpro
using tests/gnrc_sock_dns
(don't have the set-up here to test with the border router and ping6
but I trust your testing there). One minor nit, to prevent errors introduced in future fixes. Other than that you may squash.
sys/net/application_layer/dns/dns.c
Outdated
|
||
sock_dns_hdr_t *hdr = (sock_dns_hdr_t*) buf; | ||
memset(hdr, 0, sizeof(*hdr)); | ||
hdr->id = 0; /* random? */ |
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.
I know this is just pulled down, but this should at least come from a variable now, that it is re-set on every retry.
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.
random_bytes(&hdr->id, sizeof(hdr->id));
?
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.
Don't overshoot ;-)
We need to set `res` to 0 to signal success, otherwise we end up in the print usage case.
When using ping6 with an IP address, don't do a DNS lookup. Hostnames can't contain ':', so use that to tell them apart from plain IP addressees.
Regarding the border router not forwarding the RDNSS option:
|
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.
Re-ACK
Saving RAM is more important than saving a few cycles used by re-creating the request buffer in the error case. Also reduce the size of the buffer to 128 bytes. If we are just requesting the AAAA record it is unlikely for the reply to take up the maximum size of 512 bytes. We were already placing restrictions on the domain name length, those are now actually a bit more relaxed (112 bytes instead of 64)
The implementation already did that, now also reflect this in the documentation.
I didn't know such option exists, but it gets set automatically if I will investigate the 2. & 3. when I'm home. |
but not for |
When I add |
And with |
Contribution description
Previously DNS resolution in
ping6
would always fail.This was due to a slew of minor bugs in
sock_dns
andgnrc_icmpv6_echo
.This PR fixes them, so DNS resolution is working properly now.
Testing procedure
If you are using a board with direct WiFi or Ethernet connection (e.g. esp8266 or esp32), it should suffice to add
USEMODULE += sock_dns
toexamples/gnrc_networking
.On a 6LoWPAN device, the border router (
examples/gnrc_border_router
) doesn't seem to forward DNS information, so you have to resort totests/gnrc_sock_dns
to being able to set the DNS server manually by calling e.g.dns server 2620:119:35::35:
.You should now be able to ping a host by name:
Issues/PRs references
fixes #13447
follow-up on #13443