Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Client Migration (Client Side) #4218

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3ca34bb
Add active migration support.
masa-koz Mar 28, 2024
cb3545e
fix nits
masa-koz Mar 30, 2024
ac71d73
move the codes into the separate functions.
masa-koz Mar 30, 2024
5ca2a72
Merge branch 'microsoft:main' into add_active_migration
masa-koz Mar 31, 2024
a339913
Change the ConnID and reset Congestion Control.
masa-koz Apr 6, 2024
2bed382
Merge branch 'main' into add_active_migration
masa-koz Dec 18, 2024
257f270
Merge branch 'add_active_migration' of https://github.com/masa-koz/ms…
masa-koz Dec 18, 2024
c6f7e3d
Defer sending a path challange if there is no unused ConnID
masa-koz Dec 18, 2024
ac1f616
Release bindings and assert non-null for retired paths in connection …
masa-koz Dec 18, 2024
2b3c6fd
Accept adding local address before connection start
masa-koz Dec 18, 2024
9e287a7
Add support for multiple local addresses in connection tests
masa-koz Dec 18, 2024
5da50d7
Replace all the existing source connection IDs if we find the collisi…
masa-koz Dec 18, 2024
d1d69a3
run ./scripts/update-sidecar.ps1
masa-koz Dec 21, 2024
12c1579
Fix missing newline at end of file in quic_gtest.h
masa-koz Dec 21, 2024
f2c9629
Define local address management parameters only when preview features…
masa-koz Dec 21, 2024
b85b832
Improve local address handling in path tests with retry logic for add…
masa-koz Dec 21, 2024
e5e4c7b
Merge branch 'main' into add_active_migration
masa-koz Jan 2, 2025
e0691f3
Refactoring
masa-koz Jan 9, 2025
1cd0b78
Enhance UdpPortChangeOnly condition for server connections in QuicPat…
masa-koz Jan 9, 2025
64a35a7
Refactor migration test to use QUIC_MIGRATION_TYPE and improve path m…
masa-koz Jan 10, 2025
aaf479d
Merge branch 'main' into add_active_migration
masa-koz Jan 10, 2025
01f7e15
Validate buffer and address in local address add/remove functions
masa-koz Jan 10, 2025
6d53d03
Refactor QUIC CID source functions to remove unnecessary connection p…
masa-koz Jan 10, 2025
dda0b00
Add partition index to UDP configuration for new path binding
masa-koz Jan 13, 2025
5730945
Update PathProbeHelper instantiation to use std::nothrow and fix QUIC…
masa-koz Jan 18, 2025
8f11fe7
Merge branch 'add_active_migration' of https://github.com/masa-koz/ms…
masa-koz Jan 18, 2025
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
91 changes: 74 additions & 17 deletions src/core/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,46 +560,101 @@
BOOLEAN
QuicBindingAddSourceConnectionID(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CID_HASH_ENTRY* SourceCid
_In_ QUIC_CID_SLIST_ENTRY* SourceCid
)
{
return QuicLookupAddLocalCid(&Binding->Lookup, SourceCid, NULL);
}

_IRQL_requires_max_(DISPATCH_LEVEL)
BOOLEAN
QuicBindingAddAllSourceConnectionIDs(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CONNECTION* Connection
)
{
for (CXPLAT_SLIST_ENTRY* Link = Connection->SourceCids.Next;
Link != NULL;
Link = Link->Next) {

QUIC_CID_SLIST_ENTRY* Entry =
CXPLAT_CONTAINING_RECORD(
Link,
QUIC_CID_SLIST_ENTRY,
Link);
if (!QuicBindingAddSourceConnectionID(Binding, Entry)) {
QuicBindingRemoveAllSourceConnectionIDs(Binding, Connection);
return FALSE;

Check warning on line 587 in src/core/binding.c

View check run for this annotation

Codecov / codecov/patch

src/core/binding.c#L586-L587

Added lines #L586 - L587 were not covered by tests
}
}

return TRUE;
}

_IRQL_requires_max_(DISPATCH_LEVEL)
void
QuicBindingRemoveSourceConnectionID(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CID_HASH_ENTRY* SourceCid,
_In_ CXPLAT_SLIST_ENTRY** Entry
_In_ QUIC_CID_HASH_ENTRY* SourceCid
)
{
QuicLookupRemoveLocalCid(&Binding->Lookup, SourceCid, Entry);
QuicLookupRemoveLocalCid(&Binding->Lookup, SourceCid);
}

