Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc/ipv6/nib: make ABR run-time configurable #21081

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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: 15 additions & 1 deletion sys/include/net/gnrc/ipv6/nib/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,19 @@ extern "C" {
#endif

/**
* @brief activate router advertising at interface start-up
* @brief activate router advertising at interface start-up
*/
#ifndef CONFIG_GNRC_IPV6_NIB_ADV_ROUTER
#define CONFIG_GNRC_IPV6_NIB_ADV_ROUTER 0
#endif

/**
* @brief activate authoritative border router functionality at interface start-up
*/
#ifndef CONFIG_GNRC_IPV6_NIB_ABR
#define CONFIG_GNRC_IPV6_NIB_ABR CONFIG_GNRC_IPV6_NIB_6LBR
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can add a line to the docs of the border router (or border router example?) about how to possibility to make a 6lbr non-authorative.

#endif

/**
* @brief Include a Route Information Option for subnets
* on other interfaces in normal Router Advertisements
Expand Down Expand Up @@ -226,6 +233,13 @@ extern "C" {
#endif
#endif

/**
* @brief Start sending RAs when a RA has been received
*/
#ifndef CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C_AUTO_ADV
#define CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C_AUTO_ADV CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C
#endif

/**
* @brief Multihop duplicate address detection
*
Expand Down
7 changes: 7 additions & 0 deletions sys/include/net/netopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,13 @@
*/
NETOPT_6LO_IPHC,

/**
* @brief (@ref netopt_enable_t) authoritative border router
*
* @see [RFC 6775](https://datatracker.ietf.org/doc/html/rfc6775#section-4.3)
*/
NETOPT_6LO_ABR,

/**
* @brief (uint8_t) retry amount from missing ACKs of the last transmission
*
Expand Down Expand Up @@ -1030,7 +1037,7 @@
/**
* @brief Basic callback type on network disconnection @ref NETOPT_CONNECT
*/
typedef void (*netopt_on_disconnect_result_t) (void *netif, const struct netopt_disconnect_result *res);

Check warning on line 1040 in sys/include/net/netopt.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

/**
* @brief Basic network connect request
Expand Down
33 changes: 33 additions & 0 deletions sys/net/gnrc/netif/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@
res = sizeof(netopt_enable_t);
break;
#endif /* MODULE_GNRC_SIXLOWPAN_IPHC */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
case NETOPT_6LO_ABR:
assert(opt->data_len == sizeof(netopt_enable_t));
*((netopt_enable_t *)opt->data) = (netif->flags & GNRC_NETIF_FLAGS_6LO_ABR)
? NETOPT_ENABLE
: NETOPT_DISABLE;
res = sizeof(netopt_enable_t);
break;
#endif
default:
break;
}
Expand Down Expand Up @@ -409,6 +418,30 @@
res = sizeof(netopt_enable_t);
break;
#endif /* MODULE_GNRC_SIXLOWPAN_IPHC */
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
case NETOPT_6LO_ABR:
assert(opt->data_len == sizeof(netopt_enable_t));

extern void _start_search_rtr(gnrc_netif_t *netif);
extern void _stop_search_rtr(gnrc_netif_t *netif);
Comment on lines +425 to +426
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to make this a proper API? It could also be in one of the internal NIB headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could also be in one of the internal NIB headers.

Unfortunately the ones in gnrc/network_layer/ipv6/nib are only accessible from the nib module, not the netif one.


if (*(((netopt_enable_t *)opt->data)) == NETOPT_ENABLE) {
if (!(netif->flags & GNRC_NETIF_FLAGS_6LO_ABR)) {
/* we were no ABR before */
_stop_search_rtr(netif);
}
netif->flags |= GNRC_NETIF_FLAGS_6LO_ABR;
}
else {
if (netif->flags & GNRC_NETIF_FLAGS_6LO_ABR) {
/* we were a ABR before */
_start_search_rtr(netif);
}
netif->flags &= ~GNRC_NETIF_FLAGS_6LO_ABR;
}
res = sizeof(netopt_enable_t);
break;
#endif
case NETOPT_RAWMODE:
if (*(((netopt_enable_t *)opt->data)) == NETOPT_ENABLE) {
netif->flags |= GNRC_NETIF_FLAGS_RAWMODE;
Expand Down Expand Up @@ -2156,4 +2189,4 @@
}
}
}
/** @} */

Check warning on line 2192 in sys/net/gnrc/netif/gnrc_netif.c

View workflow job for this annotation

GitHub Actions / static-tests

