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

53 Commits

Author SHA1 Message Date
Matt Joras
4208ad861e Stats for QuicVersion
Summary: It is useful to know at what frequency we are receiving each version.

Reviewed By: yangchi

Differential Revision: D22071299

fbshipit-source-id: 1e6f909d2b3a65cf54decc35f7e2e321d0ff8f24
2020-06-16 17:05:41 -07:00
Yang Chi
69a9e94252 StatelessReset parsing fix
Summary:
(1) Only read out the token if the parsing host is a client and the
token matches client's token
(2) More fallbacks to Stateless reset when parsing short header packet. The
only exception would be when we don't have 1-rtt cipher.

Reviewed By: mjoras

Differential Revision: D21868631

fbshipit-source-id: 159edf7ab21061ddd5a5ef17f6b18209c3de24e7
2020-06-03 17:44:58 -07:00
Matt Joras
30bff94e85 Introduce new connection rate limits.
Summary:
This introduces a rate limit to new connections created by a worker.

Right now it will simply send a VN, but eventually this will only issue a RETRY for unverified initials.

Reviewed By: udippant

Differential Revision: D21614905

fbshipit-source-id: 1832fbdad525c53fb1cb810aa9d7bae868c267d6
2020-05-18 16:40:43 -07:00
Yang Chi
1f0f29c2bb Fallback to chained memory data path if the batching mode isn't GSO
Summary: safety check, in case someone passes in a bad config

Reviewed By: mjoras

Differential Revision: D21383830

fbshipit-source-id: 60ab9e9e350855d6013c39590fb5c0d4a8e4f1ef
2020-05-07 10:56:26 -07:00
Yang Chi
cd7339e454 Give caller some control over if writeStreamFrameHeader should write length
Summary:
Becuase when we clone an existing packet, the logic inside the current
writetStreamFrameHeader is no longer correct.

Reviewed By: mjoras

Differential Revision: D21383828

fbshipit-source-id: 8e6bbb048eefd97ca7cf17b89edc2f395f274a73
2020-05-07 10:56:26 -07:00
Matt Joras
989352e12f Back out "avoid unnecessary userspace routing of packets"
Summary: As in title.

Reviewed By: lnicco

Differential Revision: D21337477

fbshipit-source-id: 6fa71a638172a9b017170ec2f8c6c6639a6e1d3d
2020-04-30 18:58:36 -07:00
Yang Chi
2a1529068d Move Quic packet header encoding out of builder constructor
Summary:
Currently the packet builder contructor will encode the packet
builder. This is fine when the builder creates its own output buffer. If later
on we decides not to use this builder, or it fails to build packet, the buffer
will be thrown away. But once the builder uses a buffer provided by caller, and
will be reused, we can no longer just throw it away if we decide not to use
this builder. So we have to delay the header encoding until we know we will use
the builder.

This is still not enough to solve the case where we want to use this builder,
it builds, then it fails . For that, we will need to retreat the tail position
of the IOBuf.

Reviewed By: mjoras

Differential Revision: D21000658

fbshipit-source-id: 4d758b3e260463b17c870618ba68bd4b898a7d4c
2020-04-28 22:14:21 -07:00
Yang Chi
081b63ffce Give QuicServerWorker an output buffer for GSO write with continuous memory
Summary: as title

Reviewed By: mjoras

Differential Revision: D20919833

fbshipit-source-id: 8cd9674d7bccf115cbdac5b976ba70e5dcb70e14
2020-04-28 22:14:20 -07:00
Udip Pant
1b57db5da4 avoid unnecessary userspace routing of packets
Summary:
for initial or zero-rtt packets, or in the case of short-header packets, if the
worker-id already matches, we do not need to do any userspace routing of
packets.

Reviewed By: mjoras

Differential Revision: D21219335

fbshipit-source-id: 988614530960a621a02c0375f4a507b333f66e69
2020-04-24 11:49:55 -07:00
Luca Niccolini
5ca21a5278 rename infoCallback to statsCallback
Summary:
```
find ./quic | xargs -I{} sed -i "s/infoCallback/statsCallback/g" {}
find ./quic | xargs -I{} sed -i "s/InfoCallback/StatsCallback/g" {}
```

(Note: this ignores all push blocking failures!)

Reviewed By: mjoras

Differential Revision: D20860675

