1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-24 04:01:07 +03:00
Commit Graph

43 Commits

Author SHA1 Message Date
Matt Joras
d3e8fe246a Convert IntervalSet from throwing exceptions to using CHECKs with Expected error handling
Summary:
This commit converts IntervalSet to use CHECKs instead of throwing exceptions and provides safe tryInsert methods that return quic::Expected for error handling.

**Core Problem Solved:**
IntervalSet was throwing `std::invalid_argument` exceptions in two scenarios:
1. When constructing an Interval with `start > end`
2. When interval bounds exceed the maximum allowed value

This change eliminates exceptions in favor of CHECKs (for internal validation) and Expected-based error handling (for caller validation).

**Implementation Details:**

**1. IntervalSet Core Changes:**
- Replaced `throw std::invalid_argument` with `CHECK_LE` in Interval constructor
- Replaced `throw std::invalid_argument` with `CHECK_LE` in `insert(start, end)`
- Added `IntervalSetError` enum for error classification
- Added `folly::Expected` include

**2. Safe API Layer:**
- Added `tryInsert(interval)` method returning `Expected<Unit, IntervalSetError>`
- Added `tryInsert(start, end)` method with pre-validation
- Added `tryInsert(point)` method
- Added static `Interval::tryCreate()` method for safe interval construction

**3. Updated  Code:**
- **QuicWriteCodec.cpp**: Updated `fillFrameWithPacketReceiveTimestamps` to use `tryInsert`
  - Returns `QuicError` if interval validation fails
  - Maintains existing error handling patterns
- **QuicTransportFunctions.cpp**: Updated `implicitAckCryptoStream` to use `tryInsert`
  - Logs errors and continues processing other packets
  - Robust error handling for crypto stream implicit acks

Reviewed By: kvtsoy

Differential Revision: D76792362

fbshipit-source-id: 5bd7c22e69a91d60cc41c603a1f2380893f4c8a0
2025-08-19 10:47:24 -07:00
Aman Sharma
be7139756a Add zone to direct encap transport param functionality
Summary:
* Now, we have the notion of a "zone".  The zone is a uint8_t, and is meant to be a bitmask (i.e. it can take on values 0x1, 0x2, 0x4, 0x8, ...)
* We've added the zone to the client transport parameter associated with direct encap.
* Now, the server's transport settings have a "supported zones" bitmask. For example, it a server supports zones 0x1 and 0x4, the value of the bitmask would be 0x1 | 0x4.
* The server responds to a client with its direct encap address only if the client is in a supported zone.

Reviewed By: jbeshay

Differential Revision: D79480555

fbshipit-source-id: ef9ed8aafd82cb9fb3677ca79c052d930f8bf5b5
2025-08-04 12:07:12 -07:00
Aman Sharma
264ff79f12 Make "onFullHandshakeDone" fire client-side with null safety check
Summary:
This makes the following changes:
* Make the onFullHandshakeDone function fire client-side, when the final transport parameters from the peer have been received.
* Make the onFullHandshakeDone function take in an optional vector of peer transport parameters

Reviewed By: jbeshay

Differential Revision: D77902403

fbshipit-source-id: 024f278c9204bb870add6fb0b1ad717944899929
2025-07-15 13:56:36 -07:00
Matt Joras
4601c4bdae Migrate folly::Expected to quic::Expected
Summary:
This migrates the quic code to use quic::Expected instead of folly::Expected. quic::Expected is a vendored wrapper for expected-lite, which itself matches std::expected. std::expected is not available to us, but once it is, we would be able to further simplify to the std version.

This migration is almost entirely mechanical.
 ---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?session_id=7044a18e-4d22-11f0-afeb-97de80927172&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=7044a18e-4d22-11f0-afeb-97de80927172&tab=Trace)
 ---
