From 4a1d9421538a892f790d49515b896fa6f609935b Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Mon, 15 May 2023 22:35:55 +0200 Subject: [PATCH 1/4] Make it clearer that packet is being dropped at tcpip --- os/net/ipv6/tcpip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index aad8ba2875c..a0b32a91a08 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -672,6 +672,7 @@ tcpip_ipv6_output(void) /* Look for a next hop */ if((nexthop = get_nexthop(&ipaddr)) == NULL) { + LOG_WARN("output: No next-hop found, dropping packet\n"); goto exit; } annotate_transmission(nexthop); From ad8e70f54de40b87cb9447a21246d1933e59eb9f Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Mon, 15 May 2023 22:36:52 +0200 Subject: [PATCH 2/4] Minor improvements to RPL, TSCH, uip logging and code-style --- os/net/ipv6/uip-ds6.c | 4 ++-- os/net/mac/tsch/tsch-schedule.c | 6 +++--- os/net/mac/tsch/tsch.c | 5 +++-- os/net/routing/rpl-classic/rpl-dag.c | 4 ++-- os/net/routing/rpl-classic/rpl-ext-header.c | 11 ++++++----- os/net/routing/rpl-classic/rpl-icmp6.c | 3 +-- os/net/routing/rpl-classic/rpl-private.h | 4 +++- os/net/routing/rpl-lite/rpl.c | 3 ++- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/os/net/ipv6/uip-ds6.c b/os/net/ipv6/uip-ds6.c index 98510173d2e..4efbcdbda2b 100644 --- a/os/net/ipv6/uip-ds6.c +++ b/os/net/ipv6/uip-ds6.c @@ -282,7 +282,7 @@ uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen, locprefix->plifetime = ptime; LOG_INFO("Adding prefix "); LOG_INFO_6ADDR(&locprefix->ipaddr); - LOG_INFO_("length %u, flags %x, Valid lifetime %lx, Preffered lifetime %lx\n", + LOG_INFO_(" len %u, flags %x, valid/preferred lifetime %lx/%lx\n", ipaddrlen, flags, vtime, ptime); return locprefix; } else { @@ -312,7 +312,7 @@ uip_ds6_prefix_add(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen, } LOG_INFO("Adding prefix "); LOG_INFO_6ADDR(&locprefix->ipaddr); - LOG_INFO_("length %u, vlifetime %lu\n", ipaddrlen, interval); + LOG_INFO_(" len %u, valid lifetime %lu\n", ipaddrlen, interval); return locprefix; } return NULL; diff --git a/os/net/mac/tsch/tsch-schedule.c b/os/net/mac/tsch/tsch-schedule.c index 32893a7f725..25524e1461c 100644 --- a/os/net/mac/tsch/tsch-schedule.c +++ b/os/net/mac/tsch/tsch-schedule.c @@ -91,8 +91,7 @@ tsch_schedule_add_slotframe(uint16_t handle, uint16_t size) /* Add the slotframe to the global list */ list_add(slotframe_list, sf); } - LOG_INFO("add_slotframe %u %u\n", - handle, size); + LOG_INFO("Adding slotframe %u, size %u\n", handle, size); tsch_release_lock(); return sf; } @@ -125,7 +124,8 @@ tsch_schedule_remove_slotframe(struct tsch_slotframe *slotframe) /* Now that the slotframe has no links, remove it. */ if(tsch_get_lock()) { - LOG_INFO("remove slotframe %u %u\n", slotframe->handle, slotframe->size.val); + LOG_INFO("Remove slotframe %u, size %u\n", + slotframe->handle, slotframe->size.val); memb_free(&slotframe_memb, slotframe); list_remove(slotframe_list, slotframe); tsch_release_lock(); diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index 3200af02f7f..3343698cbf1 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -481,7 +481,8 @@ eb_input(struct input_packet *current_input) LOG_WARN("Updating TSCH hopping sequence from EB\n"); } else { - LOG_WARN("TSCH:! parse_eb: hopping sequence too long (%u)\n", eb_ies.ie_hopping_sequence_len); + LOG_WARN("parse_eb: Hopping sequence too long (%u)\n", + eb_ies.ie_hopping_sequence_len); } } } @@ -947,7 +948,7 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) if(!(p = tsch_queue_add_packet(&tsch_eb_address, 1, NULL, NULL))) { LOG_ERR("! could not enqueue EB packet\n"); } else { - LOG_INFO("TSCH: enqueue EB packet %u %u\n", + LOG_INFO("Enqueuing EB packet %u %u\n", packetbuf_totlen(), packetbuf_hdrlen()); p->tsch_sync_ie_offset = tsch_sync_ie_offset; p->header_len = hdr_len; diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index dcdb6aebcc0..dec2699c337 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -869,7 +869,7 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p) rpl_print_neighbor_list(); } } else if(best_dag->rank != old_rank) { - LOG_DBG("RPL: Preferred parent update, rank changed from %u to %u\n", + LOG_DBG("Preferred parent update, rank changed from %u to %u\n", (unsigned)old_rank, best_dag->rank); } return best_dag; @@ -1656,7 +1656,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio) /* Parent info has been updated, trigger rank recalculation. */ p->flags |= RPL_PARENT_FLAG_UPDATED; - LOG_INFO("preferred DAG "); + LOG_INFO("Preferred DAG "); LOG_INFO_6ADDR(&instance->current_dag->dag_id); LOG_INFO_(", rank %u, min_rank %u, ", instance->current_dag->rank, instance->current_dag->min_rank); diff --git a/os/net/routing/rpl-classic/rpl-ext-header.c b/os/net/routing/rpl-classic/rpl-ext-header.c index fdf69fb5e55..32c0750bb5b 100644 --- a/os/net/routing/rpl-classic/rpl-ext-header.c +++ b/os/net/routing/rpl-classic/rpl-ext-header.c @@ -119,7 +119,7 @@ rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset) sender = nbr_table_get_from_lladdr(rpl_parents, packetbuf_addr(PACKETBUF_ADDR_SENDER)); if(sender != NULL && (rpl_opt->flags & RPL_HDR_OPT_RANK_ERR)) { - /* A rank error was signalled -- attempt to repair it by updating + /* A rank error was signaled -- attempt to repair it by updating the sender's rank from the ext header. */ sender->rank = sender_rank; if(RPL_IS_NON_STORING(instance)) { @@ -135,9 +135,10 @@ rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset) sender_closer = sender_rank < instance->current_dag->rank; - LOG_DBG("Packet going %s, sender closer %d (%d < %d)\n", + + LOG_DBG("Packet going %s, sender%s closer (%d < %d)\n", down == 1 ? "down" : "up", - sender_closer, + sender_closer ? "" : " not", sender_rank, instance->current_dag->rank); @@ -154,14 +155,14 @@ rpl_ext_header_hbh_update(uint8_t *ext_buf, int opt_offset) if(rpl_opt->flags & RPL_HDR_OPT_RANK_ERR) { RPL_STAT(rpl_stats.loop_errors++); - LOG_ERR(" Rank error signalled in RPL option!\n"); + LOG_ERR("Rank error signaled in RPL option!\n"); /* Packet must be dropped and dio trickle timer reset, see RFC6550 - 11.2.2.2 */ rpl_reset_dio_timer(instance); return 0; } - LOG_WARN("Single error tolerated\n"); + LOG_WARN("One inconsistency along path is tolerated\n"); RPL_STAT(rpl_stats.loop_warnings++); rpl_opt->flags |= RPL_HDR_OPT_RANK_ERR; return 1; diff --git a/os/net/routing/rpl-classic/rpl-icmp6.c b/os/net/routing/rpl-classic/rpl-icmp6.c index 3219e85dbed..8b56dda95da 100644 --- a/os/net/routing/rpl-classic/rpl-icmp6.c +++ b/os/net/routing/rpl-classic/rpl-icmp6.c @@ -816,8 +816,7 @@ dao_input_storing(void) uint8_t out_seq; out_seq = prepare_for_dao_fwd(sequence, rep); - LOG_DBG("Forwarding No-path DAO to parent - out_seq:%d", - out_seq); + LOG_DBG("Forwarding No-path DAO out_seq:%d to parent ", out_seq); LOG_DBG_6ADDR(rpl_parent_get_ipaddr(dag->preferred_parent)); LOG_DBG_("\n"); diff --git a/os/net/routing/rpl-classic/rpl-private.h b/os/net/routing/rpl-classic/rpl-private.h index de3eeb90182..1127afa3a20 100644 --- a/os/net/routing/rpl-classic/rpl-private.h +++ b/os/net/routing/rpl-classic/rpl-private.h @@ -150,7 +150,9 @@ #define RPL_ROUTE_INFINITE_LIFETIME 0xFFFFFFFF #define RPL_LIFETIME(instance, lifetime) \ - (((lifetime) == RPL_INFINITE_LIFETIME) ? RPL_ROUTE_INFINITE_LIFETIME : (unsigned long)(instance)->lifetime_unit * (lifetime)) + (((lifetime) == RPL_INFINITE_LIFETIME) ? \ + RPL_ROUTE_INFINITE_LIFETIME : \ + (unsigned long)(instance)->lifetime_unit * (lifetime)) #ifndef RPL_CONF_MIN_HOPRANKINC diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 7200e828add..e2f336054cd 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -110,7 +110,8 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx) Updating from here is unsafe; postpone */ LOG_INFO("packet sent to "); LOG_INFO_LLADDR(addr); - LOG_INFO_(", status %u, tx %u, new link metric %u\n", status, numtx, rpl_neighbor_get_link_metric(nbr)); + LOG_INFO_(", status %u, tx %u, new link metric %u\n", + status, numtx, rpl_neighbor_get_link_metric(nbr)); rpl_timers_schedule_state_update(); } } From d4590d4a839b3bd84639a5667a2403071700b5f9 Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Mon, 15 May 2023 22:47:51 +0200 Subject: [PATCH 3/4] Don't LOG_INFO for every consistent RPL DIO --- os/net/routing/rpl-classic/rpl-dag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index dec2699c337..26d9d490097 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -1606,9 +1606,9 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio) /* The DIO comes from a valid DAG, so we can refresh its lifetime. */ dag->lifetime = (1UL << (instance->dio_intmin + instance->dio_intdoubl)) * RPL_DAG_LIFETIME / 1000; - LOG_INFO("Set DAG "); - LOG_INFO_6ADDR(&dag->dag_id); - LOG_INFO_(" lifetime to %ld\n", (long int)dag->lifetime); + LOG_DBG("Set DAG "); + LOG_DBG_6ADDR(&dag->dag_id); + LOG_DBG_(" lifetime to %ld\n", (long int)dag->lifetime); /* * At this point, we know that this DIO pertains to a DAG that we From 8d6e635e8899aec380890ea13fb2eb21a1c77f2c Mon Sep 17 00:00:00 2001 From: Andreas Urke Date: Mon, 15 May 2023 23:00:07 +0200 Subject: [PATCH 4/4] Remove unused legacy PACKETBUF_ATTR_PACKET_TYPE_* defines --- os/net/packetbuf.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/os/net/packetbuf.h b/os/net/packetbuf.h index 5a3aa9cc986..e4886eb3cba 100644 --- a/os/net/packetbuf.h +++ b/os/net/packetbuf.h @@ -203,12 +203,6 @@ struct packetbuf_addr { linkaddr_t addr; }; -#define PACKETBUF_ATTR_PACKET_TYPE_DATA 0 -#define PACKETBUF_ATTR_PACKET_TYPE_ACK 1 -#define PACKETBUF_ATTR_PACKET_TYPE_STREAM 2 -#define PACKETBUF_ATTR_PACKET_TYPE_STREAM_END 3 -#define PACKETBUF_ATTR_PACKET_TYPE_TIMESTAMP 4 - enum { PACKETBUF_ATTR_NONE,