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

net: lwm2m: Correctly Support Bootstrap-Delete Operation #29964

Closed
broglep-work opened this issue Nov 12, 2020 · 1 comment · Fixed by #30200
Closed

net: lwm2m: Correctly Support Bootstrap-Delete Operation #29964

broglep-work opened this issue Nov 12, 2020 · 1 comment · Fixed by #30200
Assignees
Labels
area: LWM2M Enhancement Changes/Updates/Additions to existing features

Comments

@broglep-work
Copy link
Contributor

broglep-work commented Nov 12, 2020

Summary

  • DELETE / is implemented as DELETE /0
  • DELETE /and DELETE /x for x != 0 is not supported/implemented

Background

Zephyr client should support bootstrap-delete according to the specification.
Currently the support is only implementing partially and that part not according to the specification:

  • If the client is in bootstrap mode and bootstrap server sends a DELETE request without Uri-Path option, then bootstrap_delete will be executed (wm2m_engine.c:3344)
  • bootstrap_delete deletes SECURITY instances > 0

Given bootstrap_delete is called when no uri option is set, the assumed contract of that method is that it should correspond to DELETE / where all Instances of all Objects in the LwM2M Client MUST be removed (except for the two cases mentioned above) where The two exceptions are the LwM2M Bootstrap-Server Account, potentially including an associated Instance of an OSCORE Object ID:21, and the single Instance of the mandatory Device Object (ID:3), which are not affected by any Delete operation.

Proposal

  1. Fix: Adjust current code to delete all other object instances as well
  2. Enhancement: Support both no Uri-Path header and empty Uri-Path header, and treat them the same way
  3. Enhancement: Support deletion of all instance of a particular object

Side Note

Sending a DELETE /x request to the client in bootstrap mode is executed as DELETE /x/0 (goes through regular delete request handler that does not check if uri path has length >=2 as it is not allowed by the spec outside of bootstrap, object and instance id must be set)

@broglep-work broglep-work added the Enhancement Changes/Updates/Additions to existing features label Nov 12, 2020
@rlubos
Copy link
Contributor

rlubos commented Nov 23, 2020

@broglep-work Thanks for reporting. Indeed the current implementation oversimplified a lot. I've pushed a PR with proposed changes: #30200

I've verified that DELETE / and DELETE /x works as expected, I wasn't able to verify DELETE /x/y though as the bootstrap serves I tried with did not issue such operation. I'm not expecting any surprises there though since the same bootstrap_delete handler shall be called then, which implements single resource removal in a straightforward way.

During the rework I've also realized that bootstrap DISCOVER operation is totally broken, but that's a story for a separate PR.

rlubos added a commit to rlubos/zephyr that referenced this issue Nov 24, 2020
Rework the bootstrap DELETE operation, to support deletion of multiple
resources.

Current implementation had several oversimplifications, making it not
spec-compliant:
* DELETE `/` removed only Security object instances (!= 0)
* DELETE `/x` was handled as DELETE `/x/0`, therefore not removing all
  of the object instances.

Since the above is only supported during bootstrap and not regular
Device management, this functionality was implemented in the
`bootstrap_delete` function, which now will be called for all DELETE
operations initiated during bootstrap. The regular LwM2M DELETE handler
will only be called during regular Device management, as it has more
strict limitations on what can be deleted.

Additionally, handle empty URI Path option as `/`, therefore indicating
deletion of all resources.

Fixes zephyrproject-rtos#29964

Signed-off-by: Robert Lubos <[email protected]>
nashif pushed a commit that referenced this issue Dec 1, 2020
Rework the bootstrap DELETE operation, to support deletion of multiple
resources.

Current implementation had several oversimplifications, making it not
spec-compliant:
* DELETE `/` removed only Security object instances (!= 0)
* DELETE `/x` was handled as DELETE `/x/0`, therefore not removing all
  of the object instances.

Since the above is only supported during bootstrap and not regular
Device management, this functionality was implemented in the
`bootstrap_delete` function, which now will be called for all DELETE
operations initiated during bootstrap. The regular LwM2M DELETE handler
will only be called during regular Device management, as it has more
strict limitations on what can be deleted.

Additionally, handle empty URI Path option as `/`, therefore indicating
deletion of all resources.

Fixes #29964

Signed-off-by: Robert Lubos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LWM2M Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants