-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add support for accessory DNS browse and resolve on Thread devices. #8132
Add support for accessory DNS browse and resolve on Thread devices. #8132
Conversation
b8c358c
to
67a2990
Compare
Currently Thread platform doesn't provide mDNS browse and resolve implementation. Moreover there is no way to trigger browse or resolve queries on accessory devices to perform operational discovery from accessory device perspective. For all: * Added set of dns shell commands allowing to invoke dns browse and dns resolve commands. For Thread: * Implemented ChipMdnsBrowse and ChipMdnsResolve. * Implemented ThreadStackMgr DnsResolve and DnsBrowse commands using OpenThread API for performing DNS queries. * Changed SRP service buffers sizes to allow handling Commissionable Discovery records (currently it was assumed to support only Operational Discovery and sizes are not big enough). * Added configs allowing to decide whether Thread DNS client and Thread Commissionable Discovery should be enabled (to avoid potential memory consumption problems on different platforms as Commissionable Discovery data are pretty heavy). For nrfconnect: * Enabled DNS client and commissionable discovery support by default. * Extended shell commands documentation about dns. What this change doesn't introduce: * Support for commissionable discovery on Thread devices, it only allows for handling commissionable discovery records responses when performing dns browse. * DNS browsing/resolving support on platforms other than nrfconnect, as it needs to be enabled individually by setting CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
67a2990
to
6cbb0b7
Compare
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
Is there a bloat report available for this change ? |
@tima-q I don't know, could you give me a hint how to enable it if I should be able to do that? |
@kkasperczyk-no Typically it triggers automatically on your PR as part of the CI. (did see some talk about issues with it) |
Sure, so in my particular case for lock-app on nrfconnect sizes changed accordingly: That includes building with new shell DNS commands, DNS client support and CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY = y, so assuming bigger txt arrays for commissionable records. Nevertheless it may not show real memory impact, as browse and resolve result objects are created in callbacks, so it will be allocated on stack and it's hard to predict real usage. |
src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp
Outdated
Show resolved
Hide resolved
ef95d30
to
7cbca44
Compare
if (!isResolverStarted) | ||
{ | ||
chip::Mdns::Resolver::Instance().StartResolver(&chip::DeviceLayer::InetLayer, chip::Mdns::kMdnsPort); | ||
chip::Mdns::Resolver::Instance().SetResolverDelegate(&sDnsShellResolverDelegate); |
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 am generally concerned at all of the code we're building up that enforces the singleton pattern for the mDNS module. I'm not sure why this is necessary. But it's going to force platforms that cannot tolerate this to interact with mDNS outside of the sdk, reducing the usefulness of the sdk's mDNS code in such cases.
And I think such scenarios are likely. All it would take for this to break is a single case where multiple separate, but concurrent discovery operations need to occur at the same time. I can think of several cases where a node would want to do that.
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.
@msandstedt Can you provide any use cases where using the singleton pattern for mDNS can be limiting? I always thought that the biggest issue in our codebase is that we allow a single delegate in certain components, so it's hard to spawn multiple jobs of the same kind in parallel. I thought that some pattern like:
struct ResolveRequest
{
NodeId mNodeId;
// ... other request params
OnComplete mOnCompleteCallback;
ResolveRequest* mNext;
void Complete(ResolveResult* result);
void Cancel();
};
might be a good idea to solve this issue. But I would welcome any arguments for multiple instances of the mDNS server in CHIP as well.
…roject-chip#8132) * Add support for accessory DNS browse and resolve on Thread devices. Currently Thread platform doesn't provide mDNS browse and resolve implementation. Moreover there is no way to trigger browse or resolve queries on accessory devices to perform operational discovery from accessory device perspective. For all: * Added set of dns shell commands allowing to invoke dns browse and dns resolve commands. For Thread: * Implemented ChipMdnsBrowse and ChipMdnsResolve. * Implemented ThreadStackMgr DnsResolve and DnsBrowse commands using OpenThread API for performing DNS queries. * Changed SRP service buffers sizes to allow handling Commissionable Discovery records (currently it was assumed to support only Operational Discovery and sizes are not big enough). * Added configs allowing to decide whether Thread DNS client and Thread Commissionable Discovery should be enabled (to avoid potential memory consumption problems on different platforms as Commissionable Discovery data are pretty heavy). For nrfconnect: * Enabled DNS client and commissionable discovery support by default. * Extended shell commands documentation about dns. What this change doesn't introduce: * Support for commissionable discovery on Thread devices, it only allows for handling commissionable discovery records responses when performing dns browse. * DNS browsing/resolving support on platforms other than nrfconnect, as it needs to be enabled individually by setting CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT * Addressed review comments
Problem
Currently Thread platform doesn't provide mDNS browse and resolve implementation. Moreover there is no way to trigger browse or resolve queries on accessory devices to perform operational discovery from accessory device perspective.
Change overview
For all:
For Thread:
(to avoid potential memory consumption problems on different platforms as Commissionable Discovery data are pretty heavy).
For nrfconnect:
What this change doesn't introduce:
responses when performing dns browse.
CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
Testing
It was tested only for Thread devices using set of
dns
CHIP shell commands on nrfconnect platform.Prerequisities:
Discovery_ImplPlatform.cpp
implementation uses dns browse only for searching_matterc._udp
records (so commissionable ones) and resolve for searching_matter._tcp
records.CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT
andchip_build_libshell
enabled.Steps to test:
dns resolve <fabric-id> <node-id>
(e.g.dns resolve 5544332211 1
) command in the accessory shell terminal. For nrfconnect platform CHIP shell commands must be additionally preceded bymatter
prefix (somatter dns resolve ...
). Expected output on success:Expected output on failure (service not found):
dns browse
command in the accessory shell terminal. For nrfconnect platform CHIP shell commands must be additionally preceded bymatter
prefix (somatter dns browse
).Expected output on success:
Expected output on empty browse result: