-
Notifications
You must be signed in to change notification settings - Fork 363
quic: premature 1-RTT packets #6805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quic: premature 1-RTT packets #6805
Conversation
akhinvasara-jumptrading
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catches, thank you! 🔥 Left a couple suggestions to tighten it up and grab some adjacent wins.
src/waltz/quic/fd_quic.c
Outdated
| /* only allow 1-RTT "flag" frames when connection is ACTIVE, to prevent e.g. early 1-RTT PINGs */ | ||
| if( conn->flags | ||
| && conn->upd_pkt_number >= app_pkt_number | ||
| && conn->state == FD_QUIC_CONN_STATE_ACTIVE ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of state ACTIVE, let's check that we have 1-rtt keys available.
fd_uint_extract_bit( conn->keys_avail, fd_quic_enc_level_appdata_id )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually used that check initially, but changed to ACTIVE state check since, iiuc:
- client-side 1-RTT keys are available as soon as
Handshakeis received in response toInitial(at which point client is inHANDSHAKE_COMPLETE) - server still rejects short headers until its connection is in
Establishedstate, which only happens once it receivesHandshakeback from the client. - the earliest safe signal that we can send 1-RTT is if we have 1-RTT keys locally &
peer_enc_level==appdata, which anyway only happens when we receive HANDSHAKE_DONE / transition to ACTIVE (unless there is some packet reordering, but idk how often that happens/significant it is)
Lmk if you still want me to amend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tldr: yes pls, amending would be great :) thank you!
I think amending would still be good, because waiting for the handshake done turns the 1-rtt into 2-rtt.
It's def buggy to send 1-rtt before we have the keys for it - but the uncommon case of packet reordering isn't worth always waiting the extra round trip.
It's also OK for the server to fail to decrypt, it should just drop the packet, not kill the connection. And we will just retx the packet anyway.
akhinvasara-jumptrading
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thanks v much for catching this and doing a couple iterations of the impl!
nbridge-jump
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Nice work
730db26
730db26 to
8b1d62d
Compare
|
I pushed a minimal revision of the It looks like the test couldn't handle the new flow:
The test was only cranking 20 iterations as fast as possible, even though it uses wall clock, so it was never reaching the retry. One thing about it is that it shows that by sending 1-RTT Lmk what you want to do. |
akhinvasara-jumptrading
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thanks very much
d2fd47d
into
firedancer-io:main
Problem
fd_quiccurrently allows 1-RTT "flag" packets (PING,MAX_DATA, etc) to be sent even when handshake is ongoing.Those packets are then discarded server-side (at least in
quinn-rs) due to decryption failure.From my quick testing, the current scheduling of e.g. PINGs vs handshake completion does not lead to many (any?) such occurrences in normal operation, but I did observe some when artificially delaying the handshake replies.
Opening this PR for consideration from eyes more familiar with
fd_quic.Solution
Require the connection to be in ACTIVE state before allowing
fd_quic_enc_level_appdata_iddue to pending flag packets.This PR also gates PINGs consistently between the first and second scheduling sites.