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

Move chip tool resolve command to address_resolver #15544

Conversation

andy31415
Copy link
Contributor

Problem

Looking for a path to start using address resolution logic instead of ResolveProxy, since address resolution handles prioritization and timeouts as well as parallel search potential.

Change overview

Changed chip-tool discovery resolve to use addresss_resolve. This PR is a delta from #15536 (since it requires MRP and tcp data to display).

Since nodedata MRP parameters seem to NOT be optional, I updated the tool to always print out MRP settings that it would use. This means that it would not print out DNSSD data but rather the configuration that other CHIP operations would/should use.

Testing

Manually ran ./out/linux-x64-chip-tool/chip-tool discover resolve 0x000000000001E1B9 0x116362B9D227A22A observed values were printed out.

@github-actions
Copy link

github-actions bot commented Feb 24, 2022

PR #15544: Size comparison from a4d427d to f0188e8

Increases (2 builds for linux)
platform target config section a4d427d f0188e8 change % change
linux chip-tool debug (read only) 8994605 9002349 7744 0.1
(read/write) 298488 298808 320 0.1
.bss 40384 40448 64 0.2
.data.rel.ro 250872 251144 272 0.1
.rodata 480405 480981 576 0.1
.text 7905749 7912485 6736 0.1
chip-tool-ipv6only arm64 (read only) 8749020 8756812 7792 0.1
(read/write) 411617 412033 416 0.1
.bss 58625 58673 48 0.1
.data.rel.ro 296568 296840 272 0.1
.got 51408 51496 88 0.2
.rodata 456644 456916 272 0.1
.text 7427924 7434660 6736 0.1
Full report (45 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section a4d427d f0188e8 change % change
cyw30739 light cyw930739m2evb_01 (read/write) 599230 599230 0 0.0
.app_xip_area 504076 504076 0 0.0
.bss 77844 77844 0 0.0
.data 652 652 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock cyw930739m2evb_01 (read/write) 557282 557282 0 0.0
.app_xip_area 463664 463664 0 0.0
.bss 76348 76348 0 0.0
.data 616 616 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 578006 578006 0 0.0
.app_xip_area 474956 474956 0 0.0
.bss 85452 85452 0 0.0
.data 560 560 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 916184 916184 0 0.0
(read/write) 128608 128608 0 0.0
.bss 126560 126560 0 0.0
.data 2048 2048 0 0.0
.text 916176 916176 0 0.0
BRD4161A+rpc (read only) 946288 946288 0 0.0
(read/write) 145552 145552 0 0.0
.bss 143336 143336 0 0.0
.data 2212 2212 0 0.0
.text 946280 946280 0 0.0
lock-app BRD4161A+wf200 (read only) 985904 985904 0 0.0
(read/write) 120364 120364 0 0.0
.bss 118436 118436 0 0.0
.data 1924 1924 0 0.0
.text 985896 985896 0 0.0
window-app BRD4161A (read only) 850440 850440 0 0.0
(read/write) 126512 126512 0 0.0
.bss 124592 124592 0 0.0
.data 1916 1916 0 0.0
.text 850432 850432 0 0.0
esp32 all-clusters-app c3devkit (read only) 952106 952106 0 0.0
(read/write) 1392906 1392906 0 0.0
.dram0.bss 62944 62944 0 0.0
.dram0.data 14172 14172 0 0.0
.flash.rodata 196896 196896 0 0.0
.flash.text 952106 952106 0 0.0
.iram0.text 62056 62056 0 0.0
m5stack (read only) 1002231 1002231 0 0.0
(read/write) 458392 458392 0 0.0
.dram0.bss 68080 68080 0 0.0
.dram0.data 34072 34072 0 0.0
.flash.rodata 224112 224112 0 0.0
.flash.text 996847 996847 0 0.0
.iram0.text 123399 123399 0 0.0
k32w light k32w061+release (read/write) 691784 691784 0 0.0
.bss 77480 77480 0 0.0
.data 1924 1924 0 0.0
.text 606580 606580 0 0.0
lock k32w061+release (read/write) 694880 694880 0 0.0
.bss 77688 77688 0 0.0
.data 1964 1964 0 0.0
.text 609428 609428 0 0.0
linux all-clusters-app debug (read only) 2392177 2392177 0 0.0
(read/write) 144688 144688 0 0.0
.bss 59232 59232 0 0.0
.data 1360 1360 0 0.0
.data.rel.ro 78392 78392 0 0.0
.dynamic 592 592 0 0.0
.got 4160 4160 0 0.0
.init 27 27 0 0.0
.init_array 904 904 0 0.0
.rodata 203717 203717 0 0.0
.text 2025714 2025714 0 0.0
bridge-app debug+rpc (read only) 1718061 1718061 0 0.0
(read/write) 92736 92736 0 0.0
.bss 47552 47552 0 0.0
.data 2042 2042 0 0.0
.data.rel.ro 38088 38088 0 0.0
.dynamic 592 592 0 0.0
.got 3912 3912 0 0.0
.init 27 27 0 0.0
.init_array 536 536 0 0.0
.rodata 140532 140532 0 0.0
.text 1461749 1461749 0 0.0
chip-tool debug (read only) 8994605 9002349 7744 0.1
(read/write) 298488 298808 320 0.1
.bss 40384 40448 64 0.2
.data 1164 1164 0 0.0
.data.rel.ro 250872 251144 272 0.1
.dynamic 608 608 0 0.0
.got 4784 4784 0 0.0
.init 27 27 0 0.0
.init_array 624 624 0 0.0
.rodata 480405 480981 576 0.1
.text 7905749 7912485 6736 0.1
chip-tool-ipv6only arm64 (read only) 8749020 8756812 7792 0.1
(read/write) 411617 412033 416 0.1
.bss 58625 58673 48 0.1
.data 1216 1216 0 0.0
.data.rel.ro 296568 296840 272 0.1
.dynamic 560 560 0 0.0
.got 51408 51496 88 0.2
.init 24 24 0 0.0
.init_array 208 208 0 0.0
.rodata 456644 456916 272 0.1
.text 7427924 7434660 6736 0.1
door-lock-app debug (read only) 1933689 1933689 0 0.0
(read/write) 119128 119128 0 0.0
.bss 50496 50496 0 0.0
.data 1050 1050 0 0.0
.data.rel.ro 62200 62200 0 0.0
.dynamic 592 592 0 0.0
.got 4096 4096 0 0.0
.init 27 27 0 0.0
.init_array 656 656 0 0.0
.rodata 172540 172540 0 0.0
.text 1612690 1612690 0 0.0
lighting-app debug+rpc (read only) 2068553 2068553 0 0.0
(read/write) 124488 124488 0 0.0
.bss 51424 51424 0 0.0
.data 1472 1472 0 0.0
.data.rel.ro 66144 66144 0 0.0
.dynamic 608 608 0 0.0
.got 4128 4128 0 0.0
.init 27 27 0 0.0
.init_array 704 704 0 0.0
.rodata 165137 165137 0 0.0
.text 1747986 1747986 0 0.0
ota-provider-app debug (read only) 1866257 1866257 0 0.0
(read/write) 114792 114792 0 0.0
.bss 50368 50368 0 0.0
.data 1320 1320 0 0.0
.data.rel.ro 57480 57480 0 0.0
.dynamic 608 608 0 0.0
.got 4352 4352 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 157683 157683 0 0.0
.text 1558034 1558034 0 0.0
ota-requestor-app debug (read only) 1876977 1876977 0 0.0
(read/write) 116560 116560 0 0.0
.bss 51232 51232 0 0.0
.data 1192 1192 0 0.0
.data.rel.ro 58744 58744 0 0.0
.dynamic 592 592 0 0.0
.got 4152 4152 0 0.0
.init 27 27 0 0.0
.init_array 616 616 0 0.0
.rodata 151460 151460 0 0.0
.text 1576706 1576706 0 0.0
shell debug (read only) 2360377 2360377 0 0.0
(read/write) 147168 147168 0 0.0
.bss 67552 67552 0 0.0
.data 864 864 0 0.0
.data.rel.ro 73096 73096 0 0.0
.dynamic 592 592 0 0.0
.got 4144 4144 0 0.0
.init 27 27 0 0.0
.init_array 888 888 0 0.0
.rodata 203698 203698 0 0.0
.text 2000146 2000146 0 0.0
thermostat-no-ble arm64 (read only) 2160996 2160996 0 0.0
(read/write) 148577 148577 0 0.0
.bss 65265 65265 0 0.0
.data 1056 1056 0 0.0
.data.rel.ro 75080 75080 0 0.0
.dynamic 560 560 0 0.0
.got 4216 4216 0 0.0
.init 24 24 0 0.0
.init_array 352 352 0 0.0
.rodata 132308 132308 0 0.0
.text 1810384 1810384 0 0.0
tv-app debug (read only) 2586969 2586969 0 0.0
(read/write) 148624 148624 0 0.0
.bss 65824 65824 0 0.0
.data 3168 3168 0 0.0
.data.rel.ro 73624 73624 0 0.0
.dynamic 592 592 0 0.0
.got 4528 4528 0 0.0
.init 27 27 0 0.0
.init_array 872 872 0 0.0
.rodata 197693 197693 0 0.0
.text 2215538 2215538 0 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2449528 2449528 0 0.0
.bss 191016 191016 0 0.0
.data 5512 5512 0 0.0
.text 1412100 1412100 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2414288 2414288 0 0.0
.bss 188188 188188 0 0.0
.data 5800 5800 0 0.0
.text 1376860 1376860 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2350044 2350044 0 0.0
.bss 187092 187092 0 0.0
.data 5776 5776 0 0.0
.text 1312644 1312644 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1155428 1155428 0 0.0
.bss 11952 11952 0 0.0
.data 4512 4512 0 0.0
.text 118812 118812 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2340040 2340040 0 0.0
.bss 185736 185736 0 0.0
.data 5608 5608 0 0.0
.text 1302612 1302612 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1038339 1038339 0 0.0
bss 125756 125756 0 0.0
rodata 135572 135572 0 0.0
text 699796 699796 0 0.0
lighting-app nrf52840dk_nrf52840 (read/write) 1001659 1001659 0 0.0
bss 122064 122064 0 0.0
rodata 115860 115860 0 0.0
text 686232 686232 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 967975 967975 0 0.0
bss 119148 119148 0 0.0
rodata 107240 107240 0 0.0
text 663456 663456 0 0.0
nrf52840dongle_nrf52840 (read/write) 1017643 1017643 0 0.0
bss 123112 123112 0 0.0
rodata 115504 115504 0 0.0
text 690884 690884 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 904470 904470 0 0.0
bss 119352 119352 0 0.0
rodata 107972 107972 0 0.0
text 595944 595944 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 930655 930655 0 0.0
bss 120280 120280 0 0.0
rodata 104648 104648 0 0.0
text 628664 628664 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 834282 834282 0 0.0
bss 117600 117600 0 0.0
rodata 96680 96680 0 0.0
text 539140 539140 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 501603 501603 0 0.0
bss 52584 52584 0 0.0
rodata 44500 44500 0 0.0
text 342712 342712 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 928899 928899 0 0.0
bss 120012 120012 0 0.0
rodata 103628 103628 0 0.0
text 628092 628092 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 924875 924875 0 0.0
bss 120016 120016 0 0.0
rodata 103324 103324 0 0.0
text 624348 624348 0 0.0
shell nrf52840dk_nrf52840 (read/write) 788795 788795 0 0.0
bss 112360 112360 0 0.0
rodata 74836 74836 0 0.0
text 525496 525496 0 0.0
p6 all-clusters-app default (read/write) 2487592 2487592 0 0.0
.bss 118664 118664 0 0.0
.data 2688 2688 0 0.0
.text 1445856 1445856 0 0.0
light-app default (read/write) 2394792 2394792 0 0.0
.bss 112984 112984 0 0.0
.data 2536 2536 0 0.0
.text 1353056 1353056 0 0.0
lock-app default (read/write) 2358344 2358344 0 0.0
.bss 112728 112728 0 0.0
.data 2496 2496 0 0.0
.text 1316608 1316608 0 0.0
qpg lighting-app qpg6105+debug (read only) 600968 600968 0 0.0
(read/write) 146936 146936 0 0.0
.bss 90904 90904 0 0.0
.data 1124 1124 0 0.0
.text 595648 595648 0 0.0
lock-app qpg6105+debug (read only) 566744 566744 0 0.0
(read/write) 146936 146936 0 0.0
.bss 90912 90912 0 0.0
.data 1076 1076 0 0.0
.text 561424 561424 0 0.0
persistent-storage-app qpg6105+debug (read only) 99536 99536 0 0.0
(read/write) 146941 146941 0 0.0
.bss 24001 24001 0 0.0
.data 180 180 0 0.0
.text 94216 94216 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 882394 882394 0 0.0
bss 86336 86336 0 0.0
noinit 37160 37160 0 0.0
text 623642 623642 0 0.0

@andy31415
Copy link
Contributor Author

fast track after 24h

@andy31415 andy31415 merged commit c1d14cc into project-chip:master Feb 25, 2022

/////////// DiscoverCommand Interface /////////
CHIP_ERROR RunCommand(NodeId remoteId, uint64_t fabricId) override
{
ReturnErrorOnFailure(mDNSResolver.Init(chip::DeviceLayer::UDPEndPointManager()));
mDNSResolver.SetOperationalDelegate(this);
ChipLogProgress(chipTool, "Dnssd: Searching for NodeId: %" PRIx64 " FabricId: %" PRIx64 " ...", remoteId, fabricId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this logging get removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced the entire content of the command , so I ended up removing all existing content. Did not seem like a very important log as it basically repeats command-line arguments so it will likely not provide extra information for the user (although it could be used to validate that parsing is ok).

I can add it back if it seems important.


if (retryInterval.HasValue())
ChipLogProgress(chipTool, " MRP retry interval (active): %" PRIu32 "ms", retryInterval.Value().count());
result.address.ToString(addrBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

But ... this command was in fact meant to be used to log all the addresses being advertised, so it could be used for testing that. This breaks the command, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could see no obvious docks that would say "it lists all addresses". I assumed any mention of "all addresses" is not correct because our mdns implementations cannot seem to guarantee this - at least avahi can only show one it seems (at least when I poked at it I could not get it to give me multiple addresses).

Copy link
Contributor

Choose a reason for hiding this comment

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

This command is meant for testing purposes. Yes, the docs are not great. But this was one of the few things we had that we could use to actually see what ips are ending up resolving in practice.... What is the replacement?

And yes, with Avahi the results were wrong. That should be fixed in the Avahi intergration bits, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding of the use was do resolve like chip library does and give me the result hence my implementation. Is there a need for full results? I was assuming no since we are aware not all libs coud do it.

I see no very direct replacements so I would be willing to re-work or undo the change (prefer rework really since I would change the name to "resolve-all-addresses").

For debug the resolver logs its own lookups so there is data there beyond just one address and we can enhance that (this command was using LogProgress as well, so maybe no loss in data, but some loss in formatting and we may need to force resolver to log all addresses instead of just new best picks).

I would like to understand the use case though - who uses this command and where. My change was assuming "this does a resolve of a node and wants the same result as the regular chip library". If instead we want "Log content of DNSSD resolve packets" that works too. In that case I think we should not be using Proxy but rather use the DNSSD interfaces only (as there is no parallelism).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tagging @vivien-apple to see how to follow up on this. I am unsure who uses this and where

Copy link
Contributor

Choose a reason for hiding this comment

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

The original goal of this command was to get the ip/port used by the controller to talk to a commissioned device. It was mostly a tool to debug the darwin backend without having to resort to ChipTool iOS.

Now I believe it has evolved over time to be used as a debug tool when dealing with mdns advertisement related issues, so a replacement would be useful. About using Proxy versus dnssd interfaces, this is mostly a story of what is the easiest thing to use since the focus for this utility is really on the dnssd data, not on the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to take any specific action here to have all addresses reported or is this usable as-is?

I would prefer as little delta as possible - either keep as is or if we need to see all addresses to add logging into the address resolver for each address since that seems to serve the "use for debug" purpose and the final result is useful to "get the ip/port used by the controller".

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding logging into the resolver would be a good idea, I think, and sufficient ofor debugging purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created #15653 for this.

@andy31415 andy31415 deleted the move_chip_tool_resolve_command_to_resolver branch June 14, 2023 12:25
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.

4 participants