From c48173eb5bf3a29c84465ec35547c53aab941865 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 24 Mar 2018 07:40:52 -0700 Subject: [PATCH 1/4] RPL Lite: whenever hearing an old version from the root, reset DIO timer to let the root know about the current version --- os/net/routing/rpl-lite/rpl-dag.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index 00ee1663e..a2a18c59a 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -395,9 +395,15 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) return; } - /* If the DIO sender is on an older version of the DAG, ignore it. The node - will eventually hear the global repair and catch up. */ + /* If the DIO sender is on an older version of the DAG, do not process it + * further. The sender will eventually hear the global repair and catch up. */ if(rpl_lollipop_greater_than(curr_instance.dag.version, dio->version)) { + if(dio->rank == ROOT_RANK) { + /* Before returning, if the DIO was from the root, an old DAG versions + * likely incidates a root reboot. Reset our DIO timer to make sure the + * root hears our version ASAP, and in trun triggers a global repair. */ + rpl_timers_dio_reset("Heard old version from root"); + } return; } @@ -412,10 +418,12 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) * Must come first, as it might remove all neighbors, and we then need * to re-add this source of the DIO to the neighbor table */ if(rpl_lollipop_greater_than(dio->version, curr_instance.dag.version)) { - if(curr_instance.dag.rank == ROOT_RANK) { /* The root should not hear newer versions */ + if(curr_instance.dag.rank == ROOT_RANK) { + /* The root should not hear newer versions unless it just rebooted */ LOG_ERR("inconsistent DIO version (current: %u, received: %u), initiate global repair\n", curr_instance.dag.version, dio->version); - curr_instance.dag.version = dio->version; /* Update version and trigger global repair */ + /* Update version and trigger global repair */ + curr_instance.dag.version = dio->version; rpl_global_repair("Inconsistent DIO version"); } else { LOG_WARN("new DIO version (current: %u, received: %u), apply global repair\n", From 24e24b8edcc658e6098904b6fbdaaf12b46c9fc6 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 12 Apr 2018 17:34:35 +0200 Subject: [PATCH 2/4] coap: added check for block offset overflow in block2 requests. The block offset is stored in a signed variable in calls to CoAP handlers and too large block offsets will overflow into negative values. Thanks to Bruno Melo for reporting this issue. --- os/net/app-layer/coap/coap-engine.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/os/net/app-layer/coap/coap-engine.c b/os/net/app-layer/coap/coap-engine.c index fb85b5b15..cbfa70ee9 100644 --- a/os/net/app-layer/coap/coap-engine.c +++ b/os/net/app-layer/coap/coap-engine.c @@ -199,10 +199,18 @@ coap_receive(const coap_endpoint_t *src, new_offset = block_offset; } - /* call CoAP framework and check if found and allowed */ - status = call_service(message, response, - transaction->message + COAP_MAX_HEADER_SIZE, - block_size, &new_offset); + if(new_offset < 0) { + LOG_DBG("Blockwise: block request offset overflow\n"); + coap_status_code = BAD_OPTION_4_02; + coap_error_message = "BlockOutOfScope"; + status = COAP_HANDLER_STATUS_CONTINUE; + } else { + /* call CoAP framework and check if found and allowed */ + status = call_service(message, response, + transaction->message + COAP_MAX_HEADER_SIZE, + block_size, &new_offset); + } + if(status != COAP_HANDLER_STATUS_CONTINUE) { if(coap_status_code == NO_ERROR) { From fc8619608af1ca2766c57d2b4a00b61a26ae8608 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Fri, 13 Apr 2018 14:27:01 +0200 Subject: [PATCH 3/4] fixed typo in comment. --- os/net/routing/rpl-lite/rpl-dag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index a2a18c59a..6fe58f273 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -401,7 +401,7 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) if(dio->rank == ROOT_RANK) { /* Before returning, if the DIO was from the root, an old DAG versions * likely incidates a root reboot. Reset our DIO timer to make sure the - * root hears our version ASAP, and in trun triggers a global repair. */ + * root hears our version ASAP, and in turn triggers a global repair. */ rpl_timers_dio_reset("Heard old version from root"); } return; From 0df3c4fb90297d1e9e57f8e6f4cee409fb899b66 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Thu, 5 Apr 2018 05:35:27 -0700 Subject: [PATCH 4/4] CoAP: enable calling coap_get_payload with a NULL pointer --- os/net/app-layer/coap/coap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/os/net/app-layer/coap/coap.c b/os/net/app-layer/coap/coap.c index 42a2d5cef..c28e2d8b5 100644 --- a/os/net/app-layer/coap/coap.c +++ b/os/net/app-layer/coap/coap.c @@ -1115,13 +1115,10 @@ coap_set_header_size1(coap_message_t *coap_pkt, uint32_t size) int coap_get_payload(coap_message_t *coap_pkt, const uint8_t **payload) { - if(coap_pkt->payload) { + if(payload != NULL) { *payload = coap_pkt->payload; - return coap_pkt->payload_len; - } else { - *payload = NULL; - return 0; } + return coap_pkt->payload != NULL ? coap_pkt->payload_len : 0; } int coap_set_payload(coap_message_t *coap_pkt, const void *payload, size_t length)