1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-09 20:42:44 +03:00
Commit Graph

145 Commits

Author SHA1 Message Date
Konstantin Tsoy
b51ee87995 Add idle timer checker
Reviewed By: mjoras

Differential Revision: D60913168

fbshipit-source-id: 1b14a2e17545ba24f879e7212153eee19cfe9972
2024-08-07 18:55:45 -07:00
Aman Sharma
55bf4a2d27 Move DSR-related APIs to QuicServerTransport
Reviewed By: mjoras

Differential Revision: D59768195

fbshipit-source-id: 8f0780019e5cd9bc3a3863fe30140b8da160c0bc
2024-07-31 10:48:06 -07:00
Giuseppe Ottaviano
cd4268b8f8 IOBuf moveToFbString().toStdString() -> to<std::string>()
Summary: Constructing an `fbstring` from an `IOBuf` and then converting that to `std::string` is inefficient: if the `IOBuf` is chained, that can end up copying the data twice. `to<std::string>()` does exactly one copy.

Reviewed By: mjoras

Differential Revision: D58379802

fbshipit-source-id: a1094dd63ae00fc123e0d695a800a017004562e9
2024-06-12 12:03:12 -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
c34e6eb1e0 Check that transport is still open in maybeStopWriteLooperAndArmSocketWritableEvent();
Summary: We can throw in `writeSocketDataAndCatch()` and that would result in transport closure with drain (with drain keeping the socket alive), but the congestion controller would be reset in close: https://fburl.com/code/zxwfye5u and `maybeStopWriteLooperAndArmSocketWritableEvent()` trips over it later when executed in scope exit.

Reviewed By: mjoras

Differential Revision: D57728369

fbshipit-source-id: 51a4719ae97fab0e90e3ae093a3f56be5a096aff
2024-05-23 11:09:34 -07:00
Joseph Beshay
71b8af4b1a Add new batch writer SinglePacketBackpressureBatchWriter to retry failed writes
Summary:
The existing batch writers do not handle failed writes to the AsyncUDPSocket. A packet that fails to be written is detected as a packet loss later when feedback is received from the peer. This negatively impacts the congestion controller because of the fake loss signal, and artificially inflates the number of retransmitted packets/bytes.

This change adds a new batch writer (SinglePacketBackpressuretBatchWriter) that retains the buffers when a write fails. For subsequent writes, the writer retries the same buffer. No new packets are scheduled until the retried buffer succeeds.

Notes:
- To make sure that retry writes are scheduled, the write callback is installed on the socket when a buffer needs to be retried.
- The retries are for an already scheduled packet. The connection state reflects the timing of the first attempt. This could still have an impact on rtt samples, etc. but it this is a milder impact compared to fake losses/retranmissions.
- Any changes outside of the batch writer only impact the new batch writer. Existing batch writers do not use the fields and are not affected by the changes in this diff.

Reviewed By: kvtsoy

Differential Revision: D57597576

fbshipit-source-id: 9476d71ce52e383c5946466f64bb5eecd4f5d549
2024-05-22 15:35:32 -07:00
Konstantin Tsoy
bc6f00a4f0 Use writable events on the socket
Summary: Use writable events on the socket (disabled by default)

Reviewed By: jbeshay

Differential Revision: D56305786

fbshipit-source-id: f04dea326587268c96915f7a39338ff21dee4aec
2024-05-21 20:06:29 -07:00
Joseph Beshay
3eef6d0e55 Add ToS field to ReceivedUdpPacket
Summary: Adds new field `tosValue` to  ReceivedUdpPacket so it is accessible in the rest of the read path.

Reviewed By: kvtsoy

Differential Revision: D54912161

fbshipit-source-id: ea4714fa2374d38e915fc850387e1094d1fb8adf
2024-05-15 11:51:15 -07:00
Joseph Beshay
7f2cb16408 Refactor QuicClient and Server transports to process ReceivedUdpPackets with attached metadata
Summary: ReceivedUdpPacket has attached metadata (currently timings and later in the stack, tos values). Rather than passing the metadata separately in the read path for the client and the server, this propagates the ReceivedUdpPacket further up so this metadata is easier to use in the rest of the stack.

Reviewed By: mjoras

Differential Revision: D54912162

fbshipit-source-id: c980d5b276704f5bba780ac16a380bbb4e5bedad
2024-05-09 11:05:32 -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
Vadim Meleshuk
16501032fa Add open_streams metric
Summary: I want to have visibility in to the current count of streams. There are already callback methods onNew/onClosed, unfortunately, the latter is not called when connections are closed, so I had to fix that to prevent the metric from uncontrolled growth. I am still not positive it's correct and was thinking of hooking into QuicStreamState destructor instead.

Reviewed By: kvtsoy

Differential Revision: D56195487

