From 4b58e5d41bb794804d869e4c874cacda1f01e775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Fri, 14 Feb 2020 11:41:30 +0100 Subject: [PATCH 1/4] gnrc_rpl_p2p: fix cleanup timer usage --- sys/include/net/gnrc/rpl/dodag.h | 8 ++++++++ sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c | 13 +++++++++---- sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/sys/include/net/gnrc/rpl/dodag.h b/sys/include/net/gnrc/rpl/dodag.h index 6cdebf7edc..8fca28712b 100644 --- a/sys/include/net/gnrc/rpl/dodag.h +++ b/sys/include/net/gnrc/rpl/dodag.h @@ -147,6 +147,14 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent); */ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent); +/** + * @brief Removes the dodag state of @p dodag after + * GNRC_RPL_CLEANUP_TIME milliseconds + * + * @param[in] dodag Pointer to the DODAG + */ +void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag); + /** * @brief Start a local repair. * diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c index 4631d1902f..c3f7bc75a7 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c @@ -246,6 +246,14 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent) return true; } +void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag) +{ + evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event); + ((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = 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); +} + void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag) { DEBUG("RPL: [INFO] Local Repair started\n"); @@ -260,10 +268,7 @@ void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag) if (dodag->my_rank != GNRC_RPL_INFINITE_RANK) { dodag->my_rank = GNRC_RPL_INFINITE_RANK; trickle_reset_timer(&dodag->trickle); - evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event); - ((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = 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); + gnrc_rpl_cleanup_start(dodag); } } diff --git a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c index 8c7bebd35f..b2551b6073 100644 --- a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c +++ b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c @@ -56,7 +56,7 @@ void gnrc_rpl_p2p_update(void) p2p_ext->lifetime_sec -= GNRC_RPL_LIFETIME_UPDATE_STEP; if (p2p_ext->lifetime_sec <= 0) { gnrc_rpl_dodag_remove_all_parents(p2p_ext->dodag); - p2p_ext->dodag->instance->cleanup = GNRC_RPL_CLEANUP_TIME; + gnrc_rpl_cleanup_start(p2p_ext->dodag); continue; } p2p_ext->dro_delay -= GNRC_RPL_LIFETIME_UPDATE_STEP; From 50423d60cfe87a5e6733014ee4e2c4307a3f4d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Fri, 14 Feb 2020 11:41:56 +0100 Subject: [PATCH 2/4] gnrc_rpl_p2p: use correct parameters for trickle_start() --- sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c index b2551b6073..b45f2f9e92 100644 --- a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c +++ b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c @@ -110,9 +110,9 @@ gnrc_rpl_instance_t *gnrc_rpl_p2p_root_init(uint8_t instance_id, ipv6_addr_t *do p2p_ext->maxrank = GNRC_RPL_P2P_MAX_RANK; p2p_ext->dro_delay = -1; - trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, - GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), - dodag->dio_interval_doubl, dodag->dio_redun); + trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_MSG, + (1 << dodag->dio_min), dodag->dio_interval_doubl, + dodag->dio_redun); return instance; } From 08c3dedf386f3cb142906e21f6af106896b5b270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Fri, 14 Feb 2020 11:42:33 +0100 Subject: [PATCH 3/4] gnrc_rpl_p2p: use correct netif functions --- sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c index b45f2f9e92..f85bff16ea 100644 --- a/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c +++ b/sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c @@ -163,7 +163,7 @@ void gnrc_rpl_p2p_rdo_parse(gnrc_rpl_p2p_opt_rdo_t *rdo, gnrc_rpl_p2p_ext_t *p2p return; } - p2p_ext->for_me = (gnrc_ipv6_netif_find_by_addr(NULL, &rdo->target) != KERNEL_PID_UNDEF); + p2p_ext->for_me = (gnrc_netif_get_by_ipv6_addr(&rdo->target) != NULL); p2p_ext->reply = (rdo->compr_flags & (1 << GNRC_RPL_P2P_RDO_FLAGS_REPLY)) >> GNRC_RPL_P2P_RDO_FLAGS_REPLY; @@ -195,10 +195,19 @@ void gnrc_rpl_p2p_rdo_parse(gnrc_rpl_p2p_opt_rdo_t *rdo, gnrc_rpl_p2p_ext_t *p2p if (!p2p_ext->for_me) { ipv6_addr_t *me = NULL; - if(gnrc_ipv6_netif_find_by_prefix(&me, &p2p_ext->dodag->dodag_id) == KERNEL_PID_UNDEF) { - DEBUG("RPL: no address configured\n"); + gnrc_netif_t *netif = gnrc_netif_get_by_pid(p2p_ext->dodag->iface); + if(netif == NULL) { + DEBUG("RPL: no interface configured\n"); return; } + + me = gnrc_netif_ipv6_addr_best_src(netif, &p2p_ext->dodag->dodag_id, false); + + if(me == NULL) { + DEBUG("RPL: no source address found\n"); + return; + } + addr = ((uint8_t *) &p2p_ext->addr_vec[i]) + p2p_ext->compr; memcpy(addr, ((uint8_t *) me) + p2p_ext->compr, addr_len); p2p_ext->addr_numof++; @@ -337,7 +346,6 @@ void gnrc_rpl_p2p_recv_DRO(gnrc_pktsnip_t *pkt, ipv6_addr_t *src) addr_len = sizeof(ipv6_addr_t) - p2p_ext->compr; ipv6_addr_t addr = p2p_ext->dodag->dodag_id; - ipv6_addr_t *me = NULL; addr_vec = addr_snip->data; rdo = rdo_snip->data; @@ -347,7 +355,9 @@ void gnrc_rpl_p2p_recv_DRO(gnrc_pktsnip_t *pkt, ipv6_addr_t *src) memcpy(&addr.u8[p2p_ext->compr], &addr_vec[addr_len * rdo->lmn], addr_len); } - if (gnrc_ipv6_netif_find_by_addr(&me, &addr) == dodag->iface) { + gnrc_netif_t *netif = gnrc_netif_get_by_ipv6_addr(&addr); + + if (netif && (netif->pid == dodag->iface)) { gnrc_ipv6_nib_ft_add(&p2p_ext->target, IPV6_ADDR_BIT_LEN, src, dodag->iface, p2p_ext->dodag->default_lifetime * p2p_ext->dodag->lifetime_unit); From ab414ce8138fb8bb30f0eec821bcf1b71edf8e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 19 Feb 2020 15:42:30 +0100 Subject: [PATCH 4/4] tests: add simple compile test for gnrc_rpl_p2p --- tests/gnrc_rpl_p2p/Makefile | 7 +++++++ tests/gnrc_rpl_p2p/Makefile.ci | 31 ++++++++++++++++++++++++++++++ tests/gnrc_rpl_p2p/main.c | 28 +++++++++++++++++++++++++++ tests/gnrc_rpl_p2p/tests/01-run.py | 18 +++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 tests/gnrc_rpl_p2p/Makefile create mode 100644 tests/gnrc_rpl_p2p/Makefile.ci create mode 100644 tests/gnrc_rpl_p2p/main.c create mode 100755 tests/gnrc_rpl_p2p/tests/01-run.py diff --git a/tests/gnrc_rpl_p2p/Makefile b/tests/gnrc_rpl_p2p/Makefile new file mode 100644 index 0000000000..6e3db2980a --- /dev/null +++ b/tests/gnrc_rpl_p2p/Makefile @@ -0,0 +1,7 @@ +include ../Makefile.tests_common + +USEMODULE += gnrc_ipv6_router_default +USEMODULE += auto_init_gnrc_rpl +USEMODULE += gnrc_rpl_p2p + +include $(RIOTBASE)/Makefile.include diff --git a/tests/gnrc_rpl_p2p/Makefile.ci b/tests/gnrc_rpl_p2p/Makefile.ci new file mode 100644 index 0000000000..6e67c40e46 --- /dev/null +++ b/tests/gnrc_rpl_p2p/Makefile.ci @@ -0,0 +1,31 @@ +BOARD_INSUFFICIENT_MEMORY := \ + arduino-duemilanove \ + arduino-leonardo \ + arduino-mega2560 \ + arduino-nano \ + arduino-uno \ + atmega328p \ + chronos \ + i-nucleo-lrwan1 \ + msb-430 \ + msb-430h \ + nucleo-f030r8 \ + nucleo-f031k6 \ + nucleo-f042k6 \ + nucleo-f070rb \ + nucleo-f072rb \ + nucleo-f103rb \ + nucleo-f302r8 \ + nucleo-f303k8 \ + nucleo-f334r8 \ + nucleo-l031k6 \ + nucleo-l053r8 \ + stm32f030f4-demo \ + stm32f0discovery \ + stm32l0538-disco \ + telosb \ + waspmote-pro \ + wsn430-v1_3b \ + wsn430-v1_4 \ + z1 \ + # diff --git a/tests/gnrc_rpl_p2p/main.c b/tests/gnrc_rpl_p2p/main.c new file mode 100644 index 0000000000..2e31545d44 --- /dev/null +++ b/tests/gnrc_rpl_p2p/main.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 HAW + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief Compile test for gnrc_rpl_p2p + * + * @author Cenk Gündoğan + * + * @} + */ + +#include + +int main(void) +{ + puts("[SUCCESS]"); + + return 0; +} diff --git a/tests/gnrc_rpl_p2p/tests/01-run.py b/tests/gnrc_rpl_p2p/tests/01-run.py new file mode 100755 index 0000000000..b2a6d492a3 --- /dev/null +++ b/tests/gnrc_rpl_p2p/tests/01-run.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2020 HAW Hamburg +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import sys +from testrunner import run + + +def testfunc(child): + child.expect_exact(u"[SUCCESS]") + + +if __name__ == "__main__": + sys.exit(run(testfunc))