Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpl: remove rpl_get_my_dodag() dependency in rpl_delete_all_parents() #2633

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sys/net/include/rpl/rpl_dodag.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool rpl_equal_id(ipv6_addr_t *id1, ipv6_addr_t *id2);
ipv6_addr_t *rpl_get_my_preferred_parent(void);
void rpl_delete_parent(rpl_parent_t *parent);
void rpl_delete_worst_parent(void);
void rpl_delete_all_parents(void);
void rpl_delete_all_parents(rpl_dodag_t *dodag);
rpl_parent_t *rpl_find_preferred_parent(rpl_dodag_t *dodag);
void rpl_parent_update(rpl_dodag_t *dodag, rpl_parent_t *parent);
void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank);
Expand Down
28 changes: 12 additions & 16 deletions sys/net/routing/rpl/rpl_dodag.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void rpl_leave_dodag(rpl_dodag_t *dodag)
{
dodag->joined = 0;
dodag->my_preferred_parent = NULL;
rpl_delete_all_parents();
rpl_delete_all_parents(dodag);
trickle_stop(&dodag->trickle);
vtimer_remove(&dodag->dao_timer);
}
Expand Down Expand Up @@ -204,13 +204,9 @@ rpl_parent_t *rpl_find_parent(rpl_dodag_t *dodag, ipv6_addr_t *address)

void rpl_delete_parent(rpl_parent_t *parent)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();

if ((my_dodag != NULL) && rpl_equal_id(&my_dodag->my_preferred_parent->addr,
&parent->addr)) {
my_dodag->my_preferred_parent = NULL;
if (parent == parent->dodag->my_preferred_parent) {
parent->dodag->my_preferred_parent = NULL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgundogan I assume that rpl_equal_id(...) is obsolete/wrong in the RPL implementation since we now provide multiple DODAGs?


memset(parent, 0, sizeof(*parent));
}

Expand All @@ -235,16 +231,15 @@ void rpl_delete_worst_parent(void)

}

void rpl_delete_all_parents(void)
void rpl_delete_all_parents(rpl_dodag_t *dodag)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();

if (my_dodag != NULL) {
my_dodag->my_preferred_parent = NULL;
}

dodag->my_preferred_parent = NULL;
for (int i = 0; i < RPL_MAX_PARENTS; i++) {
memset(&parents[i], 0, sizeof(parents[i]));
if (parents[i].dodag && (dodag->instance->id == parents[i].dodag->instance->id) &&
(!memcmp(&dodag->dodag_id, &parents[i].dodag->dodag_id, sizeof(ipv6_addr_t)))) {
memset(&parents[i], 0, sizeof(parents[i]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this must be rpl_delete_parent(&parents[i]) to additionally delete the dodag->my_preferred_parent if its the same one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dodag->my_preferred_parent is set to NULL before entering the for loop

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👓 sorry, somehow missed that line

}
}
}

Expand Down Expand Up @@ -401,7 +396,8 @@ void rpl_global_repair(rpl_dodag_t *my_dodag, ipv6_addr_t *p_addr, uint16_t rank
return;
}

rpl_delete_all_parents();
rpl_delete_all_parents(my_dodag);
my_dodag->version = my_dodag->version;
my_dodag->dtsn++;
my_dodag->my_preferred_parent = rpl_new_parent(my_dodag, p_addr, rank);

Expand Down Expand Up @@ -433,7 +429,7 @@ void rpl_local_repair(rpl_dodag_t *my_dodag)

my_dodag->my_rank = INFINITE_RANK;
my_dodag->dtsn++;
rpl_delete_all_parents();
rpl_delete_all_parents(my_dodag);
trickle_reset_timer(&my_dodag->trickle);

}
Expand Down