From 55a0eda72698bf6bf97f02f136de4e5d7e15420e Mon Sep 17 00:00:00 2001 From: BFNOC <15773134+BFNOC@users.noreply.github.com> Date: Mon, 9 Nov 2026 22:03:03 +0800 Subject: [PATCH] fix(imscore): keep an old-SA port-s timeout a failure when the retirement sweep marks it --- .../internal/vowifi/imscore/port_s_session.go | 5 ++-- .../imscore/refresh_security_switch_test.go | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/third_party/vowifi-go/internal/vowifi/imscore/port_s_session.go b/third_party/vowifi-go/internal/vowifi/imscore/port_s_session.go index f27587ea..4f87c12a 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/port_s_session.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/port_s_session.go @@ -131,10 +131,11 @@ func (s *Service) recordPortSClosed(conn net.Conn, err error, now time.Time) boo // Vodafone DE reset its flow from the old port_pc about 230 s after the // switch with nothing over the new SAs yet (hideck#90). A reset or close // it sent is that SA replacement, not a lost port-s; a timeout is only our - // side noticing silence and still counts as a failure. + // side noticing silence and still counts as a failure, even when our + // retirement swept the flow after the timeout had already ended it. saRetiredVia := "" switch { - case connection.saRetired: + case connection.saRetired && kind != portSCloseTimeout: kind, saRetiredVia = portSCloseSARetired, "ue_retired" case (kind == portSClosePeerReset || kind == portSCloseEOF) && s.onReplacedSAs(conn): kind, saRetiredVia = portSCloseSARetired, "old_port_pc" diff --git a/third_party/vowifi-go/internal/vowifi/imscore/refresh_security_switch_test.go b/third_party/vowifi-go/internal/vowifi/imscore/refresh_security_switch_test.go index 39fbf0d5..0eefd36c 100644 --- a/third_party/vowifi-go/internal/vowifi/imscore/refresh_security_switch_test.go +++ b/third_party/vowifi-go/internal/vowifi/imscore/refresh_security_switch_test.go @@ -617,6 +617,29 @@ func TestPCSCFResetOfOldSAPortSAwaitsTheNewSAs(t *testing.T) { } } +// A timeout that ended an old-SA flow before our retirement swept it is still +// a failure, not the SAs going. +func TestOldSAPortSTimeoutBeforeRetirementSweepStaysAFailure(t *testing.T) { + svc, _, _, _, _ := switchRefreshService(t, 200, switchedSecurityServer) + if _, _, err := svc.runRegisterAttempt(context.Background()); err != nil { + t.Fatalf("refresh: %v", err) + } + pipe, pcscf := net.Pipe() + defer pcscf.Close() + portS := addressedConn{Conn: pipe, + local: &net.TCPAddr{IP: net.IPv4(10, 0, 0, 2), Port: 41001}, + remote: &net.TCPAddr{IP: net.IPv4(10, 0, 0, 1), Port: 16381}} + if !svc.trackProtectedPortSConnection(portS, time.Now()) { + t.Fatal("port-s flow not tracked") + } + // The reader has its ETIMEDOUT but has not recorded it yet. + svc.retireReplacedSecurity(svc.saRetirement.Load(), "test") + svc.recordPortSClosed(portS, syscall.ETIMEDOUT, time.Now()) + if got := svc.capturePortSSession().lastCloseKind; got != portSCloseTimeout { + t.Fatalf("close kind = %q, want %q", got, portSCloseTimeout) + } +} + // A failure of the port-s flow over the new SAs is kept when the old flow // goes with the old SAs afterwards. func TestOldSAPortSResetKeepsNewFlowFailure(t *testing.T) {