From 7358f691b99d894cba972319f1152c0b69668f82 Mon Sep 17 00:00:00 2001 From: Jen Date: Tue, 8 Oct 2024 23:34:35 +1100 Subject: [PATCH] Pref64 lifetime fix (#46) * PREF64 default lifetime should be 3xMaxRtrAdvInterval, not just MaXRtrAdvInterval See Section 4.1 of RFC8781 --- internal/plugin/plugin.go | 2 +- internal/plugin/plugin_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index b6e58df..13c8d05 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -95,7 +95,7 @@ func NewPREF64(prefix netip.Prefix, maxInterval time.Duration) *PREF64 { // See https://datatracker.ietf.org/doc/html/rfc8781#section-4.1-2 lifetime := maxPref64Lifetime if int(maxInterval.Seconds())*3 < int(lifetime.Seconds()) { - lifetimeSeconds := int(maxInterval.Seconds()) + lifetimeSeconds := int(maxInterval.Seconds()) * 3 if r := int(lifetimeSeconds) % 8; r > 0 { lifetimeSeconds += 8 - r } diff --git a/internal/plugin/plugin_test.go b/internal/plugin/plugin_test.go index 6b6c326..686af79 100644 --- a/internal/plugin/plugin_test.go +++ b/internal/plugin/plugin_test.go @@ -856,7 +856,7 @@ func TestNewPREF64(t *testing.T) { want: &PREF64{ Inner: &ndp.PREF64{ Prefix: simplePrefix, - Lifetime: time.Minute * 10, + Lifetime: time.Minute * 30, }, }, }, @@ -889,7 +889,7 @@ func TestNewPREF64(t *testing.T) { want: &PREF64{ Inner: &ndp.PREF64{ Prefix: simplePrefix, - Lifetime: time.Second * 16, + Lifetime: time.Second * 32, }, }, },