fbshipit-source-id: 901bce9473327a8f7ef1bc0f70af10899784d681
2024-04-24 19:39:14 -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
Joseph Beshay
96b65104dc Move QuicEventBase and QuicTimer callback operations back to the Callbacks themselves.
Summary:
This moves all the loop and timer callback operations back to the callbacks instead of relying the QuicEventBase to perform them. I.e. it's now Callback::cancelCallback() instead of QuicEventBase::cancelCallback(&callback).

To simplify the design, the lifetime of LoopCallbackWrapper and TimerCallbackWrapper has been changed. Previously these wrappers lasted for one iteration of the loop or the timer callback. In the new design the wrapper is created the first time the callback is scheduled and is only destroyed when the callback is destroyed. This significantly simplifies the lifetime management of the wrapper and the code overall.

While transitioning LibevQuicEventBase to this new design, this change also consolidates the QuicTimer functionality in the LibevQuicEventBase itself.

Reviewed By: hanidamlaj, mjoras

Differential Revision: D52217879

fbshipit-source-id: da7b95d592650ddc112813fdc3b9f5010d32e7fb
2024-01-03 12:38:20 -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
Brandon Schlinker
83ad2ad99d Cleanup and modularize receive path, improve timestamp support [20/x]
Summary:
This diff renames `ReceivedPacket` to `ReceivedUdpPacket` to clarify that it maps to a UDP packet and not a QUIC packet. A single UDP packet can contain multiple QUIC packets due to coalescing.

--

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: silver23arrow

Differential Revision: D48788809

fbshipit-source-id: 3793c30212d545e226f3e5337289bc2601dfa553
2023-11-28 07:47:57 -08:00
Brandon Schlinker
04facac67d Cleanup and modularize receive path, improve timestamp support [15/x]
Summary:
This diff drops `NetworkDataSingle` in favor of `ReceivedPacket`. The latter contains a `ReceivedPacket::Timings` field that has the same `receiveTimePoint` currently in `NetworkDataSingle`, while also providing other useful signals.

--

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: silver23arrow

Differential Revision: D48739219

fbshipit-source-id: fc2cdb7b425d68c729dd3bec00b6c6ff3c4bf8ec
2023-11-05 19:58:46 -08:00
Brandon Schlinker
05b98a99db Cleanup and modularize receive path, improve timestamp support [11/x]
Summary:
This diff:
1. Introduces a new `ReceivedPacket::Timings` structure, which will be expanded upon in subsequent diffs.
2. Adds a `ReceivedPacket::Timings` field to each `ReceivedPacket`
3. Uses the accessors added in the previous diff (D48724715) to populate the `ReceivedPacket::Timings` structure in each `ReceivedPacket` held by a `NetworkData` object. This is done by propagating the `NetworkData::receiveTimePoint` field to all `ReceivedPacket` held in a `NetworkData.` This propagation occurs each time a `ReceivedPacket` is added. The value is propagated again if the `NetworkData::receiveTimePoint` field is updated by looping over all previously added `ReceivedPacket`.

--

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

Differential Revision: D48725209

fbshipit-source-id: 580e7d7d1f3587f9947774b5ed19e9985df404c9
2023-11-05 19:58:46 -08:00
Andrii Vasylevskyi
c0e008c266 Folly SocketOptionMap with strings - separate cmsgs
Summary: Splitting cmgs from socket options.

Reviewed By: mjoras

Differential Revision: D49557451

fbshipit-source-id: fa3005170d049557d1c845fd14b0ada73b58b377
2023-10-01 11:33:09 -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
Brandon Schlinker
086822ca76 Cleanup and modularize receive path, improve timestamp support [2/x]
Summary:
This diff:
- Changes `NetworkDataSingle` to have `ReceivedPacket` instead of `Buf`, in line with earlier change to `NetworkData` in D48714615

--

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: mjoras

Differential Revision: D48714796

fbshipit-source-id: d96c2abc81e7c27a01bcd0dd552f274a0c1ede26
2023-09-21 07:57:58 -07:00
Konstantin Tsoy
264bf20d9a Update flow control settings names to reflect that these are indeed flow
Summary: Update flow control settings names to reflect that these are indeed flow control

Reviewed By: jbeshay

Differential Revision: D48137685

fbshipit-source-id: a48372e21cdd529480e25785a9bd5de456427ef3
2023-08-18 10:21:24 -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
fe12ab7241 Hide direct timer invocations on the event base into the wrapper
Summary: Needed for future libev-based event base impl.

Reviewed By: hanidamlaj

Differential Revision: D46670916

fbshipit-source-id: 55740ed05da9c1f54cc8639ece89d1f21aaff0d3
2023-07-12 17:26:15 -07:00
Konstantin Tsoy
4a0dd1e2a4 QuicAsyncUDPSocketWrapper
Reviewed By: jbeshay

