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+coap: Cherry-pick fixes and changes to CoAP and LwM2M #2312

Merged
merged 29 commits into from
Nov 28, 2024

Conversation

SeppoTakalo
Copy link
Contributor

Cherry-pick changes from upstream. Mostly fixes for coap_client but few changes to LwM2M engine as well.

SeppoTakalo and others added 28 commits November 28, 2024 15:58
Use security mode (PSK or X509) to detect if we should
set the socket option to verify hostname.

PSK security mode cannot verify hostnames as this information
is coming in the certificate, so don't set the options.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 73a3438)
Add shell command for listing multiple objects, resources
or resource instances.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 8068cb2)
… on get_s64() success

Currently GCC complains that temp64 may be used uninitialized in this
 function. Adds a check to ensure time is valid before assignining
 and fixes GCC warning.

Signed-off-by: Brandon Allen <[email protected]>
(cherry picked from commit bb24c83)
…cipher list

Add TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 to the list for use with x509
certificates. The LWM2M v1.1 specification says that a LWM2M client
which used X509 certificates must support this ciphersuite and
additional ciphersuites may be supported.

Signed-off-by: Jeroen Broersen <[email protected]>
(cherry picked from commit f889c1a)
…characters (B005)

All strip functions remove any of the provided characters instead of a
prefix/suffix. This is likely a bug.

See https://docs.astral.sh/ruff/rules/strip-with-multi-characters/

Signed-off-by: Pieter De Gendt <[email protected]>
(cherry picked from commit 175bfb4)
* Use sys_rand_get() and seed the CoAP library, so our MIDs are
  random.
* Set socket events per socket, so we don't accidentally receive
  on wrong socket
* Reply with correct tokens

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit ca67f51)
Add test where we receive same UDP packet twice.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 83bc1fc)
… lost

Test a scenario where Ack is received but the actual response
is not coming.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 120aabb)
Add testcases for testing client's retry behaviour.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 5559a52)
Add testcase where sending Ack to incomming Confirmable message fails.
This should be reported to application as now the server is unaware
that transmission have succeeded, so we cannot thread it as success.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit fc51fa4)
… another fails

CoAP client should be able to push data through functioning socket
while another sockets is failing or reporting poll() errors.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 237b26c)
Add test for ongoing observation and cancellation.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 05a6ba6)
When server responds with CoAP RESET, we should inform the
client and stop the request.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 107dc9b)
… on response

When response is received and handled, don't just clear the structure
but instead mark it as ongoing=false.
So if we later on receive a duplicate response for it, we can still
respond with Ack or Rst.

This is achieved by using release_internal_request() when we don't
expect any response for it and reset_internal_request() when we really
fill up a new request.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 41ee35a)
Incomming Message-ID is already parsed, use it as a parameter to
get_request_with_mid().

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 7b0cce4)
If our internal structure is cleared, don't match tokens.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 934c74f)
When response is already handled, don't forward anymore responses
to the client application.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit a1368a7)
Return the -errno when zsock_sendto() or zsock_recvfrom() fails, so
rest of the code can deal with return values, instead of separately
comparing errno and return value.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 48434a3)
…esponding with Ack

Even if we receive duplicate confirmable message, we should still
respond with the Ack. Just don't deliver the second callback.

This is achieved by moving the MID deduplication to after Ack handling.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit c0eb260)
…ted to callback

When the client fails when parsing the response and we stop proceeding,
we should report that to the application.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit f72d634)
poll() only for sockets that have traffic ongoing or have some lifetime
left.
On socket failures during a poll(), stop listening for the socket.
Application can recover by reconnecting the socket.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit f0c6efe)
Add a new API to cancel just one, or mathing requests,
instead of cancelling all ongoing requests.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit b3f3bce)
…wM2M context

The pull context LwM2M client's set_socketoptions callback is currently
unused and can't be set by a user. Add a public API to set the
pull context's client's set_socketoptions callback.

Signed-off-by: Andi Gerl <[email protected]>
(cherry picked from commit 9c24214)
Use real-time scheduler with 100x speedup, so timeouts are
accurate enough, but still fast for tests to run.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 34a6d5a)
Refactor tests to be a bit shorter, so its easier to read
and copy-paste for a new testcase

All idioms like "ret = somecall(); zasser.." are replaced with just
"zassert_ok(some_call());"

Commonly used structures are global and initialized once.

To avoid cross-test side-effects, suite_after-function is added
to cleanup all requests.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit d64748c)
Add test for sending multiple non-confirmable requests.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 23345d2)
When waiting for response after receiving the empty Ack, client
actually used way too timeout.
CoAP timeout only holds the timeout value in ms. t0 is the starting time.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 6c16966)
Non-confirmable CoAP requests need lifetime tracking as well
so we can free the structure after a timeout.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 2066cf6)
CoAP client does not modify any of the members, so
change all pointers to const.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit bc4f026)
@SeppoTakalo SeppoTakalo requested a review from a team November 28, 2024 14:02
@SeppoTakalo SeppoTakalo added this to the ncs-2.9.0 milestone Nov 28, 2024
@rlubos rlubos merged commit f995b7d into nrfconnect:main Nov 28, 2024
17 checks passed
@SeppoTakalo SeppoTakalo deleted the lwm2m_coap_cherrypick branch November 29, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants