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 17 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
90 changes: 73 additions & 17 deletions src/core/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,46 +560,100 @@
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)) {
return FALSE;

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

View check run for this annotation

Codecov / codecov/patch

src/core/binding.c#L586

Added line #L586 was 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 @@ -1282,10 +1336,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 @@ -1320,6 +1374,8 @@
}
goto Exit;
}
CXPLAT_DBG_ASSERT(NewConnection->RemoteHashEntry != NULL);
NewConnection->RemoteHashEntry->Binding = Binding;

QuicWorkerQueueConnection(NewConnection->Worker, NewConnection);

Expand Down Expand Up @@ -1353,7 +1409,7 @@

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

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

View check run for this annotation

Codecov / codecov/patch

src/core/binding.c#L1412

Added line #L1412 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
32 changes: 32 additions & 0 deletions src/core/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,24 @@

return QUIC_STATUS_SUCCESS;
}
#if QUIC_TEST_MANUAL_CONN_ID_GENERATION
if (Param == QUIC_PARAM_CONFIGURATION_CONN_ID_GENERATION_DISABLED) {

Check warning on line 454 in src/core/configuration.c

View check run for this annotation

Codecov / codecov/patch

src/core/configuration.c#L454

Added line #L454 was not covered by tests

if (*BufferLength < sizeof(BOOLEAN)) {
*BufferLength = sizeof(BOOLEAN);
return QUIC_STATUS_BUFFER_TOO_SMALL;

Check warning on line 458 in src/core/configuration.c

View check run for this annotation

Codecov / codecov/patch

src/core/configuration.c#L456-L458

Added lines #L456 - L458 were not covered by tests
}

if (Buffer == NULL) {
return QUIC_STATUS_INVALID_PARAMETER;

Check warning on line 462 in src/core/configuration.c

View check run for this annotation

Codecov / codecov/patch

src/core/configuration.c#L461-L462

Added lines #L461 - L462 were not covered by tests
}

*BufferLength = sizeof(BOOLEAN);
*(BOOLEAN*)Buffer = Configuration->Settings.ConnIDGenDisabled;

Check warning on line 466 in src/core/configuration.c

View check run for this annotation

Codecov / codecov/patch

src/core/configuration.c#L465-L466

Added lines #L465 - L466 were not covered by tests

return QUIC_STATUS_SUCCESS;

Check warning on line 468 in src/core/configuration.c

View check run for this annotation

Codecov / codecov/patch

src/core/configuration.c#L468

Added line #L468 was not covered by tests
}
#endif

return QUIC_STATUS_INVALID_PARAMETER;
}
Expand Down Expand Up @@ -559,6 +577,20 @@

return QUIC_STATUS_SUCCESS;

#if QUIC_TEST_MANUAL_CONN_ID_GENERATION
case QUIC_PARAM_CONFIGURATION_CONN_ID_GENERATION_DISABLED:

if (Buffer == NULL ||
BufferLength < sizeof(BOOLEAN)) {
return QUIC_STATUS_INVALID_PARAMETER;

Check warning on line 585 in src/core/configuration.c

View check run for this annotation

Codecov / codecov/patch

src/core/configuration.c#L585

Added line #L585 was not covered by tests
}

Configuration->Settings.IsSet.ConnIDGenDisabled = TRUE;
Configuration->Settings.ConnIDGenDisabled = *(BOOLEAN*)Buffer;

return QUIC_STATUS_SUCCESS;
#endif

#ifdef WIN32
case QUIC_PARAM_CONFIGURATION_SCHANNEL_CREDENTIAL_ATTRIBUTE_W:

Expand Down
Loading
Loading