Differential Revision: D46379200

fbshipit-source-id: f6a7c1cf68108872e05e6fd8adb7f00aae22b2ed
2023-07-11 15:21:15 -07:00
Konstantin Tsoy
dccfc706b5 QuicEventBase wrapper
Summary:
Create and use an actual wrapper around folly::EventBase.
Later an interface will be added that the wrapper will be implementing.

Reviewed By: jbeshay

Differential Revision: D45822401

fbshipit-source-id: 3b33f796c31043ec2881b753a9b60943bdf91f1d
2023-06-15 17:12:24 -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
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
Luca Niccolini
93096fc8b9 use uint32 for max Datagram size
Reviewed By: hanidamlaj

Differential Revision: D44080220

fbshipit-source-id: e84c2e3718f7d06fd245770855c8cdc05f49bd86
2023-03-15 02:02:59 -07:00
Konstantin Tsoy
aa0fd83223 Implement setStreamGroupRtxPolicy()
Summary: Implement setStreamGroupRtxPolicy()

Reviewed By: mjoras

Differential Revision: D39698378

fbshipit-source-id: c6fc5a9a9ab7f322775565f6df629103b36b2a36
2023-02-23 21:31:24 -08:00
Konstantin Tsoy
b4cb994fd8 Add enableCustomRetransmissionPolicies()
Summary: Add enableCustomRetransmissionPolicies()

Reviewed By: mjoras

Differential Revision: D39658775

fbshipit-source-id: 1413e6a3112e406222df4ce54e6036f518432a82
2023-02-23 21:31:24 -08:00
Joseph Beshay
b801d9b61d Update naming of maxStreamGroupsAdvertized to match that of similar variables
Summary: This is a cosmetic change to make the naming consistent for all the advertised* variables in the transport settings.

Reviewed By: sharmafb

Differential Revision: D42465443

fbshipit-source-id: d570cbb1a2ca017105ac335b8efc404cb73f3c57
2023-01-26 12:22:38 -08:00
Matt Joras
1275798146 Make the AckState for Initial/Handshake a unique_ptr
Summary:
We don't need to carry these states after the handshake is confirmed, so make them pointers instead. This will facilitate adding a structure to the AckState for tracking duplicate packets.

(Note: this ignores all push blocking failures!)

Reviewed By: hanidamlaj

Differential Revision: D41626895

fbshipit-source-id: d8ac960b3672b9bb9adaaececa53a1203ec801e0
2022-12-20 11:08:43 -08:00
Hani Damlaj
c22ee0a8ab StopSending Closes Ingress
Summary: - transport settings to enable the following behaviour: invoking stopSending() now drops buffered ingress data and closes the ingress path

Reviewed By: mjoras

Differential Revision: D40678864

fbshipit-source-id: 7dd5c7843909d5ac8cc309292b31d1d87b97a2f5
2022-11-14 18:06:47 -08:00
Hani Damlaj
e1f8e0df1d No-op StopSending If Ingress Closed
Summary: - as title, we should just no-op ::StopSending when ingress is already closed

Reviewed By: jbeshay, mjoras

Differential Revision: D40990383

fbshipit-source-id: e0cd64facf78f510eabe8198e93a643c6ebfb89e
2022-11-04 19:00:24 -07:00
Konstantin Tsoy
bad5e085ba Enable more tests for Windows
Summary: Enable more tests for Windows

Reviewed By: mjoras

Differential Revision: D39595126

fbshipit-source-id: 702d243ff7fbb5ffdb18af2dd1d13c184599ef75
2022-09-20 21:01:48 -07:00
Brandon Schlinker
5b8e0de5bd Improve transport close handling and observability
Summary:
The current `close` observer event marks when `closeImpl` is called. However, the actual close of the socket may be delayed for some time while the socket drains. I've changed the existing event to `closeStarted` and added a new event `closing` that marks the close of the underlying `AsyncUDPSocket`.

Adding the `closeStarted` event required two other changes which are difficult to separate from this diff:
- When a transport is destroyed, `QuicTransportBase` was calling `closeImpl` and also closing the UDP socket. However, because the `folly::ObserverContainer` used to store observers is maintained in classes that derive from `QuicTransportBase`, the observers are gone by the time the UDP socket is closed in the base class destructor. Thus, the UDP socket should be closed by the derived classes in their respective destructors. This requirement is inline with the existing code: `closeImpl` is called by all derived classes in their destructors. Made this change and added `DCHECK` statements in the `QuicTransportBase` destructor to ensure that derived classes cleanup after themselves.
- Writing tests with draining enabled and disabled required being able to set the transport settings. However, all of the existing `QuicTypedTransportTest` test cases were designed to operate after the connection was accepted (for the server impls) or established (for client impls), and transport settings cannot be updated at this state. Resolving this required adding new test classes in which the accept/connect operation is delayed until requested by the test.

