-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quic: handle ACK frame in packet which drops number space
Avoid incorrectly closing a connection with a protocol violation error when we receive a single packet containing a CRYPTO frame that causes us to drop a packet number space (forgetting what packet numbers we've sent in that space) followed by an ACK frame. Fixes golang/go#70703 Change-Id: I37554cb6a3086736cb9d772f8a3441b544d414dc Reviewed-on: https://go-review.googlesource.com/c/net/+/634616 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
- Loading branch information
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build go1.21 | ||
|
||
package quic | ||
|
||
import ( | ||
"crypto/tls" | ||
"testing" | ||
) | ||
|
||
func TestConnReceiveAckForUnsentPacket(t *testing.T) { | ||
tc := newTestConn(t, serverSide, permissiveTransportParameters) | ||
tc.handshake() | ||
tc.writeFrames(packetType1RTT, | ||
debugFrameAck{ | ||
ackDelay: 0, | ||
ranges: []i64range[packetNumber]{{0, 10}}, | ||
}) | ||
tc.wantFrame("ACK for unsent packet causes CONNECTION_CLOSE", | ||
packetType1RTT, debugFrameConnectionCloseTransport{ | ||
code: errProtocolViolation, | ||
}) | ||
} | ||
|
||
// Issue #70703: If a packet contains both a CRYPTO frame which causes us to | ||
// drop state for a number space, and also contains a valid ACK frame for that space, | ||
// we shouldn't complain about the ACK. | ||
func TestConnReceiveAckForDroppedSpace(t *testing.T) { | ||
tc := newTestConn(t, serverSide, permissiveTransportParameters) | ||
tc.ignoreFrame(frameTypeAck) | ||
tc.ignoreFrame(frameTypeNewConnectionID) | ||
|
||
tc.writeFrames(packetTypeInitial, | ||
debugFrameCrypto{ | ||
data: tc.cryptoDataIn[tls.QUICEncryptionLevelInitial], | ||
}) | ||
tc.wantFrame("send Initial crypto", | ||
packetTypeInitial, debugFrameCrypto{ | ||
data: tc.cryptoDataOut[tls.QUICEncryptionLevelInitial], | ||
}) | ||
tc.wantFrame("send Handshake crypto", | ||
packetTypeHandshake, debugFrameCrypto{ | ||
data: tc.cryptoDataOut[tls.QUICEncryptionLevelHandshake], | ||
}) | ||
|
||
tc.writeFrames(packetTypeHandshake, | ||
debugFrameCrypto{ | ||
data: tc.cryptoDataIn[tls.QUICEncryptionLevelHandshake], | ||
}, | ||
debugFrameAck{ | ||
ackDelay: 0, | ||
ranges: []i64range[packetNumber]{{0, tc.lastPacket.num + 1}}, | ||
}) | ||
tc.wantFrame("handshake finishes", | ||
packetType1RTT, debugFrameHandshakeDone{}) | ||
tc.wantIdle("connection is idle") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters