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

gnrc_rpl: new default route when old one was deleted #5141

Merged
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
22 changes: 20 additions & 2 deletions sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,30 @@ bool gnrc_rpl_parent_add_by_addr(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *addr,

bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
{
if (parent == parent->dodag->parents) {
assert(parent != NULL);

gnrc_rpl_dodag_t *dodag = parent->dodag;

if (parent == dodag->parents) {
fib_remove_entry(&gnrc_ipv6_fib_table,
(uint8_t *) ipv6_addr_unspecified.u8,
sizeof(ipv6_addr_t));

/* set the default route to the next parent for now */
if (parent->next) {
uint32_t now = xtimer_now() / SEC_IN_USEC;
fib_add_entry(&gnrc_ipv6_fib_table,
dodag->iface,
(uint8_t *) ipv6_addr_unspecified.u8,
sizeof(ipv6_addr_t),
FIB_FLAG_NET_PREFIX,
parent->next->addr.u8,
sizeof(ipv6_addr_t),
FIB_FLAG_RPL_ROUTE,
(parent->next->lifetime - now) * SEC_IN_MS);
}
Copy link
Member

Choose a reason for hiding this comment

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

else we keep the old 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.

yes, for the case that this parent (to delete) is not the preferred parent, the fib default entry is not removed and should still point to the preferred parent

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, looked at the wrong if:

if there is no parent->next then we basically have no parents left, so we cannot add a new fib entry

Copy link
Member

Choose a reason for hiding this comment

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

but we could remove the removed parent from the FIB

Copy link
Member Author

Choose a reason for hiding this comment

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

That's done in line 200 if I understand you correctly

Copy link
Member

Choose a reason for hiding this comment

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

ahh sry 👓

}
LL_DELETE(parent->dodag->parents, parent);
LL_DELETE(dodag->parents, parent);
memset(parent, 0, sizeof(gnrc_rpl_parent_t));
return true;
}
Expand Down