Reviewed By: mjoras

Differential Revision: D39249604

fbshipit-source-id: 0ebf8b719c4d3b01d4f9509cf2b9a4fc72c2e737
2022-09-10 10:39:11 -07:00
Brandon Schlinker
82d7ea9972 Support shared_ptr based observers
Summary: As titled, enables `QuicSocket` to support observers that are managed pointers. The underlying support for this was added to `folly::ObserverContainer` in D35455208.

Differential Revision: D36921806

fbshipit-source-id: 0ed710977d08866ae32ed7231101c6de163aecf3
2022-08-16 09:24:21 -07:00
Konstantin Tsoy
e208ceffdd Implement group streams receiver api in transport
Summary: Implement group streams receiver api in transport

Reviewed By: mjoras

Differential Revision: D36419901

fbshipit-source-id: 98bfefa1a4205fde8764f2e4300f51156667e024
2022-06-06 17:11:39 -07:00
Konstantin Tsoy
e66b3b25cb Add a flag to notify user on new streams explicitly
Summary:
Current behavior is to create streams "lazily", that is pre-allocate stream ids that are lower than the stream id received in stream frame, even though we have not seen the lower streams yet. The `onNew(Bi|Uni)directionalStream()` callbacks are also raised implicitly, that is on lower stream ids pre-allocation, instead of when we actually get a stream frame with those lower ids.

With the new flag the callbacks will be raised to the user on actual arrival of the frame with the stream id on the wire.

Reviewed By: mjoras

Differential Revision: D36465978

fbshipit-source-id: 91faaadaad106a2bf62348c8fe8f00b3d7c61c2c
2022-05-19 20:01:28 -07:00
Brandon Schlinker
744ae1f78e Use folly::ObserverContainer for socket observer [4/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Changes `LegacyObserver` to inherit from the new `Observer` class by adding a compatibility layer. This compatibility layer enables existing observers to continue to be supported.
- Changes generation of observer events so that they are routed through `ObserverContainer::invokeInterfaceMethod`
- Temporarily removes some of the reentrancy protection that previously existed, as it was not being applied consistently — some events had reentrancy protection, some did not. This will be reintroduced in the next diff.
- Improves some unit tests for observers during the transition process.

Differential Revision: D35268271

fbshipit-source-id: 5731c8a9aa8da8a2da1dd23d093e5f2e1a692653
2022-04-18 04:19:31 -07:00
Brandon Schlinker
ea056eb960 Use folly::ObserverContainer for socket observer [2/x]
Summary:
This diff is part of larger change to switch to using `folly::ObserverContainer` (introduced in D27062840).

This diff:
- Renames `quic::Observer` to `quic::LegacyObserver`.
- Switches to using `quic::SocketObserverInterface` instead of `quic::Observer` when referencing structures used for the observer interface. For instance, `quic::Observer::WriteEvent` changes to `quic::SocketObserverInterface::WriteEvent`.

Differential Revision: D35000152

fbshipit-source-id: f387231fd58e8e763c3d7ed0a9c6fcec3b2324e2
2022-04-18 04:19:31 -07:00
Richard Barnes
e27b107c6a use gmock 1.10 instead of 1.8
Summary: See D34622171 for details

Differential Revision: D34688142

fbshipit-source-id: ec0c3fdd92723629e0c484388b9ae24436780cf9
2022-03-07 20:03:35 -08:00
Gilson Takaasi Gil
7f2f302f96 Revert D34351084: Migrate from googletest 1.8 to googletest 1.10
Differential Revision:
D34351084 (715dec85be)

Original commit changeset: 939b3985ab63

Original Phabricator Diff: D34351084 (715dec85be)

fbshipit-source-id: 2fd17e0ccd9d1f1d643f4a372d84cb95f5add1f8
2022-03-03 04:41:46 -08:00
Dimitri Bouche
715dec85be Migrate from googletest 1.8 to googletest 1.10 (#67)
Summary:
X-link: https://github.com/facebookincubator/hsthrift/pull/67

Updating `googletest` from `1.8.0` to `1.10.0`

Reviewed By: mzlee, igorsugak, luciang, meyering, r-barnes

Differential Revision: D34351084

fbshipit-source-id: 939b3985ab63a06b6d511ec8711c2d5863bdfea8
2022-03-03 03:46:03 -08:00
Konstantin Tsoy
a70ffbeb29 Rename ConnectionCallbackNew back to ConnectionCallback
Summary: Rename ConnectionCallbackNew back to ConnectionCallback

Reviewed By: mjoras

Differential Revision: D33979956

fbshipit-source-id: 6c133a406c4bf6799838ffc36701267a938cb4a3
2022-02-23 12:57:31 -08:00