Skip to content
Open
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
16 changes: 16 additions & 0 deletions sys/include/net/gnrc/rpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
#define GNRC_RPL_COUNTER_MAX (255)
#define GNRC_RPL_COUNTER_LOWER_REGION (127)
#define GNRC_RPL_COUNTER_SEQ_WINDOW (16)
#define GNRC_RPL_COUNTER_INIT (GNRC_RPL_COUNTER_MAX - GNRC_RPL_COUNTER_SEQ_WINDOW + 1)

Check warning on line 300 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

static inline uint8_t GNRC_RPL_COUNTER_INCREMENT(uint8_t counter)
{
Expand Down Expand Up @@ -446,11 +446,27 @@
#define GNRC_RPL_OPT_DODAG_CONF (4)
#define GNRC_RPL_OPT_TARGET (5)
#define GNRC_RPL_OPT_TRANSIT (6)
#define GNRC_RPL_OPT_TRANSIT_E_FLAG_SHIFT (7)

Check failure on line 449 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_OPT_TRANSIT_E_FLAG_SHIFT (macro definition) of group net_gnrc_rpl is not documented.
#define GNRC_RPL_OPT_TRANSIT_E_FLAG (1 << GNRC_RPL_OPT_TRANSIT_E_FLAG_SHIFT)

Check failure on line 450 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_OPT_TRANSIT_E_FLAG (macro definition) of group net_gnrc_rpl is not documented.
#define GNRC_RPL_OPT_SOLICITED_INFO (7)
#define GNRC_RPL_OPT_PREFIX_INFO (8)
#define GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT (1 << 6)

Check failure on line 453 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT (macro definition) of group net_gnrc_rpl is not documented.
#define GNRC_RPL_OPT_TARGET_DESC (9)
/** @} */

/**
* @name RPL DIO Base Object fields
* @see <a href="https://tools.ietf.org/html/rfc6550#section-6.3">
* DODAG Information Object (DIO)
* </a>
* @{
*/
#define GNRC_RPL_GROUNDED_SHIFT (7)

Check failure on line 464 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_GROUNDED_SHIFT (macro definition) of group net_gnrc_rpl is not documented.
#define GNRC_RPL_MOP_SHIFT (3)

Check failure on line 465 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_MOP_SHIFT (macro definition) of group net_gnrc_rpl is not documented.
#define GNRC_RPL_SHIFTED_MOP_MASK (0x7)

Check failure on line 466 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_SHIFTED_MOP_MASK (macro definition) of group net_gnrc_rpl is not documented.
#define GNRC_RPL_PRF_MASK (0x7)

Check failure on line 467 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

Member GNRC_RPL_PRF_MASK (macro definition) of group net_gnrc_rpl is not documented.


Check warning on line 469 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
/**
* @brief Rank of the root node
*/
Expand Down Expand Up @@ -499,7 +515,7 @@
* RFC 6550, section 3.5.1, Rank Comparison (DAGRank())
* </a>
*/
#define DAGRANK(rank,mhri) (rank/mhri)

Check warning on line 518 in sys/include/net/gnrc/rpl.h

View workflow job for this annotation

GitHub Actions / static-tests

comma should be followed by whitespace

/**
* @name Global / Local instance id masks
Expand Down Expand Up @@ -761,3 +777,3 @@
#endif

/** @} */
12 changes: 8 additions & 4 deletions sys/include/net/gnrc/rpl/dodag.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ bool gnrc_rpl_instance_add(uint8_t instance_id, gnrc_rpl_instance_t **inst);
*/
bool gnrc_rpl_instance_remove_by_id(uint8_t instance_id);

/**
* @brief Remove a RPL DODAG with the pointer @p dodag from its instance.
*
* @param[in] dodag Pointer to the RPL DODAG to remove.
*/
void gnrc_rpl_dodag_remove(gnrc_rpl_dodag_t *dodag);

/**
* @brief Remove a RPL instance with the pointer @p inst.
*
* @param[in] inst Pointer to the RPL instance to remove.
*
* @return true, on success.
* @return false, otherwise.
*/
bool gnrc_rpl_instance_remove(gnrc_rpl_instance_t *inst);
void gnrc_rpl_instance_remove(gnrc_rpl_instance_t *inst);

/**
* @brief Get the RPL instance with the id @p instance_id.
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/rpl/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
* @return Negative, if the first parent is preferred.
*/
int (*parent_cmp)(gnrc_rpl_parent_t *parent1, gnrc_rpl_parent_t *parent2);
gnrc_rpl_dodag_t *(*which_dodag)(gnrc_rpl_dodag_t *, gnrc_rpl_dodag_t *); /**< compare for dodags */
int (*which_dodag)(gnrc_rpl_dodag_t *, gnrc_rpl_dio_t *); /**< compare for dodags */

/**
* @brief Reset the state of the objective function.
Expand All @@ -294,7 +294,7 @@
* @param[in] dodag RPL dodag object.
*/
void (*reset)(gnrc_rpl_dodag_t *dodag);
void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int); /**< retrieves the state of a parent*/

