From b228748a222ce7ba9e121256e0245bb5a55944b3 Mon Sep 17 00:00:00 2001 From: Fran Bull Date: Mon, 29 Jun 2026 11:13:05 -0700 Subject: [PATCH] feature/conn25: return expired addrs from index lookups We can use them for traffic until they are actually removed from the table. Updates tailscale/corp#43180 Co-authored-by: Fran Bull Co-authored-by: Michael Ben-Ami Signed-off-by: Fran Bull Signed-off-by: Michael Ben-Ami --- feature/conn25/addrAssignments.go | 6 +++--- feature/conn25/addrAssignments_test.go | 11 +---------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/feature/conn25/addrAssignments.go b/feature/conn25/addrAssignments.go index a6c637128..7c700adb4 100644 --- a/feature/conn25/addrAssignments.go +++ b/feature/conn25/addrAssignments.go @@ -79,7 +79,7 @@ func (a *addrAssignments) insertWithExpiry(as *addrs, d time.Duration) error { func (a *addrAssignments) lookupByDomainDst(domain dnsname.FQDN, dst netip.Addr) (*addrs, bool) { v, ok := a.byDomainDst[domainDst{domain: domain, dst: dst}] - if !ok || v.expiresAt.Before(a.clock.Now()) { + if !ok { return &addrs{}, false } return v, true @@ -87,7 +87,7 @@ func (a *addrAssignments) lookupByDomainDst(domain dnsname.FQDN, dst netip.Addr) func (a *addrAssignments) lookupByMagicIP(mip netip.Addr) (*addrs, bool) { v, ok := a.byMagicIP[mip] - if !ok || v.expiresAt.Before(a.clock.Now()) { + if !ok { return &addrs{}, false } return v, true @@ -95,7 +95,7 @@ func (a *addrAssignments) lookupByMagicIP(mip netip.Addr) (*addrs, bool) { func (a *addrAssignments) lookupByTransitIP(tip netip.Addr) (*addrs, bool) { v, ok := a.byTransitIP[tip] - if !ok || v.expiresAt.Before(a.clock.Now()) { + if !ok { return &addrs{}, false } return v, true diff --git a/feature/conn25/addrAssignments_test.go b/feature/conn25/addrAssignments_test.go index 4811564b1..ce26b80a1 100644 --- a/feature/conn25/addrAssignments_test.go +++ b/feature/conn25/addrAssignments_test.go @@ -41,17 +41,8 @@ func TestAssignmentsExpire(t *testing.T) { if err == nil { t.Fatal("expected an error but got nil") } - // After a time greater than the default expiry passes, the assignment should - // not be returned. - clock.Advance(defaultExpiry * 2) - foundAsAfter, okAfter := assignments.lookupByMagicIP(as.magic) - if okAfter { - t.Fatal("expected not to find (expired)") - } - if foundAsAfter.isValid() { - t.Fatal("expected zero val") - } // We should only be able to write old addresses again if they've been removed from the maps (eg with popExpired). + clock.Advance(defaultExpiry * 2) err = assignments.insert(as) if err == nil { t.Fatal("expected an error but got nil")