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

Phase 2 of enabling new Stream Frame: Reliable Reset #3817

Merged
merged 128 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
9ee2cdb
initialize signature and test case
ProjectsByJackHe Aug 16, 2023
657cb66
update fn description
ProjectsByJackHe Aug 16, 2023
b6c5767
add ifdef preview feature
ProjectsByJackHe Aug 16, 2023
723740d
use get set params
ProjectsByJackHe Aug 17, 2023
fb68ffd
remove unnecessary alloc and add null buffer check
ProjectsByJackHe Aug 17, 2023
a038e8f
update control.cpp to conform to standards
ProjectsByJackHe Aug 17, 2023
660d7f2
update packing order and feature variables
ProjectsByJackHe Aug 17, 2023
b860449
test pass but should not pass
ProjectsByJackHe Aug 17, 2023
492cd25
add delay send
ProjectsByJackHe Aug 17, 2023
8280288
add GetParam for debugging
ProjectsByJackHe Aug 18, 2023
47a9e67
add loss detection and further logging
ProjectsByJackHe Aug 18, 2023
aa4eb7b
Update src/core/stream.c
ProjectsByJackHe Aug 21, 2023
25d92f4
use same settings for client/server
ProjectsByJackHe Aug 21, 2023
ffba903
get rid of useless buffer
ProjectsByJackHe Aug 21, 2023
277ea12
move test code to EOF
ProjectsByJackHe Aug 21, 2023
21981dc
update receive path
ProjectsByJackHe Aug 21, 2023
b0cbd62
Try and test and see if this works
ProjectsByJackHe Aug 21, 2023
49b8cb7
we should queue up a reliable reset frame
ProjectsByJackHe Aug 21, 2023
ef4e5d7
only complete send unsent requests
ProjectsByJackHe Aug 21, 2023
7a4ea9e
include new tests to check send/recv offsets
ProjectsByJackHe Aug 22, 2023
4f23ee5
Update src/inc/msquicp.h with a high bit.
ProjectsByJackHe Aug 22, 2023
8640e1a
put case at the end
ProjectsByJackHe Aug 22, 2023
0b44813
remove redudant line of code
ProjectsByJackHe Aug 22, 2023
0294c68
add logging
ProjectsByJackHe Aug 22, 2023
7ac6c71
rename stream variable
ProjectsByJackHe Aug 22, 2023
b37dd7b
get rid of useless parameter in stream
ProjectsByJackHe Aug 22, 2023
2e5d4a1
add event indication recv side
ProjectsByJackHe Aug 22, 2023
dedeb16
fail if local resets the send before setting offset
ProjectsByJackHe Aug 22, 2023
b5bcf5b
add checks and remove bad while loop
ProjectsByJackHe Aug 22, 2023
510abc4
Add another unit test to send multiple times
ProjectsByJackHe Aug 23, 2023
bd7fd86
ack path update: ensure we only close send path if enough bytes get a…
ProjectsByJackHe Aug 23, 2023
6d58b12
update tests and validate other paths
ProjectsByJackHe Aug 23, 2023
b9f02e6
add further logging
ProjectsByJackHe Aug 24, 2023
a9078aa
update endoffset check
ProjectsByJackHe Aug 24, 2023
d0af2ea
better progress
ProjectsByJackHe Aug 24, 2023
f360c3f
move recv offset >= reliable to receivecomplete path
ProjectsByJackHe Aug 24, 2023
1f75cf4
improve logging and clear send flags when done
ProjectsByJackHe Aug 24, 2023
4f248c2
don't retransmit lost stream frames if we aborted reliably
ProjectsByJackHe Aug 25, 2023
b957edb
update comments and use streamshutdownrecv abort silent
ProjectsByJackHe Aug 25, 2023
9e7b0e2
fixed stream leak
ProjectsByJackHe Aug 26, 2023
3b2f017
add back cleanup
ProjectsByJackHe Aug 26, 2023
3948c93
get rid of useless param
ProjectsByJackHe Aug 28, 2023
a82499f
add an automation script to automatically run certain commands X times
ProjectsByJackHe Aug 29, 2023
67deddb
update clog with more logging
ProjectsByJackHe Aug 29, 2023
ba104f9
Update src/core/stream.c
ProjectsByJackHe Aug 29, 2023
8bfc172
error out if we try using a feature not negotiated
ProjectsByJackHe Aug 29, 2023
5960381
update clog
ProjectsByJackHe Aug 29, 2023
e93b478
clean up code and remove iostream
ProjectsByJackHe Aug 29, 2023
d5a7f4e
generate dotnet and update logging
ProjectsByJackHe Aug 29, 2023
cf2bb52
get rid of 69420
ProjectsByJackHe Aug 30, 2023
8a52a3b
add enabling reliablereset to fuzzing
ProjectsByJackHe Aug 31, 2023
a059432
add additional param testing
ProjectsByJackHe Sep 2, 2023
fb4c56b
no need to indicate irrelevant event
ProjectsByJackHe Sep 2, 2023
ec387f9
change error code and update flags
ProjectsByJackHe Sep 2, 2023
9dbfc0b
update sidecar
ProjectsByJackHe Sep 2, 2023
5d4e699
update datatest
ProjectsByJackHe Sep 2, 2023
d1e9df4
use ACK instead of local reset
ProjectsByJackHe Sep 5, 2023
28c338d
Add packet loss to test
ProjectsByJackHe Sep 5, 2023
331e71c
error out instead of ignoring
ProjectsByJackHe Sep 5, 2023
45a7d9b
update clog
ProjectsByJackHe Sep 5, 2023
c3ebef9
integrate numiterations to test.ps1 script
ProjectsByJackHe Sep 5, 2023
9abc6cd
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 8, 2023
b76e782
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 8, 2023
08ea49e
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 8, 2023
fc58da6
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 8, 2023
229c835
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 8, 2023
f59d213
simiplify logic in test.ps1 script
ProjectsByJackHe Sep 8, 2023
da4df37
add stub for support for multiple reliable sends
ProjectsByJackHe Sep 8, 2023
6bbebbf
Update src/core/stream_send.c
ProjectsByJackHe Sep 8, 2023
c0e93b9
Update src/core/stream_send.c
ProjectsByJackHe Sep 8, 2023
802f170
Update src/core/stream_send.c
ProjectsByJackHe Sep 8, 2023
641a22a
update logging to include trace events
ProjectsByJackHe Sep 8, 2023
275799b
clean up useless code
ProjectsByJackHe Sep 8, 2023
b859f15
update test suite to improve code coverage
ProjectsByJackHe Sep 9, 2023
82825c5
add new flag instead of multi-plexing
ProjectsByJackHe Sep 11, 2023
c56ef13
send order and number of events completed matches up
ProjectsByJackHe Sep 15, 2023
ee56e9a
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 15, 2023
ff54e2e
Update src/core/stream_recv.c
ProjectsByJackHe Sep 15, 2023
181d210
Update src/core/stream_recv.c
ProjectsByJackHe Sep 15, 2023
d438e08
Update src/core/stream.c
ProjectsByJackHe Sep 15, 2023
f62d8cb
more tests lol
ProjectsByJackHe Sep 15, 2023
6bc4046
Merge branch 'main' into jackhe/phase2-issue-3775
ProjectsByJackHe Sep 18, 2023
0dbddc9
do not fail connection if shutdown immediate
ProjectsByJackHe Sep 18, 2023
514b0f5
int and unsigned int comparison fix
ProjectsByJackHe Sep 18, 2023
2d1f43c
got rid of reliance on std:vector
ProjectsByJackHe Sep 18, 2023
7c02e49
remote clashing ioctl
ProjectsByJackHe Sep 18, 2023
4078f19
remove debug logging
ProjectsByJackHe Sep 19, 2023
c824335
update error code, and add new send / recv events
ProjectsByJackHe Sep 20, 2023
977d365
Update src/core/stream_send.c
ProjectsByJackHe Sep 21, 2023
e75d524
Update src/core/stream_send.c
ProjectsByJackHe Sep 21, 2023
a32e6d1
Update src/core/stream_send.c
ProjectsByJackHe Sep 21, 2023
4ae103c
Update src/core/stream_send.c
ProjectsByJackHe Sep 21, 2023
d245f6d
resolve design decisions
ProjectsByJackHe Sep 21, 2023
a5ed957
log state change
ProjectsByJackHe Sep 21, 2023
260a416
log state change
ProjectsByJackHe Sep 22, 2023
35c8cbb
proper error code logic
ProjectsByJackHe Sep 22, 2023
c7b1997
make the pipes independent from each other
ProjectsByJackHe Sep 25, 2023
c2795a2
update event test
ProjectsByJackHe Sep 25, 2023
c5e7a47
make send and abort more explicit
ProjectsByJackHe Sep 25, 2023
307a62f
fix build errors
ProjectsByJackHe Sep 25, 2023
a627537
add error code tests
ProjectsByJackHe Sep 25, 2023
91cc286
update tests to adhere to public interface
ProjectsByJackHe Sep 26, 2023
1bcc0a2
revert brand new event
ProjectsByJackHe Sep 26, 2023
3ed1ad2
Merge branch 'jackhe/phase2-issue-3775' of https://github.com/microso…
ProjectsByJackHe Sep 26, 2023
54241c3
add docs for Reliable Reset
ProjectsByJackHe Sep 26, 2023
31e8364
Update docs/api/StreamShutdown.md
ProjectsByJackHe Sep 27, 2023
4177358
Update src/core/stream_recv.c
ProjectsByJackHe Sep 27, 2023
7cc1f3f
Update src/core/stream_send.c
ProjectsByJackHe Sep 27, 2023
c106cee
Update src/test/lib/ApiTest.cpp
ProjectsByJackHe Sep 27, 2023
1fb82d2
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 27, 2023
0000359
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 27, 2023
c8fe100
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 27, 2023
8d63d3e
Update src/test/lib/DataTest.cpp
ProjectsByJackHe Sep 27, 2023
094bc8f
improve recv comment
ProjectsByJackHe Sep 27, 2023
fdc78ab
clean up code
ProjectsByJackHe Sep 27, 2023
c21430d
update man pages and C hashtag (sharp) code
ProjectsByJackHe Sep 27, 2023
0ad3e14
Update src/core/stream_recv.c
ProjectsByJackHe Sep 28, 2023
c4a1de7
rename and add comment
ProjectsByJackHe Sep 28, 2023
718ebba
Merge branch 'jackhe/phase2-issue-3775' of https://github.com/microso…
ProjectsByJackHe Sep 28, 2023
e3eabc5
update hasstreamcontrolframes
ProjectsByJackHe Sep 28, 2023
da57e63
reset > reset reliable
ProjectsByJackHe Sep 28, 2023
8c24091
Merge branch 'main' into jackhe/phase2-issue-3775
ProjectsByJackHe Sep 29, 2023
a33c336
make comment more readable
ProjectsByJackHe Sep 29, 2023
f499b06
Merge branch 'jackhe/phase2-issue-3775' of https://github.com/microso…
ProjectsByJackHe Sep 29, 2023
da32350
Update src/test/MsQuicTests.h
ProjectsByJackHe Sep 29, 2023
4e7f90c
Update src/test/MsQuicTests.h
ProjectsByJackHe Sep 29, 2023
e5d6411
Update src/test/MsQuicTests.h
ProjectsByJackHe Sep 29, 2023
9a2318e
Update src/test/bin/winkernel/control.cpp
ProjectsByJackHe Sep 29, 2023
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
1 change: 1 addition & 0 deletions docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ These parameters are access by calling [GetParam](./api/GetParam.md) or [SetPara
| `QUIC_PARAM_STREAM_IDEAL_SEND_BUFFER_SIZE`<br> 2 | uint64_t - bytes | Get-only | Ideal buffer size to queue to the stream. Assumes only one stream sends steadily. |
| `QUIC_PARAM_STREAM_PRIORITY` <br> 3 | uint16_t | Get/Set | Stream priority. |
| `QUIC_PARAM_STREAM_STATISTICS` <br> 4 | QUIC_STREAM_STATISTICS | Get-only | Stream-level statistics. |
| `QUIC_PARAM_STREAM_RELIABLE_OFFSET` <br> 5 | uint64_t | Get/Set | Part of the new Reliable Reset preview feature. Sets/Gets the number of bytes a sender must send before closing SEND path.

## See Also

Expand Down
4 changes: 4 additions & 0 deletions docs/api/StreamShutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ The stream can also be gracefully shutdown via the `QUIC_SEND_FLAG_FIN` flag. Se

Any stream (even one that hasn't been started) may be called to shutdown. If the stream has not been started yet, then the shutdown is effectively queued. If the app never calls [StreamStart](StreamStart.md) then the shutdown will never been sent out on the wire.

# Reliable Reset

If an app decides to enable Preview Features, the shutdown path can be configured with the QUIC_PARAM_STREAM_RELIABLE_OFFSET Stream parameter, which determines the number of bytes a sender must deliver before it can shut down their SEND path.

# See Also

[StreamOpen](StreamOpen.md)<br>
Expand Down
25 changes: 19 additions & 6 deletions scripts/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ This script runs the MsQuic tests.
.Parameter DuoNic
Uses DuoNic instead of loopback (DuoNic must already be installed via 'prepare-machine.ps1 -InstallDuoNic').

.Parameter NumIterations
Number of times to run this particular command. Catches tricky edge cases due to random nature of networks.

.EXAMPLE
test.ps1

Expand All @@ -85,6 +88,8 @@ This script runs the MsQuic tests.
.EXAMPLE
test.ps1 -LogProfile Full.Verbose -Compress

.EXAMPLE
test.ps1 -Filter ParameterValidation* -NumIterations 10
#>

param (
Expand Down Expand Up @@ -172,7 +177,10 @@ param (
[switch]$UseQtip = $false,

[Parameter(Mandatory = $false)]
[string]$OsRunner = ""
[string]$OsRunner = "",

[Parameter(Mandatory = $false)]
[int]$NumIterations = 1
)

Set-StrictMode -Version 'Latest'
Expand Down Expand Up @@ -344,12 +352,17 @@ if (![string]::IsNullOrWhiteSpace($ExtraArtifactDir)) {
$TestArguments += " -ExtraArtifactDir $ExtraArtifactDir"
}

# Run the script.
if (!$Kernel -and !$SkipUnitTests) {
Invoke-Expression ($RunTest + " -Path $MsQuicPlatTest " + $TestArguments)
Invoke-Expression ($RunTest + " -Path $MsQuicCoreTest " + $TestArguments)
for ($iteration = 1; $iteration -le $NumIterations; $iteration++) {
if ($NumIterations -gt 1) {
Write-Host "------- Iteration $iteration -------"
}
# Run the script.
if (!$Kernel -and !$SkipUnitTests) {
Invoke-Expression ($RunTest + " -Path $MsQuicPlatTest " + $TestArguments)
Invoke-Expression ($RunTest + " -Path $MsQuicCoreTest " + $TestArguments)
}
Invoke-Expression ($RunTest + " -Path $MsQuicTest " + $TestArguments)
}
Invoke-Expression ($RunTest + " -Path $MsQuicTest " + $TestArguments)

if ($CodeCoverage) {
# Merge code coverage results
Expand Down
9 changes: 4 additions & 5 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -4705,7 +4705,8 @@ QuicConnRecvFrames(
case QUIC_FRAME_STREAM_6:
case QUIC_FRAME_STREAM_7:
case QUIC_FRAME_MAX_STREAM_DATA:
case QUIC_FRAME_STREAM_DATA_BLOCKED: {
case QUIC_FRAME_STREAM_DATA_BLOCKED:
case QUIC_FRAME_RELIABLE_RESET_STREAM: {
if (Closed) {
if (!QuicStreamFrameSkip(
FrameType, PayloadLength, Payload, &Offset)) {
Expand Down Expand Up @@ -5316,7 +5317,7 @@ QuicConnRecvFrames(
case QUIC_FRAME_IMMEDIATE_ACK: // Always accept the frame, because we always enable support.
AckImmediately = TRUE;
break;

case QUIC_FRAME_TIMESTAMP: { // Always accept the frame, because we always enable support.
if (!Connection->State.TimestampRecvNegotiated) {
QuicTraceEvent(
Expand All @@ -5343,9 +5344,7 @@ QuicConnRecvFrames(
Packet->SendTimestamp = Frame.Timestamp;
break;
}

case QUIC_FRAME_RELIABLE_RESET_STREAM:
// TODO - Implement this frame.

default:
//
// No default case necessary, as we have already validated the frame
Expand Down
25 changes: 25 additions & 0 deletions src/core/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,31 @@ QuicFrameLog(
Frame.Timestamp);
break;
}

case QUIC_FRAME_RELIABLE_RESET_STREAM: {
QUIC_RELIABLE_RESET_STREAM_EX Frame;
if (!QuicReliableResetFrameDecode(PacketLength, Packet, Offset, &Frame)) {
QuicTraceLogVerbose(
FrameLogReliableResetStreamInvalid,
"[%c][%cX][%llu] RELIABLE_RESET_STREAM [Invalid]",
PtkConnPre(Connection),
PktRxPre(Rx),
PacketNumber);
return FALSE;
}

QuicTraceLogVerbose(
FrameLogReliableResetStream,
"[%c][%cX][%llu] RELIABLE_RESET_STREAM ID:%llu ErrorCode:0x%llX FinalSize:%llu ReliableSize:%llu",
PtkConnPre(Connection),
PktRxPre(Rx),
PacketNumber,
Frame.StreamID,
Frame.ErrorCode,
Frame.FinalSize,
Frame.ReliableSize);
break;
}

default:
CXPLAT_FRE_ASSERT(FALSE);
Expand Down
13 changes: 13 additions & 0 deletions src/core/loss_detection.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ QuicLossDetectionOnPacketAcknowledged(
QuicStreamOnResetAck(Packet->Frames[i].RESET_STREAM.Stream);
break;

case QUIC_FRAME_RELIABLE_RESET_STREAM:
QuicStreamOnResetReliableAck(Packet->Frames[i].RELIABLE_RESET_STREAM.Stream);
break;

case QUIC_FRAME_CRYPTO:
QuicCryptoOnAck(&Connection->Crypto, &Packet->Frames[i]);
break;
Expand Down Expand Up @@ -699,6 +703,15 @@ QuicLossDetectionRetransmitFrames(
FALSE);
break;

case QUIC_FRAME_RELIABLE_RESET_STREAM:
NewDataQueued |=
QuicSendSetStreamSendFlag(
&Connection->Send,
Packet->Frames[i].RELIABLE_RESET_STREAM.Stream,
QUIC_STREAM_SEND_FLAG_RELIABLE_ABORT,
FALSE);
break;

case QUIC_FRAME_STOP_SENDING:
NewDataQueued |=
QuicSendSetStreamSendFlag(
Expand Down
1 change: 1 addition & 0 deletions src/core/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ QuicSendSetStreamSendFlag(
if (Stream->Flags.LocalCloseAcked) {
SendFlags &=
~(QUIC_STREAM_SEND_FLAG_SEND_ABORT |
QUIC_STREAM_SEND_FLAG_RELIABLE_ABORT |
QUIC_STREAM_SEND_FLAG_DATA_BLOCKED |
QUIC_STREAM_SEND_FLAG_DATA |
QUIC_STREAM_SEND_FLAG_OPEN |
Expand Down
18 changes: 10 additions & 8 deletions src/core/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ QuicPacketTypeToEncryptLevelV2(
// stream. The order reflects the order the data is framed into a packet.
//

#define QUIC_STREAM_SEND_FLAG_DATA_BLOCKED 0x0001U
#define QUIC_STREAM_SEND_FLAG_MAX_DATA 0x0002U
#define QUIC_STREAM_SEND_FLAG_SEND_ABORT 0x0004U
#define QUIC_STREAM_SEND_FLAG_RECV_ABORT 0x0008U
#define QUIC_STREAM_SEND_FLAG_DATA 0x0010U
#define QUIC_STREAM_SEND_FLAG_OPEN 0x0020U
#define QUIC_STREAM_SEND_FLAG_FIN 0x0040U
#define QUIC_STREAM_SEND_FLAG_DATA_BLOCKED 0x0001U
#define QUIC_STREAM_SEND_FLAG_MAX_DATA 0x0002U
#define QUIC_STREAM_SEND_FLAG_SEND_ABORT 0x0004U
#define QUIC_STREAM_SEND_FLAG_RECV_ABORT 0x0008U
#define QUIC_STREAM_SEND_FLAG_DATA 0x0010U
#define QUIC_STREAM_SEND_FLAG_OPEN 0x0020U
#define QUIC_STREAM_SEND_FLAG_FIN 0x0040U
#define QUIC_STREAM_SEND_FLAG_RELIABLE_ABORT 0x0080U

#define QUIC_STREAM_SEND_FLAGS_ALL 0xFFFFU

Expand All @@ -211,7 +212,8 @@ inline BOOLEAN HasStreamControlFrames(uint32_t Flags)
(QUIC_STREAM_SEND_FLAG_DATA_BLOCKED |
QUIC_STREAM_SEND_FLAG_MAX_DATA |
QUIC_STREAM_SEND_FLAG_SEND_ABORT |
QUIC_STREAM_SEND_FLAG_RECV_ABORT);
QUIC_STREAM_SEND_FLAG_RECV_ABORT |
QUIC_STREAM_SEND_FLAG_RELIABLE_ABORT);
}

inline BOOLEAN HasStreamDataFrames(uint32_t Flags)
Expand Down
3 changes: 3 additions & 0 deletions src/core/sent_packet_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ QuicSentPacketMetadataReleaseFrames(
case QUIC_FRAME_STREAM:
QuicStreamSentMetadataDecrement(Metadata->Frames[i].STREAM.Stream);
break;
case QUIC_FRAME_RELIABLE_RESET_STREAM:
QuicStreamSentMetadataDecrement(Metadata->Frames[i].RELIABLE_RESET_STREAM.Stream);
break;
#pragma warning(pop)
default:
//
Expand Down
3 changes: 3 additions & 0 deletions src/core/sent_packet_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ typedef struct QUIC_SENT_FRAME_METADATA {
struct {
QUIC_STREAM* Stream;
} RESET_STREAM;
struct {
QUIC_STREAM* Stream;
} RELIABLE_RESET_STREAM;
struct {
QUIC_STREAM* Stream;
} STOP_SENDING;
Expand Down
99 changes: 98 additions & 1 deletion src/core/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,13 @@ QuicStreamShutdown(
// and shutdown complete events now, if they haven't already been
// delivered.
//
if (Stream->Flags.RemoteCloseResetReliable || Stream->Flags.LocalCloseResetReliable) {
QuicTraceLogStreamWarning(
ShutdownImmediatePendingReliableReset,
Stream,
"Invalid immediate shutdown request (pending reliable reset).");
return;
}
QuicStreamIndicateSendShutdownComplete(Stream, FALSE);
QuicStreamIndicateShutdownComplete(Stream);
}
Expand Down Expand Up @@ -633,7 +640,7 @@ QuicStreamParamSet(

case QUIC_PARAM_STREAM_PRIORITY: {

if (BufferLength != sizeof(Stream->SendPriority)) {
if (BufferLength != sizeof(Stream->SendPriority) || Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}
Expand All @@ -659,6 +666,58 @@ QuicStreamParamSet(
break;
}

case QUIC_PARAM_STREAM_RELIABLE_OFFSET:

if (BufferLength != sizeof(uint64_t) || Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}

if (!Stream->Connection->State.ReliableResetStreamNegotiated ||
*(uint64_t*)Buffer > Stream->QueuedSendOffset) {
Status = QUIC_STATUS_INVALID_STATE;
break;
}

if (Stream->Flags.LocalCloseReset) {
Status = QUIC_STATUS_INVALID_STATE;
break;
}

if (!Stream->Flags.LocalCloseResetReliable) {
//
// We haven't called shutdown reliable yet. App can set ReliableOffsetSend to be whatever.
//
Stream->ReliableOffsetSend = *(uint64_t*)Buffer;
} else if (*(uint64_t*)Buffer < Stream->ReliableOffsetSend) {
//
// TODO - Determine if we need to support this feature in future iterations.
//
// We have previously called shutdown reliable.
// Now we are loosening the conditions of the ReliableReset,
// but we have already sent the peer a stale frame, we must retransmit
// this new frame, and update the metadata.
//
QuicTraceLogStreamInfo(
MultipleReliableResetSendNotSupported,
Stream,
"Multiple RELIABLE_RESET frames sending not supported.");
Status = QUIC_STATUS_INVALID_STATE;
break;
} else {
Status = QUIC_STATUS_INVALID_STATE;
break;
}

QuicTraceLogStreamInfo(
ReliableSendOffsetSet,
Stream,
"Reliable send offset set to %llu",
*(uint64_t*)Buffer);

Status = QUIC_STATUS_SUCCESS;
break;

default:
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
Expand Down Expand Up @@ -838,6 +897,44 @@ QuicStreamParamGet(
Status = QUIC_STATUS_SUCCESS;
break;
}

case QUIC_PARAM_STREAM_RELIABLE_OFFSET:
if (*BufferLength < sizeof(uint64_t)) {
*BufferLength = sizeof(uint64_t);
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
break;
}
if (Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}
if (Stream->ReliableOffsetSend == 0) {
Status = QUIC_STATUS_INVALID_STATE;
break;
}
*(uint64_t*) Buffer = Stream->ReliableOffsetSend;
Status = QUIC_STATUS_SUCCESS;
break;

case QUIC_PARAM_STREAM_RELIABLE_OFFSET_RECV:
if (*BufferLength < sizeof(uint64_t)) {
*BufferLength = sizeof(uint64_t);
Status = QUIC_STATUS_BUFFER_TOO_SMALL;
break;
}
if (Buffer == NULL) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}
if (!Stream->Flags.RemoteCloseResetReliable) {
Status = QUIC_STATUS_INVALID_STATE;
break;
}

*(uint64_t*)Buffer = Stream->RecvMaxLength;
Status = QUIC_STATUS_SUCCESS;
break;

default:
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
Expand Down
Loading