From c5c8482b4db821e026178700947edbea615e506a Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 11 Dec 2024 19:23:53 +0100 Subject: [PATCH] gnrc/ipv6_auto_subnets: unicast RA if upstream is 6lo --- sys/net/gnrc/network_layer/ipv6/nib/nib.c | 5 +++-- .../ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib.c b/sys/net/gnrc/network_layer/ipv6/nib/nib.c index 3cfb7d2aad..43f25c729d 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c @@ -849,8 +849,9 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, /* notify optional PIO consumer */ if (IS_USED(MODULE_GNRC_IPV6_NIB_RTR_ADV_PIO_CB)) { extern void gnrc_ipv6_nib_rtr_adv_pio_cb(gnrc_netif_t *netif, - const ndp_opt_pi_t *pio); - gnrc_ipv6_nib_rtr_adv_pio_cb(netif, (ndp_opt_pi_t *)opt); + const ndp_opt_pi_t *pio, + const ipv6_addr_t *src); + gnrc_ipv6_nib_rtr_adv_pio_cb(netif, (ndp_opt_pi_t *)opt, &ipv6->src); } break; } diff --git a/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c b/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c index a4760530cc..282f79ca78 100644 --- a/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c +++ b/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c @@ -404,7 +404,7 @@ static bool _remove_old_prefix(gnrc_netif_t *netif, } static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t *upstream, - const ndp_opt_pi_t *pio) + const ndp_opt_pi_t *pio, const ipv6_addr_t *src) { gnrc_netif_t *downstream = NULL; gnrc_pktsnip_t *ext_opts = NULL; @@ -490,13 +490,14 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t /* immediately send an RA with RIO */ if (ext_opts) { - gnrc_ndp_rtr_adv_send(upstream, NULL, NULL, true, ext_opts); + gnrc_ndp_rtr_adv_send(upstream, NULL, src, true, ext_opts); } else { DEBUG("auto_subnets: Options empty, not sending RA\n"); } } -void gnrc_ipv6_nib_rtr_adv_pio_cb(gnrc_netif_t *upstream, const ndp_opt_pi_t *pio) +void gnrc_ipv6_nib_rtr_adv_pio_cb(gnrc_netif_t *upstream, const ndp_opt_pi_t *pio, + const ipv6_addr_t *src) { /* create a subnet for each downstream interface */ unsigned subnets = gnrc_netif_numof() - 1; @@ -515,8 +516,12 @@ void gnrc_ipv6_nib_rtr_adv_pio_cb(gnrc_netif_t *upstream, const ndp_opt_pi_t *pi } #if IS_USED(MODULE_GNRC_IPV6_AUTO_SUBNETS_SIMPLE) + /* 'don't broadcast RA if we are a 6lo node - unicast allows l2 retransmissions */ + if (!gnrc_netif_is_6ln(upstream)) { + src = NULL; + } /* if we are the only router on this bus, we can directly choose a prefix */ - _configure_subnets(subnets, 0, upstream, pio); + _configure_subnets(subnets, 0, upstream, pio, src); #else /* store PIO information for later use */ @@ -689,7 +694,7 @@ static void _process_pio_cache(uint8_t subnets, uint8_t idx_start, gnrc_netif_t } /* use PIO for prefix configuration */ - _configure_subnets(subnets, idx_start, upstream, &_pio_cache[i]); + _configure_subnets(subnets, idx_start, upstream, &_pio_cache[i], NULL); /* invalidate entry */ _pio_cache[i].len = 0;