Skip to content

Commit 7e7af30

Browse files
authored
Merge pull request #21256 from benpicco/sys/net/gnrc-fixes
gnrc/ipv6/nib: improve debug output, declutter code
2 parents 7c44b06 + 034f783 commit 7e7af30

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

sys/net/gnrc/netif/gnrc_netif.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,11 +1078,13 @@ static int _create_candidate_set(const gnrc_netif_t *netif,
10781078
* (so don't consider tentative addresses for source address
10791079
* selection) */
10801080
gnrc_netif_ipv6_addr_dad_trans(netif, i)) {
1081+
DEBUG(" -> skip tentative address\n");
10811082
continue;
10821083
}
10831084
/* Check if we only want link local addresses */
10841085
if (ll_only && !ipv6_addr_is_link_local(tmp)) {
1085-
continue;
1086+
DEBUG(" -> skip non link-local address\n");
1087+
continue;
10861088
}
10871089
/* "For all multicast and link-local destination addresses, the set of
10881090
* candidate source addresses MUST only include addresses assigned to
@@ -1743,12 +1745,10 @@ static void _process_events_await_msg(gnrc_netif_t *netif, msg_t *msg)
17431745

17441746
/* First drain the queues before blocking the thread */
17451747
/* Events will be handled before messages */
1746-
DEBUG("gnrc_netif: handling events\n");
17471748
event_t *evp;
17481749
/* We can not use event_loop() or event_wait() because then we would not
17491750
* wake up when a message arrives */
17501751
while ((evp = _gnrc_netif_fetch_event(netif))) {
1751-
DEBUG("gnrc_netif: event %p\n", (void *)evp);
17521752
if (evp->handler) {
17531753
evp->handler(evp);
17541754
}
@@ -1758,7 +1758,6 @@ static void _process_events_await_msg(gnrc_netif_t *netif, msg_t *msg)
17581758
if (msg_waiting > 0) {
17591759
return;
17601760
}
1761-
DEBUG("gnrc_netif: waiting for events\n");
17621761
/* Block the thread until something interesting happens */
17631762
thread_flags_wait_any(THREAD_FLAG_MSG_WAITING | THREAD_FLAG_EVENT);
17641763
}

sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ _nib_offl_entry_t *_nib_abr_iter_pfx(const _nib_abr_entry_t *abr,
845845
_nib_abr_entry_t *_nib_abr_iter(const _nib_abr_entry_t *last);
846846
#else
847847
#define _nib_abr_iter(abr) NULL
848+
#define _nib_abr_add_pfx(abr, pfx) (void)abr
848849
#endif
849850

850851
/**

sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ static gnrc_pktsnip_t *_add_rio(gnrc_netif_t *netif, gnrc_pktsnip_t *ext_opts, b
202202

203203
if (local_pfx || (offl && routed_pfx)) {
204204

205-
DEBUG("nib: adding downstream subnet to RA\n");
205+
DEBUG("nib: adding downstream subnet %s/%u to RA on %u\n",
206+
ipv6_addr_to_str(addr_str, &entry->pfx, sizeof(addr_str)),
207+
entry->pfx_len, netif->pid);
206208
uint32_t valid_ltime = (entry->valid_until == UINT32_MAX) ? UINT32_MAX :
207209
((entry->valid_until - now) / MS_PER_SEC);
208210
gnrc_pktsnip_t *snip = gnrc_ndp_opt_ri_build(&entry->pfx,

sys/net/gnrc/network_layer/ipv6/nib/nib.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,9 @@ static void _handle_mtuo(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
552552
static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
553553
const ndp_opt_rdnss_impl_t *rdnsso);
554554
#endif
555-
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
556555
static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
557556
const ndp_opt_pi_t *pio,
558557
_nib_abr_entry_t *abr);
559-
#else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
560-
static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
561-
const ndp_opt_pi_t *pio);
562-
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
563558
static uint32_t _handle_rio(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
564559
const ndp_opt_ri_t *pio);
565560
/** @} */
@@ -688,8 +683,8 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
688683

689684
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
690685
sixlowpan_nd_opt_abr_t *abro = NULL;
691-
_nib_abr_entry_t *abr = NULL;
692686
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
687+
_nib_abr_entry_t *abr = NULL;
693688
uint32_t next_timeout = UINT32_MAX;
694689

695690
assert(netif != NULL);
@@ -789,9 +784,8 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
789784
}
790785
else {
791786
dr = _nib_drl_get(&ipv6->src, netif->pid);
792-
793-
DEBUG("nib: router lifetime was 0. Removing router and routes via it.");
794787
if (dr != NULL) {
788+
DEBUG("nib: router lifetime was 0. Removing router and routes via it.\n");
795789
_handle_rtr_timeout(dr);
796790
}
797791
dr = NULL;
@@ -844,15 +838,9 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
844838
break;
845839
case NDP_OPT_PI: {
846840
uint32_t min_pfx_timeout;
847-
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
848841
min_pfx_timeout = _handle_pio(netif,
849842
(const icmpv6_hdr_t *)rtr_adv,
850843
(ndp_opt_pi_t *)opt, abr);
851-
#else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
852-
min_pfx_timeout = _handle_pio(netif,
853-
(const icmpv6_hdr_t *)rtr_adv,
854-
(ndp_opt_pi_t *)opt);
855-
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
856844
next_timeout = _min(next_timeout, min_pfx_timeout);
857845

858846
/* notify optional PIO consumer */
@@ -1702,13 +1690,8 @@ static inline bool _multihop_p6c(gnrc_netif_t *netif, _nib_abr_entry_t *abr)
17021690
#define _multihop_p6c(netif, abr) (false)
17031691
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
17041692

1705-
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
17061693
static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
17071694
const ndp_opt_pi_t *pio, _nib_abr_entry_t *abr)
1708-
#else /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
1709-
static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
1710-
const ndp_opt_pi_t *pio)
1711-
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
17121695
{
17131696
uint32_t valid_ltime;
17141697
uint32_t pref_ltime;
@@ -1764,11 +1747,9 @@ static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6,
17641747
}
17651748
if ((pfx = _nib_pl_add(netif->pid, &pio->prefix, pio->prefix_len,
17661749
valid_ltime, pref_ltime))) {
1767-
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
17681750
if (abr != NULL) {
17691751
_nib_abr_add_pfx(abr, pfx);
17701752
}
1771-
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C */
17721753
if (pio->flags & NDP_OPT_PI_FLAGS_L) {
17731754
pfx->flags |= _PFX_ON_LINK;
17741755
}

0 commit comments

Comments
 (0)