mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 00:01:20 +00:00
fix(imscore): keep a newer port-s failure when the old SAs' flow closes
- Skip the last-live-connection fallback for sa_retired closes - Test that retiring the old flow keeps a newer flow's reset
This commit is contained in:
1 parent
f47296d0ad
commit
4f02691c08
2 files changed
+31
-2
No files matched your search
@@ -127,11 +127,13 @@ func (s *Service) recordPortSClosed(conn net.Conn, err error, now time.Time) boo
|
||||
kind = portSCloseSARetired
|
||||
}
|
||||
// Retired cleanup must not replace the latest failure. An older live
|
||||
// connection still matters if it is the final downlink on this registrar.
|
||||
// connection still matters if it is the final downlink on this registrar,
|
||||
// unless it went with the old SAs after a newer flow had opened.
|
||||
relevant := tracked && strings.EqualFold(registrar, currentRegistrar)
|
||||
current := relevant &&
|
||||
(connection.generation == s.portSSession.generation ||
|
||||
(kind != portSCloseLocal && !s.hasLivePortSConnectionLocked(currentRegistrar)))
|
||||
(kind != portSCloseLocal && kind != portSCloseSARetired &&
|
||||
!s.hasLivePortSConnectionLocked(currentRegistrar)))
|
||||
if current {
|
||||
if kind != portSCloseLocal {
|
||||
s.udpDownlinkProven.Store(false)
|
||||
|
||||
+27
@@ -560,3 +560,30 @@ func TestRetiredPortSFlowAwaitsTheNewSAs(t *testing.T) {
|
||||
t.Fatal("SMS readiness requires the retired port-s flow")
|
||||
}
|
||||
}
|
||||
|
||||
// Retiring the old SAs closes the old port-s flow; when a newer flow has
|
||||
// already failed, that failure stays the one recovery acts on.
|
||||
func TestRetiredOldFlowKeepsNewFlowFailure(t *testing.T) {
|
||||
svc, _, _, _, _ := switchRefreshService(t, 200, switchedSecurityServer)
|
||||
if _, _, err := svc.runRegisterAttempt(context.Background()); err != nil {
|
||||
t.Fatalf("refresh: %v", err)
|
||||
}
|
||||
portS := func(remotePort int) net.Conn {
|
||||
pipe, pcscf := net.Pipe()
|
||||
t.Cleanup(func() { pcscf.Close() })
|
||||
conn := 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: remotePort}}
|
||||
if !svc.trackProtectedPortSConnection(conn, time.Now()) {
|
||||
t.Fatal("port-s flow not tracked")
|
||||
}
|
||||
return conn
|
||||
}
|
||||
oldFlow, newFlow := portS(16381), portS(16382)
|
||||
svc.recordPortSClosed(newFlow, syscall.ECONNRESET, time.Now())
|
||||
svc.markPortSSARetired(oldFlow)
|
||||
svc.recordPortSClosed(oldFlow, io.EOF, time.Now())
|
||||
if got := svc.capturePortSSession().lastCloseKind; got != portSClosePeerReset {
|
||||
t.Fatalf("close kind = %q, want the new flow's %q", got, portSClosePeerReset)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user