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 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 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
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
83 changes: 65 additions & 18 deletions src/core/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,46 +560,91 @@ _IRQL_requires_max_(DISPATCH_LEVEL)
BOOLEAN
QuicBindingAddSourceConnectionID(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CID_HASH_ENTRY* SourceCid
_In_ QUIC_CONNECTION* Connection,
_In_ QUIC_CID_SLIST_ENTRY* SourceCid
)
{
return QuicLookupAddLocalCid(&Binding->Lookup, SourceCid, NULL);
return QuicLookupAddLocalCid(&Binding->Lookup, Connection, 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, Connection, Entry)) {
return FALSE;
}
}

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);
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** HashLink = &Entry->HashEntries.Next;
while (*HashLink != NULL) {
QUIC_CID_HASH_ENTRY* HashEntry =
CXPLAT_CONTAINING_RECORD(
*HashLink,
QUIC_CID_HASH_ENTRY,
Link);
if (HashEntry->Binding == Binding) {
QuicBindingRemoveSourceConnectionID(Binding, HashEntry);
*HashLink = (*HashLink)->Next;
CXPLAT_FREE(HashEntry, QUIC_POOL_CIDHASH);
HashEntry = NULL;
} else {
HashLink = &(*HashLink)->Next;
}
}
}
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 +1327,10 @@ QuicBindingCreateConnection(

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 +1365,8 @@ QuicBindingCreateConnection(
}
goto Exit;
}
CXPLAT_DBG_ASSERT(NewConnection->RemoteHashEntry != NULL);
NewConnection->RemoteHashEntry->Binding = Binding;

QuicWorkerQueueConnection(NewConnection->Worker, NewConnection);

Expand Down Expand Up @@ -1353,7 +1400,7 @@ QuicBindingCreateConnection(

} else {
NewConnection->SourceCids.Next = NULL;
CXPLAT_FREE(SourceCid, QUIC_POOL_CIDHASH);
CXPLAT_FREE(SourceCid, QUIC_POOL_CIDSLIST);
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
45 changes: 32 additions & 13 deletions src/core/binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,19 @@ _IRQL_requires_max_(DISPATCH_LEVEL)
BOOLEAN
QuicBindingAddSourceConnectionID(
_In_ QUIC_BINDING* Binding,
_In_ QUIC_CID_HASH_ENTRY* SourceCid
_In_ QUIC_CONNECTION* Connection,
_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 +395,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 +522,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);
}
35 changes: 22 additions & 13 deletions src/core/cid.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,21 @@ 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;
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* Parent;

} QUIC_CID_HASH_ENTRY;

Expand All @@ -178,18 +187,18 @@ 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 +210,23 @@ 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 @@ QuicConfigurationParamGet(

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

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

if (Buffer == NULL) {
return QUIC_STATUS_INVALID_PARAMETER;
}

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

return QUIC_STATUS_SUCCESS;
}
#endif

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

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;
}

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