Skip to content

Commit

Permalink
Pref64 lifetime fix (#46)
Browse files Browse the repository at this point in the history
* PREF64 default lifetime should be 3xMaxRtrAdvInterval, not just MaXRtrAdvInterval

See Section 4.1 of RFC8781
  • Loading branch information
furry13 authored Oct 8, 2024
1 parent b5334b1 commit 7358f69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func TestNewPREF64(t *testing.T) {
want: &PREF64{
Inner: &ndp.PREF64{
Prefix: simplePrefix,
Lifetime: time.Minute * 10,
Lifetime: time.Minute * 30,
},
},
},
Expand Down Expand Up @@ -889,7 +889,7 @@ func TestNewPREF64(t *testing.T) {
want: &PREF64{
Inner: &ndp.PREF64{
Prefix: simplePrefix,
Lifetime: time.Second * 16,
Lifetime: time.Second * 32,
},
},
},
Expand Down

0 comments on commit 7358f69

Please sign in to comment.