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

Darwin: Fix error handling in GetMACAddressFromInterfaces #32658

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

ksperling-apple
Copy link
Contributor

Correctly return CHIP_ERROR_NOT_FOUND when there is no active, primary interface to get the MAC address from.

Also tidy up management of IOKit objects. (Use of IOObjectGetRetainCount is completely wrong here.)

Fixes #29556

Correctly return CHIP_ERROR_NOT_FOUND when there is no active, primary
interface to get the MAC address from.

Also tidy up management of IOKit objects. (Use of IOObjectGetRetainCount is
completely wrong here.)
Copy link
Contributor

@bzbarsky-apple bzbarsky-apple left a comment

Choose a reason for hiding this comment

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

Thank you; this is a definite improvement on what we have right now.

One thing to consider as a followup: what this will do is that if we return error the caller will generate a random "mac address" to use as the hostname. And it will be a different one each time this is called.

Maybe what we should do is just have a static buffer in here that we randomly generate ourselves, once per process lifetime, in the case when we don't find an actual MAC address. That said, if we randomly roll our MAC addresses on some schedule we might want to roll that one too, not have it be just process-lifetime.

Anyway, all that is followup fodder.

@ksperling-apple
Copy link
Contributor Author

Fast-tracking Darwin-only change.

@mergify mergify bot merged commit c644692 into project-chip:master Mar 21, 2024
68 checks passed
@andy31415
Copy link
Contributor

andy31415 commented Mar 21, 2024

PR #32658: Size comparison from 03531f7 to 1c7c7ad

Decreases (2 builds for efr32)
platform target config section 03531f7 1c7c7ad change % change
efr32 lighting-app BRD4161A+rs9116 (read/write) 933912 933904 -8 -0.0
.text 734532 734524 -8 -0.0
BRD4187C (read/write) 1110840 1110832 -8 -0.0
.text 912228 912220 -8 -0.0
Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
platform target config section 03531f7 1c7c7ad change % change
bl602 lighting-app bl602 (read/write) 1437770 1437770 0 0.0
.bss 85352 85352 0 0.0
.data 9496 9496 0 0.0
.rodata 158432 158432 0 0.0
.text 1103848 1103848 0 0.0
bl602+mfd (read/write) 1452194 1452194 0 0.0
.bss 85512 85512 0 0.0
.data 9472 9472 0 0.0
.rodata 157392 157392 0 0.0
.text 1119166 1119166 0 0.0
bl602+rpc (read/write) 1485418 1485418 0 0.0
.bss 93384 93384 0 0.0
.data 9872 9872 0 0.0
.rodata 166000 166000 0 0.0
.text 1135494 1135494 0 0.0
bl702 lighting-app bl702 (read only) 3478 3478 0 0.0
(read/write) 1202215 1202215 0 0.0
.bss 11133 11133 0 0.0
.data 3680 3680 0 0.0
.rodata 107784 107784 0 0.0
.text 972748 972748 0 0.0
bl702+mfd (read only) 3478 3478 0 0.0
(read/write) 1213271 1213271 0 0.0
.bss 11309 11309 0 0.0
.data 3656 3656 0 0.0
.rodata 106724 106724 0 0.0
.text 984758 984758 0 0.0
bl702+rpc (read only) 3478 3478 0 0.0
(read/write) 1293963 1293963 0 0.0
.bss 19613 19613 0 0.0
.data 4216 4216 0 0.0
.rodata 123156 123156 0 0.0
.text 1047712 1047712 0 0.0
bl706-eth (read/write) 1019929 1019929 0 0.0
.bss 23708 23708 0 0.0
.data 3256 3256 0 0.0
.rodata 101116 101116 0 0.0
.text 763876 763876 0 0.0
bl706-wifi (read/write) 1254514 1254514 0 0.0
.bss 10577 10577 0 0.0
.data 3688 3688 0 0.0
.rodata 122116 122116 0 0.0
.text 995722 995722 0 0.0
bl702l lighting-app bl702l (read only) 512 512 0 0.0
(read/write) 1171792 1171792 0 0.0
.bss 16328 16328 0 0.0
.data 5040 5040 0 0.0
.rodata 101788 101788 0 0.0
.text 965846 965846 0 0.0
bl702l+mfd (read only) 512 512 0 0.0
(read/write) 1182940 1182940 0 0.0
.bss 16504 16504 0 0.0
.data 5024 5024 0 0.0
.rodata 100728 100728 0 0.0
.text 977912 977912 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 (read only) 774060 774060 0 0.0
(read/write) 168624 168624 0 0.0
.bss 90628 90628 0 0.0
.data 3560 3560 0 0.0
.rodata 81820 81820 0 0.0
.text 691976 691976 0 0.0
lock-ftd LP_EM_CC1354P10_6 (read only) 790484 790484 0 0.0
(read/write) 178872 178872 0 0.0
.bss 100876 100876 0 0.0
.data 3560 3560 0 0.0
.rodata 76004 76004 0 0.0
.text 714216 714216 0 0.0
lock-mtd LP_EM_CC1354P10_6 (read only) 779124 779124 0 0.0
(read/write) 173312 173312 0 0.0
.bss 95316 95316 0 0.0
.data 3560 3560 0 0.0
.rodata 102756 102756 0 0.0
.text 676104 676104 0 0.0
pump-app LP_EM_CC1354P10_6 (read only) 731396 731396 0 0.0
(read/write) 167592 167592 0 0.0
.bss 89360 89360 0 0.0
.data 3552 3552 0 0.0
.rodata 77484 77484 0 0.0
.text 653648 653648 0 0.0
pump-controller-app LP_EM_CC1354P10_6 (read only) 716916 716916 0 0.0
(read/write) 167800 167800 0 0.0
.bss 89584 89584 0 0.0
.data 3544 3544 0 0.0
.rodata 73260 73260 0 0.0
.text 643392 643392 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL (read only) 583402 583402 0 0.0
(read/write) 207992 207992 0 0.0
.bss 201228 201228 0 0.0
.data 1640 1640 0 0.0
.rodata 86610 86610 0 0.0
.text 494668 494668 0 0.0
lock CC3235SF_LAUNCHXL (read only) 628674 628674 0 0.0
(read/write) 208336 208336 0 0.0
.bss 201720 201720 0 0.0
.data 1496 1496 0 0.0
.rodata 107066 107066 0 0.0
.text 519484 519484 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 569195 569195 0 0.0
.app_xip_area 458949 458949 0 0.0
.bss 65080 65080 0 0.0
.data 744 744 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 551867 551867 0 0.0
.app_xip_area 436861 436861 0 0.0
.bss 69832 69832 0 0.0
.data 752 752 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 571995 571995 0 0.0
.app_xip_area 463253 463253 0 0.0
.bss 63616 63616 0 0.0
.data 704 704 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
switch cyw930739m2evb_01 (read/write) 564931 564931 0 0.0
.app_xip_area 452909 452909 0 0.0
.bss 66816 66816 0 0.0
.data 784 784 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A+rs9116 (read/write) 933912 933904 -8 -0.0
.bss 197960 197960 0 0.0
.data 1396 1396 0 0.0
.text 734532 734524 -8 -0.0
BRD4187C (read/write) 1110840 1110832 -8 -0.0
.bss 195176 195176 0 0.0
.data 3416 3416 0 0.0
.text 912228 912220 -8 -0.0
lock-app BRD4161A+wf200 (read/write) 1123420 1123420 0 0.0
.bss 186788 186788 0 0.0
.data 2800 2800 0 0.0
.text 933812 933812 0 0.0
window-app BRD4187C (read/write) 1157792 1157792 0 0.0
.bss 167424 167424 0 0.0
.data 3328 3328 0 0.0
.text 987020 987020 0 0.0
esp32 all-clusters-app c3devkit (read only) 1211614 1211614 0 0.0
(read/write) 1749744 1749744 0 0.0
.dram0.bss 74320 74320 0 0.0
.dram0.data 13620 13620 0 0.0
.flash.rodata 252272 252272 0 0.0
.flash.text 1211614 1211614 0 0.0
.iram0.text 75530 75530 0 0.0
m5stack (read only) 1253855 1253855 0 0.0
(read/write) 536336 536336 0 0.0
.dram0.bss 81256 81256 0 0.0
.dram0.data 35164 35164 0 0.0
.flash.rodata 283996 283996 0 0.0
.flash.text 1247691 1247691 0 0.0
.iram0.text 125403 125403 0 0.0
k32w contact k32w0+release (read only) 604912 604912 0 0.0
(read/write) 79460 79460 0 0.0
.bss 67300 67300 0 0.0
.data 2176 2176 0 0.0
.text 604376 604376 0 0.0
k32w1+release (read only) 1024 1024 0 0.0
(read/write) 699776 699776 0 0.0
.bss 71148 71148 0 0.0
.data 2848 2848 0 0.0
.text 586400 586400 0 0.0
light k32w0+release (read only) 606896 606896 0 0.0
(read/write) 79320 79320 0 0.0
.bss 67156 67156 0 0.0
.data 2180 2180 0 0.0
.text 606360 606360 0 0.0
k32w1+release (read only) 1024 1024 0 0.0
(read/write) 791196 791196 0 0.0
.bss 80628 80628 0 0.0
.data 2048 2048 0 0.0
.text 669160 669160 0 0.0
linux air-purifier-app debug (read only) 2621093 2621093 0 0.0
(read/write) 128968 128968 0 0.0
.bss 46544 46544 0 0.0
.data 2240 2240 0 0.0
.data.rel.ro 74248 74248 0 0.0
.dynamic 608 608 0 0.0
.got 4544 4544 0 0.0
.init 27 27 0 0.0
.init_array 752 752 0 0.0
.rodata 184624 184624 0 0.0
.text 2258981 2258981 0 0.0
all-clusters-app debug (read only) 5927209 5927209 0 0.0
(read/write) 480440 480440 0 0.0
.bss 134848 134848 0 0.0
.data 4528 4528 0 0.0
.data.rel.ro 333640 333640 0 0.0
.dynamic 624 624 0 0.0
.got 5360 5360 0 0.0
.init 27 27 0 0.0
.init_array 1392 1392 0 0.0
.rodata 349328 349328 0 0.0
.text 5144483 5144483 0 0.0
all-clusters-minimal-app debug (read only) 5208057 5208057 0 0.0
(read/write) 236392 236392 0 0.0
.bss 127680 127680 0 0.0
.data 4432 4432 0 0.0
.data.rel.ro 97208 97208 0 0.0
.dynamic 624 624 0 0.0
.got 5280 5280 0 0.0
.init 27 27 0 0.0
.init_array 1120 1120 0 0.0
.rodata 288362 288362 0 0.0
.text 4684963 4684963 0 0.0
bridge-app debug (read only) 4602457 4602457 0 0.0
(read/write) 217240 217240 0 0.0
.bss 118176 118176 0 0.0
.data 6208 6208 0 0.0
.data.rel.ro 86144 86144 0 0.0
.dynamic 624 624 0 0.0
.got 5248 5248 0 0.0
.init 27 27 0 0.0
.init_array 816 816 0 0.0
.rodata 228970 228970 0 0.0
.text 4153171 4153171 0 0.0
chip-tool debug (read only) 12044449 12044449 0 0.0
(read/write) 521520 521520 0 0.0
.bss 94424 94424 0 0.0
.data 5122 5122 0 0.0
.data.rel.ro 414744 414744 0 0.0
.dynamic 624 624 0 0.0
.got 5768 5768 0 0.0
.init 27 27 0 0.0
.init_array 784 784 0 0.0
.rodata 448665 448665 0 0.0
.text 10889987 10889987 0 0.0
chip-tool-ipv6only arm64 (read only) 11366292 11366292 0 0.0
(read/write) 587872 587872 0 0.0
.bss 103512 103512 0 0.0
.data 4496 4496 0 0.0
.data.rel.ro 454592 454592 0 0.0
.dynamic 512 512 0 0.0
.got 16944 16944 0 0.0
.init 24 24 0 0.0
.init_array 256 256 0 0.0
.rodata 354596 354596 0 0.0
.text 10133384 10133384 0 0.0
lighting-app debug+rpc+ui (read only) 5525969 5525969 0 0.0
(read/write) 226032 226032 0 0.0
.bss 119144 119144 0 0.0
.data 4832 4832 0 0.0
.data.rel.ro 94544 94544 0 0.0
.dynamic 672 672 0 0.0
.got 5888 5888 0 0.0
.init 27 27 0 0.0
.init_array 928 928 0 0.0
.rodata 353908 353908 0 0.0
.text 4925363 4925363 0 0.0
lock-app debug (read only) 4669817 4669817 0 0.0
(read/write) 204824 204824 0 0.0
.bss 113600 113600 0 0.0
.data 4128 4128 0 0.0
.data.rel.ro 80392 80392 0 0.0
.dynamic 624 624 0 0.0
.got 5200 5200 0 0.0
.init 27 27 0 0.0
.init_array 848 848 0 0.0
.rodata 254890 254890 0 0.0
.text 4203251 4203251 0 0.0
ota-provider-app debug (read only) 4298145 4298145 0 0.0
(read/write) 193296 193296 0 0.0
.bss 113280 113280 0 0.0
.data 4336 4336 0 0.0
.data.rel.ro 69776 69776 0 0.0
.dynamic 624 624 0 0.0
.got 4536 4536 0 0.0
.init 27 27 0 0.0
.init_array 712 712 0 0.0
.rodata 207946 207946 0 0.0
.text 3897203 3897203 0 0.0
ota-requestor-app debug (read only) 4427617 4427617 0 0.0
(read/write) 197728 197728 0 0.0
.bss 114208 114208 0 0.0
.data 4736 4736 0 0.0
.data.rel.ro 72896 72896 0 0.0
.dynamic 624 624 0 0.0
.got 4472 4472 0 0.0
.init 27 27 0 0.0
.init_array 760 760 0 0.0
.rodata 214090 214090 0 0.0
.text 4015987 4015987 0 0.0
shell debug (read only) 2895217 2895217 0 0.0
(read/write) 156360 156360 0 0.0
.bss 62736 62736 0 0.0
.data 1392 1392 0 0.0
.data.rel.ro 86464 86464 0 0.0
.dynamic 592 592 0 0.0
.got 4072 4072 0 0.0
.init 27 27 0 0.0
.init_array 1072 1072 0 0.0
.rodata 185280 185280 0 0.0
.text 2536594 2536594 0 0.0
thermostat-no-ble arm64 (read only) 4417492 4417492 0 0.0
(read/write) 245432 245432 0 0.0
.bss 121832 121832 0 0.0
.data 3376 3376 0 0.0
.data.rel.ro 103624 103624 0 0.0
.dynamic 512 512 0 0.0
.got 8616 8616 0 0.0
.init 24 24 0 0.0
.init_array 424 424 0 0.0
.rodata 159436 159436 0 0.0
.text 3923416 3923416 0 0.0
tv-app debug (read only) 5716937 5716937 0 0.0
(read/write) 352592 352592 0 0.0
.bss 244368 244368 0 0.0
.data 6528 6528 0 0.0
.data.rel.ro 94424 94424 0 0.0
.dynamic 624 624 0 0.0
.got 5496 5496 0 0.0
.init 27 27 0 0.0
.init_array 1144 1144 0 0.0
.rodata 290058 290058 0 0.0
.text 5184771 5184771 0 0.0
tv-casting-app debug (read only) 9869185 9869185 0 0.0
(read/write) 340304 340304 0 0.0
.bss 156272 156272 0 0.0
.data 2976 2976 0 0.0
.data.rel.ro 174176 174176 0 0.0
.dynamic 624 624 0 0.0
.got 5072 5072 0 0.0
.init 27 27 0 0.0
.init_array 1176 1176 0 0.0
.rodata 382616 382616 0 0.0
.text 9020803 9020803 0 0.0
mbed lock-app-release cy8cproto_062_4343w (read only) 6224 6224 0 0.0
(read/write) 2532376 2532376 0 0.0
.bss 220472 220472 0 0.0
.data 5200 5200 0 0.0
.text 1495060 1495060 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1062496 1062496 0 0.0
bss 133111 133111 0 0.0
rodata 102584 102584 0 0.0
text 779604 779604 0 0.0
nrf7002dk_nrf5340_cpuapp (read only) 4 4 0 0.0
(read/write) 1223936 1223936 0 0.0
bss 127147 127147 0 0.0
rodata 151172 151172 0 0.0
text 795600 795600 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1010072 1010072 0 0.0
bss 131969 131969 0 0.0
rodata 89848 89848 0 0.0
text 740940 740940 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 (read only) 834440 834440 0 0.0
(read/write) 1796860 1796860 0 0.0
.bss 196236 196236 0 0.0
.data 2664 2664 0 0.0
.text 1589572 1589572 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 (read only) 837584 837584 0 0.0
(read/write) 1718908 1718908 0 0.0
.bss 193116 193116 0 0.0
.data 2640 2640 0 0.0
.text 1514764 1514764 0 0.0
light cy8ckit_062s2_43012 (read only) 844312 844312 0 0.0
(read/write) 1638012 1638012 0 0.0
.bss 186580 186580 0 0.0
.data 2448 2448 0 0.0
.text 1440596 1440596 0 0.0
lock cy8ckit_062s2_43012 (read only) 817160 817160 0 0.0
(read/write) 1667660 1667660 0 0.0
.bss 213740 213740 0 0.0
.data 2440 2440 0 0.0
.text 1443092 1443092 0 0.0
qpg lighting-app qpg6105+debug (read/write) 1130052 1130052 0 0.0
.bss 102480 102480 0 0.0
.data 824 824 0 0.0
.text 642432 642432 0 0.0
lock-app qpg6105+debug (read/write) 1090012 1090012 0 0.0
.bss 97224 97224 0 0.0
.data 844 844 0 0.0
.text 602396 602396 0 0.0
stm32 light STM32WB5MM-DK (read/write) 601241 601241 0 0.0
.bss 128344 128344 0 0.0
.data 668 668 0 0.0
.rodata 79700 79700 0 0.0
.text 382800 382800 0 0.0
telink air-quality-sensor-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 824026 824026 0 0.0
bss 49684 49684 0 0.0
text 616822 616822 0 0.0
all-clusters-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 1092872 1092872 0 0.0
bss 101804 101804 0 0.0
text 793934 793934 0 0.0
all-clusters-minimal-app tlsr9528a (read only) 47960 47960 0 0.0
(read/write) 1050344 1050344 0 0.0
bss 110108 110108 0 0.0
text 765256 765256 0 0.0
bridge-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 911056 911056 0 0.0
bss 93140 93140 0 0.0
text 652732 652732 0 0.0
contact-sensor-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 825650 825650 0 0.0
bss 49732 49732 0 0.0
text 618512 618512 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a (read only) 51584 51584 0 0.0
(read/write) 931368 931368 0 0.0
bss 77732 77732 0 0.0
text 698660 698660 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d (read only) 29122 29122 0 0.0
(read/write) 1074228 1074228 0 0.0
bss 100220 100220 0 0.0
text 778116 778116 0 0.0
lock-app-dfu tlsr9528a (read only) 51584 51584 0 0.0
(read/write) 903760 903760 0 0.0
bss 69196 69196 0 0.0
text 653924 653924 0 0.0
ota-requestor-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 930028 930028 0 0.0
bss 92720 92720 0 0.0
text 671810 671810 0 0.0
pump-app tlsr9258a_retention (read only) 51774 51774 0 0.0
(read/write) 828382 828382 0 0.0
bss 49840 49840 0 0.0
text 621574 621574 0 0.0
pump-controller-app tlsr9518adk80d (read only) 31872 31872 0 0.0
(read/write) 791956 791956 0 0.0
bss 56040 56040 0 0.0
text 592250 592250 0 0.0
shell tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 677312 677312 0 0.0
bss 73672 73672 0 0.0
text 462570 462570 0 0.0
smoke_co_alarm-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 833186 833186 0 0.0
bss 51364 51364 0 0.0
text 624882 624882 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d (read only) 32220 32220 0 0.0
(read/write) 851917 851917 0 0.0
bss 59516 59516 0 0.0
text 636960 636960 0 0.0
thermostat tlsr9518adk80d (read only) 31872 31872 0 0.0
(read/write) 817604 817604 0 0.0
bss 56328 56328 0 0.0
text 611934 611934 0 0.0
window-covering tlsr9258a (read only) 51584 51584 0 0.0
(read/write) 835696 835696 0 0.0
bss 68104 68104 0 0.0
text 627192 627192 0 0.0

@ksperling-apple ksperling-apple deleted the darwin-primary-mac branch March 22, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] Darwin ConfigurationManagerImpl::GetPrimaryWiFiMACAddress returns success without getting a MAC address
3 participants