Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/SwiftNetwork/Path/PathProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public struct PathProperties: CustomStringConvertible {
static public let useLinkHeuristics = Flags(rawValue: 1 << 31)
static public let hasOverrideTrafficClass = Flags(rawValue: 1 << 32)
static public let fallbackIsOpportunistic = Flags(rawValue: 1 << 33)
static public let hasMigrationInfoFlag = Flags(rawValue: 1 << 34)
}

/// The link quality measurement of the link-layer network attachment.
Expand Down Expand Up @@ -358,6 +359,12 @@ public struct PathProperties: CustomStringConvertible {
get { flags.contains(.fallbackIsOpportunistic) }
set { if newValue { flags.insert(.fallbackIsOpportunistic) } else { flags.remove(.fallbackIsOpportunistic) } }
}
#if !(NETWORK_PRIVATE || NETWORK_DRIVERKIT)
var hasMigrationInfo: Bool {
get { flags.contains(.hasMigrationInfoFlag) }
set { if newValue { flags.insert(.hasMigrationInfoFlag) } else { flags.remove(.hasMigrationInfoFlag) } }
}
#endif
var fallbackIsForced: Bool {
get { flags.contains(.fallbackIsForced) }
set { if newValue { flags.insert(.fallbackIsForced) } else { flags.remove(.fallbackIsForced) } }
Expand Down
9 changes: 8 additions & 1 deletion Sources/SwiftNetwork/Protocols/ManyToManyProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public protocol MultiplexingPath: UpperProtocolHandler {
var identifier: MultiplexingPathIdentifier { get }
init(parent: ParentProtocol)
var pathIsPrimary: Bool { get set }
var pathHasMigrationInfo: Bool { get set }
}

@_spi(ProtocolProvider)
Expand Down Expand Up @@ -932,8 +933,13 @@ extension ManyToManyDatapathProtocol where Path.ParentProtocol == Self, Path: In
parameters: parameters,
path: path
)
if multiplexingPaths.isEmpty { newPath.pathIsPrimary = true }
let isFirstPath = multiplexingPaths.isEmpty
if isFirstPath { newPath.pathIsPrimary = true }
if path?.hasMigrationInfo == true { newPath.pathHasMigrationInfo = true }
multiplexingPaths[newPath.identifier] = newPath
if !isFirstPath {
handlePathChanged(path: newPath.identifier, event: .available, isPrimary: newPath.pathIsPrimary)
}
}
}

Expand Down Expand Up @@ -1953,6 +1959,7 @@ open class MultiplexingDatagramPath<ParentProtocol: ManyToManyOutboundDatagramPr
public var lowerReceiveQueue = FrameArray()

public var pathIsPrimary: Bool = false
public var pathHasMigrationInfo: Bool = false

@_optimize(speed)
public var reference: ProtocolInstanceReference {
Expand Down
16 changes: 14 additions & 2 deletions Sources/SwiftNetwork/QUIC/Migration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ extension QUICConnection {
event: MultiplexingPathEvent,
isPrimary: Bool
) {
guard !migration.activeMigrationDisabled else {
// Ignore if migration is disabled
guard !migration.activeMigrationDisabled || isServer else {
return
}

Expand All @@ -183,6 +182,13 @@ extension QUICConnection {
if !path.isRouteEstablished {
path.changeState(to: .routeEstablished)
}
if isServer, path != currentPath, !path.isValidated {
if path.pathHasMigrationInfo {
path.useSlowProbeInterval = true
}
path.beginValidation()
sendFrames(on: path)
}
break
case .unavailable:
if path.isOpenForSending, let dcid = path.dcid,
Expand All @@ -199,6 +205,12 @@ extension QUICConnection {
break
}

if isServer {
for (id, path) in multiplexingPaths where path.state == .routeUnavailable {
multiplexingPaths.removeValue(forKey: id)
}
}

log.debug("Existing paths:")
applyToAllPaths { path in
log.debug(
Expand Down
Loading