Skip to content

Commit

Permalink
gnrc/ipv6_auto_subnets: allow to configure minimal prefix length
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed May 23, 2023
1 parent 9358a44 commit 2a76911
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
*/

#include "compiler_hints.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/netif/hdr.h"
Expand Down Expand Up @@ -141,6 +142,14 @@
#define CONFIG_GNRC_IPV6_AUTO_SUBNETS_PREFIX_FIX_LEN (0)
#endif

/**
* @brief Minimal length of a new prefix.
* e.g. Linux will only accept /64 prefixes for SLAAC
*/
#ifndef CONFIG_GNRC_IPV6_AUTO_SUBNETS_PREFIX_MIN_LEN
#define CONFIG_GNRC_IPV6_AUTO_SUBNETS_PREFIX_MIN_LEN (0)
#endif

/**
* @brief Number of subnets that can be configured.
*
Expand Down Expand Up @@ -369,6 +378,10 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t
return;
}

if (new_prefix_len < may_be_zero(CONFIG_GNRC_IPV6_AUTO_SUBNETS_PREFIX_MIN_LEN)) {
new_prefix_len = CONFIG_GNRC_IPV6_AUTO_SUBNETS_PREFIX_MIN_LEN;
}

while ((downstream = gnrc_netif_iter(downstream))) {
gnrc_pktsnip_t *tmp;
ipv6_addr_t new_prefix;
Expand Down

0 comments on commit 2a76911

Please sign in to comment.