source file is too long
2 changes: 1 addition & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ static gnrc_pktsnip_t *_build_ext_opts(gnrc_netif_t *netif,
}
#endif /* CONFIG_GNRC_IPV6_NIB_DNS */
if (gnrc_netif_is_6lr(netif)) {
assert(abr != NULL);
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)
assert(abr != NULL);
uint16_t ltime_min;
gnrc_pktsnip_t *abro;

Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/_nib-router.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static inline void _init_iface_router(gnrc_netif_t *netif)
netif->flags |= GNRC_NETIF_FLAGS_IPV6_RTR_ADV;
}

if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)) {
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ABR)) {
netif->flags |= GNRC_NETIF_FLAGS_6LO_ABR;
}
}
Expand Down
31 changes: 22 additions & 9 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@
/* 6LBR interface does not send RS.
A non-advertising router sends RS or a 6LN that is advertising or not
has to refetch router information */
return !gnrc_netif_is_6lbr(netif) &&
(!gnrc_netif_is_rtr_adv(netif) || gnrc_netif_is_6ln(netif));
if (gnrc_netif_is_6lbr(netif)) {
return false;
}
return !gnrc_netif_is_rtr_adv(netif) || gnrc_netif_is_6ln(netif);
OlegHahm marked this conversation as resolved.
Show resolved Hide resolved
}

void gnrc_ipv6_nib_init(void)
Expand Down Expand Up @@ -167,6 +169,19 @@
#endif
}

void _start_search_rtr(gnrc_netif_t *netif)
{
uint32_t next_rs_time = random_uint32_range(0, NDP_MAX_RS_MS_DELAY);

_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR, &netif->ipv6.search_rtr,
next_rs_time);
}

void _stop_search_rtr(gnrc_netif_t *netif)
{
_evtimer_del(&netif->ipv6.search_rtr);
}

void gnrc_ipv6_nib_iface_up(gnrc_netif_t *netif)
{
assert(netif != NULL);
Expand All @@ -185,11 +200,9 @@
}
_add_static_lladdr(netif);
_auto_configure_addr(netif, &ipv6_addr_link_local_prefix, 64U);
if (_should_search_rtr(netif)) {
uint32_t next_rs_time = random_uint32_range(0, NDP_MAX_RS_MS_DELAY);

_evtimer_add(netif, GNRC_IPV6_NIB_SEARCH_RTR, &netif->ipv6.search_rtr,
next_rs_time);
if (_should_search_rtr(netif)) {
_start_search_rtr(netif);
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
else {
Expand All @@ -208,7 +221,7 @@

_deinit_iface_arsm(netif);
if (_should_search_rtr(netif)) {
_evtimer_del(&netif->ipv6.search_rtr);
_stop_search_rtr(netif);
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)
else {
Expand Down Expand Up @@ -562,7 +575,7 @@
icmpv6_len -= (opt->len << 3), \
opt = (ndp_opt_t *)(((uint8_t *)opt) + (opt->len << 3)))

#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ROUTER)

Check warning on line 578 in sys/net/gnrc/network_layer/ipv6/nib/nib.c

View workflow job for this annotation

GitHub Actions / static-tests

full block {} expected in the control structure
static void _handle_rtr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_rtr_sol_t *rtr_sol, size_t icmpv6_len)
{
Expand Down Expand Up @@ -781,7 +794,7 @@
else {
dr = _nib_drl_get(&ipv6->src, netif->pid);

DEBUG("nib: router lifetime was 0. Removing router and routes via it.");
DEBUG("nib: router lifetime was 0. Removing router and routes via it.\n");
if (dr != NULL) {
_handle_rtr_timeout(dr);
}
Expand Down Expand Up @@ -907,7 +920,7 @@
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
if (gnrc_netif_is_6ln(netif) && !gnrc_netif_is_6lbr(netif)) {
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C)) {
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C_AUTO_ADV)) {
_set_rtr_adv(netif);
}
/* but re-fetch information from router in time */
Expand Down
4 changes: 4 additions & 0 deletions sys/shell/cmds/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static const struct {
netopt_t opt;
} flag_cmds[] = {
{ "6lo", NETOPT_6LO },
{ "abr", NETOPT_6LO_ABR },
{ "ack_req", NETOPT_ACK_REQ },
{ "gts", NETOPT_GTS_TX },
{ "pan_coord", NETOPT_PAN_COORD },
Expand Down Expand Up @@ -887,6 +888,9 @@ static void _netif_list(netif_t *iface)
#ifdef MODULE_GNRC_SIXLOWPAN
line_thresh = _netif_list_flag(iface, NETOPT_6LO, "6LO ", line_thresh);
#endif
#if CONFIG_GNRC_IPV6_NIB_6LBR
line_thresh = _netif_list_flag(iface, NETOPT_6LO_ABR, "ABR ", line_thresh);
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
line_thresh += _LINE_THRESHOLD + 1; /* enforce linebreak after this option */
line_thresh = _netif_list_flag(iface, NETOPT_6LO_IPHC, "IPHC ",
Expand Down
Loading