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

17 Commits

Author SHA1 Message Date
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