-
Notifications
You must be signed in to change notification settings - Fork 3k
NSAPI DNS query IP version check for non LWIP stacks. #11375
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
Conversation
@tymoteuszblochmobica, thank you for your changes. |
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.
Accept also NSAPI_UNSPEC
as cellular stack does not always get IP address from a modem.
If gethostbyname(,,version)
was given it should probably be accepted in any case.
If we don't have IPv4 then should not accept A records, and if we don't have IPv6 then should not accept AAAA records.
If we have both IPv4 and IPv6 then get_ip_address
prefers IPv6, but DNS should also query IPv4 servers as that might be the network's primary DNS server.
Please also fix astyle failures |
Function gethostbyname remains unchanged. This fix refers only nsapi_dns_query_multiple (). First nsapi_dns_get_server_addr(stack, &index, &total_attempts, &send_success, &dns_addr, interface_name) If it fails then dns_addr->set_addr(dns_servers[*index - DNS_STACK_SERVERS_NUM]); Inside nsapi_dns.cpp there is secondary storage for DNS servers static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = { and it is used in this approach. Previously it was a reason of improper behavoiur due to dns_addr->set_addr sets first adress from nsapi_dns dns_servers table (8.8.8.8) even if required version was IP6. if(dns_addr.get_ip_version() != version){ to find next adresses from stack->get_dns_server or nsapi_dns dns_servers table. I assume stack->get_dns_server is implemented only for LWIP so in case of cellular stack nsapi_dns dns_servers will be used. Im confused with : If nsapi_dns_query_multiple (,version==NSAPI_UNSPEC) and stack->get_dns_server is not implemented for cellular, how can we get proper DNS IP version? |
e2265e2
to
7e9817e
Compare
@tymoteuszblochmobica I think that |
Do you mean |
@tymoteuszblochmobica If dual-stack is not required then A/AAAA version could be devised from the versions of the DNS servers' addresses? |
7e9817e
to
33eae52
Compare
Current implementation: dns_append_question selects which record we want |
@tymoteuszblochmobica Probably |
@tymoteuszblochmobica @AriParkkila How can we progress this PR? Is it still relevant? |
@AriParkkila . I talked to @tymoteuszblochmobica and it seems that the version should always be set before reaching the Do you agree? |
It doesn't seem so with cellular modems/networks as we don't always get IP address at all. |
features/netsocket/nsapi_dns.cpp
Outdated
@@ -1025,6 +1030,11 @@ static void nsapi_dns_query_async_send(void *ptr) | |||
return; | |||
} | |||
|
|||
if (dns_addr.get_ip_version() != query->version) { |
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.
Probably this should also have version != NSAPI_UNSPEC &&
It could be better to give |
@AriParkkila , please help me make sure I understand the background correctly... :) I assume that our entry point to the DNS resolution is
This PR will only affect the cellular modems which rely on our implementation of Now, your point is: what happens if DNS resolution takes place when the device doesn't have an IP address - do I understand correctly? |
Yes, the modem has IP address but it does not tell it to the device via AT commands. That is, we don't know the IP address type on the device, but since the modem has IP address DNS query is working fine. |
@AriParkkila , ok, we see your point now, thanks a lot for being patient with us 😃 But does this device actually use our |
33eae52
to
b8a18e2
Compare
Reviewers please review |
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 guess the most recent push from Tymoteusz includes @AriParkkila 's request: in case the ip version is unspecified the request will be send based upon whatever was specified in the dns_addr
.
I think it's best to wait for Ari's approval, though.
CI started |
I also restarted travis, internal fault |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
NetworkStack::gethostbyname(name, address, version) should return the same IP version as network interface.
There was solution #10794 for case when LWIP is in use.
This is fix for AT modems where DNS_API does the selection of server address.
Pull request type
Reviewers
@AriParkkila
@kjbracey-arm
@SeppoTakalo
@kivaisan
@mikaleppanen
Release Notes