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

143 Commits

Author SHA1 Message Date
Aman Sharma
1cc00f77a4 Move core functionality to QuicTransportBaseLite [24/n]
Summary:
There are many files in this diff, but the relevant ones are:
* quic/api/QuicSocket.h
* quic/api/QuicSocketLite.h
* quic/api/QuicTransportBase.h
* quic/api/QuicTransportBaseLite.cpp
* quic/observer/SocketObserverContainer.h

The purpose of this is to include the observer functionality within the Lite class. Ideally, we'd remove it from the Lite class, but that's going to require some more detailed changes to the interfaces we're using, because observers are used quite a lot within common code (for example, AckHandlers.cpp).

I'll make those changes some time after the QuicTransportBase split, as they're going to take a while.

Reviewed By: jbeshay, mjoras, kvtsoy

Differential Revision: D65685667

fbshipit-source-id: feb07bcf35d6af2e5c2b538ff463b01b67c6aff9
2024-11-14 13:02:10 -08:00
Aman Sharma
d4cc0c2415 Move core functionality to QuicTransportBaseLite [22/n]
Summary: See title.

Reviewed By: hanidamlaj

Differential Revision: D65604620

fbshipit-source-id: 59557eabe841bbc2053f95bec227564f1272d8a6
2024-11-08 15:04:24 -08:00
Aman Sharma
a4247ec4d5 Move core functionality to QuicTransportBaseLite [21/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D65282152

fbshipit-source-id: 273a2df9aca0aa84b2e1137d99a473e02de0953b
2024-11-01 11:46:43 -07:00
Aman Sharma
384c39f862 Move core functionality to QuicTransportBaseLite [17/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64547922

fbshipit-source-id: fa1e7c22122062b468878a232f545ba1f2619925
2024-10-23 18:25:46 -07:00
Aman Sharma
6875e7cdf5 Move core functionality to QuicTransportBaseLite [16/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64546909

fbshipit-source-id: de8989a0c292dfa8ff05d943ffaee23f1e6923d3
2024-10-23 13:39:16 -07:00
Aman Sharma
520ae73630 Move core functionality to QuicTransportBaseLite [15/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64542784

fbshipit-source-id: a155c441b3d2cf0a8220e7ddebd94f0335cb9420
2024-10-23 10:02:08 -07:00
Aman Sharma
c1b9dcbb89 Move core functionality to QuicTransportBaseLite [14/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64342347

fbshipit-source-id: 721414fdca39f70d8902b3df5afb0fde0d171480
2024-10-16 12:40:37 -07:00
Aman Sharma
0882df9999 Move core functionality to QuicTransportBaseLite [13/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64342282

fbshipit-source-id: 93faad3e53b1aba27dae268fc690480acf27d705
2024-10-16 12:40:37 -07:00
Aman Sharma
40e0652725 Move core functionality to QuicTransportBaseLite [12/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64338559

fbshipit-source-id: 7c2c884e0c855c443874ab1b891bd285d24c4cf1
2024-10-16 12:40:37 -07:00
Aman Sharma
5c8a4463ea Move core functionality to QuicTransportBaseLite [11/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64185699

fbshipit-source-id: 7f79eeb4f1f1cf043b8e3e3a513f407c796dc51e
2024-10-14 11:58:31 -07:00
Aman Sharma
cfbdfda64b Move core functionality to QuicTransportBaseLite [10/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64065782

fbshipit-source-id: b0fb37e57b59ac6f28cf6f0b2d59d750a63398ca
2024-10-14 11:58:31 -07:00
Aman Sharma
9374a6b0e4 Move core functionality to QuicTransportBaseLite [9/n]
Summary: See title.

Reviewed By: kvtsoy

Differential Revision: D64065220

fbshipit-source-id: e027275d565ee8967de4eb4855475244bae334a0
2024-10-14 11:58:31 -07:00
Alan Frindell
a7fbe490ad Move QuicSocket callbacks outside of QuicSocket
Summary:
I have need of these in the proxygen WebTransport implementation, and don't want the full dependency on QuicSocket.

Also refactored WriteCallback into StreamWriteCallback and ConnWriteCallback, leaving the original WriteCallback as both for now.

Reviewed By: hanidamlaj

Differential Revision: D63486821

fbshipit-source-id: 4b16ad871c4deac4e262c12835ad5c457e9240da
2024-10-10 22:13:23 -07:00
Aman Sharma
c62dac180e Move core functionality to QuicTransportBaseLite [7/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D64065113

fbshipit-source-id: 31f9a29a88bf763156d42c49df9db0f6f8e1a9d0
2024-10-09 17:37:33 -07:00
Aman Sharma
7be7cfffb0 Move core functionality to QuicTransportBaseLite [5/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D63986096

fbshipit-source-id: 5543b943acf5397db3951186f50181e1c31b7e0b
2024-10-08 11:12:03 -07:00
Aman Sharma
e0e445ff01 Move core functionality to QuicTransportBaseLite [4/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D63984103

fbshipit-source-id: f21f3c4759dfa463319cefb7731c793c0fa9905d
2024-10-08 11:12:03 -07:00
Aman Sharma
5a9ebd333d Move core functionality to QuicTransportBaseLite [3/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D63917728

fbshipit-source-id: 4e5389c1747b59cf30fea37ed9e5802007f2e49b
2024-10-08 11:12:03 -07:00
Aman Sharma
e5c822b9d4 Move core functionality to QuicTransportBaseLite [2/n]
Summary: See title.

Reviewed By: mjoras

Differential Revision: D63914228

fbshipit-source-id: 3860b33688a4efe99374a55dde226b7ceaab8d2f
2024-10-08 11:12:03 -07:00
Aman Sharma
0b2743fdae Move core functionality to QuicTransportBaseLite [1/n]
Summary: See title

Reviewed By: mjoras

Differential Revision: D63860679

fbshipit-source-id: b7116792c2bf99a98f62d719febddd133cce94d5
2024-10-04 17:28:20 -07:00
Aman Sharma
0cab280fc4 Create a QuicSocketLite, QuicTransportBaseLite
Summary: See title

Reviewed By: mjoras

Differential Revision: D63785017

fbshipit-source-id: a72fde2f0e5304f3ce6f2d1653e482e2fe439602
2024-10-04 14:54:43 -07:00
Matt Joras
e903f277da Introduce OptionalIntegral and OptionalMicros
Summary: We have a lot of optionals that are either integral values or std::chrono::microseconds. These end up wasting memory, where we can instead store sentinel values to encode whether the value is there or not. This reduces the effective range of the type by one value, but that is an acceptable tradeoff.

Reviewed By: kvtsoy

Differential Revision: D57684368

fbshipit-source-id: b406b86011f9b8169b6e5e925265f4829928cc63
2024-06-11 11:02:02 -07:00
Matt Joras
aefc9e369b Introduce quic::Optional
Summary:
The idea here is to make it so we can swap out the type we are using for optionality. In the near term we are going to try swapping towards one that more aggressively tries to save size.

For now there is no functional change and this is just a big aliasing diff.

Reviewed By: sharmafb

Differential Revision: D57633896

fbshipit-source-id: 6eae5953d47395b390016e59cf9d639f3b6c8cfe
2024-06-11 11:02:02 -07:00
Konstantin Tsoy
58e57ebaf6 Make maxWritableOnConn() public
Summary: So client conn can be queried

Reviewed By: mjoras

Differential Revision: D56787895

fbshipit-source-id: fbd76aed35910e36075739d3e6f1775d6600c225
2024-05-02 00:59:53 -07:00
Matt Joras
d74250d7a6 Use CircularDeque in streams and datagram state.
Summary:
std::deque by default allocates a large block on the heap for managing its state. This has a fixed memory cost both per connection (because of the crypto streams) and per stream. CircularDeque by comparison does not have this overhead and is only 32 bytes per structure.

For example:
```
                          "size": 656,
                          "name": "readBuffer",
                          "typePath": ["a0", "conn_", "ptr_val", "cryptoState", "ptr_val", "initialStream", "readBuffer"],
                          "typeNames": ["std::deque<quic::StreamBuffer, std::allocator<quic::StreamBuffer>>"],
```
This should save about 6kB per connection with no streams, and additional memory per stream.

Reviewed By: jbeshay, hanidamlaj

Differential Revision: D56578219

fbshipit-source-id: ab2b529fa9a4169bea6862b11ccbf178c6f5abb1
2024-04-25 09:34:27 -07:00
Kyle Nekritz
5986d37294 Add getExportedKeyingMaterial to QuicSocket API.
Summary: This allows for applications to derive exported key material.

Reviewed By: hanidamlaj

Differential Revision: D55643408

fbshipit-source-id: 00a2bb7d050dc37ea5917d4b1f70bf9e0975de0c
2024-04-25 08:24:54 -07:00
Jake Bolam
3570f0122f Revert D56496459: Use CircularDeque in streams and datagram state.
Differential Revision:
D56496459

Original commit changeset: ec4049614939

Original Phabricator Diff: D56496459

fbshipit-source-id: 5b1ee6dcfe59ae2e62a6d818f5839d95d26d4431
2024-04-25 04:37:33 -07:00
Matt Joras
01690c4159 Use CircularDeque in streams and datagram state.
Summary:
std::deque by default allocates a large block on the heap for managing its state. This has a fixed memory cost both per connection (because of the crypto streams) and per stream. CircularDeque by comparison does not have this overhead and is only 32 bytes per structure.

For example:
```
                          "size": 656,
                          "name": "readBuffer",
                          "typePath": ["a0", "conn_", "ptr_val", "cryptoState", "ptr_val", "initialStream", "readBuffer"],
                          "typeNames": ["std::deque<quic::StreamBuffer, std::allocator<quic::StreamBuffer>>"],
```
This should save about 6kB per connection with no streams, and additional memory per stream.

Reviewed By: kvtsoy

Differential Revision: D56496459

fbshipit-source-id: ec4049614939f885f64481bd374c81e74ad47c66
2024-04-25 00:43:04 -07:00
Aman Sharma
875bca11da Make a getPeerTransportParams function
Summary: I'm putting this up to get some initial feedback. I'm writing a function to get the peer transport parameters so that we can get them in the HQSession and set the QUIC fingerprint.

Reviewed By: hanidamlaj

Differential Revision: D54399572

fbshipit-source-id: 594294c26a5b34bc99a8d286a66be9cdbe7fff02
2024-04-08 17:57:40 -07:00
Phillip Prigozhiy
08ad34b2d6 Add getSelfCertificate to QuicServerTransport
Summary: Adding virtual method getSelfCertificate to QuicSocket that's overriden in QuicServerTransport that returns the server cert.

Reviewed By: mjoras

Differential Revision: D54234662

fbshipit-source-id: fcef6399bc660ff41243336aacdfadd6e8975193
2024-03-12 12:10:49 -07:00
Joseph Beshay
e606de45db Add stream read/write errors to the StreamTransportInfo struct
Summary: As title.

Reviewed By: sharmafb

Differential Revision: D52678304

fbshipit-source-id: 3df2d588c40d40059141c72d0945d31b319b61f8
2024-01-11 19:35:07 -08:00
Joseph Beshay
ead139adef Move all mvfst use-cases to the new Eventbase, Timer, and Socket interfaces
Summary:
This is the major transition that updates mvfst code to use the new interfaces. The new Folly implementations of the interfaces maintain all the existing behavior of folly types so this should not introduce any functional change. The core changes are:
- Update the BatchWriters to use the new interfaces.
- Update the FunctionLooper to use the new interfaces.
- Change QuicServerTransport to take the folly types and wrap them in the new types for use in the QuicTransportBase.

The rest of the diff is for updating all the existing uses of the QuicTrasnport to initialize the necessary types and pass them to the QUIC transport instead of directly passing folly types.

Reviewed By: mjoras

Differential Revision: D51413481

fbshipit-source-id: 5ed607e12b9a52b96148ad9b4f8f43899655d936
2023-12-14 00:24:12 -08:00
Matt Joras
f7a59e8465 onStreamPreReaped
Summary: Move the callback to before the stream is destroyed.

Reviewed By: jbeshay

Differential Revision: D52127833

fbshipit-source-id: 1a9dbcf9ad92dbdb4e15409a418307dc6852b091
2023-12-13 11:19:53 -08:00
Matt Joras
9285422f2a Add onStreamPreReaped.
Summary: This is potentially useful to an application to know when the underlying stream state has been freed by the transport.

Reviewed By: jbeshay

Differential Revision: D52048888

fbshipit-source-id: e7b2d33c3702ce8aa348459a37094198d16af60f
2023-12-13 10:08:47 -08:00
Timm Böttger
5fca38ef00 Use MaybeManagedPtr for QuickSocket for optional lifetime management
Summary:
`connSetupCallback_` and `connCallback_` in `QuicTransportBase.h` are raw pointers, which delegates the responsibility to keep these callbacks alive to the caller.

There are use cases where it would be convenient to be able to tie the lifetime of the callback to the Quic transport, e.g,. as long as the Quic transport is alive, it keeps the callbacks alive as well.

This diff uses MaybeManagedPtr to achieve this lifetime tie if desired. A MaybeManagedPtr intialized with a shared pointer manages lifetime of the contained object, whereas a MaybeManagedPtr initialized with a raw pointer does not manage lifetime of the contained object. This way caller can decide to pass in a shared ptr or raw pointer and achieve the desired behavior.

Note that we cannot simply use a shared_ptr for that. Using a shared_ptr would potentially mean that callbacks passed are destroyed when the transport is destroyed. Callbacks would not be destroyed if they were managed by a shared_ptr already, but this is something we cannot assume for every case. This would thus be a change in semantics to the current implementation, where the callbacks can outlive the transport.

Reviewed By: mjoras

Differential Revision: D49502381

fbshipit-source-id: 771a9328b99dc4f94f8e9679f9caf98af9180428
2023-11-03 09:37:21 -07:00
Brandon Schlinker
a1445434b0 Cleanup and modularize receive path, improve timestamp support [5/x]
Summary:
This diff changes `QuicAsyncUDPSocketWrapper` so that it is an abstraction layer that inherits from `QuicAsyncUDPSocketType`, instead of simply being a container with aliases.
- Key changes in `QuicAsyncUDPSocketWrapper.h`, the rest of the updates switch us from using `QuicAsyncUDPSocketType` to `QuicAsyncUDPSocketWrapper`.
- It's difficult to mock the UDP socket today given that we expose the entire `folly::AsyncUDPSocket` type to the higher layers of the QUIC stack. This complicates testing and emulation because any mock / fake has to implement low level primitives like `recvmmsg`, and because the `folly::AsyncUDPSocket` interface can change over time.
- Pure virtual functions will be defined in `QuicAsyncUDPSocketWrapper` in a follow up diff to start creating an interface between the higher layers of the mvfst QUIC stack and the UDP socket, and this interface will abstract away lower layer details such as `cmsgs` and `io_vec`, and instead focus on populating higher layer structures such as `NetworkData` and `ReceivedPacket` (D48714615). This will make it easier for us to mock or fake the UDP socket.

This diff relies on changes to `folly::MockAsyncUDPSocket` introduced in D48717389.

--

This diff is part of a larger stack focused on the following:

- **Cleaning up client and server UDP packet receive paths while improving testability.** We currently have multiple receive paths for client and server. Capabilities vary significantly and there are few tests. For instance:
  - The server receive path supports socket RX timestamps, abet incorrectly in that it does not store timestamp per packet. In comparison, the client receive path does not currently support socket RX timestamps, although the code in `QuicClientTransport::recvmsg` and `QuicClientTransport::recvmmsg` makes reference to socket RX timestamps, making it confusing to understand the capabilities available when tracing through the code. This complicates the tests in `QuicTypedTransportTests`, as we have to disable test logic that depends on socket RX timestamps for client tests.
  - The client currently has three receive paths, and none of them are well tested.

- **Modularize and abstract components in the receive path.** This will make it easier to mock/fake the UDP socket and network layers.
  - `QuicClientTransport` and `QuicServerTransport` currently contain UDP socket handling logic that operates over lower layer primitives such `cmsg` and `io_vec` (see `QuicClientTransport::recvmmsg` and `...::recvmsg` as examples).
  - Because this UDP socket handling logic is inside of the mvfst transport implementations, it is difficult to test this logic in isolation and mock/fake the underlying socket and network layers. For instance, injecting a user space network emulator that operates at the socket layer would require faking `folly::AsyncUDPSocket`, which is non-trivial given that `AsyncUDPSocket` does not abstract away intricacies arising from the aforementioned lower layer primitives.
  - By shifting this logic into an intermediate layer between the transport and the underlying UDP socket, it will be easier to mock out the UDP socket layer when testing functionality at higher layers, and inject fake components when we want to emulate the network between a mvfst client and server. It will also be easier for us to have unit tests focused on testing interactions between the UDP socket implementation and this intermediate layer.

- **Improving receive path timestamping.** We only record a single timestamp per `NetworkData` at the moment, but (1) it is possible for a `NetworkData` to have multiple packets, each with their own timestamps, and (2) we should be able to record both userspace and socket timestamps.

Reviewed By: jbeshay, hanidamlaj

Differential Revision: D48717388

fbshipit-source-id: 4f34182a69ab1e619e454da19e357a6a2ee2b9ab
2023-09-21 07:57:58 -07:00
Ashkan Nikravesh
4862982004 throttling-detector: create an interface to provide throttling signals to CCAs
Summary: An interface which will be extended by throttling detectors and will provide throttling signal to CCAs. This interface can be set through `QuicSocket` and can be accessed via `QuicConnectionStateBase`.

Reviewed By: silver23arrow, jbeshay

Differential Revision: D47027498

fbshipit-source-id: 6a2b9ee51ca54395e10500dd7c9787968cc281d4
2023-08-30 17:01:06 -07:00
Christian Clauss
b8396fc119 Fix typos discovered by codespell
Summary:
`codespell --ignore-words-list=arithmetics,atleast,crate,crated,deriver,ect,hel,onl,startin,whats --skip="*.lock"`
* https://pypi.org/project/codespell

X-link: https://github.com/facebookincubator/mvfst/pull/307

Reviewed By: hanidamlaj, lnicco

Differential Revision: D47809078

Pulled By: kvtsoy

fbshipit-source-id: 566557f2389746db541ff265a5dec8d6404b3701
2023-07-26 17:10:41 -07:00
Konstantin Tsoy
73edee8252 Back out "Fix typos discovered by codespell"
Summary:
Original commit changeset: 337824bc37bc

Original Phabricator Diff: D47722462

Reviewed By: jbeshay, terrelln, lnicco

Differential Revision: D47801753

fbshipit-source-id: 795ffcccbc2223608e2a707ec2e5bcc7dd974eb3
2023-07-26 12:49:13 -07:00
Facebook Community Bot
9d89b66485 Re-sync with internal repository 2023-07-25 09:45:22 -07:00
Konstantin Tsoy
08aba67f8b Rename a few headers
Summary:
And add comments to the new events classes.

Old naming:
```
Events.h/cpp
  -> EventsMobile.h/cpp
```

New naming:
```
QuicEventBase.h/cpp
  -> QuicLibevEventBase.h/cpp
```

Reviewed By: hanidamlaj, mjoras

Differential Revision: D47140799

fbshipit-source-id: 6a25e76c454b0f8468d830feb4dfd99c1576c8b8
2023-07-13 18:39:45 -07:00
Konstantin Tsoy
401f72867a Use QuicBackingEventBase instead of folly::EventBase
Summary: Use QuicBackingEventBase instead of folly::EventBase

Reviewed By: mjoras

Differential Revision: D47135548

fbshipit-source-id: c779d66a044bddb61586e2603a7d4bb4e96ac1a0
2023-07-13 18:39:45 -07:00
Konstantin Tsoy
4a0dd1e2a4 QuicAsyncUDPSocketWrapper
Reviewed By: jbeshay

Differential Revision: D46379200

fbshipit-source-id: f6a7c1cf68108872e05e6fd8adb7f00aae22b2ed
2023-07-11 15:21:15 -07:00
Hani Damlaj
c88d675119 fix gcc warnings
Summary: - add folly::unreachable() statements where applicable

Reviewed By: mjoras

Differential Revision: D46911632

fbshipit-source-id: 22b337f4c255e973da19cc15cc928c847091472b
2023-06-26 18:59:24 -07:00
Crystal Jin
0fd6ba7f78 Use finalWriteOffset for stream bytes sent
Reviewed By: JunqiWang

Differential Revision: D46663584

fbshipit-source-id: 1b22eb90501a9b904c17818991d01e5a0fbf2734
2023-06-13 08:16:16 -07:00
Konstantin Tsoy
fdedffa855 QuicEventBase
Summary:
A wrapper for `folly::EventBase` to be used throughout mvfst library.
Right now it's simply a `using QuicEventBase = folly::EventBase` in the new `quic/common/Events.h`, so no functional changes.

The change to the wrapper usage is constrained to QuicTransportBase and the code around for now - basically excluding top level client and server code that is still using `folly::EventBase` directly.

Subsequent changes will introduce a proper wrapper implementation getting rid of `using QuicEventBase = folly::EventBase` in the new class.

Reviewed By: mjoras

Differential Revision: D44757549

fbshipit-source-id: 5a0dd120ec319a474452eaec64a27f660144acdf
2023-05-23 14:16:15 -07:00
Joseph Beshay
a55b14d0f0 Rename QUIC lossbyPto to lossByTimeout to avoid confusion with PTO (probe timeout)
Summary: Classifying loss as `byPto` is confusing because it is not related to Probe Timeouts (PTO). This changes the occurrences of this name in the transport code to `byTimeout`.

Reviewed By: mjoras, kvtsoy

Differential Revision: D45788216

fbshipit-source-id: 9900b928d3f44572a21d6ed7e76be658e21451c7
2023-05-16 12:37:47 -07:00
Paul Farcasanu
e56d4bd7f6 refactor setStreamPriority to accept Priority struct
Summary:
## Context
Context: see summary for D43854603.

## In this diff
In this diff, make way for easily adding new elements to Priority struct.

Reviewed By: afrind

Differential Revision: D43882907

fbshipit-source-id: f74f6ec41162a970dcd666bfa5192676f968d740
2023-03-28 16:00:38 -07:00
Crystal Jin
b78833805a Expose stream bytes received in StreamTransportInfo
Reviewed By: hanidamlaj

Differential Revision:
D43921381

Privacy Context Container: L1127813

fbshipit-source-id: f2e659c602e792b27617b75e1eb1f4d9841138f9
2023-03-09 11:09:02 -08:00
Crystal Jin
9dab1046b1 Propagate stream bytes sent up stack for logging
Reviewed By: hanidamlaj

Differential Revision:
D43852121

Privacy Context Container: L1071327

fbshipit-source-id: 7cc94ac52667d1757cb1d0aa150ccbc6562eaf09
2023-03-08 15:39:11 -08:00
Hani Damlaj
f04fb4a58d document semantics of stream reaping
Summary:
Eventually we'd like to replace mvfst's policy on how/when streams are reaped.

Currently, streams are reaped when we deliver eof to callback or callback is uninstalled via `setReadCallback(id, nullptr)`. We're working on removing the eof delivered to callback as a predicate to reaping streams.

Reviewed By: mjoras

Differential Revision: D43544949

fbshipit-source-id: 7ef84aefe702ae8686ccb95265a25060830b7013
2023-03-03 05:39:57 -08:00