Browse Source

Merge pull request #6935 from smlng/net/rpl/fix_parent_timer

rpl: make parent lifetime consistent with other timers
master
Sebastian Meiling 6 years ago committed by GitHub
parent
commit
a14445ed86
  1. 15
      sys/net/gnrc/routing/rpl/gnrc_rpl.c
  2. 3
      sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
  3. 3
      sys/shell/commands/sc_gnrc_rpl.c

15
sys/net/gnrc/routing/rpl/gnrc_rpl.c

@ -252,23 +252,22 @@ static void *_event_loop(void *args)
void _update_lifetime(void)
{
uint32_t now = xtimer_now_usec();
uint16_t now_sec = now / US_PER_SEC;
gnrc_rpl_parent_t *parent;
gnrc_rpl_instance_t *inst;
for (uint8_t i = 0; i < GNRC_RPL_PARENTS_NUMOF; ++i) {
parent = &gnrc_rpl_parents[i];
if (parent->state != 0) {
if ((int32_t)(parent->lifetime - now_sec) <= GNRC_RPL_LIFETIME_UPDATE_STEP) {
if (parent->lifetime > GNRC_RPL_LIFETIME_UPDATE_STEP) {
if (parent->lifetime > (2 * GNRC_RPL_LIFETIME_UPDATE_STEP)) {
gnrc_rpl_send_DIS(parent->dodag->instance, &parent->addr);
}
parent->lifetime -= GNRC_RPL_LIFETIME_UPDATE_STEP;
}
else {
gnrc_rpl_dodag_t *dodag = parent->dodag;
gnrc_rpl_parent_remove(parent);
gnrc_rpl_parent_update(dodag, NULL);
continue;
}
else if ((int32_t)(parent->lifetime - now_sec) <= (GNRC_RPL_LIFETIME_UPDATE_STEP * 2)) {
gnrc_rpl_send_DIS(parent->dodag->instance, &parent->addr);
}
}
}

3
sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

@ -265,8 +265,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
{
/* update Parent lifetime */
if (parent != NULL) {
uint32_t now = xtimer_now_usec();
parent->lifetime = (now / US_PER_SEC) + (dodag->default_lifetime * dodag->lifetime_unit);
parent->lifetime = dodag->default_lifetime * dodag->lifetime_unit;
#ifdef MODULE_GNRC_RPL_P2P
if (dodag->instance->mop != GNRC_RPL_P2P_MOP) {
#endif

3
sys/shell/commands/sc_gnrc_rpl.c

@ -304,8 +304,7 @@ int _gnrc_rpl_dodag_show(void)
LL_FOREACH(gnrc_rpl_instances[i].dodag.parents, parent) {
printf("\t\tparent [addr: %s | rank: %d | lifetime: %" PRIu32 "s]\n",
ipv6_addr_to_str(addr_str, &parent->addr, sizeof(addr_str)),
parent->rank, ((int32_t) (parent->lifetime - (((uint32_t) xnow / US_PER_SEC))))
< 0 ? 0 : (parent->lifetime - ((uint32_t) xnow / US_PER_SEC)));
parent->rank, parent->lifetime);
}
}
return 0;

Loading…
Cancel
Save