Merge branch 'release-4.1' into fix/rpl-various

This commit is contained in:
Simon Duquennoy 2018-04-13 18:07:39 +02:00 committed by GitHub
commit 2adf8544b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 13 deletions

View File

@ -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) {

View File

@ -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)

View File

@ -397,9 +397,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 turn triggers a global repair. */
rpl_timers_dio_reset("Heard old version from root");
}
return;
}
@ -414,10 +420,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",