fixed clearing of state flag and avoid starting retransmission timer

This commit is contained in:
Joakim Eriksson 2015-10-02 07:38:52 +02:00
parent 8afe3fb9b7
commit 09c624dcd3
4 changed files with 26 additions and 19 deletions

View File

@ -106,6 +106,9 @@ void uip_ds6_notification_rm(struct uip_ds6_notification *n);
#define RPL_ROUTE_SET_NOPATH_RECEIVED(route) do { \ #define RPL_ROUTE_SET_NOPATH_RECEIVED(route) do { \
(route)->state.state_flags |= RPL_ROUTE_ENTRY_NOPATH_RECEIVED; \ (route)->state.state_flags |= RPL_ROUTE_ENTRY_NOPATH_RECEIVED; \
} while(0) } while(0)
#define RPL_ROUTE_CLEAR_NOPATH_RECEIVED(route) do { \
(route)->state.state_flags &= ~RPL_ROUTE_ENTRY_NOPATH_RECEIVED; \
} while(0)
#define RPL_ROUTE_IS_DAO_PENDING(route) \ #define RPL_ROUTE_IS_DAO_PENDING(route) \
((route->state.state_flags & RPL_ROUTE_ENTRY_DAO_PENDING) != 0) ((route->state.state_flags & RPL_ROUTE_ENTRY_DAO_PENDING) != 0)

View File

@ -201,6 +201,8 @@ ns_input(void)
#endif /*UIP_CONF_IPV6_CHECKS */ #endif /*UIP_CONF_IPV6_CHECKS */
nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr); nbr = uip_ds6_nbr_lookup(&UIP_IP_BUF->srcipaddr);
if(nbr == NULL) { if(nbr == NULL) {
uip_lladdr_t lladdr_aligned;
extract_lladdr_aligned(&lladdr_aligned);
uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned, uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,
0, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL); 0, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);
} else { } else {
@ -638,12 +640,11 @@ rs_input(void)
} else { } else {
/* If LL address changed, set neighbor state to stale */ /* If LL address changed, set neighbor state to stale */
if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
uip_ds6_nbr_get_ll(nbr), UIP_LLADDR_LEN) != 0) { uip_ds6_nbr_get_ll(nbr), UIP_LLADDR_LEN) != 0) {
uip_ds6_nbr_t nbr_data = *nbr; uip_ds6_nbr_t nbr_data = *nbr;
uip_ds6_nbr_rm(nbr); uip_ds6_nbr_rm(nbr);
nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned, nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,
nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, 0, NBR_STALE, 0, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);
NBR_TABLE_REASON_IPV6_ND, NULL);
nbr->reachable = nbr_data.reachable; nbr->reachable = nbr_data.reachable;
nbr->sendns = nbr_data.sendns; nbr->sendns = nbr_data.sendns;
nbr->nscount = nbr_data.nscount; nbr->nscount = nbr_data.nscount;
@ -872,8 +873,8 @@ ra_input(void)
if(nbr == NULL) { if(nbr == NULL) {
uip_lladdr_t lladdr_aligned; uip_lladdr_t lladdr_aligned;
extract_lladdr_aligned(&lladdr_aligned); extract_lladdr_aligned(&lladdr_aligned);
nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned, 1, nbr = uip_ds6_nbr_add(&UIP_IP_BUF->srcipaddr, &lladdr_aligned,
NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL); 1, NBR_STALE, NBR_TABLE_REASON_IPV6_ND, NULL);
} else { } else {
uip_lladdr_t *lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr); uip_lladdr_t *lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr);
if(nbr->state == NBR_INCOMPLETE) { if(nbr->state == NBR_INCOMPLETE) {

View File

@ -53,6 +53,7 @@
#include "net/rpl/rpl-private.h" #include "net/rpl/rpl-private.h"
#include "net/packetbuf.h" #include "net/packetbuf.h"
#include "net/ipv6/multicast/uip-mcast6.h" #include "net/ipv6/multicast/uip-mcast6.h"
#include "random.h"
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
@ -811,11 +812,12 @@ dao_input(void)
uip_icmp6_send(rpl_get_parent_ipaddr(dag->preferred_parent), uip_icmp6_send(rpl_get_parent_ipaddr(dag->preferred_parent),
ICMP6_RPL, RPL_CODE_DAO, buffer_length); ICMP6_RPL, RPL_CODE_DAO, buffer_length);
} }
if(flags & RPL_DAO_K_FLAG) { }
/* indicate that we accepted the no-path DAO */ /* independent if we remove or not - ACK the request */
dao_ack_output(instance, &dao_sender_addr, sequence, if(flags & RPL_DAO_K_FLAG) {
RPL_DAO_ACK_UNCONDITIONAL_ACCEPT); /* indicate that we accepted the no-path DAO */
} dao_ack_output(instance, &dao_sender_addr, sequence,
RPL_DAO_ACK_UNCONDITIONAL_ACCEPT);
} }
goto discard; goto discard;
} }
@ -851,8 +853,9 @@ dao_input(void)
goto discard; goto discard;
} }
/* State is all zeroes, set lifetime but no need for other initialization. */ /* set lifetime and clear NOPATH bit */
rep->state.lifetime = RPL_LIFETIME(instance, lifetime); rep->state.lifetime = RPL_LIFETIME(instance, lifetime);
RPL_ROUTE_CLEAR_NOPATH_RECEIVED(rep);
#if RPL_CONF_MULTICAST #if RPL_CONF_MULTICAST
fwd_dao: fwd_dao:
@ -978,15 +981,13 @@ dao_output(rpl_parent_t *parent, uint8_t lifetime)
/* Sending a DAO with own prefix as target */ /* Sending a DAO with own prefix as target */
dao_output_target(parent, &prefix, lifetime); dao_output_target(parent, &prefix, lifetime);
/* keep track of my own sending of DAO for handling ack and loss of ack */
instance->my_dao_seqno = dao_sequence;
#if RPL_WITH_DAO_ACK #if RPL_WITH_DAO_ACK
instance->my_dao_transmissions = 1; /* keep track of my own sending of DAO for handling ack and loss of ack */
ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT, if(lifetime != RPL_ZERO_LIFETIME) {
handle_dao_retransmission, parent); instance->my_dao_seqno = dao_sequence;
if(lifetime == RPL_ZERO_LIFETIME) { instance->my_dao_transmissions = 1;
rpl_set_downward_link(0); ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT,
handle_dao_retransmission, parent);
} }
#else #else
/* We know that we have tried to register so now we are assuming /* We know that we have tried to register so now we are assuming

View File

@ -238,6 +238,8 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
rep->state.dag = dag; rep->state.dag = dag;
rep->state.lifetime = RPL_LIFETIME(dag->instance, dag->instance->default_lifetime); rep->state.lifetime = RPL_LIFETIME(dag->instance, dag->instance->default_lifetime);
/* always clear state flags for the no-path received when adding/refreshing */
RPL_ROUTE_CLEAR_NOPATH_RECEIVED(rep);
PRINTF("RPL: Added a route to "); PRINTF("RPL: Added a route to ");
PRINT6ADDR(prefix); PRINT6ADDR(prefix);