Skip to content

Commit 5a73b9e

Browse files
authored
Add configuration surface for resumption and 0-RTT for server. (#481)
1 parent 5d64178 commit 5a73b9e

File tree

7 files changed

+92
-0
lines changed

7 files changed

+92
-0
lines changed

src/core/connection.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ QuicConnApplySettings(
433433
Settings->UnidiStreamCount);
434434
}
435435

436+
if (Settings->ServerResumptionLevel > QUIC_SERVER_NO_RESUME) {
437+
QUIC_DBG_ASSERT(!Connection->State.Started);
438+
//
439+
// TODO: allocate memory for handshake TP here
440+
//
441+
Connection->State.ResumptionEnabled = TRUE;
442+
}
443+
436444
QuicSendApplySettings(&Connection->Send, Settings);
437445
QuicCongestionControlInitialize(&Connection->CongestionControl, Settings);
438446
}

src/core/connection.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ typedef union QUIC_CONNECTION_STATE {
140140
//
141141
BOOLEAN UseRoundRobinStreamScheduling : 1;
142142

143+
//
144+
// Indicates that this connection has resumption enabled and needs to
145+
// keep the TLS state and transport parameters until it is done sending
146+
// resumption tickets.
147+
//
148+
BOOLEAN ResumptionEnabled : 1;
149+
143150
#ifdef QuicVerifierEnabledByAddr
144151
//
145152
// The calling app is being verified (app or driver verifier).

src/core/quicdef.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ QUIC_STATIC_ASSERT(
403403
//
404404
#define QUIC_DEFAULT_MAX_DATAGRAM_LENGTH 0xFFFF
405405

406+
//
407+
// By default, resumption and 0-RTT are not enabled for servers.
408+
// If an application want to use these features, it must explicitly enable them.
409+
//
410+
#define QUIC_DEFAULT_SERVER_RESUMPTION_LEVEL QUIC_SERVER_NO_RESUME
411+
406412
/*************************************************************
407413
PERSISTENT SETTINGS
408414
*************************************************************/
@@ -437,3 +443,5 @@ QUIC_STATIC_ASSERT(
437443
#define QUIC_SETTING_CONN_FLOW_CONTROL_WINDOW "ConnFlowControlWindow"
438444

439445
#define QUIC_SETTING_MAX_BYTES_PER_KEY_PHASE "MaxBytesPerKey"
446+
447+
#define QUIC_SETTING_SERVER_RESUMPTION_OR_ZERORTT "ResumptionLevel"

src/core/session.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,25 @@ QuicSessionParamGet(
881881
Status = QUIC_STATUS_SUCCESS;
882882
break;
883883

884+
case QUIC_PARAM_SESSION_SERVER_RESUMPTION_LEVEL:
885+
if (*BufferLength < sizeof(QUIC_SERVER_RESUMPTION_LEVEL)) {
886+
*BufferLength = sizeof(QUIC_SERVER_RESUMPTION_LEVEL);
887+
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
888+
break;
889+
}
890+
891+
if (Buffer == NULL) {
892+
Status = QUIC_STATUS_INVALID_PARAMETER;
893+
break;
894+
}
895+
896+
*BufferLength = sizeof(QUIC_SERVER_RESUMPTION_LEVEL);
897+
*(QUIC_SERVER_RESUMPTION_LEVEL*)Buffer =
898+
(QUIC_SERVER_RESUMPTION_LEVEL)Session->Settings.ServerResumptionLevel;
899+
900+
Status = QUIC_STATUS_SUCCESS;
901+
break;
902+
884903
default:
885904
Status = QUIC_STATUS_INVALID_PARAMETER;
886905
break;
@@ -1095,6 +1114,27 @@ QuicSessionParamSet(
10951114
break;
10961115
}
10971116

1117+
case QUIC_PARAM_SESSION_SERVER_RESUMPTION_LEVEL: {
1118+
if (BufferLength != sizeof(QUIC_SERVER_RESUMPTION_LEVEL) ||
1119+
*(QUIC_SERVER_RESUMPTION_LEVEL*)Buffer > QUIC_SERVER_RESUME_AND_ZERORTT) {
1120+
Status = QUIC_STATUS_INVALID_PARAMETER;
1121+
break;
1122+
}
1123+
1124+
Session->Settings.AppSet.ServerResumptionLevel = TRUE;
1125+
Session->Settings.ServerResumptionLevel =
1126+
*(QUIC_SERVER_RESUMPTION_LEVEL*)Buffer;
1127+
1128+
QuicTraceLogInfo(
1129+
SessionServerResumptionLevelSet,
1130+
"[sess][%p] Updated Server resume/0-RTT to %hhu",
1131+
Session,
1132+
Session->Settings.ServerResumptionLevel);
1133+
1134+
Status = QUIC_STATUS_SUCCESS;
1135+
break;
1136+
}
1137+
10981138
default:
10991139
Status = QUIC_STATUS_INVALID_PARAMETER;
11001140
break;

src/core/settings.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ QuicSettingsSetDefault(
9292
if (!Settings->AppSet.MaxBytesPerKey) {
9393
Settings->MaxBytesPerKey = QUIC_DEFAULT_MAX_BYTES_PER_KEY;
9494
}
95+
if (!Settings->AppSet.ServerResumptionLevel) {
96+
Settings->ServerResumptionLevel = QUIC_DEFAULT_SERVER_RESUMPTION_LEVEL;
97+
}
9598
}
9699

97100
_IRQL_requires_max_(PASSIVE_LEVEL)
@@ -176,6 +179,9 @@ QuicSettingsCopy(
176179
if (!Settings->AppSet.MaxBytesPerKey) {
177180
Settings->MaxBytesPerKey = ParentSettings->MaxBytesPerKey;
178181
}
182+
if (!Settings->AppSet.ServerResumptionLevel) {
183+
Settings->ServerResumptionLevel = ParentSettings->ServerResumptionLevel;
184+
}
179185
}
180186

181187
_IRQL_requires_max_(PASSIVE_LEVEL)
@@ -455,6 +461,19 @@ QuicSettingsLoad(
455461
Settings->MaxBytesPerKey = QUIC_DEFAULT_MAX_BYTES_PER_KEY;
456462
}
457463
}
464+
465+
if (!Settings->AppSet.ServerResumptionLevel) {
466+
ValueLen = sizeof(Value);
467+
QuicStorageReadValue(
468+
Storage,
469+
QUIC_SETTING_SERVER_RESUMPTION_OR_ZERORTT,
470+
(uint8_t*)&Value,
471+
&ValueLen);
472+
if (Value > QUIC_SERVER_RESUME_AND_ZERORTT) {
473+
Value = QUIC_SERVER_RESUME_AND_ZERORTT;
474+
}
475+
Settings->ServerResumptionLevel = (uint8_t)Value;
476+
}
458477
}
459478

460479
_IRQL_requires_max_(PASSIVE_LEVEL)
@@ -488,4 +507,5 @@ QuicSettingsDump(
488507
QuicTraceLogVerbose(SettingDumpStreamRecvBufferDefault, "[sett] StreamRecvBufferDefault= %u", Settings->StreamRecvBufferDefault);
489508
QuicTraceLogVerbose(SettingDumpConnFlowControlWindow, "[sett] ConnFlowControlWindow = %u", Settings->ConnFlowControlWindow);
490509
QuicTraceLogVerbose(SettingDumpMaxBytesPerKey, "[sett] MaxBytesPerKey = %llu", Settings->MaxBytesPerKey);
510+
QuicTraceLogVerbose(SettingDumpServerResumptionLevel, "[sett] ServerResumptionLevel = %hhu", Settings->ServerResumptionLevel);
491511
}

src/core/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ typedef struct QUIC_SETTINGS {
1010
BOOLEAN PacingDefault : 1;
1111
BOOLEAN MigrationEnabled : 1;
1212
BOOLEAN DatagramReceiveEnabled : 1;
13+
uint8_t ServerResumptionLevel : 2;
1314
uint8_t MaxPartitionCount; // Global only
1415
uint8_t MaxOperationsPerDrain; // Global only
1516
uint16_t RetryMemoryLimit; // Global only
@@ -59,6 +60,7 @@ typedef struct QUIC_SETTINGS {
5960
BOOLEAN StreamRecvBufferDefault : 1;
6061
BOOLEAN ConnFlowControlWindow : 1;
6162
BOOLEAN MaxBytesPerKey : 1;
63+
BOOLEAN ServerResumptionLevel : 1;
6264
} AppSet;
6365

6466
} QUIC_SETTINGS;

src/inc/msquic.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ typedef enum QUIC_PARAM_LEVEL {
328328
QUIC_PARAM_LEVEL_STREAM
329329
} QUIC_PARAM_LEVEL;
330330

331+
typedef enum QUIC_SERVER_RESUMPTION_LEVEL {
332+
QUIC_SERVER_NO_RESUME,
333+
QUIC_SERVER_RESUME_ONLY,
334+
QUIC_SERVER_RESUME_AND_ZERORTT
335+
} QUIC_SERVER_RESUMPTION_LEVEL;
336+
331337
//
332338
// Parameters for QUIC_PARAM_LEVEL_GLOBAL.
333339
//
@@ -351,6 +357,7 @@ typedef enum QUIC_PARAM_LEVEL {
351357
#define QUIC_PARAM_SESSION_MAX_BYTES_PER_KEY 5 // uint64_t - bytes
352358
#define QUIC_PARAM_SESSION_MIGRATION_ENABLED 6 // uint8_t (BOOLEAN)
353359
#define QUIC_PARAM_SESSION_DATAGRAM_RECEIVE_ENABLED 7 // uint8_t (BOOLEAN)
360+
#define QUIC_PARAM_SESSION_SERVER_RESUMPTION_LEVEL 8 // QUIC_SERVER_RESUMPTION_LEVEL
354361

355362
//
356363
// Parameters for QUIC_PARAM_LEVEL_LISTENER.

0 commit comments

Comments
 (0)