Check warning on line 297 in sys/include/net/gnrc/rpl/structs.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

/**
* @brief Initialize the objective function.
Expand Down Expand Up @@ -361,7 +361,7 @@
/**
* @brief internal unpacked struct type for DIS solicited option insertion
*/
typedef struct {

Check warning on line 364 in sys/include/net/gnrc/rpl/structs.h

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'struct' not followed by a single space
uint8_t type; /**< Option Type: 0x07 */
uint8_t length; /**< Option Length: 19 bytes*/
uint8_t instance_id; /**< id of the instance */
Expand Down
83 changes: 48 additions & 35 deletions sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "net/gnrc.h"
#include "net/eui64.h"
#include "gnrc_rpl_internal/globals.h"
#include "of0.h"

#ifdef MODULE_NETSTATS_RPL
#include "gnrc_rpl_internal/netstats.h"
Expand All @@ -49,19 +50,11 @@
#include "net/gnrc/rpl/p2p.h"
#endif

#define ENABLE_DEBUG 0
#define ENABLE_DEBUG 1
#include "debug.h"

static char addr_str[IPV6_ADDR_MAX_STR_LEN];

#define GNRC_RPL_GROUNDED_SHIFT (7)
#define GNRC_RPL_MOP_SHIFT (3)
#define GNRC_RPL_OPT_TRANSIT_E_FLAG_SHIFT (7)
#define GNRC_RPL_OPT_TRANSIT_E_FLAG (1 << GNRC_RPL_OPT_TRANSIT_E_FLAG_SHIFT)
#define GNRC_RPL_SHIFTED_MOP_MASK (0x7)
#define GNRC_RPL_PRF_MASK (0x7)
#define GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT (1 << 6)

/**
* @brief Checks validity of DIO control messages
*
Expand Down Expand Up @@ -628,7 +621,7 @@ static bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt

/* check the DODAG ID */
if (sol->VID_flags & GNRC_RPL_DIS_SOLICITED_INFO_FLAG_D) {
if (memcmp(&sol->dodag_id, &inst->dodag.dodag_id, sizeof(ipv6_addr_t)) != 0) {
if (!ipv6_addr_equal(&sol->dodag_id, &inst->dodag.dodag_id)) {
DEBUG("RPL: RPL SOLICITED INFO option, ignore DIS cause: DODAGID mismatch\n");
return false;
}
Expand Down Expand Up @@ -905,6 +898,42 @@ void _recv_DIO_for_new_dodag(gnrc_rpl_instance_t *inst, gnrc_rpl_dio_t *dio, ker

}

/**
* @brief Handles a received DIO message for a DODAG that is different from the
* one we currently participate in.
*
* @param[in] inst The @p RPL instance of the current DODAG.
* @param[in] dio The @p DIO packet for the other DODAG.
* @param[in] src The address of the sender.
* @param[in] len The length of the DIO packet.
*/
static void _recv_DIO_for_different_dodag(gnrc_rpl_instance_t *inst, gnrc_rpl_dio_t *dio,
kernel_pid_t iface,
ipv6_addr_t *src, uint16_t len)
{
/* DIO received from a different DODAG */
DEBUG("RPL: DIO received from another DODAG, but same instance.\n");

gnrc_rpl_dodag_t *dodag = &inst->dodag;

/* clear parent from old dodag if present */
gnrc_rpl_parent_t *parent = dodag->parents;
while (parent) {
if (ipv6_addr_equal(&parent->addr, src)) {
gnrc_rpl_parent_remove(parent);
break;
}
parent = parent->next;
}

/* decide between old and new dodag */
if (gnrc_rpl_get_of0()->which_dodag(dodag, dio) > 0) {
DEBUG("RPL: switch to new DODAG.\n");
gnrc_rpl_dodag_remove(dodag);
_recv_DIO_for_new_dodag(inst, dio, iface, src, len);
}
}

/**
* @brief Handles a received DIO message for an existing DODAG.
*
Expand All @@ -914,17 +943,11 @@ void _recv_DIO_for_new_dodag(gnrc_rpl_instance_t *inst, gnrc_rpl_dio_t *dio, ker
* @param[in] len The length of the DIO packet.
*/
static void _recv_DIO_for_existing_dodag(gnrc_rpl_instance_t *inst, gnrc_rpl_dio_t *dio,
ipv6_addr_t *src, uint16_t len)
ipv6_addr_t *src,
uint16_t len)
{
gnrc_rpl_dodag_t *dodag = &inst->dodag;

/* ignore dodags with other dodag_id's for now */
/* TODO: choose DODAG with better rank */
if (memcmp(&dodag->dodag_id, &dio->dodag_id, sizeof(ipv6_addr_t)) != 0) {
DEBUG("RPL: DIO received from another DODAG, but same instance - ignore\n");
return;
}

if (inst->mop != ((dio->g_mop_prf >> GNRC_RPL_MOP_SHIFT) & GNRC_RPL_SHIFTED_MOP_MASK)) {
DEBUG("RPL: invalid MOP for this instance.\n");
return;
Expand All @@ -937,21 +960,6 @@ static void _recv_DIO_for_existing_dodag(gnrc_rpl_instance_t *inst, gnrc_rpl_dio
}
#endif

if (GNRC_RPL_COUNTER_GREATER_THAN(dio->version_number, dodag->version)) {
if (dodag->node_status == GNRC_RPL_ROOT_NODE) {
dodag->version = GNRC_RPL_COUNTER_INCREMENT(dio->version_number);
trickle_reset_timer(&dodag->trickle);
}
else {
dodag->version = dio->version_number;
gnrc_rpl_local_repair(dodag);
}
}
else if (GNRC_RPL_COUNTER_GREATER_THAN(dodag->version, dio->version_number)) {
trickle_reset_timer(&dodag->trickle);
return;
}
Comment on lines -940 to -953
Copy link
Contributor Author

@elenaf9 elenaf9 Oct 2, 2025

Choose a reason for hiding this comment

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

I think, different DODAG versions should be treated as different DODAGs because they affect also our parent set etc. (e.g., per RFC all parents in the parent set must be the same DODAG version). So the old logic of just increasing our version and leaving the rest as it is wasn't really RFC conformant.
Is my understanding correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

The version number is incremented when something happens that requires that the DODAG be rebuilt. It's not a different DODAG. One should attach to the highest version number (with lollipop numbering, I think)

Copy link
Contributor Author

@elenaf9 elenaf9 Oct 3, 2025

Choose a reason for hiding this comment

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

The version number is incremented when something happens that requires that the DODAG be rebuilt. It's not a different DODAG. One should attach to the highest version number (with lollipop numbering, I think)

Yes, that was also my understanding.
But implementation wise, I was thinking that we could still treat a new DODAG version the same as we treat joining a completely different DODAG: clear the parent set, reset trickle, reset other parameters...
The old implementation effectively also just triggered a local repair (=> implemented in RIOT as poising of all ranks and cleanup of the current dodag).

But thinking about it again now, we probably don't want to reset all parameters, like dtsn or DAO sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Side note: I don't think that increasing a DODAG version as a root is currently even implemented in RIOT.


if (dodag->node_status == GNRC_RPL_ROOT_NODE) {
if (byteorder_ntohs(dio->rank) != GNRC_RPL_INFINITE_RANK) {
trickle_increment_counter(&dodag->trickle);
Expand Down Expand Up @@ -996,6 +1004,11 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
else if (inst == NULL) {
DEBUG("RPL: Could not allocate a new instance.\n");
}
else if (!ipv6_addr_equal(&inst->dodag.dodag_id, &dio->dodag_id)
|| (inst->dodag.version != dio->version_number)) {

_recv_DIO_for_different_dodag(inst, dio, iface, src, len);
}
else {
_recv_DIO_for_existing_dodag(inst, dio, src, len);
}
Expand Down Expand Up @@ -1256,7 +1269,7 @@ void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, kernel_pid_t iface, ipv6_addr_t *src

/* check if the D flag is set before accessing the DODAG id */
if ((dao->k_d_flags & GNRC_RPL_DAO_D_BIT)) {
if (memcmp(&dodag->dodag_id, (ipv6_addr_t *)(dao + 1), sizeof(ipv6_addr_t)) != 0) {
if (!ipv6_addr_equal(&dodag->dodag_id, (ipv6_addr_t *)(dao + 1))) {
DEBUG("RPL: DAO with unknown DODAG id (%s)\n", _ip_addr_str((ipv6_addr_t *)(dao + 1)));
return;
}
Expand Down Expand Up @@ -1319,7 +1332,7 @@ void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, kernel_pid_t iface, ipv6

/* check if the D flag is set before accessing the DODAG id */
if ((dao_ack->d_reserved & GNRC_RPL_DAO_ACK_D_BIT)) {
if (memcmp(&dodag->dodag_id, (ipv6_addr_t *)(dao_ack + 1), sizeof(ipv6_addr_t)) != 0) {
if (!ipv6_addr_equal(&dodag->dodag_id, (ipv6_addr_t *)(dao_ack + 1))) {
DEBUG("RPL: DAO-ACK with unknown DODAG id (%s)\n",
_ip_addr_str((ipv6_addr_t *)(dao_ack + 1)));
return;
Expand Down
15 changes: 10 additions & 5 deletions sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

gnrc_rpl_send_DIO(inst, (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes);
DEBUG("trickle callback: Instance (%d) | DODAG: (%s)\n", inst->id,
ipv6_addr_to_str(addr_str,&dodag->dodag_id, sizeof(addr_str)));

Check warning on line 68 in sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

View workflow job for this annotation

GitHub Actions / static-tests

comma should be followed by whitespace
}

/* The lifetime of the default route should exceed the parent timeout interval
Expand Down Expand Up @@ -113,26 +113,31 @@

bool gnrc_rpl_instance_remove_by_id(uint8_t instance_id)
{
for(uint8_t i = 0; i < GNRC_RPL_INSTANCES_NUMOF; ++i) {

Check warning on line 116 in sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'for' not followed by a single space
if (gnrc_rpl_instances[i].id == instance_id) {
return gnrc_rpl_instance_remove(&gnrc_rpl_instances[i]);
gnrc_rpl_instance_remove(&gnrc_rpl_instances[i]);
return true;
}
}
return false;
}

bool gnrc_rpl_instance_remove(gnrc_rpl_instance_t *inst)
void gnrc_rpl_dodag_remove(gnrc_rpl_dodag_t *dodag)
{
gnrc_rpl_dodag_t *dodag = &inst->dodag;
#ifdef MODULE_GNRC_RPL_P2P
gnrc_rpl_p2p_ext_remove(dodag);
#endif
gnrc_rpl_dodag_remove_all_parents(dodag);
trickle_stop(&dodag->trickle);
evtimer_del(&gnrc_rpl_evtimer, (evtimer_event_t *)&dodag->dao_event);
evtimer_del(&gnrc_rpl_evtimer, (evtimer_event_t *)&inst->cleanup_event);
evtimer_del(&gnrc_rpl_evtimer, (evtimer_event_t *)&dodag->instance->cleanup_event);

}

void gnrc_rpl_instance_remove(gnrc_rpl_instance_t *inst)
{
gnrc_rpl_dodag_remove(&inst->dodag);
memset(inst, 0, sizeof(gnrc_rpl_instance_t));
return true;
}

gnrc_rpl_instance_t *gnrc_rpl_instance_get(uint8_t instance_id)
Expand Down Expand Up @@ -223,7 +228,7 @@
(*parent)->state = GNRC_RPL_PARENT_ACTIVE;
(*parent)->addr = *addr;
(*parent)->rank = GNRC_RPL_INFINITE_RANK;
evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)(&(*parent)->timeout_event));

Check warning on line 231 in sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
((evtimer_event_t *)(&(*parent)->timeout_event))->next = NULL;
(*parent)->timeout_event.msg.type = GNRC_RPL_MSG_TYPE_PARENT_TIMEOUT;
(*parent)->timeout_event.msg.content.ptr = (*parent);
Expand Down Expand Up @@ -259,7 +264,7 @@

void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag)
{
evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event);

Check warning on line 267 in sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = CONFIG_GNRC_RPL_CLEANUP_TIME;
dodag->instance->cleanup_event.msg.type = GNRC_RPL_MSG_TYPE_INSTANCE_CLEANUP;
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->instance->cleanup_event, gnrc_rpl_pid);
Expand Down Expand Up @@ -289,7 +294,7 @@
if ((parent != NULL) && (parent->state != GNRC_RPL_PARENT_UNUSED)) {
parent->state = GNRC_RPL_PARENT_ACTIVE;
evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&parent->timeout_event);
((evtimer_event_t *)&(parent->timeout_event))->offset = (dodag->default_lifetime - 1) * dodag->lifetime_unit * MS_PER_SEC;

Check warning on line 297 in sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
parent->timeout_event.msg.type = GNRC_RPL_MSG_TYPE_PARENT_TIMEOUT;
evtimer_add_msg(&gnrc_rpl_evtimer, &parent->timeout_event, gnrc_rpl_pid);
#ifdef MODULE_GNRC_RPL_P2P
Expand Down
72 changes: 60 additions & 12 deletions sys/net/gnrc/routing/rpl/of0.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@

static uint16_t calc_rank(gnrc_rpl_dodag_t *, uint16_t);
static int parent_cmp(gnrc_rpl_parent_t *, gnrc_rpl_parent_t *);
static gnrc_rpl_dodag_t *which_dodag(gnrc_rpl_dodag_t *, gnrc_rpl_dodag_t *);
static int which_dodag(gnrc_rpl_dodag_t *, gnrc_rpl_dio_t *);
static void reset(gnrc_rpl_dodag_t *);

static gnrc_rpl_of_t gnrc_rpl_of0 = {
.ocp = 0x0,
.calc_rank = calc_rank,
.parent_cmp = parent_cmp,
.which_dodag = which_dodag,
.reset = reset,
.ocp = 0x0,
.calc_rank = calc_rank,
.parent_cmp = parent_cmp,
.which_dodag = which_dodag,
.reset = reset,
.parent_state_callback = NULL,
.init = NULL,
.process_dio = NULL
.init = NULL,
.process_dio = NULL
};

gnrc_rpl_of_t *gnrc_rpl_get_of0(void)
Expand Down Expand Up @@ -87,9 +87,57 @@ int parent_cmp(gnrc_rpl_parent_t *parent1, gnrc_rpl_parent_t *parent2)
return 0;
}

/* Not used yet */
gnrc_rpl_dodag_t *which_dodag(gnrc_rpl_dodag_t *d1, gnrc_rpl_dodag_t *d2)
int which_dodag(gnrc_rpl_dodag_t *d1, gnrc_rpl_dio_t *dio)
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we wanted to compare two gnrc_rpl_dodag_ts, we'd first need to allocate the whole dodag structure based on the DIO, and even create a new RPL instance too because we only support one DODAG per instance.
I don't think this makes sense, given that in practice we only ever compare the info from DIOs with the current DODAG.

(void) d2;
return d1;
/* parent set must not be empty */
if ((d1->node_status != GNRC_RPL_ROOT_NODE) && !d1->parents) {
return 1;
}

/* prefer grounded dodag */
int dio_grounded = dio->g_mop_prf >> GNRC_RPL_GROUNDED_SHIFT;
if (d1->grounded > dio_grounded) {
return -1;
}
else if (dio_grounded > d1->grounded) {
return 1;
}

int dio_prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK;

/* prefer dodag with more preferable root */
if (d1->prf > dio_prf) {
return -1;
}
else if (dio_prf > d1->prf) {
return 1;
}

/* prefer DODAG with more recent version */
if (memcmp(&d1->dodag_id, &dio->dodag_id, sizeof(ipv6_addr_t)) != 0) {
if (GNRC_RPL_COUNTER_GREATER_THAN(d1->version, dio->version_number)) {
return -1;
}
else if (GNRC_RPL_COUNTER_GREATER_THAN(dio->version_number, d1->version)) {
return 1;
}
}

/* prefer dodag with lesser resulting rank */
/* TODO: calc rank properly */
int d1_rank = d1->parents->rank;
int d2_rank = byteorder_ntohs(dio->rank);
if (d1_rank < d2_rank) {
return -1;
}
else if (d2_rank < d1_rank) {
return 1;
}

/* prefer DODAG for which there is an alternate parent */
if (d1->parents->next) {
return -1;
}

return 0;
}
5 changes: 1 addition & 4 deletions sys/shell/cmds/gnrc_rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ int _gnrc_rpl_instance_remove(char *arg1)
return 1;
}

if (gnrc_rpl_instance_remove(inst) == false) {
printf("error: could not remove instance (%d)\n", instance_id);
return 1;
}
gnrc_rpl_instance_remove(inst);

printf("success: removed instance (%d)\n", instance_id);
return 0;
Expand Down
Loading