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

206 Commits

Author SHA1 Message Date
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
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
Yang Chi
591f27c6f1 Remove a few quic traces
Summary:
Remove all the stream events, packet/udp recv event and ack event.
They are >40%  of  the  events.

Reviewed By: mjoras

Differential Revision: D19466165

fbshipit-source-id: 3a20b201e630527e6d25d1a14f0f520728190d50
2020-01-29 17:10:32 -08:00
Matt Joras
98e12004d0 Set a cap on the UDP send packet length.
Summary: This is a somewhat arbitrary limit, but is useful for keepin a client from making the server build an enormous packet.

Reviewed By: yangchi

Differential Revision: D19438682

fbshipit-source-id: 2ec3b8c8ba630804e954f606ada2cc00682b3657
2020-01-17 13:21:20 -08:00
Matt Joras
431acc838f Optimize ACK frame writing
Summary:
Previously we stored an `IntervalSet` in each `WriteAckFrame`. We don't need to do this, as by the time we are writing an `ACK` the `IntervalSet` is complete. Instead of bothering with the `IntervalSet` operations, we can simply serialize it to a reverse-sorted `vector.`

Additionally this has some micro-optimizations for filling the ACK frame, with a new function for getting varint size.

Reviewed By: yangchi

Differential Revision: D19397728

fbshipit-source-id: ba6958fb36a4681edaa8394b1bcbbec3472e177d
2020-01-16 10:40:40 -08:00
Matt Joras
066796b52d Pings are allowed in non-protected packets
Summary: As in title.

Reviewed By: yangchi

Differential Revision: D19411304

fbshipit-source-id: 674fb4ccb428badefe28b6ffe11a3b55b92afe6c
2020-01-15 13:17:43 -08:00
Udip Pant
74f98d4604 Move the fizz code into its own package
Summary:
This moves the fizz specific part of the handshake into its own folder and library.

There is a bit of smurf naming going on as a result, not sure it is worth fixing or not at this stage. Maybe this code should be a in namespace named quic::fizz .

This should be doable with the client as well as soon as the key cache situation is figured out.
 ---
## Proxygen Canary

Reviewed By: yangchi

Differential Revision: D19290919

fbshipit-source-id: 48d7f7c70db42c65f7dffe3256805c268a481198
2020-01-09 20:59:54 -08:00
Subodh Iyengar
e524c0c069 iobufqueue diediedie
Summary:
Don't use IOBufQueue for most operations in mvfst and use BufQueue instead. Since BufQueue did not support a splitAtMost, added it in instead.

The only place that we still use IOBufQueue is in crypto because fizz still requires it

Reviewed By: mjoras

Differential Revision: D18846960

fbshipit-source-id: 4320b7f8614f8d2c75f6de0e6b786d33650e9656
2019-12-06 12:06:44 -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
Raghu Nallamothu
e06de27550 Merge Application Close Frame and Connection Close Frame
Summary: As a part of Draft 17, application close frame has been removed, we use connection close frame to represent both application close and connection close.

Reviewed By: mjoras

Differential Revision: D18580856

fbshipit-source-id: d274fa2d3dbc59b926bca5a2b8a20328ae582703
2019-12-03 15:02:06 -08:00
Viktor Chynarov
20807a350d Exchange active_connection_id_limit in transport parameters [2/2]
Summary:
Client will set their active_connection_id_limit to the server as 7 (so it will
have 8 conn ids in total).

Reviewed By: JunqiWang

Differential Revision: D18532441

fbshipit-source-id: b0be65cec9f7c483469b0b4a2810bc370a6945c3
2019-11-20 08:46:56 -08:00
Aman Sharma
69ac8aeb62 De-templatize stream state machine logic
Summary: The state machine logic is quite abstruse, this modifies it to make it more readable.

Reviewed By: siyengar

Differential Revision: D18488301

fbshipit-source-id: c6fd52973880931e34904713e8b147f56d0c4629
2019-11-19 20:18:11 -08:00
Viktor Chynarov
7504453972 Use Path Rate Limiter for conn migration
Summary:
Use the Path rate limiter introduced in the previous diff.

When we initialize path validation of an unvalidated peer address,
enable pathValidationRateLimit.

When we receive a proper PATH_RESPONSE frame, disable this limit.

If this limit is enabled, we will check the pathValidationLimiter for
the amount of bytes we are allowed to write.

Change the migration tests in QuicServerTransportTest to use this new limiter
instead of writableByteLimits.

Update shouldWriteData to directly use the new congestionControlWritableBytes
function.

Reviewed By: yangchi

Differential Revision: D18145774

fbshipit-source-id: 1fe4fd5be7486077c58b0d1285dfb03f6c62831c
2019-11-14 13:48:17 -08:00
Junqi Wang
0fced3e95c No migration when 0-RTT packets come from different peer
Summary: 0-RTT packet is also in AppData pn space

