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

[network] interface-aware DNS lookups #2864

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

avtolstoy
Copy link
Member

@avtolstoy avtolstoy commented Feb 18, 2025

Problem

Despite the fact that we store all interface-specific DNS servers (statically configured or over DHCP/PPP etc) the resolver only uses the first and then on failure subsequent servers in this table. There is no API to tell the resolver to use only interface X.

This may have undesired effect even on cloud connectivity. For example, in case of M SoM with eth, wifi and cellular available, but eth and wifi providing bogus DNS responses (app firewall or other reasons), while the connection can still be performed over cellular, it might fail because we are unable to correctly resolve cloud server address.

Solution

  1. Introduce an API to perform interface-aware lookups
  2. Make sure that when initiating a cloud connection we perform lookups through the ACM-selected network interface
  3. Make sure that ACM round-robins interfaces for DNS lookups in case of reachability failures. This is not ideal, but is a trade-off to not perform up to currently 3 blocking DNS lookups per each interface, as that can take a signficant amount of time.

Steps to Test

TODO

References

particle-iot/lwip#17


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@avtolstoy avtolstoy added this to the 6.3.1 milestone Feb 18, 2025
@avtolstoy avtolstoy force-pushed the feature/interface-aware-dns-lookups branch 4 times, most recently from 78ff74d to 069beee Compare February 18, 2025 16:36
Copy link
Member

@scott-brust scott-brust Feb 18, 2025

Choose a reason for hiding this comment

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

roundRobinInterfaceForDns_++;
}
}
CHECK(getCloudHostnameAndPort(&info, &type, !fullTest, iface));
Copy link
Member

Choose a reason for hiding this comment

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

Will using the iface from the round robin selection above filter out all the other resolved addresses from the other interfaces dns_tables?
Are we relying on there being multiple entries in info in order to implicitly associate a resolved address with a network interface? Do we only test one interface with this change?

Copy link
Member

Choose a reason for hiding this comment

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

I guess in situations where lastTestFailed did not fail, we will still test all interfaces. IE iface = NETWORK_INTERFACE_ALL. So in effect, we will round robin test 1 interface at a time with its DNS until it succeeds. Then all subsequent tests will use all available interfaces

Copy link
Member Author

@avtolstoy avtolstoy Feb 19, 2025

Choose a reason for hiding this comment

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

Something like that, yes. It's just a trade-off to get out of this weird state:

This may have undesired effect even on cloud connectivity. For example, in case of M SoM with eth, wifi and cellular available, but eth and wifi providing bogus DNS responses (app firewall or other reasons), while the connection can still be performed over cellular, it might fail because we are unable to correctly resolve cloud server address.

Again, ideally during the test we'd resolve X number of times per each iface with its set of servers, but it's a blocking call and might take a while, so as a trade off - normally we use NETWORK_INTERFACE_ALL - so the default prioritization in DNS server list, in case we see a complete reachability failure we'll round robin through all ifaces/their dns servers to try to correctly resolve, yes, this might take several iterations - but we'll recover. And cloud connection layer subsequently will use the same servers/interface to resolve before establishing connection.

@avtolstoy avtolstoy force-pushed the feature/interface-aware-dns-lookups branch from 069beee to f7ac87e Compare February 19, 2025 16:22
@scott-brust scott-brust self-requested a review February 19, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants