From 8afe3fb9b79c6b39130e52f1188c4900557e3154 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Wed, 23 Sep 2015 09:12:35 +0200 Subject: [PATCH] fixed so that DAO NACK now is either for the path or for RPL root - if from root then do not try to switch parent since that will not help --- core/net/rpl/rpl-icmp6.c | 10 +++++++--- core/net/rpl/rpl-mrhof.c | 5 ++++- core/net/rpl/rpl-private.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 6ff0dcfee..0851cd9a2 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -663,6 +663,7 @@ dao_input(void) int learned_from; rpl_parent_t *parent; uip_ds6_nbr_t *nbr; + int is_root; prefixlen = 0; parent = NULL; @@ -695,6 +696,8 @@ dao_input(void) sequence = buffer[pos++]; dag = instance->current_dag; + is_root = (dag->rank == ROOT_RANK(instance)); + /* Is the DAG ID present? */ if(flags & RPL_DAO_D_FLAG) { if(memcmp(&dag->dag_id, &buffer[pos], sizeof(dag->dag_id))) { @@ -829,7 +832,8 @@ dao_input(void) if(flags & RPL_DAO_K_FLAG) { /* signal the failure to add the node */ dao_ack_output(instance, &dao_sender_addr, sequence, - RPL_DAO_ACK_UNABLE_TO_ACCEPT); + is_root ? RPL_DAO_ACK_UNABLE_TO_ACCEPT_ROOT : + RPL_DAO_ACK_UNABLE_TO_ACCEPT); } goto discard; } @@ -838,11 +842,11 @@ dao_input(void) if(rep == NULL) { RPL_STAT(rpl_stats.mem_overflows++); PRINTF("RPL: Could not add a route after receiving a DAO\n"); - if(flags & RPL_DAO_K_FLAG) { /* signal the failure to add the node */ dao_ack_output(instance, &dao_sender_addr, sequence, - RPL_DAO_ACK_UNABLE_TO_ACCEPT); + is_root ? RPL_DAO_ACK_UNABLE_TO_ACCEPT_ROOT : + RPL_DAO_ACK_UNABLE_TO_ACCEPT); } goto discard; } diff --git a/core/net/rpl/rpl-mrhof.c b/core/net/rpl/rpl-mrhof.c index acf2b1d54..6da2ec304 100644 --- a/core/net/rpl/rpl-mrhof.c +++ b/core/net/rpl/rpl-mrhof.c @@ -122,8 +122,11 @@ reset(rpl_dag_t *dag) static void dao_ack_callback(rpl_parent_t *p, int status) { + if(status == RPL_DAO_ACK_UNABLE_TO_ACCEPT_ROOT) { + return; + } /* here we need to handle failed DAO's and other stuff */ - PRINTF("RPL: MRHOF - DAO ACK received with status: %d", status); + PRINTF("RPL: MRHOF - DAO ACK received with status: %d\n", status); if(status >= RPL_DAO_ACK_UNABLE_TO_ACCEPT) { /* punish the ETX as if this was 10 packets lost */ neighbor_link_callback(p, MAC_TX_OK, 10); diff --git a/core/net/rpl/rpl-private.h b/core/net/rpl/rpl-private.h index 017efb474..161cdc532 100644 --- a/core/net/rpl/rpl-private.h +++ b/core/net/rpl/rpl-private.h @@ -94,6 +94,7 @@ #define RPL_DAO_ACK_UNCONDITIONAL_ACCEPT 0 #define RPL_DAO_ACK_ACCEPT 1 /* 1 - 127 is OK but not good */ #define RPL_DAO_ACK_UNABLE_TO_ACCEPT 128 /* >127 is fail */ +#define RPL_DAO_ACK_UNABLE_TO_ACCEPT_ROOT 255 /* root can not accept */ #define RPL_DAO_ACK_TIMEOUT -1