Skip to content

Commit

Permalink
RDNSS/RDNSSL lifetimes shall be 3 times MaxRtrAdvInterval (#48)
Browse files Browse the repository at this point in the history
* RDNSS/RDNSSL lifetimes shall me 3 times MaxRtrAdvInterval

See RFC8106 (which obsoletes RFC6106)
  • Loading branch information
furry13 authored Oct 8, 2024
1 parent 9da478e commit b5334b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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{},
},
Expand Down
8 changes: 6 additions & 2 deletions internal/config/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
14 changes: 7 additions & 7 deletions internal/config/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
Expand Down

0 comments on commit b5334b1

Please sign in to comment.