fbshipit-source-id: 4fe99a375b5983da51b6727d7f40788f89083ab3
2020-04-11 11:16:51 -07:00
Luca Niccolini
f7d2680483 QuicStatsFactory does not depend on evb
Summary: cleanup unused extra argument

Reviewed By: dddmello

Differential Revision: D20884241

fbshipit-source-id: 5de241e5cff0c79b13f170f5764cb8c62dd4eeab
2020-04-08 14:40:07 -07:00
Yang Chi
59a394e8f5 New Quic packet drop reason for the case TransportFactory refuses to create
Summary: as title

Reviewed By: mjoras

Differential Revision: D20629105

fbshipit-source-id: b156a03055dbe2c665aac51d924fd024ebf4e9b7
2020-03-31 00:04:43 -07:00
Yedidya Feldblum
ace2cc78a6 Unqualify uses of folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams
Summary: Unqualify nearly all uses of `folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams` since nearly all uses already have `OnDataAvailableParams` in scope.

Differential Revision: D20450063

fbshipit-source-id: c0fd49a7eace44a6edc8086762c44753224788dd
2020-03-16 02:57:30 -07:00
Dan Melnic
ba5ef797a5 Add UDP GRO support
Summary: Add UDP GRO support

Reviewed By: mjoras

Differential Revision: D20347326

fbshipit-source-id: be3c31f070c4f2c1ef84f9e2df60f49a5fcabd93
2020-03-13 10:12:22 -07:00
Yang Chi
9cea11f2bd QuicServerWorker rejects CID already present in CID Map
Summary:
The CID Algo can possibly generate a CID that's already in the map.
This diff adds a mechanism to reject such CID and try another one.
ServerStateMachine will loop encoding CIDs until either QuicServerWorker no
longer rejects, or encode fails

Reviewed By: udippant, vchynarov

Differential Revision: D20251043

fbshipit-source-id: a38e4e8b33007779a9710c32057d47f32f7d1774
2020-03-09 16:06:22 -07:00
TJ Yin
a396f62335 Replace folly::Optional::hasValue() by has_value()
Differential Revision: D19882830

fbshipit-source-id: 031217f9890351022bc8d171f0ccd7e045dd6972
2020-02-26 08:40:44 -08:00
Yang Chi
85117a7339 new quic stats callback for incoming client initials
Summary: as title

Reviewed By: lnicco

Differential Revision: D20104477

fbshipit-source-id: da43366447cfbd17d9e635f07c06b893e7138ea2
2020-02-25 19:02:59 -08:00
Yang Chi
04e487dc71 Move MockQuicStates to quic/state/test directory
Summary:
our convention has always been to put the mock in the test dir under
the real class

Reviewed By: lnicco

Differential Revision: D20104476

fbshipit-source-id: 5215ffc9af7a6d7a5ac41109723a71f68f852af7
2020-02-25 19:02:59 -08:00
Yang Chi
76de6e15c0 Workaround lack of const noexept support in public GMock for Quic ConnIdAlgo
Summary: 9 years and counting since c++11 is a thing.

Reviewed By: mjoras

Differential Revision: D20068892

fbshipit-source-id: e9d486d588481232de9dac5eb8e4f0b8dbf38bb6
2020-02-24 15:16:45 -08:00
Matt Joras
6827637d45 Use NiceMock in more tests
Summary: When we don't use NiceMock we end up with a ton of spam in failing tests for every callback that we didn't EXPECT. This makes failed test output extremely noisy.

Reviewed By: sharmafb

Differential Revision: D19977113

fbshipit-source-id: 1a083fba13308cd3f2859da364c8106e349775bb
2020-02-19 21:46:46 -08:00
Yang Chi
87e3e9f8af Replace deref parseCid result with explicit error checking
Summary: deref a folly::Expected can throw if it's an error

Reviewed By: mjoras

Differential Revision: D19977541

fbshipit-source-id: d8f841c1c685c91c4ebd7d3a2ceb4aa1110de06b
2020-02-19 15:54:12 -08:00
Yang Chi
5f51f4436f Exception-free Quic ConnIdAlgo
Summary: no more surprises in upper layer

Reviewed By: mjoras

Differential Revision: D19976510

fbshipit-source-id: 3487e9aa2cb28d7bc748f13bc2bbc393216b4a8a
2020-02-19 15:54:11 -08:00
Matt Joras
c1ec43136d Check if we can parse before parsing the DCID.
Summary: As in title.

Reviewed By: yangchi

Differential Revision: D19943642

fbshipit-source-id: f99699b3a7697970445ac1f9e0e15a916940d841
2020-02-17 21:07:35 -08:00
Yang Chi
65a6c9bfe2 Remove Sheding APIs from QuicServerTransport
Summary:
The current shedding APIs in the transport would accept a new
connection and then immediately close it. This will fail the request and waste server resources.

This diff
removes all the Shedding functions from transport and let upper layer handle
it.

Reviewed By: udippant

Differential Revision: D19729902

fbshipit-source-id: 6daab5902235b6daa8d059b51cc1229d1042f892
2020-02-05 17:29:17 -08:00
Udip Pant
21a7efb2e3 remove constraints of 4-bytes minimum len for connection-id
Summary:
New QUIC draft no longer has this limitation for connection-id, and allows
connid of len 0 -> 20.

This diff removes the constraints. I still kept the requirement for
*server-chosen* conn-id

Reviewed By: mjoras, lnicco

Differential Revision: D19507366

fbshipit-source-id: 4c73f45617f40b29d47d2d86b7598f6c95588d0a
2020-01-23 21:59:49 -08:00
Udip Pant
43ffa9bbf0 Remove a flaky test block in QuicServer Test
Summary:
rejectNewConnections() runs asynchronously. As such, it is not guaranteed to complete before the next line where client writes packets. As a result,
server sometimes rejects the connection

Reviewed By: lnicco

Differential Revision: D19356730

fbshipit-source-id: 6e2e6571937737f30da1a1ffdcefdb759a0e9a73
2020-01-13 19:04:30 -08:00
Udip Pant
887e3b467b synchronously run operations on QuicServer to start / stop packet forwarding
Summary:
The async nature of the set up results in flakiness in unit tests.
For example, in QuicServerTest::TakeoverTest, clients send packets to server
right after setup, such as start / stop packetForwarding or pauseReads()
On the other hand, making them synchronous should be fine, since these are
called only during startup

Reviewed By: yangchi

Differential Revision: D19343423

fbshipit-source-id: 43cc169983d7f764b74c87f2188a9f8372007d84
2020-01-10 12:12:16 -08:00
Yang Chi
332b3c340c Use original server cid chosen by client for source addr based routing
Summary:
Currently, before server generate the destination CID, we route packets with client's address, port and client's source connection ID. But now that client can use 0-len source connection ID, the different connections from the same client address and port will be routed to the same server connections.

This diff changes it to use client's initial destination connection ID as part of the routing key.

Reviewed By: udippant

Differential Revision: D19268354

fbshipit-source-id: 837f5bd2f1e3a74957afacf7aabad922b1719219
2020-01-06 08:58:12 -08:00
Udip Pant
ba79292fa9 reset existing (takeover) socket when rebinding to different address
Reviewed By: afrind

Differential Revision: D18925452

fbshipit-source-id: dc431cbf899eb8e21a18d421a640e4f0649743cb
2019-12-20 17:29:28 -08:00
Subodh Iyengar
ed15255982 deliver evb data immediately
Summary:
If we are on the evb, process the packet on the evb immediately.

Previously evb would schedule a runInLoop in another event loop.
This saves 1 event loop to be able to process a packet in the common
case.

Reviewed By: mjoras

Differential Revision: D18897493

fbshipit-source-id: 91c073ae0aef58e999f001e64f13612c3788869f
2019-12-09 23:16:59 -08:00
Subodh Iyengar
d2fa2cbcd6 process multiple packets on recvmsg
Summary:
In the current client code we read one packet, go back to epoll, and then read
another packet. This is not very efficient.

This changes it so that we can read multiple packets in one go from an epoll
callback.

This only performs changes on the client

Reviewed By: mjoras

Differential Revision: D18797962

fbshipit-source-id: 81be82111064ade4fe3a07b1d9d3d01e180f29f5
2019-12-04 12:04:10 -08:00
Udip Pant
80b3a9f393 add more checks for internally forwarded data
Summary:
This adds checks for forwarded data on all the possible branches that lead to
forwarding of packets to another process

Reviewed By: mjoras

Differential Revision: D18416971

fbshipit-source-id: 22dc3fd63de615904a411f90164a138bf0ef56e0
2019-11-18 11:05:36 -08:00
Yang Chi
97cfde6af3 Remove Quic transport from source address map after usage of Cid data
Summary:
Before any CID is available, the source address routing
table might be the only owner of the transport. Removing the transport from
there deletes the transport. connectionIdData param is a const ref to a member
of the connection state owned by the transport. So deleting transport also
deletes this vector, which makes the const ref invalidated.

Reviewed By: vchynarov

Differential Revision: D18253200

fbshipit-source-id: 728b15d0872164ba6549a32e10a5a3611e808f27
2019-11-01 11:32:25 -07:00
Viktor Chynarov
fb39e9c520 Issue initial server conn id using helper [2/x]
Summary:
Using the helper introduced in the previous diff, we replace generating the
initial server connection id, adding it to the selfConnectionIds, and
generating the initial stateless reset token.

Reviewed By: yangchi

Differential Revision: D18066595

fbshipit-source-id: f37450eecf0926ec145bc7a7194f2a1651cae024
2019-10-28 17:46:58 -07:00
Viktor Chynarov
27536bc1e4 Delete all transport connIds from server connIdMap on unbound [3/3]
Summary:
This diff is the one that introduces+passes the test of multiple server conn
ids routing to a single transport.

Currently, there is still only one time in non-test code that more than one
server connection id is added. This diff ensures when we call connectionUnbound
we remove all associated connection ids.

Reviewed By: udippant

Differential Revision: D17479563

fbshipit-source-id: 8d0ebbf26251f7bef44cdea53dfd4ff93ab465ae
2019-10-09 08:25:07 -07:00
Yang Chi
6b41822007 Fix use after free in QuicServerWorker
Summary:
If the server connection is never generated, source address map may
have the only shared_ptr to the transport. Erase from the map then use the
transport is clearly a use-after-free bug.

Reviewed By: udippant, lnicco

Differential Revision: D17733297

fbshipit-source-id: 80d141293458920a0ba6c5eaed14dcbeec17d3ff
2019-10-02 23:00:49 -07:00
Subodh Iyengar
322eb2ebc4 remove codecresult variant
Summary: remove the variant for codec result and replace it with a custom variant type

Reviewed By: yangchi

Differential Revision: D17247099

fbshipit-source-id: 19e24c14732eb6e8496aee7064f20c48bdf254e0
2019-09-30 17:02:24 -07:00
Udip Pant
e3b792e7f1 set IP_PMTUDISC_PROBE instead of dontFragment (i.e. PMTUDISC_DO)
Summary:
mvfst will need to handle pmtu in an app specific way. So just set DF bits but
not pmtu.

Reviewed By: siyengar

Differential Revision: D17624134

fbshipit-source-id: 14f445bbb6a971efb8a3d550c84c3d4af53f8517
2019-09-27 13:14:33 -07:00
Viktor Chynarov
2bd01800f3 Use set of transports instead of connIdMap for server shutdown [2/x]
Summary:
Currently, there is a 1:1 relationship between conn Id and transports. So for
all connections with a bound connection id, we iterate over all
connectionIdMap_ entries and delete the associate transport.

This won't work if connectionIdMap_ will map multiple conn ids to a single
transport.

Reviewed By: JunqiWang

Differential Revision: D17456965

fbshipit-source-id: 8923540abf205cfd10ad09d637e8c05790b4acf9
2019-09-27 07:57:44 -07:00
Viktor Chynarov
0c836629cf Support for server routing multiple conn ids [1/x]
Summary:
Add new data structure, `ConnectionIdInfo` which is will store
ConnectionId, folly::SocketAddress, and uint64_t sequenceNumber.

Add `addConnectionId()` method to QuicServerTransport, which will both
create+add a `ConnectionIdData` object to `ServerConnectionIds` and
call `routingCb_->onConnectionIdAvailable`.

Add a matching-source address check in QuicServerWorker when matching
based on ConnectionId.

Update QuicServerTest to test for change of address on one conn id.

Right now the semantics (apart from dropping mismatched source addresses
on the same connection id) are the same. Only one conn id can ever be added.

After this, we need to allow the QuicServerWorker to
hold a list of transports. Right now, `shutdownAllConnections()` works
because the mapping of conn Id<->transport is 1:1.

Reviewed By: JunqiWang

Differential Revision: D17427573

fbshipit-source-id: 47b34d722fce8b48a5e185b0aeb05624a4fb8e94
2019-09-26 14:37:27 -07:00
Subodh Iyengar
6f6ed4d56e remove variant type for QuicPacket
Summary:
Remove the variant type for RegularQuicPacket and VersionNegotiationPacket.

This allows us to move version negotiation parsing to be only used on the client and only done explicitly
before a version is negotiated.

Reviewed By: yangchi

Differential Revision: D17242788

fbshipit-source-id: 502caf6849f0b7e6778f1470dc160d01f17a33af
2019-09-19 17:31:47 -07:00
Subodh Iyengar
04baa15a04 Custom variant type for packetheader
Summary:
Make a custom variant type for PacketHeader. By not relying on boost::variant
this reduces the code size of the implementation.

This uses a combination of a union type as well as a enum type to emulate a variant

Reviewed By: yangchi

Differential Revision: D17187589

fbshipit-source-id: 00c2b9b8dd3f3e73af766d84888b13b9d867165a
2019-09-19 17:31:47 -07:00
Viktor Chynarov
a7efbe7644 Remove unnecessary ParsedHeader wrapper struct [1/x]
Summary:
*Motivation*:
I realize there's a bit of duplication with packet parsing code, for instance,
`QuicHeaderCodec.cpp` is used in only one place, but it should be possible
to de-dupe some code.

First step, get rid of this unnecessary wrapper class.

Reviewed By: JunqiWang

Differential Revision: D17192229

fbshipit-source-id: c831abb05ae56e3ece4affd368d0f180e14fa133
2019-09-06 13:42:40 -07:00
Luca Niccolini
cf842aab47 cleanup some unused includes and using
Reviewed By: yangchi

Differential Revision: D16976466

fbshipit-source-id: c1fc2ee0795997f498ac7431542bbfbf1f0d2fb2
2019-08-24 02:03:39 -07:00
Matt Joras
049b512646 Write stream frame header and data separately.
Summary:
Prior to this diff we would clone out an entire flow control's worth of data from the writebuffer and then clone out a smaller portion of that to write into the packet builder. This is extremely wasteful when we have a large flow control window.

Additionally we would always write the stream data length field even when we are going to fill the remainder of the packet with the current stream frame. By first calculating the amount of data that needs to can be written and writing the header, we can now omit the data length field when we can fill the whole packet.

Reviewed By: yangchi

Differential Revision: D15769514

fbshipit-source-id: 95ac74eebcde87dd06de54405d7f69c42362e29c
2019-08-22 15:59:41 -07:00
Viktor Chynarov
b9bbc0d858 Remove clientConnId from ServerConnIdParams
Summary:
This parameter duplicates the one in the QuicConnectionStateBase.

It is set everywhere the canonical one is, and it isn't used directly in any
manner that is separate from QuicConnectionStateBase::clientConnId.

This diff changes the following:

 * removed clientConnId from ServerConnIdParams
 * add setter to directly initialize clientConnId on the transport from the
   connection
 * update tests

Reviewed By: udippant

Differential Revision: D16711180

fbshipit-source-id: 63e667aa0df8a79757f18fb3ffc178c7c9613e1a
2019-08-19 15:04:14 -07:00
Bonnie Xu
61bf94680a add QUIC_STATS for Stateless Reset
Summary: Added QUIC_STATS for stateless reset.

Reviewed By: afrind

Differential Revision: D16679632

fbshipit-source-id: a80179fd4f2f9b2cb1297af47687b4b8a190de84
2019-08-16 16:24:56 -07:00
Udip Pant
14b4c52fff fix a race condition in UDPReader in QuicServerTest
Summary:
if OnDataAvailable() gets called before the readOne(), then `bufPromise_` would
be null, and thus the available buffer (buf_) wouldn't get appended to the
bufPromise_.

Reviewed By: sharma95

Differential Revision: D15960463

fbshipit-source-id: b48df104a021a9e89e863d09a0124c6b19228113
2019-06-23 22:36:31 -07:00
Bonnie Xu
2762cc1597 Setup stateless reset token
Summary: Replace hard coded stateless reset token with a token from the stateless reset token generator.

Reviewed By: yangchi

Differential Revision: D15481858

fbshipit-source-id: 30c96843c38c616600466b2fabb6defd5fcc5799
2019-06-13 08:44:53 -07:00
Leonidas Kontothanassis
ddc845a855 Add connection drop logic for QUIC
Summary: Add connection drop logic for QUIC

Reviewed By: mjoras

Differential Revision: D15361528

fbshipit-source-id: 55d9bf9d818786f23c9c6d600ca928ba7b265d4f
2019-05-23 10:03:18 -07:00