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

Do not use an undefined node id for mdns advertising #7488

Conversation

vivien-apple
Copy link
Contributor

@vivien-apple vivien-apple commented Jun 9, 2021

Problem

If an accessory already connected to the network and without any admin pairing is on the network, the mdns advertisement is 0000000000000000-0000000000000000 instead of beeing (for example): 0000000000000000-0000000000BC5C01 if the node id is 12344321.

Change overview

  • Do not use an undefined node id from the admin pairing table

Testing

@github-actions
Copy link

github-actions bot commented Jun 9, 2021

Size increase report for "gn_qpg6100-example-build" from 77e727c

File Section File VM
chip-qpg6100-lighting-example.out .text 16 16
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.text,16,16
.debug_info,0,4
.debug_str,0,-1
.debug_line,0,-3
.debug_ranges,0,-16
[Unmapped],0,-16
.debug_loc,0,-32


@@ -48,7 +48,7 @@ NodeId GetCurrentNodeId()

// Search for one admin pairing and use its node id.
auto pairing = GetGlobalAdminPairingTable().cbegin();
if (pairing != GetGlobalAdminPairingTable().cend())
if (pairing != GetGlobalAdminPairingTable().cend() && pairing->GetNodeId() != kUndefinedNodeId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrt the TODO above:

// TODO: once operational credentials are implemented, node ID should be read from them

I would think that once we are getting the node ID from operational credentials, we should remove this check.

@github-actions
Copy link

github-actions bot commented Jun 9, 2021

Size increase report for "nrfconnect-example-build" from 77e727c

File Section File VM
chip-lock.elf text 8 8
chip-lock.elf device_handles -8 -8
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
text,8,8
.debug_info,0,4
.debug_line,0,-4
device_handles,-8,-8
.debug_ranges,0,-16
.debug_loc,0,-32

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize


@andy31415
Copy link
Contributor

Could you explain the situation a bit?

Why do we have an admin pairing info without a well defined node id? Should the admin pairing info be missing in that case?
I would have expected the fix to be "do not have an invalid admin pairing" rather than "if admin pairing is invalid, ignore it".

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.

I think this could definitely use a comment answering @andy31415's question. Is this about the time period between an admin being added and a node id being provisioned? Or nodes that were partially provisioned? Or something else?

@woody-apple
Copy link
Contributor

@Damian-Nordic
Copy link
Contributor

Damian-Nordic commented Jun 11, 2021

Not sure what's @vivien-apple's case, but it once happened to me that the pairing window has expired and when I started BLE advertising again, a new admin has been allocated and after the commissioning the previously allocated admin had the node ID uninitialized. I guess this change will fix such issues although it might be better to remove incomplete admins when commissioning fails.

Copy link
Contributor

@andy31415 andy31415 left a comment

Choose a reason for hiding this comment

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

Marking as changes requested to not get merged until we understand the case.

not having an invalid state at all seems better than ignoring invalid state when we see it.

@vivien-apple
Copy link
Contributor Author

Could you explain the situation a bit?

Why do we have an admin pairing info without a well defined node id? Should the admin pairing info be missing in that case?
I would have expected the fix to be "do not have an invalid admin pairing" rather than "if admin pairing is invalid, ignore it".

I'm... not sure. Asking @shana-apple since she may have an answer.

But actually this is interesting. I dig more into the code and I'm curious of what is the right fix here.

The current code flow is, when the pairing window is opened, the next available admin id is populated to the AdminPairingTable (in this case 0) without a node id. The reason for not assigning any node id is because it is currently assigned at

// TODO: Remove temporary code once AddOptCert is implemented

The comment "AddOpCert is implemented" suggests that NodeId should be populated when an operational certificate is received ?

@shana-apple
Copy link
Contributor

Could you explain the situation a bit?
Why do we have an admin pairing info without a well defined node id? Should the admin pairing info be missing in that case?
I would have expected the fix to be "do not have an invalid admin pairing" rather than "if admin pairing is invalid, ignore it".

I'm... not sure. Asking @shana-apple since she may have an answer.

But actually this is interesting. I dig more into the code and I'm curious of what is the right fix here.

The current code flow is, when the pairing window is opened, the next available admin id is populated to the AdminPairingTable (in this case 0) without a node id. The reason for not assigning any node id is because it is currently assigned at

// TODO: Remove temporary code once AddOptCert is implemented

The comment "AddOpCert is implemented" suggests that NodeId should be populated when an operational certificate is received ?

This will be resolved by my next patch. This wasn't just AddOpCert landing but further implementation is needed to hook it all up.

@vivien-apple
Copy link
Contributor Author

After some investigations, it seems like the issue here is that the accessory is locally broadcasting using AdvertiseOperational instead of AdvertiseCommissionableNode. I will update the patch

@woody-apple
Copy link
Contributor

/rebase

1 similar comment
@woody-apple
Copy link
Contributor

/rebase

@woody-apple woody-apple requested a review from andy31415 June 17, 2021 01:31
@woody-apple woody-apple force-pushed the Mdns_AdvertisingUndefinedPairing branch from 9c25983 to f1c5a6c Compare June 17, 2021 01:47
@stale
Copy link

stale bot commented Jun 24, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label Jun 24, 2021
@stale
Copy link

stale bot commented Jul 1, 2021

This stale pull request has been automatically closed. Thank you for your contributions.

@stale stale bot closed this Jul 1, 2021
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.

7 participants