Reviewed By: vchynarov

Differential Revision: D18353017

fbshipit-source-id: a39fe5aae823fbe0d7522f895cff05cc9395928b
2019-11-11 10:21:13 -08:00
Junqi Wang
52de3eb832 Reset mrtt on connection migration
Reviewed By: yangchi

Differential Revision: D18397845

fbshipit-source-id: ce1c7bcf4495b1a937892589c4c4131288f7d28f
2019-11-08 09:10:12 -08:00
Viktor Chynarov
45e71f737a Add QLog events for ConnMigration, PathValidation
Summary:
QLogConnectionMigrationEvent:
Allow observing client-side ConnectionMigration attempts (replacing the
socket), and observing the server-side changing the peer address it
is writing to.

QLogPathValidationEvent:
Allow observing successful/failed path validation attempts.
Success is considered as a correct PathResponse being returned.
A Failure is only published on the timeout expiring, not an invalid
PathChallenge frame being returned (we do not cancel this).

There are already QlogEvents for PathChallenge/PathResponse that
can be observed.

Reviewed By: JunqiWang

Differential Revision: D18340999

fbshipit-source-id: 512108f82a6e082021c0bd3254f108c128b17ba3
2019-11-08 08:39:36 -08:00
Junqi Wang
a87bbc6fa8 Clear pending path challenge frame when migrating again
Summary:
When server has a pending path challenge frame to be sent, it's
possible that client can migrate again. This diff handles that case.

Reviewed By: vchynarov

Differential Revision: D18351213

fbshipit-source-id: c6887db0274ccddf267eb227de0a7de7ee103b4c
2019-11-06 10:51:56 -08: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
3dd52b323a Create helper to generate server-side connection id [1/x]
Summary:
My goal in this stack is to properly support the functionality of issuing new
connection ids.

There are at least three cases in which this is done (server-side):
* generate initial server connection id based on host id parameters
* provide several NewConnectionId frames to the client (for use with
   migration) after handshake
* responding to RetireConnectionIdFrame and issuing more NewConnectionId frames
  as needed

**Changes**:
* move connIdAlgo away from parent ConnectionStateBase to just
  QuicServerConnectionState
* create virtual function in ConnectionStateBase to generate
  folly::none ConnectionIdData by default,
  and server subclass will generate a new server id
* add unit tests to test this behaviour.

Intended for Junqi's diff of server issuing 7 new connection ids
to be rebased on this (D15178642)

Reviewed By: yangchi

Differential Revision: D17840780

fbshipit-source-id: 1a01077742d01d058eb0a726c4c9c44e39eafb24
2019-10-28 17:46:58 -07:00
Raghu Nallamothu
e06c0848e0 T24905463 - [quic][ping] Implement ping in Quic
Summary: Implement ping functionality in ping

Reviewed By: yangchi

Differential Revision: D17885286

fbshipit-source-id: 4c328d14a023057d6889818250c0129c06e60874
2019-10-21 17:07:12 -07:00
Carmi Grushko
a8e76fc3ea Ping frames are retransmittable
Summary:
This will treat incoming ping frames as retransmittable frames and
update ack state accordingly.

Reviewed By: lhuang04, yangchi

Differential Revision: D17841073

fbshipit-source-id: be19ec9a9dae7f0c2d416fab5deac7487861c4e2
2019-10-09 14:59:13 -07:00
Carmi Grushko
3fc265f115 Sync quic/server
Reviewed By: lhuang04

Differential Revision: D17837374

fbshipit-source-id: 0bf3347a0dfd056b8c36973d900efbfef5e86872
2019-10-09 13:38:25 -07:00
Yang Chi
2d24a250f7 Ping frames are retransmittable
Summary:
This will treat incoming ping frames as retransmittable frames and
update ack state accordingly.

Reviewed By: siyengar

Differential Revision: D17832707

