mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-06 00:01:20 +00:00
fix(imscore): keep an old-SA port-s timeout a failure when the retirement sweep marks it
This commit is contained in:
1 parent
9f2cdefb29
commit
55a0eda726
2 files changed
+26
-2
No files matched your search
@@ -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"
|
||||
|
||||
+23
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user