[PATCH 0/2] A few small improvements to RAdv
Hello, I'm sending a few small patches that really mostly scratch my itch. First one is just a small clarification in docs of behaviour I found surprising, second makes the built-in defaults for prefix option parameters (L and A bits, lifetimes) configurable in radv protocol instance. This is my first patch, so I'm open for comments (but if this looks alright, feel free to use as is :-) ). I didn't yet figure out what would be the best approach to test this in the test suite (BIRD is not a great RA client), so I would appreciate some guidance/hints on that. Also, I'm not entirely sure whether this feels “BIRDy” enough (I have some thoughts on that, but for now I'll skip the extensive deliberation here). I've been running this code for about a week now on my router (my networks don't use SLAAC, which was my itch), it feels stable, but I have no hard data on that. Apart from the patches heere, I have uploaded the code to <https://gitea.ledoian.cz/LEdoian/bird> (the web interface to the commits won't work, feel free to clone that). LEdoian (2): Docs: Add note about when RAdv keeps prefix RAdv: Make default prefix options configurable doc/bird.sgml | 15 ++++++++++++++- proto/radv/config.Y | 20 +++++++++++++++----- proto/radv/radv.c | 14 ++++++-------- proto/radv/radv.h | 1 + 4 files changed, 36 insertions(+), 14 deletions(-) -- 2.55.0
This was technically implied at the `prefix linger time` option, but felt quite non-obvious. --- doc/bird.sgml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index 56ad16ebb..ee5d3039d 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -6283,7 +6283,8 @@ custom option type 38 value hex:0e:10:20:01:0d:b8:00:0a:00:0b:00:00:00:00; advertised. This is useful for making exceptions from a default policy of advertising all prefixes. Note that for withdrawing an already advertised prefix it is more useful to advertise it with zero valid - lifetime. Default: no + lifetime (when reconfiguring, this happens automatically until + <ref id="radv-prefix-linger-time" name="prefix linger time"> times out). Default: no <tag><label id="radv-prefix-onlink">onlink <m/switch/</tag> This option specifies whether hosts may use the advertised prefix for -- 2.55.0
Before this, it was necessary to include all the differences from the hardcoded defaults for each prefix, as there was no inheritance. That could be an issue for deployments that don't use the BIRD's defaults (e.g. not using SLAAC or using different lifetimes). The new option `default prefix` allows overriding BIRD's default in the instance's config. This also made it possible to only have BIRD's defaults in a single place – the copy in `radv.c` is no longer useful. --- doc/bird.sgml | 12 ++++++++++++ proto/radv/config.Y | 20 +++++++++++++++----- proto/radv/radv.c | 14 ++++++-------- proto/radv/radv.h | 1 + 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/doc/bird.sgml b/doc/bird.sgml index ee5d3039d..392f95b97 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -6098,6 +6098,11 @@ definitions, prefix definitions and DNS definitions: prefix definition is matching if the network prefix is a subnet of the prefix in prefix definition. + <tag><label id="radv-default-prefix">default prefix { <m/options/ }</tag> + This allows to alter the default prefix options for this instance of RAdv. + The changed values apply for subsequent <cf/prefix/ blocks and can be + overwritten inbetween blocks. + <tag><label id="radv-rdnss">rdnss { <m/options/ }</tag> RDNSS definitions allow to specify a list of advertised recursive DNS servers together with their options. As options are seldom necessary, @@ -6387,6 +6392,11 @@ protocol radv { propagate routes yes; # Propagate the routes from the radv_routes table ipv6 { table radv_routes; export all; }; + default prefix { + preferred lifetime 3600; # use shorter lifetimes for all networks + valid lifetime 14400; + }; + interface "eth2" { max ra interval 5; # Fast failover with more routers managed yes; # Using DHCPv6 on eth2 @@ -6403,6 +6413,8 @@ protocol radv { prefix 2001:0DB8:2000::/48 { autonomous off; # Do not autoconfigure + preferred lifetime 14400; # use conventional lifetimes + valid lifetime 86400; }; rdnss 2001:0DB8:1234::10; # Short form of RDNSS diff --git a/proto/radv/config.Y b/proto/radv/config.Y index 463b79532..731a0ef38 100644 --- a/proto/radv/config.Y +++ b/proto/radv/config.Y @@ -63,6 +63,12 @@ radv_proto_start: proto_start RADV init_list(&RADV_CFG->rdnss_list); init_list(&RADV_CFG->dnssl_list); init_list(&RADV_CFG->custom_list); + + RADV_CFG->default_prefix_config = cfg_allocz(sizeof(struct radv_prefix_config)); + RADV_CFG->default_prefix_config->onlink = 1; + RADV_CFG->default_prefix_config->autonomous = 1; + RADV_CFG->default_prefix_config->valid_lifetime = DEFAULT_VALID_LIFETIME; + RADV_CFG->default_prefix_config->preferred_lifetime = DEFAULT_PREFERRED_LIFETIME; }; radv_proto_item: @@ -70,6 +76,7 @@ radv_proto_item: | proto_channel | nbrs_channel | INTERFACE radv_iface + | DEFAULT PREFIX radv_default_prefix | PREFIX radv_prefix { add_tail(&RADV_CFG->pref_list, NODE this_radv_prefix); } | RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_CFG->rdnss_list, &radv_dns_list); } | DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_CFG->dnssl_list, &radv_dns_list); } @@ -206,12 +213,8 @@ radv_iface: radv_prefix_start: net_ip6 { this_radv_prefix = cfg_allocz(sizeof(struct radv_prefix_config)); + memcpy(RADV_PREFIX, RADV_CFG->default_prefix_config, sizeof(struct radv_prefix_config)); RADV_PREFIX->prefix = *(net_addr_ip6 *) &($1); - - RADV_PREFIX->onlink = 1; - RADV_PREFIX->autonomous = 1; - RADV_PREFIX->valid_lifetime = DEFAULT_VALID_LIFETIME; - RADV_PREFIX->preferred_lifetime = DEFAULT_PREFERRED_LIFETIME; }; radv_prefix_item: @@ -251,6 +254,13 @@ radv_prefix_opt_list: radv_prefix: radv_prefix_start radv_prefix_opt_list radv_prefix_finish; +radv_default_prefix_start: +{ + this_radv_prefix = RADV_CFG->default_prefix_config; +}; + +radv_default_prefix: + radv_default_prefix_start radv_prefix_opt_list radv_prefix_finish; radv_rdnss_node: ipa diff --git a/proto/radv/radv.c b/proto/radv/radv.c index 7c2e89535..da40765af 100644 --- a/proto/radv/radv.c +++ b/proto/radv/radv.c @@ -88,13 +88,6 @@ radv_nbr_timer(timer *tm) radv_prune_neighbors(p); } -static struct radv_prefix_config default_prefix = { - .onlink = 1, - .autonomous = 1, - .valid_lifetime = DEFAULT_VALID_LIFETIME, - .preferred_lifetime = DEFAULT_PREFERRED_LIFETIME -}; - static struct radv_prefix_config dead_prefix = { }; @@ -114,7 +107,12 @@ radv_prefix_match(struct radv_iface *ifa, net_addr_ip6 *px) if (net_in_net_ip6(px, &pc->prefix)) return pc; - return &default_prefix; + struct radv_prefix_config *ret = cf->default_prefix_config; + if (!ret) { + log(L_BUG "RAdv: default config for prefixes was not allocated"); + return &dead_prefix; + } + return ret; } /* diff --git a/proto/radv/radv.h b/proto/radv/radv.h index d3f6eceef..868e2566f 100644 --- a/proto/radv/radv.h +++ b/proto/radv/radv.h @@ -56,6 +56,7 @@ struct radv_config net_addr trigger; /* Prefix of a trigger route, if defined */ u8 propagate_routes; /* Do we propagate more specific routes (RFC 4191)? */ u32 max_linger_time; /* Maximum of interface route_linger_time */ + struct radv_prefix_config *default_prefix_config; /* base config for prefixes */ }; struct radv_iface_config -- 2.55.0
participants (1)
-
LEdoian