From b5334b1517440c15ae0dcc85ece4c03adfd17e49 Mon Sep 17 00:00:00 2001 From: Jen Date: Tue, 8 Oct 2024 23:34:17 +1100 Subject: [PATCH] RDNSS/RDNSSL lifetimes shall be 3 times MaxRtrAdvInterval (#48) * RDNSS/RDNSSL lifetimes shall me 3 times MaxRtrAdvInterval See RFC8106 (which obsoletes RFC6106) --- internal/config/config_test.go | 6 +++--- internal/config/plugin.go | 8 ++++++-- internal/config/plugin_test.go | 14 +++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index d4ff693..4982b58 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -238,11 +238,11 @@ func TestParse(t *testing.T) { Lifetime: 24 * time.Hour, }, &plugin.RDNSS{ - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, Servers: []netip.Addr{netip.MustParseAddr("2001:db8::1")}, }, &plugin.DNSSL{ - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, DomainNames: []string{"lan.example.com"}, }, plugin.NewMTU(1500), @@ -265,7 +265,7 @@ func TestParse(t *testing.T) { Plugins: []plugin.Plugin{ &plugin.RDNSS{ Auto: true, - Lifetime: 8 * time.Second, + Lifetime: 12 * time.Second, }, &plugin.LLA{}, }, diff --git a/internal/config/plugin.go b/internal/config/plugin.go index c6673a6..bbbcdb2 100644 --- a/internal/config/plugin.go +++ b/internal/config/plugin.go @@ -153,7 +153,9 @@ func parsePlugins(ifi rawInterface, maxInterval time.Duration, epoch time.Time) // parseDNSSL parses a DNSSL plugin. func parseDNSSL(d rawDNSSL, maxInterval time.Duration) (*plugin.DNSSL, error) { // By default, compute lifetime as recommended by radvd. - lifetime, err := parseDuration(d.Lifetime, 2*maxInterval) + // As per RFC8106, the default lifetime SHOULD be at least + // 3 * MaxRtrAdvInterval. + lifetime, err := parseDuration(d.Lifetime, 3*maxInterval) if err != nil { return nil, fmt.Errorf("invalid lifetime: %v", err) } @@ -319,7 +321,9 @@ func parseRoute(r rawRoute, epoch time.Time) (*plugin.Route, error) { // parseRDNSS parses a RDNSS plugin. func parseRDNSS(d rawRDNSS, maxInterval time.Duration) (*plugin.RDNSS, error) { // If auto, compute lifetime as recommended by radvd. - lifetime, err := parseDuration(d.Lifetime, 2*maxInterval) + // As per RFC8106, the default lifetime SHOULD be at least + // 3 * MaxRtrAdvInterval. + lifetime, err := parseDuration(d.Lifetime, 3*maxInterval) if err != nil { return nil, fmt.Errorf("invalid lifetime: %v", err) } diff --git a/internal/config/plugin_test.go b/internal/config/plugin_test.go index 3ccd048..539069c 100644 --- a/internal/config/plugin_test.go +++ b/internal/config/plugin_test.go @@ -83,7 +83,7 @@ func Test_parseDNSSL(t *testing.T) { domain_names = ["foo.example.com"] `, d: &plugin.DNSSL{ - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, DomainNames: []string{"foo.example.com"}, }, ok: true, @@ -97,7 +97,7 @@ func Test_parseDNSSL(t *testing.T) { lifetime = "auto" `, d: &plugin.DNSSL{ - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, DomainNames: []string{"foo.example.com"}, }, ok: true, @@ -669,7 +669,7 @@ func Test_parseRDNSS(t *testing.T) { servers = ["2001:db8::1"] `, r: &plugin.RDNSS{ - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, Servers: []netip.Addr{netip.MustParseAddr("2001:db8::1")}, }, ok: true, @@ -683,7 +683,7 @@ func Test_parseRDNSS(t *testing.T) { lifetime = "auto" `, r: &plugin.RDNSS{ - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, Servers: []netip.Addr{netip.MustParseAddr("2001:db8::1")}, }, ok: true, @@ -696,7 +696,7 @@ func Test_parseRDNSS(t *testing.T) { `, r: &plugin.RDNSS{ Auto: true, - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, }, ok: true, }, @@ -709,7 +709,7 @@ func Test_parseRDNSS(t *testing.T) { `, r: &plugin.RDNSS{ Auto: true, - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, }, ok: true, }, @@ -722,7 +722,7 @@ func Test_parseRDNSS(t *testing.T) { `, r: &plugin.RDNSS{ Auto: true, - Lifetime: 20 * time.Minute, + Lifetime: 30 * time.Minute, Servers: []netip.Addr{netip.MustParseAddr("2001:db8::1")}, }, ok: true,