> Generated by [RACER](https://www.internalfb.com/wiki/RACER_(Risk-Aware_Code_Editing_and_Refactoring)/), powered by [Confucius](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?session_id=1fea6620-4d30-11f0-a206-ad0241db9ec9&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=1fea6620-4d30-11f0-a206-ad0241db9ec9&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=2bdbabba-505a-11f0-a21b-fb3d40195e00&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=2bdbabba-505a-11f0-a21b-fb3d40195e00&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=eb689fd2-5114-11f0-ade8-99c0fe2f80f2&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=eb689fd2-5114-11f0-ade8-99c0fe2f80f2&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=9bc2dcec-51f8-11f0-8604-7bc1f5225a86&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=9bc2dcec-51f8-11f0-8604-7bc1f5225a86&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=46b187ea-5cdd-11f0-9bab-7b6b886e8a09&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=46b187ea-5cdd-11f0-9bab-7b6b886e8a09&tab=Trace)

Reviewed By: kvtsoy

Differential Revision: D76488955

fbshipit-source-id: 92b9cbeac85a28722a6180464b47d84696b1e81b
2025-07-10 15:57:07 -07:00
Aman Sharma
56c0231b9d Implement direct encap transport parameter negotiation + Fix build errors
Summary:
This diff implements the transport parameter negotiation logic for direct encapsulation support on top of D77604174, addresses reviewer feedback by changing the connection state pointer to a reference, and **fixes critical build errors** caused by the constructor signature changes.

**Changes Made:**

1. **Client-side logic**: The client sends the `client_direct_encap` transport parameter with no value if `supportDirectEncap` is true.

2. **Server-side logic**: The server sends the `server_direct_encap` transport parameter if `directEncapAddress` is not null AND the client sent the `client_direct_encap` parameter. The value is the IP address bytes in network byte order.

3. **Pointer to Reference Change**: Changed `const QuicConnectionStateBase* conn_` to `const QuicConnectionStateBase& conn_` in ServerTransportParametersExtension as requested by reviewer feedback, since nullability is not possible (non-null is an invariant).

4. **🔧 Build Error Fixes**: Fixed multiple test files that were broken by the constructor signature changes:

**Build Fixes Applied:**

- **Fixed 3 critical build failures** that prevented compilation:
  - `fbcode//quic/facebook/mbed/test:mbed_client_handshake`
  - `fbcode//quic/fizz/client/handshake/test:fizz_client_handshake_test`
  - `fbcode//quic/server/handshake/test:ServerHandshakeTest`

- **Updated constructor calls** in test files to include the new `const QuicConnectionStateBase& conn` parameter
- **Fixed helper functions** like `constructServerTp()` to accept and pass connection state
- **Updated test classes** like `MalformedServerTransportParamsExt` to handle the new parameter

**Files Fixed:**
- `fbcode/quic/facebook/mbed/test/MbedClientHandshake.cpp` - Fixed 4 constructor calls and helper functions
- `fbcode/quic/fizz/client/handshake/test/FizzClientHandshakeTest.cpp` - Fixed constructor call
- `fbcode/quic/server/handshake/test/ServerHandshakeTest.cpp` - Fixed constructor call

**Test Results:**
-  `buck test fbcode//quic/facebook/mbed/test:mbed_client_handshake` → Pass 7, Fail 0
-  `buck test fbcode//quic/fizz/client/handshake/test:fizz_client_handshake_test` → Pass 12, Fail 0
-  All previously failing builds now compile successfully

**Implementation Details:**

- Added `encodeIPAddressParameter()` function to handle IP address encoding (supports both IPv4 and IPv6)
- Modified `getSupportedExtTransportParams()` to include client-side direct encap logic
- Created new `getClientDependentExtTransportParams()` function that specifically handles server-side direct encap logic based on client parameters
- Updated `ServerTransportParametersExtension` to use the new function for adding client-dependent parameters
- Updated `ServerStateMachine` to pass connection state to the extension
- **Changed constructor parameter order**: `conn` parameter now comes before `customTransportParameters` to maintain C++ default parameter rules
- **Updated member initialization order**: Fixed to match class declaration order
- **Fixed all test constructors**: Updated test cases to provide connection state parameter

**Architecture:**

Instead of overloading `getSupportedExtTransportParams()` with two parameters, the solution now uses a dedicated `getClientDependentExtTransportParams()` function that:
- Only handles parameters that depend on client capabilities (currently `server_direct_encap`)
- Returns a clean list of parameters without duplicating base transport parameters
- Provides better separation of concerns and clearer function naming

**Unit Tests Added:**

- Comprehensive test suite in `fbcode/quic/handshake/test/TransportParametersTest.cpp`
- 8 test cases covering all client/server scenarios with IPv4/IPv6 support
- Tests verify parameter presence/absence and correct IP address byte encoding
- All tests pass successfully
- **Updated test infrastructure**: Fixed ServerTransportParametersTest.cpp to work with reference-based connection state

**Requirements Fulfilled:**
 Client sends `client_direct_encap` parameter with no value if `supportDirectEncap` is true
 Server sends `server_direct_encap` parameter with IP address bytes if conditions are met
 Changed connection state from pointer to reference as requested by reviewer
 **Fixed all build errors caused by constructor signature changes**
 ---
> Generated by [RACER](https://www.internalfb.com/wiki/RACER_(Risk-Aware_Code_Editing_and_Refactoring)/), powered by [Confucius](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=8c84b14a-56a5-11f0-8e69-214e73924e50&tab=Chat), [Trace](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=8c84b14a-56a5-11f0-8e69-214e73924e50&tab=Trace)
[Session](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=439da8ee-5798-11f0-ace1b7dae9e7575d&tab=Chat), [Trace](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=439da8ee-5798-11f0-ace1-b7dae9e7575d&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=7ed2dc86-5847-11f0-8055-b73b775dc61a&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=7ed2dc86-5847-11f0-8055-b73b775dc61a&tab=Trace)
[Session](https://www.internalfb.com/confucius?session_id=8bdc0a0c-584b-11f0-9977-35e1e0d6200a&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=8bdc0a0c-584b-1f0-9977-35e1e0d6200a&tab=Trace)
**[Current Session](https://www.internalfb.com/confucius?session_id={{ session_id }}&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id={{ session_id }}&tab=Trace)**
[Session](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=08290174-5b4d-11f0-ac9d-93447239bce3&tab=Chat), [Trace](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=08290174-5b4d-11f0-ac9d-93447239bce3&tab=Trace)
[Session](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=ded2f5f2-5b6d-11f0-b259-5db72d7f2f63&tab=Chat), [Trace](https://www.internalfb.com/confucius?entry_name=RACER&mode=Focused&namespace[0]=agentrix&session_id=ded2f5f2-5b6d-11f0-b259-5db72d7f2f63&tab=Trace)

Reviewed By: hanidamlaj

Differential Revision: D77605298

fbshipit-source-id: 22d3faffaa93f1aa57e05c984339ab3b2e817ac1
2025-07-07 20:04:24 -07:00
Luca Niccolini
45db54c96f delete flow priming
Summary:
Meta:
This is unused, also it may be confusing now that we have code for 0-RTT
priming

Reviewed By: hanidamlaj

Differential Revision: D77626412

fbshipit-source-id: 6e0fd1bdb7bd2ee5fd656e5e1cc2bfba12255398
2025-07-06 10:06:07 -07:00
Crystal Jin
2976801438 Clean up recvfrom option
Reviewed By: kvtsoy

Differential Revision: D77028366

fbshipit-source-id: 554fb6f4dbe18cfd12503c828b1a7eca7467b0ca
2025-06-24 15:59:16 -07:00
Matt Joras
bf71d17f2c Remove throws from CryptoFactory
Summary: Continuing the theme, removing them from the CryptoFactory and translating to Expected.

Reviewed By: kvtsoy, jbeshay

Differential Revision: D74676120

fbshipit-source-id: 715b497e68a4e3004811038cba479c443d5398fd
2025-05-16 14:19:45 -07:00
Konstantin Tsoy
813f6a6cd1 folly::to<std::string> -> fmt::format
Reviewed By: sharmafb

Differential Revision: D74672231

fbshipit-source-id: d8f4fc542de10f26cf06df7ca42518865e8bba3a
2025-05-14 08:46:52 -07:00
Matt Joras
553fd484a2 Remove exceptions from TransportParameters
Summary: Continuing the theme, this time the TransportParameters

Reviewed By: jbeshay

Differential Revision: D74491343

fbshipit-source-id: 15f8bc0014f7163e674eb7adaf81727cbf2f35d6
2025-05-09 18:25:33 -07:00
Matt Joras
159994752d Remove exceptions from ConnectionId
Summary: This primarily involved making the constructors private and changing the callers of the factory functions. The crashing factory is only expected to be used by tests.

Reviewed By: kvtsoy

Differential Revision: D74347638

fbshipit-source-id: 4c0dd7fabaa233c8a3460c359462a22642d26f5b
2025-05-09 18:25:33 -07:00
Matt Joras
9a9dcca57c Mostly remove folly::Optional
Summary:
This is an API break, but it should mostly be a manageable one. We want to be able to compile mvfst internally without exceptions, and folly::Optional is one dependency that makes this challenging. Additionally, we already have an imported secondary optional type for performance/struct size reasons, tiny-optional.

This second optional interface is mostly compatible in an API sense (including the use of std::nullopt) with std::optional. Thus our approach is to remove the dependency on folly::Optional, and offer a quic::Optional instead.

The next diff will properly vendor tiny-optional so that quic::Optional is an independent version of it.

Reviewed By: sharmafb, kvtsoy

Differential Revision: D74133131

fbshipit-source-id: 715f8bb5043ba3bb876cacfe54236887e0686b30
2025-05-07 23:01:49 -07:00
Paul Farcasanu
c6a141bf80 Support transport isPriming
Summary:
When the transport is in priming mode it saves all packets instead of writing them on the wire, and feeds them to a callback for the caller to get the data.

Meta:
Priming mode is used to get all packets before 1-RTT cipher is available, in order for them to get replayed later.

Reviewed By: kvtsoy

Differential Revision: D71290230

fbshipit-source-id: 230650cb1e5901069dda4ef850c9c724bf33b6be
2025-05-07 09:32:06 -07:00
Konstantin Tsoy
fd8187143a use std::function in base transport
Summary: use std::function in base transport

Reviewed By: mjoras

Differential Revision: D73380174

fbshipit-source-id: 2e51c8bd28c3b7387908cfb04008836f0e6daccf
2025-04-22 20:44:16 -07:00
Aman Sharma
41667ff7c5 Change Buf -> BufPtr and RawBuf -> Buf
Summary:
Previously,
* `RawBuf` was a typealias for `std::unique_ptr<folly::IOBuf>`
* `Buf` was a typealias for `folly::IOBuf`

In this diff,
* `Buf` is a typealias for `folly::IOBuf`
* `BufPtr` is a typealias for `std::unique_ptr<folly::IOBuf>`

Reviewed By: hanidamlaj

Differential Revision: D73206576

fbshipit-source-id: 454bf6ccfce3d6571e5e931889263ed98cc24af3
2025-04-21 20:14:02 -07:00
Matt Joras
1468b24044 Remove throws from handshake layers
Summary: Continuing the theme. This removes it from client and server handshakes.

Reviewed By: kvtsoy

Differential Revision: D73335422

fbshipit-source-id: 262bad17c1ebd2bcef623b1185e38e6a63ec714b
2025-04-21 12:06:59 -07:00
Matt Joras
089bf581a7 Remove throws from socket layer
Summary: More in the theme of returning Expected instead of throwing. For the folly case, we keep the try/catches in there and translate to Expected. For Libev, we convert directly to Expected.

Reviewed By: kvtsoy

Differential Revision: D73217128

fbshipit-source-id: d00a978f24e3b29a77a8ac99a19765ae49f64df8
2025-04-19 15:20:15 -07:00
Aman Sharma
2f33a3681a Introduce a "BufHelpers" typealias
Summary: This introduces a more generic typealias so that we can, for instance, write `BufHelpers::createCombined` instead of `folly::IOBuf::createCombined`.

Reviewed By: jbeshay

Differential Revision: D73127508

fbshipit-source-id: d585790904efc8e9f92d79cbf766bafe0e84a69f
2025-04-17 11:57:01 -07:00
Paul Farcasanu
86ba5bc943 log handshake waiting for data
Reviewed By: lnicco

Differential Revision: D72988762

fbshipit-source-id: 884d75450a00e76f5e3b3ce47e7b1bfaf01aadad
2025-04-15 09:23:35 -07:00
Paul Farcasanu
a801a8351c log read encryption level
Reviewed By: kvtsoy

Differential Revision: D72985344

fbshipit-source-id: 5476a824ab826927fdd41ab889d48e18e3d1f8bb
2025-04-14 20:42:36 -07:00
Paul Farcasanu
2a20187408 log buffer sizes
Reviewed By: kvtsoy

Differential Revision: D72982170

fbshipit-source-id: 3fab297f852463e80f4df397a7bfb5ea01ed25ba
2025-04-14 20:42:36 -07:00
Paul Farcasanu
9213804210 log handshake status on failure
Reviewed By: kvtsoy

Differential Revision: D72980391

fbshipit-source-id: cdf83fba3480f9d556b62988051307e4eb4bcef9
2025-04-14 20:42:36 -07:00
Matt Joras
2a8fba588f Propagate error in scheduleFramesForPacket and writeData
Summary: As in title, this is more of a theme on adding an Expected return.

Reviewed By: kvtsoy

Differential Revision: D72579218

fbshipit-source-id: 25735535368838f1a4315667cd7e9e9b5df1c485
2025-04-08 21:06:35 -07:00
Matt Joras
67ce39cfdd Remove exception throwing from the stream manager and flow control.
Summary: I started with the QuicStreamManager, but it turns out that the path from the manager up to the close path touches a LOT, and so this is a big diff. The strategy is basically the same everywhere, add a folly::Expected and check it on every function and enforce that with [[nodiscard]]

Reviewed By: kvtsoy

Differential Revision: D72347215

fbshipit-source-id: 452868b541754d2ecab646d6c3cbd6aacf317d7f
2025-04-07 23:45:33 -07:00
Matt Joras
d153b04ec4 Add SeparateDefinitionBlocks to clang-format
Summary: As in title.

Reviewed By: kvtsoy

Differential Revision: D72543602

fbshipit-source-id: 6190b7fa541b1535eab565bac3da159c85781c0e
2025-04-07 13:20:35 -07:00
Paul Farcasanu
362340c32c log whether quic socket readable
Summary:
**Context**: adding more debugging to catch the 0RTT bug.

Wonder if the client is down to read more data. There could presumably be some bug with 0RTT + happy eyeballs where the socket isnt working.

Reviewed By: lnicco

Differential Revision: D72266611

fbshipit-source-id: 6420017efcb200dd04bb7070c6c31049bcee8148
2025-04-03 11:45:33 -07:00
Matt Joras
d9a85c0e66 Make processUdpPacketData return an expected.
Summary: Continuing the theme, remove throws and translate them to expected returns.

Reviewed By: hanidamlaj

Differential Revision: D72254169

fbshipit-source-id: 7de13d733802eef70660cf014f642883586b0850
2025-04-02 22:54:09 -07:00
Matt Joras
58eb799ea0 Remove throws from read codec.
Summary: This is a step towards removing exceptions entirely from this path. Mostly involves a mass conversion to folly::Expected and adding a CodecResult that conveys the errors.

Reviewed By: kvtsoy

Differential Revision: D71704941

fbshipit-source-id: a35825b75bf53e252cef8cbf851e2e670209e8de
2025-03-27 11:13:33 -07:00
Aman Sharma
4c0a1f3f9c Move most client read functions to non-lite version
Summary: See title

Reviewed By: kvtsoy

Differential Revision: D71479342

fbshipit-source-id: 5a7bcd5edd3d46489befa5c43974b6581aa261b6
2025-03-20 10:12:43 -07:00
Joseph Beshay
7f65f36b62 Cache the negotiated config for ACKs once the transport parameters are received
Summary: Cache the negotiated config for what ACK type to write and which fields to use once the peer transport parameters are available. This avoids computing the config with every ack frame being written.

Reviewed By: sharmafb

Differential Revision: D70004436

fbshipit-source-id: 79354f5137c77353c3a97d4c41782a700622e986
2025-02-24 12:32:50 -08:00
Joseph Beshay
31fbb343d1 Decode ACK_EXTENDED frame
Summary:
Add functionality for decoding the new ACK_EXTENDED frame.

Frame format:
```
ACK_EXTENDED Frame {
  Type (i) = 0xB1
  // Fields of the existing ACK (type=0x02) frame:
  Largest Acknowledged (i),
  ACK Delay (i),
  ACK Range Count (i),
  First ACK Range (i),
  ACK Range (..) ...,
  Extended Ack Features (i),
  // Optional ECN counts (if bit 0 is set in Features)
  [ECN Counts (..)],
  // Optional Receive Timestamps (if bit 1 is set in Features)
  [Receive Timestamps (..)]
}
// Fields from the existing ACK_ECN frame
ECN Counts {
  ECT0 Count (i),
  ECT1 Count (i),
  ECN-CE Count (i),
}
// Fields from the existing ACK_RECEIVE_TIMESTAMPS frame
Receive Timestamps {
  Timestamp Range Count (i),
  Timestamp Ranges (..) ...,
}
Timestamp Range {
  Gap (i),
  Timestamp Delta Count (i),
  Timestamp Delta (i) ...,
}
```

Reviewed By: sharmafb

Differential Revision: D68931149

fbshipit-source-id: 7eab52449db60fc41a5bf9aa48c0f695ccaca3f0
2025-02-24 12:32:50 -08:00
Joseph Beshay
b45c82b884 ACK_EXTENDED frame support
Summary:
This introduces a new frame type for acks (ACK_EXTENDED) that can carry optional fields depending on the features supported by the peer. The currently supported features set will include ECN count fields, and Receive Timstamp fields. This enables a quic connection to report both ECN counts and receive timestamps, which is not possible otherwise because they use different frame types.

Support for the extended ack as well as the set of features that can be included in it is negotiated through a new transport parameter (extended_ack_supported = 0xff0a004). Its value indicates which features are supported by the local transport. The value is an integer which is evaluated against the following bitmasks:
```
  ECN_COUNTS = 0x01,
  RECEIVE_TIMESTAMPS = 0x02,
```

This diff introduces the transport parameter and negotiates the supported features between the peers of the connection. The parameter is cached in the psk cache so the client can remember the server config. It is also encoded inside the 0-rtt ticket so the server can reject it if its local config has changed.

The following diffs add reading and writing the frame itself.

The ACK_EXTENDED frame itself will have the following format
```
ACK_EXTENDED Frame {
  Type (i) = 0xB1
  // Fields of the existing ACK (type=0x02) frame:
  Largest Acknowledged (i),
  ACK Delay (i),
  ACK Range Count (i),
  First ACK Range (i),
  ACK Range (..) ...,
  Extended Ack Features (i),
  // Optional ECN counts (if bit 0 is set in Features)
  [ECN Counts (..)],
  // Optional Receive Timestamps (if bit 1 is set in Features)
  [Receive Timestamps (..)]
}

// Fields from the existing ACK_ECN frame
ECN Counts {
  ECT0 Count (i),
  ECT1 Count (i),
  ECN-CE Count (i),
}

// Fields from the existing ACK_RECEIVE_TIMESTAMPS frame
Receive Timestamps {
  Timestamp Range Count (i),
  Timestamp Ranges (..) ...,
}

Timestamp Range {
  Gap (i),
  Timestamp Delta Count (i),
  Timestamp Delta (i) ...,
}
```

Reviewed By: sharmafb

Differential Revision: D68931151

fbshipit-source-id: 44c8c83d2f434abca97c4e85f0fa7502736cddc1
2025-02-24 12:32:50 -08:00
Konstantin Tsoy
93aff1cc9c Remove FrameType from QuicException
Summary: Not used

Reviewed By: hanidamlaj

Differential Revision: D69569612

fbshipit-source-id: 72e6c6a52dacbc06e825bc4123022dbc3c8af785
2025-02-14 19:21:05 -08:00
Konstantin Tsoy
b34e9e2a80 processUdpPacket() to return an error instead of throwing
Summary: processUdpPacket() to return an error instead of throwing

Reviewed By: sharmafb

Differential Revision: D69568271

fbshipit-source-id: 1b5b2255a0b435ac67261042cb023f7d6832122b
2025-02-14 19:21:05 -08:00
Konstantin Tsoy
4bfdd122e0 Change processUdpPacket() to return an error
Summary: Next, remove throws

Reviewed By: sharmafb

Differential Revision: D69567910

fbshipit-source-id: 5d78324b7d1a9b9e65e789ee51f0091e2547de80
2025-02-14 19:21:05 -08:00
Konstantin Tsoy
d98c90c48d Change onReadData() to return an error
Summary:
All according to plan: https://fburl.com/gdoc/pebccgi1
Changing function definitions to return errors while still throwing.

Reviewed By: sharmafb

Differential Revision: D69567329

fbshipit-source-id: 5d40ee32fe185d5674785632a9a13e4cef996988
2025-02-14 19:21:05 -08:00
Konstantin Tsoy
9418c93c02 Expose getPeerCertificate() in client
Summary: Expose getPeerCertificate() in client

Reviewed By: sharmafb

Differential Revision: D69485548

fbshipit-source-id: de6bd480554c51ad6209bc77eefc8fecd773c796
2025-02-12 16:15:02 -08:00
Konstantin Tsoy
476607c217 Clean up inline writes param
Summary: Clean up inline writes param

Differential Revision: D68977602

fbshipit-source-id: 4edb4ca08605fab76b56e706c2ccc85836018594
2025-02-04 23:51:44 -08:00
Aman Sharma
afee69d577 Remove unused iovec in QuicClientTransportLite::recvFrom
Summary: Nothing is using this. Don't know why it's here

Reviewed By: jbeshay

Differential Revision: D67988403

fbshipit-source-id: 5619d49b31c0ed72fa6b3fef6584e54a4c8fabe3
2025-01-13 15:01:59 -08:00
Aman Sharma
0411554224 Throw exception upon receiving reliable reset
Summary: For now, we're going to throw an exception when we get a RESET_STREAM_AT frame, which would terminate the connection. Later on, this logic is going to be gated on whether we and the peer support reliable resets (and we get to know this through the transport parameters).

Reviewed By: jbeshay

Differential Revision: D67866393

fbshipit-source-id: 6b2888c026fadf0f2aa5dad52314ed8250959cf6
2025-01-07 13:33:37 -08:00
Aman Sharma
ae011587d5 Add reliable_stream_reset transport parameter
Summary: This diff adds the reliable_stream_reset transport parameter to mvfst.

Reviewed By: hanidamlaj

Differential Revision: D65383676

fbshipit-source-id: cb2f6a1a90004ea489447b67ed3cfc12ca90b804
2024-12-17 11:53:15 -08:00
Aman Sharma
fca90d483b Keep track of the minimum reliable size ACKed
Summary:
With normal resets, we transition from `StreamSendState::ResetSent` to `StreamSendState::Closed` when we get an ACK for a RESET_STREAM frame.

With reliable resets, this is going to be a little more complicated. We can't automatically transition from `StreamSendState::ResetSent` to `StreamSendState::Closed` when we get an ACK for a RESET_STREAM_AT frame because it's possible that the peer hasn't yet received all data until the reliable reset offset.

My idea is the following: Keep track of the `minReliableSizeAcked`, which is the lowest value of the reliable size in any RESET_STREAM_AT frame that was ACKed by the peer. We set it to 0 if a RESET_STREAM frame was ACKed by the peer.

Then, we can transition from `StreamSendState::ResetSent` to `StreamSendState::Closed` if any one of the following two events happen:
* We get an ACK for a RESET_STREAM_AT or a RESET_STREAM frame, and all data until the `minReliableSizeAcked` has been ACKed by the peer.
* We get an ACK for stream data, and this puts us in a state where all data until the `minReliableSizeAcked` has been ACKed by the peer.

Note: This diff doesn't have any functional change. The only change is that we're keeping track of the `minReliableSizeAcked`, but aren't using it anywhere.

Reviewed By: mjoras

Differential Revision: D66781199

fbshipit-source-id: 2aa5138a18f70e9801e59e747460558ba706939c
2024-12-10 16:39:37 -08:00
Aman Sharma
5cd8b2b6c8 Make a QuicClientTransportLite
Summary: See title

Reviewed By: mjoras

Differential Revision: D65688254

fbshipit-source-id: ab3f9048934271c5c29078cd4191492f980bb9ab
2024-12-07 00:09:11 -08:00