_IRQL_requires_max_(DISPATCH_LEVEL)
void
QuicBindingRemoveConnection(
QuicBindingRemoveAllSourceConnectionIDs(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CONNECTION* Connection
)
{
if (Connection->RemoteHashEntry != NULL) {
QuicLookupRemoveRemoteHash(&Binding->Lookup, Connection->RemoteHashEntry);
CXPLAT_SLIST_ENTRY EntriesToFree = {0};

for (CXPLAT_SLIST_ENTRY* Link = Connection->SourceCids.Next;
Link != NULL;
Link = Link->Next) {

QUIC_CID_SLIST_ENTRY* Entry =
CXPLAT_CONTAINING_RECORD(
Link,
QUIC_CID_SLIST_ENTRY,
Link);

CXPLAT_SLIST_ENTRY** Link1 = &Entry->HashEntries.Next;
masa-koz marked this conversation as resolved.
Show resolved Hide resolved
while (*Link1 != NULL) {
QUIC_CID_HASH_ENTRY* Entry1 =
masa-koz marked this conversation as resolved.
Show resolved Hide resolved
CXPLAT_CONTAINING_RECORD(
*Link1,
QUIC_CID_HASH_ENTRY,
Link);
if (Entry1->Binding == Binding) {
QuicBindingRemoveSourceConnectionID(Binding, Entry1);
*Link1 = (*Link1)->Next;
CxPlatListPushEntry(&EntriesToFree, &Entry1->Link);
masa-koz marked this conversation as resolved.
Show resolved Hide resolved
} else {
Link1 = &(*Link1)->Next;
}
}
}

while (EntriesToFree.Next != NULL) {
QUIC_CID_HASH_ENTRY* Entry =
CXPLAT_CONTAINING_RECORD(
CxPlatListPopEntry(&EntriesToFree),
QUIC_CID_HASH_ENTRY,
Link);
CXPLAT_FREE(Entry, QUIC_POOL_CIDHASH);
}
QuicLookupRemoveLocalCids(&Binding->Lookup, Connection);
}

_IRQL_requires_max_(DISPATCH_LEVEL)
void
QuicBindingMoveSourceConnectionIDs(
_In_ QUIC_BINDING* BindingSrc,
_In_ QUIC_BINDING* BindingDest,
_In_ QUIC_CONNECTION* Connection
QuicBindingRemoveRemoteHash(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_REMOTE_HASH_ENTRY* RemoteHashEntry
)
{
QuicLookupMoveLocalConnectionIDs(
&BindingSrc->Lookup, &BindingDest->Lookup, Connection);
QuicLookupRemoveRemoteHash(&Binding->Lookup, RemoteHashEntry);
}

_IRQL_requires_max_(DISPATCH_LEVEL)
Expand Down Expand Up @@ -1280,10 +1335,10 @@

BOOLEAN BindingRefAdded = FALSE;
CXPLAT_DBG_ASSERT(NewConnection->SourceCids.Next != NULL);
QUIC_CID_HASH_ENTRY* SourceCid =
QUIC_CID_SLIST_ENTRY* SourceCid =
CXPLAT_CONTAINING_RECORD(
NewConnection->SourceCids.Next,
QUIC_CID_HASH_ENTRY,
QUIC_CID_SLIST_ENTRY,
Link);

QuicConnAddRef(NewConnection, QUIC_CONN_REF_LOOKUP_RESULT);
Expand Down Expand Up @@ -1318,6 +1373,8 @@
}
goto Exit;
}
CXPLAT_DBG_ASSERT(NewConnection->RemoteHashEntry != NULL);
NewConnection->RemoteHashEntry->Binding = Binding;

QuicWorkerQueueConnection(NewConnection->Worker, NewConnection);

Expand Down Expand Up @@ -1351,7 +1408,7 @@

} else {
NewConnection->SourceCids.Next = NULL;
CXPLAT_FREE(SourceCid, QUIC_POOL_CIDHASH);
CXPLAT_FREE(SourceCid, QUIC_POOL_CIDSLIST);

Check warning on line 1411 in src/core/binding.c

View check run for this annotation

Codecov / codecov/patch

src/core/binding.c#L1411

Added line #L1411 was not covered by tests
QuicConnRelease(NewConnection, QUIC_CONN_REF_LOOKUP_RESULT);
#pragma prefast(suppress:6001, "SAL doesn't understand ref counts")
QuicConnRelease(NewConnection, QUIC_CONN_REF_HANDLE_OWNER);
Expand Down
44 changes: 31 additions & 13 deletions src/core/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,18 @@ _IRQL_requires_max_(DISPATCH_LEVEL)
BOOLEAN
QuicBindingAddSourceConnectionID(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CID_HASH_ENTRY* SourceCid
_In_ QUIC_CID_SLIST_ENTRY* SourceCid
);

//
// Attempts to insert all the connection's new source CIDs into the binding's
// lookup table.
//
_IRQL_requires_max_(DISPATCH_LEVEL)
BOOLEAN
QuicBindingAddAllSourceConnectionIDs(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CONNECTION* Connection
);

//
Expand All @@ -383,30 +394,24 @@ _IRQL_requires_max_(DISPATCH_LEVEL)
void
QuicBindingRemoveSourceConnectionID(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CID_HASH_ENTRY* SourceCid,
_In_ CXPLAT_SLIST_ENTRY** Entry
_In_ QUIC_CID_HASH_ENTRY* SourceCid
);

//
// Removes all the connection's source CIDs from the binding's lookup table.
// Removes all the source CIDs from the binding's lookup table.
//
_IRQL_requires_max_(DISPATCH_LEVEL)
void
QuicBindingRemoveConnection(
QuicBindingRemoveAllSourceConnectionIDs(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CONNECTION* Connection
);

//
// Moves all the connections source CIDs from the one binding's lookup table to
// another.
//
_IRQL_requires_max_(DISPATCH_LEVEL)
void
QuicBindingMoveSourceConnectionIDs(
_In_ QUIC_BINDING* BindingSrc,
_In_ QUIC_BINDING* BindingDest,
_In_ QUIC_CONNECTION* Connection
QuicBindingRemoveRemoteHash(
masa-koz marked this conversation as resolved.
Show resolved Hide resolved
_In_ QUIC_BINDING* Binding,
_In_ QUIC_REMOTE_HASH_ENTRY* RemoteHashEntry
);

//
Expand Down Expand Up @@ -516,3 +521,16 @@ QuicRetryTokenDecrypt(
CxPlatDispatchLockRelease(&MsQuicLib.StatelessRetryKeysLock);
return QUIC_SUCCEEDED(Status);
}

//
// Helper to get the owning QUIC_BINDING for the lookup module.
//
inline
_Ret_notnull_
QUIC_BINDING*
QuicLookupGetBinding(
_In_ QUIC_LOOKUP* Lookup
)
{
return CXPLAT_CONTAINING_RECORD(Lookup, QUIC_BINDING, Lookup);
}
34 changes: 23 additions & 11 deletions src/core/cid.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,22 @@ typedef struct QUIC_CID_LIST_ENTRY {
#define QUIC_CID_VALIDATE_NULL(Conn, Cid) UNREFERENCED_PARAMETER(Cid)
#endif

typedef struct QUIC_CID_SLIST_ENTRY {

CXPLAT_SLIST_ENTRY Link;
QUIC_CONNECTION* Connection;
masa-koz marked this conversation as resolved.
Show resolved Hide resolved
CXPLAT_SLIST_ENTRY HashEntries;
QUIC_CID CID;

} QUIC_CID_SLIST_ENTRY;

typedef struct QUIC_CID_HASH_ENTRY {

CXPLAT_HASHTABLE_ENTRY Entry;
CXPLAT_SLIST_ENTRY Link;
QUIC_CONNECTION* Connection;
QUIC_CID CID;
QUIC_BINDING* Binding;
QUIC_CID_SLIST_ENTRY* CID;

} QUIC_CID_HASH_ENTRY;

Expand All @@ -178,18 +188,19 @@ typedef struct QUIC_CID_HASH_ENTRY {
//
inline
_Success_(return != NULL)
QUIC_CID_HASH_ENTRY*
QUIC_CID_SLIST_ENTRY*
QuicCidNewNullSource(
_In_ QUIC_CONNECTION* Connection
)
{
QUIC_CID_HASH_ENTRY* Entry =
(QUIC_CID_HASH_ENTRY*)CXPLAT_ALLOC_NONPAGED(
sizeof(QUIC_CID_HASH_ENTRY),
QUIC_POOL_CIDHASH);
QUIC_CID_SLIST_ENTRY* Entry =
(QUIC_CID_SLIST_ENTRY*)CXPLAT_ALLOC_NONPAGED(
sizeof(QUIC_CID_SLIST_ENTRY),
QUIC_POOL_CIDSLIST);

if (Entry != NULL) {
Entry->Connection = Connection;
Entry->HashEntries.Next = NULL;
CxPlatZeroMemory(&Entry->CID, sizeof(Entry->CID));
}

Expand All @@ -201,23 +212,24 @@ QuicCidNewNullSource(
//
inline
_Success_(return != NULL)
QUIC_CID_HASH_ENTRY*
QUIC_CID_SLIST_ENTRY*
QuicCidNewSource(
_In_ QUIC_CONNECTION* Connection,
_In_ uint8_t Length,
_In_reads_(Length)
const uint8_t* const Data
)
{
QUIC_CID_HASH_ENTRY* Entry =
(QUIC_CID_HASH_ENTRY*)
QUIC_CID_SLIST_ENTRY* Entry =
(QUIC_CID_SLIST_ENTRY*)
CXPLAT_ALLOC_NONPAGED(
sizeof(QUIC_CID_HASH_ENTRY) +
sizeof(QUIC_CID_SLIST_ENTRY) +
Length,
QUIC_POOL_CIDHASH);
QUIC_POOL_CIDSLIST);

if (Entry != NULL) {
Entry->Connection = Connection;
Entry->HashEntries.Next = NULL;
CxPlatZeroMemory(&Entry->CID, sizeof(Entry->CID));
Entry->CID.Length = Length;
if (Length != 0) {
Expand Down
Loading
Loading