Skip to content

SwiftQUIC: Provide path events when QUICPath changes or is validated#55

Open
agnosticdev wants to merge 3 commits into
mainfrom
agnosticdev/PathChanges
Open

SwiftQUIC: Provide path events when QUICPath changes or is validated#55
agnosticdev wants to merge 3 commits into
mainfrom
agnosticdev/PathChanges

Conversation

@agnosticdev

Copy link
Copy Markdown
Collaborator

There is a need for swift-nio-quic to observe events when QUICPath changes or becomes validated. This typically happens during connection migration. It is not appropriate to expose QUICPath directly so this change exposes a new type called QUICPathInfo that carries local and remote Endpoint information about the new datagram path underneath QUIC when it changes. When QUICPath changes or becomes validated QUIC checks with the lower protocol (UDP) to obtain the endpoints of the new path below it and sends a QUICEvent that can be observed at the connection level through an object such as NewStreamFlowHarness and the application level can update needed info based on these events.

Design considerations: QUICPathInfo needs to be Sendable because DomainSpecificNetworkProtocolEvent is Sendable. Endpoint is not Sendable and so I had to expose it through a computed property here. That is the need for PathAddress on QUICPathInfo.

@agnosticdev

Copy link
Copy Markdown
Collaborator Author

Another design consideration for swift-nio-quic is that this change takes into account a defined UDP and IP stack running underneath QUIC. In swift-nio-quic, QUIC sits on top of a UDP socket and so we will need to further enhance this change to know when the clients endpoint has changed there also so we can properly expose an event in this case as well.

@available(Network 0.1.0, *)
public struct QUICPathInfo: Sendable, Equatable {
public enum PathAddress: Sendable, Equatable {
case v4(IPv4Address, port: UInt16)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these stored as addresses? I think storing as endpoints would be better than forcing it to be its own tuple of address and port.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally these would be stored as an Endpoint, or as an AddressEndpoint. However those types are not Sendable and QUICPathInfo is required to be Sendable because DomainSpecificNetworkProtocolEvent is Sendable. So I moved it down to the lowest common Sendable type which is an address.

}
}

public func getPathEndpoints(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this supposed to work when we have multiple underlying paths? Which set is returned?

Also, it would be nice to return a struct type instead of a tuple

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did switch a struct in the latest changes c42008f. This change does not take into account multiple underlying paths, only the the particular path that going through the events for handlePathChanged and handlePathChallengeResponse callbacks.

@agnosticdev
agnosticdev requested a review from glbrntt July 21, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants