This commit is contained in:
Nick Banks 2022-02-09 13:45:20 -06:00 коммит произвёл GitHub
Родитель 1983e0cd93
Коммит 57b5ef919b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 119 добавлений и 86 удалений

Просмотреть файл

@ -93,7 +93,7 @@ These parameters are accessed by calling [GetParam](./api/GetParam.md) or [SetPa
| Setting | Type | Get/Set | Description |
|---------------------------------------------------|---------------|-----------|-------------------------------------------------------------------------------------------------------|
| `QUIC_PARAM_REGISTRATION_CID_PREFIX`<br> 0 | uint8_t[] | Both | CID prefix to prepend to all CIDs. Used for load balancing. |
### Configuration Parameters
@ -112,6 +112,7 @@ These parameters are accessed by calling [GetParam](./api/GetParam.md) or [SetPa
|-------------------------------------------|---------------------------|-----------|-----------------------------------------------------------|
| `QUIC_PARAM_LISTENER_LOCAL_ADDRESS`<br> 0 | QUIC_ADDR | Get-only | Get the full address tuple the server is listening on. |
| `QUIC_PARAM_LISTENER_STATS`<br> 1 | QUIC_LISTENER_STATISTICS | Get-only | Get statistics specific to this Listener instance. |
| `QUIC_PARAM_LISTENER_CID_PREFIX`<br> 2 | uint8_t[] | Both | CID prefix prepended to all CIDs. |
### Connection Parameters
@ -137,6 +138,10 @@ These parameters are accessed by calling [GetParam](./api/GetParam.md) or [SetPa
| `QUIC_PARAM_CONN_DISABLE_1RTT_ENCRYPTION`<br> 15 | uint8_t (BOOLEAN) | Both | Application must `#define QUIC_API_ENABLE_INSECURE_FEATURES` before including msquic.h. |
| `QUIC_PARAM_CONN_RESUMPTION_TICKET`<br> 16 | uint8_t[] | Set-only | Must be set on client before starting connection. |
| `QUIC_PARAM_CONN_PEER_CERTIFICATE_VALID`<br> 17 | uint8_t (BOOLEAN) | Set-only | Used for asynchronous custom certificate validation. |
| `QUIC_PARAM_CONN_LOCAL_INTERFACE`<br> 18 | uint32_t | Set-only | The local interface index to bind to. |
| `QUIC_PARAM_CONN_TLS_SECRETS`<br> 19 | QUIC_TLS_SECRETS | Set-only | The TLS secrets struct to be populated by MsQuic. |
| `QUIC_PARAM_CONN_DESIRED_VERSIONS`<br> 20 | uint8_t[] | Get-only | The desired QUIC versions for the connection. |
| `QUIC_PARAM_CONN_INITIAL_DCID_PREFIX`<br> 21 | uint8_t[] | Set-only | CID prefix prepended to initial destination CID. |
### TLS Parameters

Просмотреть файл

@ -43,6 +43,12 @@ Abstract:
//
#define MSQUIC_CID_MIN_RANDOM_BYTES 4
//
// The maximum number of bytes that we allow to overwrite the initial DCID
// prefix.
//
#define MSQUIC_CID_MAX_DCID_PREFIX 6
//
// The minimum length CIDs that MsQuic ever will generate.
//

Просмотреть файл

@ -873,8 +873,8 @@ QuicConnGenerateNewSourceCid(
Connection,
Connection->ServerID,
Connection->PartitionID,
Connection->Registration->CidPrefixLength,
Connection->Registration->CidPrefix);
Connection->CidPrefix[0],
Connection->CidPrefix+1);
if (SourceCid == NULL) {
QuicTraceEvent(
AllocFailure,
@ -1919,8 +1919,8 @@ QuicConnStart(
Connection,
NULL,
Connection->PartitionID,
Connection->Registration->CidPrefixLength,
Connection->Registration->CidPrefix);
Connection->CidPrefix[0],
Connection->CidPrefix+1);
} else {
SourceCid = QuicCidNewNullSource(Connection);
}
@ -6145,6 +6145,26 @@ QuicConnParamSet(
Status = QUIC_STATUS_SUCCESS;
break;
case QUIC_PARAM_CONN_INITIAL_DCID_PREFIX:
if (BufferLength == 0 || BufferLength > MSQUIC_CID_MAX_DCID_PREFIX ||
Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}
if (QuicConnIsServer(Connection) ||
QUIC_CONN_BAD_START_STATE(Connection)) {
Status = QUIC_STATUS_INVALID_STATE;
break;
}
CXPLAT_DBG_ASSERT(Connection->Paths[0].DestCid);
CXPLAT_DBG_ASSERT(Connection->Paths[0].DestCid->CID.Length > BufferLength);
CxPlatCopyMemory(Connection->Paths[0].DestCid->CID.Data, Buffer, BufferLength);
Status = QUIC_STATUS_SUCCESS;
break;
//
// Private
//

Просмотреть файл

@ -461,6 +461,12 @@ typedef struct QUIC_CONNECTION {
//
QUIC_CID* OrigDestCID;
//
// An app configured prefix for all connection IDs. The first byte indicates
// the length.
//
uint8_t CidPrefix[1 + MSQUIC_CID_MAX_APP_PREFIX];
//
// Sorted array of all timers for the connection.
//

Просмотреть файл

@ -670,6 +670,8 @@ QuicListenerAcceptConnection(
return;
}
memcpy(Connection->CidPrefix, Listener->CidPrefix, sizeof(Listener->CidPrefix));
if (!QuicConnGenerateNewSourceCid(Connection, TRUE)) {
return;
}
@ -693,12 +695,23 @@ QuicListenerParamSet(
const void* Buffer
)
{
UNREFERENCED_PARAMETER(Listener);
UNREFERENCED_PARAMETER(Param);
UNREFERENCED_PARAMETER(BufferLength);
UNREFERENCED_PARAMETER(Buffer);
QUIC_STATUS Status;
return QUIC_STATUS_INVALID_PARAMETER;
if (Param == QUIC_PARAM_LISTENER_CID_PREFIX) {
if (BufferLength > MSQUIC_CID_MAX_APP_PREFIX) {
return QUIC_STATUS_INVALID_PARAMETER;
}
Listener->CidPrefix[0] = (uint8_t)BufferLength;
if (BufferLength != 0) {
memcpy(Listener->CidPrefix+1, Buffer, BufferLength);
}
Status = QUIC_STATUS_SUCCESS;
} else {
Status = QUIC_STATUS_INVALID_PARAMETER;
}
return Status;
}
_IRQL_requires_max_(PASSIVE_LEVEL)
@ -762,6 +775,28 @@ QuicListenerParamGet(
Status = QUIC_STATUS_SUCCESS;
break;
case QUIC_PARAM_LISTENER_CID_PREFIX:
if (*BufferLength < Listener->CidPrefix[0]) {
*BufferLength = Listener->CidPrefix[0];
return QUIC_STATUS_BUFFER_TOO_SMALL;
}
if (Listener->CidPrefix[0] > 0) {
if (Buffer == NULL) {
return QUIC_STATUS_INVALID_PARAMETER;
}
*BufferLength = Listener->CidPrefix[0];
memcpy(Buffer, Listener->CidPrefix+1, Listener->CidPrefix[0]);
} else {
*BufferLength = 0;
}
Status = QUIC_STATUS_SUCCESS;
break;
default:
Status = QUIC_STATUS_INVALID_PARAMETER;
break;

Просмотреть файл

@ -94,6 +94,12 @@ typedef struct QUIC_LISTENER {
_Field_size_(AlpnListLength)
uint8_t* AlpnList;
//
// An app configured prefix for all connection IDs in this listener. The
// first byte indicates the length.
//
uint8_t CidPrefix[1 + MSQUIC_CID_MAX_APP_PREFIX];
} QUIC_LISTENER;
#ifdef QUIC_SILO

Просмотреть файл

@ -70,8 +70,6 @@ MsQuicRegistrationOpen(
Registration->NoPartitioning = FALSE;
Registration->SplitPartitioning = FALSE;
Registration->ExecProfile = Config == NULL ? QUIC_EXECUTION_PROFILE_LOW_LATENCY : Config->ExecutionProfile;
Registration->CidPrefixLength = 0;
Registration->CidPrefix = NULL;
Registration->ShuttingDown = 0;
Registration->ShutdownErrorCode = 0;
Registration->ShutdownFlags = 0;
@ -212,10 +210,6 @@ MsQuicRegistrationClose(
CxPlatDispatchLockUninitialize(&Registration->ConnectionLock);
CxPlatLockUninitialize(&Registration->ConfigLock);
if (Registration->CidPrefix != NULL) {
CXPLAT_FREE(Registration->CidPrefix, QUIC_POOL_CIDPREFIX);
}
CXPLAT_FREE(Registration, QUIC_POOL_REGISTRATION);
QuicTraceEvent(
@ -400,36 +394,10 @@ QuicRegistrationParamSet(
const void* Buffer
)
{
if (Param == QUIC_PARAM_REGISTRATION_CID_PREFIX) {
if (BufferLength == 0) {
if (Registration->CidPrefix != NULL) {
CXPLAT_FREE(Registration->CidPrefix, QUIC_POOL_CIDPREFIX);
Registration->CidPrefix = NULL;
}
Registration->CidPrefixLength = 0;
return QUIC_STATUS_SUCCESS;
}
if (BufferLength > MSQUIC_CID_MAX_APP_PREFIX) {
return QUIC_STATUS_INVALID_PARAMETER;
}
if (BufferLength > Registration->CidPrefixLength) {
uint8_t* NewCidPrefix = CXPLAT_ALLOC_NONPAGED(BufferLength, QUIC_POOL_CIDPREFIX);
if (NewCidPrefix == NULL) {
return QUIC_STATUS_OUT_OF_MEMORY;
}
CXPLAT_DBG_ASSERT(Registration->CidPrefix != NULL);
CXPLAT_FREE(Registration->CidPrefix, QUIC_POOL_CIDPREFIX);
Registration->CidPrefix = NewCidPrefix;
}
Registration->CidPrefixLength = (uint8_t)BufferLength;
memcpy(Registration->CidPrefix, Buffer, BufferLength);
return QUIC_STATUS_SUCCESS;
}
UNREFERENCED_PARAMETER(Registration);
UNREFERENCED_PARAMETER(Param);
UNREFERENCED_PARAMETER(BufferLength);
UNREFERENCED_PARAMETER(Buffer);
return QUIC_STATUS_INVALID_PARAMETER;
}
@ -443,27 +411,9 @@ QuicRegistrationParamGet(
void* Buffer
)
{
if (Param == QUIC_PARAM_REGISTRATION_CID_PREFIX) {
if (*BufferLength < Registration->CidPrefixLength) {
*BufferLength = Registration->CidPrefixLength;
return QUIC_STATUS_BUFFER_TOO_SMALL;
}
if (Registration->CidPrefixLength > 0) {
if (Buffer == NULL) {
return QUIC_STATUS_INVALID_PARAMETER;
}
*BufferLength = Registration->CidPrefixLength;
memcpy(Buffer, Registration->CidPrefix, Registration->CidPrefixLength);
} else {
*BufferLength = 0;
}
return QUIC_STATUS_SUCCESS;
}
UNREFERENCED_PARAMETER(Registration);
UNREFERENCED_PARAMETER(Param);
UNREFERENCED_PARAMETER(BufferLength);
UNREFERENCED_PARAMETER(Buffer);
return QUIC_STATUS_INVALID_PARAMETER;
}

Просмотреть файл

@ -56,12 +56,6 @@ typedef struct QUIC_REGISTRATION {
QUIC_CONNECTION_SHUTDOWN_FLAGS ShutdownFlags;
//
// An app configured prefix for all connection IDs in this registration.
//
uint8_t CidPrefixLength;
uint8_t* CidPrefix;
//
// Link into the global library's Registrations list.
//

Просмотреть файл

@ -2171,9 +2171,6 @@ namespace Microsoft.Quic
[NativeTypeName("#define QUIC_PARAM_GLOBAL_VERSION 0x01000005")]
public const int QUIC_PARAM_GLOBAL_VERSION = 0x01000005;
[NativeTypeName("#define QUIC_PARAM_REGISTRATION_CID_PREFIX 0x02000000")]
public const int QUIC_PARAM_REGISTRATION_CID_PREFIX = 0x02000000;
[NativeTypeName("#define QUIC_PARAM_CONFIGURATION_SETTINGS 0x03000000")]
public const int QUIC_PARAM_CONFIGURATION_SETTINGS = 0x03000000;
@ -2246,6 +2243,12 @@ namespace Microsoft.Quic
[NativeTypeName("#define QUIC_PARAM_CONN_TLS_SECRETS 0x05000013")]
public const int QUIC_PARAM_CONN_TLS_SECRETS = 0x05000013;
[NativeTypeName("#define QUIC_PARAM_CONN_DESIRED_VERSIONS 0x14000014")]
public const int QUIC_PARAM_CONN_DESIRED_VERSIONS = 0x14000014;
[NativeTypeName("#define QUIC_PARAM_CONN_INITIAL_DCID_PREFIX 0x14000015")]
public const int QUIC_PARAM_CONN_INITIAL_DCID_PREFIX = 0x14000015;
[NativeTypeName("#define QUIC_PARAM_TLS_HANDSHAKE_INFO 0x06000000")]
public const int QUIC_PARAM_TLS_HANDSHAKE_INFO = 0x06000000;

Просмотреть файл

@ -645,7 +645,6 @@ void
//
// Parameters for Registration.
//
#define QUIC_PARAM_REGISTRATION_CID_PREFIX 0x02000000 // uint8_t[]
//
// Parameters for Configuration.
@ -659,6 +658,7 @@ void
//
#define QUIC_PARAM_LISTENER_LOCAL_ADDRESS 0x04000000 // QUIC_ADDR
#define QUIC_PARAM_LISTENER_STATS 0x04000001 // QUIC_LISTENER_STATISTICS
#define QUIC_PARAM_LISTENER_CID_PREFIX 0x04000002 // uint8_t[]
//
// Parameters for Connection.
@ -686,6 +686,7 @@ void
#define QUIC_PARAM_CONN_LOCAL_INTERFACE 0x05000012 // uint32_t
#define QUIC_PARAM_CONN_TLS_SECRETS 0x05000013 // QUIC_TLS_SECRETS (SSLKEYLOGFILE compatible)
#define QUIC_PARAM_CONN_DESIRED_VERSIONS 0x05000014 // uint32_t[]
#define QUIC_PARAM_CONN_INITIAL_DCID_PREFIX 0x05000015 // bytes[]
//
// Parameters for TLS.

Просмотреть файл

@ -82,7 +82,7 @@ typedef struct CXPLAT_SLIST_ENTRY {
#define QUIC_POOL_CID 'C0cQ' // Qc0C - QUIC CID
#define QUIC_POOL_CIDHASH 'D0cQ' // Qc0D - QUIC CID Hash
#define QUIC_POOL_CIDLIST 'E0cQ' // Qc0E - QUIC CID List Entry
#define QUIC_POOL_CIDPREFIX 'F0cQ' // Qc0F - QUIC CID Prefix
#define QUIC_POOL__UNUSED_1_ 'F0cQ' // Qc0F - UNUSED
#define QUIC_POOL_ALPN '01cQ' // Qc10 - QUIC ALPN
#define QUIC_POOL_RANGE '11cQ' // Qc11 - QUIC Range
#define QUIC_POOL_SENDBUF '21cQ' // Qc12 - QUIC Send Buffer

Просмотреть файл

@ -552,8 +552,6 @@ pub const PARAM_GLOBAL_PERF_COUNTERS: u32 = 0x01000003;
pub const PARAM_GLOBAL_SETTINGS: u32 = 0x01000004;
pub const PARAM_GLOBAL_VERSION: u32 = 0x01000005;
pub const PARAM_REGISTRATION_CID_PREFIX: u32 = 0x02000000;
pub const PARAM_CONFIGURATION_SETTINGS: u32 = 0x03000000;
pub const PARAM_CONFIGURATION_TICKET_KEYS: u32 = 0x03000001;
@ -580,6 +578,8 @@ pub const PARAM_CONN_RESUMPTION_TICKET: u32 = 0x05000010;
pub const PARAM_CONN_PEER_CERTIFICATE_VALID: u32 = 0x05000011;
pub const PARAM_CONN_LOCAL_INTERFACE: u32 = 0x05000012;
pub const PARAM_CONN_TLS_SECRETS: u32 = 0x05000013;
pub const PARAM_CONN_DESIRED_VERSIONS: u32 = 0x05000014;
pub const PARAM_CONN_INITIAL_DCID_PREFIX: u32 = 0x05000015;
pub const PARAM_TLS_HANDSHAKE_INFO: u32 = 0x06000000;
pub const PARAM_TLS_NEGOTIATED_ALPN: u32 = 0x06000001;

Просмотреть файл

@ -384,9 +384,10 @@ struct SetParamHelper {
void SpinQuicSetRandomConnectionParam(HQUIC Connection)
{
uint8_t RandomBuffer[8];
SetParamHelper Helper;
switch (0x05000000 | (GetRandom(20))) {
switch (0x05000000 | (GetRandom(22))) {
case QUIC_PARAM_CONN_QUIC_VERSION: // uint32_t
// QUIC_VERSION is get-only
break;
@ -438,6 +439,12 @@ void SpinQuicSetRandomConnectionParam(HQUIC Connection)
case QUIC_PARAM_CONN_TLS_SECRETS: // QUIC_TLS_SECRETS
// TODO
break;
case QUIC_PARAM_CONN_DESIRED_VERSIONS: // uint32_t[]
break; // Get-only
case QUIC_PARAM_CONN_INITIAL_DCID_PREFIX: // bytes[]
CxPlatRandom(sizeof(RandomBuffer), RandomBuffer);
Helper.SetPtr(QUIC_PARAM_CONN_INITIAL_DCID_PREFIX, RandomBuffer, 1 + (uint8_t)GetRandom(sizeof(RandomBuffer)));
break;
default:
break;
}
@ -467,10 +474,10 @@ void SpinQuicSetRandomStreamParam(HQUIC Stream)
}
const uint32_t ParamCounts[] = {
QUIC_PARAM_GLOBAL_VERSION + 1,
QUIC_PARAM_REGISTRATION_CID_PREFIX + 1,
QUIC_PARAM_CONFIGURATION_TICKET_KEYS,
QUIC_PARAM_LISTENER_STATS + 1,
QUIC_PARAM_GLOBAL_DESIRED_VERSIONS + 1,
0,
QUIC_PARAM_CONFIGURATION_DESIRED_VERSIONS + 1,
QUIC_PARAM_LISTENER_CID_PREFIX + 1,
QUIC_PARAM_CONN_TLS_SECRETS + 1,
QUIC_PARAM_TLS_NEGOTIATED_ALPN + 1,
#ifdef WIN32 // Schannel specific TLS parameters