Skip to content

Commit 8aed2a1

Browse files
mlaschkartben
authored andcommitted
net: lwm2m: Prevent client restart on bootstrap finish retransmission
Ignore bootstrap 'transition done' state transition (ENGINE_BOOTSTRAP_TRANS_DONE) from an invalid state. The client must be in state ENGINE_BOOTSTRAP_REG_DONE to process a bootstrap finish command received from the server. The LwM2M client does not implement CoAP deduplication (rfc 7252, section 4.5) and retransmissions of the bootstrap finish command `/bs` would restart the registration client with undesired side effects. Signed-off-by: Marc Lasch <[email protected]>
1 parent e7a65ac commit 8aed2a1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

subsys/net/lib/lwm2m/lwm2m_rd_client.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,14 @@ static void sm_do_bootstrap_reg(void)
838838
void engine_bootstrap_finish(void)
839839
{
840840
LOG_INF("Bootstrap data transfer done!");
841-
/* Delay the state transition, so engine have some time to send ACK
842-
* before we close the socket
841+
/* Transition only if the client is bootstrapping, otherwise retransmissions of bootstrap
842+
* finish may restart an already registered client.
843+
* Delay the state transition, so engine have some time to send ACK before we close the
844+
* socket.
843845
*/
844-
set_sm_state_delayed(ENGINE_BOOTSTRAP_TRANS_DONE, DELAY_BEFORE_CLOSING);
846+
if (get_sm_state() == ENGINE_BOOTSTRAP_REG_DONE) {
847+
set_sm_state_delayed(ENGINE_BOOTSTRAP_TRANS_DONE, DELAY_BEFORE_CLOSING);
848+
}
845849
}
846850

847851
static int sm_bootstrap_trans_done(void)

0 commit comments

Comments
 (0)