fbshipit-source-id: 69e4a95a62bf86a707bac94399588df61c947bd3
2019-10-09 13:12:12 -07:00
Amaury Séchet
a0ebc3995b Fusion QuicFizzFactory into FizzCryptoFactory (#44)
Summary:
They are strongly coupled, which indicate this is probably better to do it as one class.
Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/44

Reviewed By: mjoras

Differential Revision: D17590918

Pulled By: yangchi

fbshipit-source-id: 2eaca079fd760107eefd2b74fa612d7a0c8b3001
2019-10-08 22:17:02 -07:00
Subodh Iyengar
68c332acb1 Use custom variant type for write frames
Summary:
Use the custom variant type for write frames as well, now that
we use them for read frames.

Reviewed By: mjoras

Differential Revision: D17776862

fbshipit-source-id: 47093146d0f1565c22e5393ed012c70e2e23d279
2019-10-07 22:43:31 -07:00
Yang Chi
6d00ae544d Temp enum fix in variant macro to unshadow QuicSimpleFrame type alias
Summary:
It looks like under some compiler flags, type alias follows a very
different rule of name shadowing. This diff adds a trailing "_E" to generated
enum names to unbreak builds. I will send another diff to make it less ugly
later. And eventually the QuicSimpleFrame won't be a type alias once it's no
longer a boost_variant.

Reviewed By: siyengar

Differential Revision: D17766330

fbshipit-source-id: 7b3c5847fd2c1eae10757bfbf9558a38f3085f10
2019-10-04 12:57:54 -07:00
Subodh Iyengar
95f509ae54 custom variant type for read frames
Summary:
Create a custom type for read frame types. This allows us to reduce size of code.
We use a macro to generate new variant types whenever we need to.

Reviewed By: yangchi

Differential Revision: D17266468

fbshipit-source-id: 59a1183dce728e71f0924f39f95a7b78449642b0
2019-10-03 18:17:39 -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
Viktor Chynarov
d7748a8382 active_connection_id_limit transport parameter
Summary:
^

This parameter was added in d-21. Default value is 0 meaning no provided
connection id apart from the initial ones. This limits the amount of connection
ids the peer provides via `NEW_CONNECTION_ID` frame.

Diff to set this value will be added in later, along with `NEW_CONNECTION_ID`.

Reviewed By: JunqiWang

Differential Revision: D17532007

fbshipit-source-id: 5b86f69a8d3372fbcb7e0882508ea2661a9d4864
2019-09-25 08:07:28 -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
Matt Joras
72e677df33 Send windowed stream limit updates
Summary:
Implement sending stream limit updates in a windowed fashion, so that as a peer exhausts its streams we will grant it additional credit. This is implemented by having the stream manager check if an update is needed on removing streams, and the api layer potentially sending an update after it initiates the check for closed streams.

This also makes some driveby changes to use `std::lower_bound` instead of `std::find` for the sorted collections in the stream manager.

Reviewed By: yangchi

Differential Revision: D16808229

fbshipit-source-id: f6e3460d43e4d165e362164be00c0cec27cf1e79
2019-09-18 11:33:03 -07:00
Viktor Chynarov
594a98be7a Stop setting clientConnId in ServerStateMachine [2/x]
Summary:
Removes clientConnId completely from ServerConnectionIdParams.

This diff first fixes an incorrect assumption; it calls
`shortHeader.getConnectionId()` which is actually the destination id (server)
not the client connection id.

Next, this entire block is unnecessary, because this will be called after
the transport is created, so the clientConnectionId will always be set.

This also setsconn.serverConnectionId earlier (shouldn't depend on
connClientId).

Reviewed By: yangchi

Differential Revision: D16792866

fbshipit-source-id: 537ba12baa9939c9d5512e46eb914c1d3a7a9aa2
2019-08-23 15:06:02 -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
Amaury Séchet
cbd77a3603 Extend CryptoFactory with makePacketNumberCipher (#40)
Summary:
The CryptoFactory is extended with makePacketNumberCipher . In order to support that feature, FizzCryptoFactory now explicitly takes a QuicFizzFactory as argument instead of a generic fizz::Factory, which is the only type that is used in practice anyways.

The cypher argument was removed because:
1/ Only one cypher is used at all. Fizz also supports ChaCha20, but using it in mvfst will throw an exception.
2/ it seems like the factory should know what cypher it is dealing with.

If a choice of cypher needs to be supported going forward, it can be done by adding state to FizzCryptoFactory.
Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/40

Reviewed By: mjoras

Differential Revision: D16785274

Pulled By: yangchi

fbshipit-source-id: a1c490e34c5ddd107e8e068d8b127c1ed00a59ec
2019-08-16 08:52:43 -07:00
Bonnie Xu
db349541f2 Update qlog format to be more complete
Summary: Update qlog format to be more complete. Adding the summary section (with extra fields like title, description, etc). This diff is just to make the format more on par with Robin's schema.

Reviewed By: mjoras

Differential Revision: D16499808

fbshipit-source-id: 56cfbb95404f7e3c6638bffda18b53f7d83048a1
2019-07-30 12:48:57 -07:00
Amaury Séchet
4f6fb57557 Add CryptoFactory to abtract Fizz specific crypto operations (#30)
Summary:
This introduce the CryptoFactory abstraction that compute keys and AEAD to be used by most of mvfst.

The fizz specific parts are abstracted into a subclass, FizzCryptoFactory, and accessed using virtual methods.

Next step is to introduce QuicFizzFactory 's features into this abstraction.
Pull Request resolved: https://github.com/facebookincubator/mvfst/pull/30

Reviewed By: JunqiWang

Differential Revision: D16459633

Pulled By: yangchi

fbshipit-source-id: 7fe2d3037ac604bfd5b002e6d25c1763e91e9472
2019-07-29 15:02:05 -07:00
Bonnie Xu
90b83d7370 Add packetBuffered event
Summary: Add packetBuffered event to qlog.

Reviewed By: yangchi

Differential Revision: D16415646

fbshipit-source-id: dda053e55b5b029278993ccc89330e2bc2d9ebb9
2019-07-25 11:52:21 -07:00
Bonnie Xu
0929100b18 Add transportStateUpdate event
Summary: Add transportStateUpdate event so it can be part of qlog.

Reviewed By: mjoras

Differential Revision: D16342467

fbshipit-source-id: 109189275d44996850b82646bab4a733a3a4c7a1
2019-07-25 11:52:19 -07:00
Matt Joras
ece3cbe387 Draft-22 varint error codes
Summary: These were changed to varints. To support this we need to do some extra horrible version plumbing. I don't want to keep this long term but it works for now.

Reviewed By: yangchi

Differential Revision: D16293568

fbshipit-source-id: a9ea9083be160aa3e6b338a7d70d7f00e44ec5ab
2019-07-18 12:07:57 -07:00
Bonnie Xu
9cbe902f81 Add packetDrop to Quic
Summary: [quic] Add packetDrop to Quic, so it can be logged in qlog.

Reviewed By: yangchi

Differential Revision: D16257829

fbshipit-source-id: ca87116f2c708538d05f28098620a5dfc2456f3e
2019-07-17 17:11:25 -07:00
Matt Joras
2f528e68c0 Draft-22 invariants change
Summary:
Draft-22 onwards uses two one byte length fields to encode connection ID length instead of one one byte length field.

To support this without disrupting existing clients we need to make our parsing version dependent. This diff accomplishes it by special casing the existing Facebook client QUIC version (0xfaceb000), and changing the default Facebook client version going forward to 0xfaceb001.

Note that this diff also changes the behavior of the ticket transport parameters. When we changed from draft-18 to draft-19 transport parameters I apparently forgot to update the ticket transport parameters to the new format.

Reviewed By: yangchi

Differential Revision: D16205090

fbshipit-source-id: e74a92fa959d308f4bb43bad76e58d4b58d07322
2019-07-16 17:59:58 -07:00
Bonnie Xu
c8fc46a7ff Rename add to addPacket
Summary: Rename `add` to `addPacket`, since `add` is an ambiguous function name, especially as we include more events.

Reviewed By: sharma95

Differential Revision: D16102141

fbshipit-source-id: 73196a5f1bcc681e3bb0a26fd9edaf34f59bf710
2019-07-08 03:34:33 -07:00
Bonnie Xu
f20f8d15a1 Added fields dcid and scid to QLogger
Summary:
Added fields dcid and scid to QLogger

This will be used in the following diff, which needs the ids to uniquely identify the output file.

Reviewed By: sharma95

Differential Revision: D15909180

fbshipit-source-id: d8db794d74cbbc85ead6afb7d5cd5179c70b646d
2019-06-25 23:37:43 -07:00
Bonnie Xu
a6606f2a52 Setup logging in Quic based on QLogger
Summary: Setup logging in Quic based on QLogger.

Reviewed By: mjoras

Differential Revision: D15818340

fbshipit-source-id: 553aaedc6043a7f079c597ef0647c5b91f3033df
2019-06-24 09:45:45 -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
Bonnie Xu
f4ae0a1efd Updated files to change syntax.
Summary: Changed existing chrono syntax to chrono_literals syntax.

Reviewed By: mjoras, sharma95

Differential Revision: D15374649

fbshipit-source-id: 40033e90cca226266ef85e4fec629f290bc5dae6
2019-05-20 12:10:46 -07:00
Bonnie Xu
8168bcf624 Update QUIC Transport Error Code Entries
Summary: Update Transport Error Codes to be in line with IETF standard found here: https://quicwg.org/base-drafts/draft-ietf-quic-transport.html, Initial QUIC Transport Error Codes Entries)

Reviewed By: yangchi

Differential Revision: D15402555

fbshipit-source-id: 3c4ba851e23eb92f81eb61a6f7046f1cc6bf7602
2019-05-20 08:14:08 -07:00
Junqi Wang
7e655863d7 Perform path validation for NAT rebinding
Summary: per spec

Reviewed By: sharma95

Differential Revision: D15162568

fbshipit-source-id: 63fa9266da29687043f598b5939a808c3ba0f75c
2019-05-20 00:48:13 -07:00
Junqi Wang
92b8876ebf Update 0-rtt ticket transport params to d-20
Reviewed By: mjoras

Differential Revision: D15293208

fbshipit-source-id: 4ea5bf6c2c335a5c034341086f9348451bed827e
2019-05-10 16:19:43 -07:00