Skip to content

Commit f865199

Browse files
committed
quic: fix appendMaxDataFrame erroneously accumulating sentLimit
sentLimit value should be of the last MAX_DATA sent to the peer. However, we are currently incorrectly incrementing its value rather than updating it. Change-Id: Id73ce651158e7c4f031e8a2e5099e9d36a6a6964 Reviewed-on: https://go-review.googlesource.com/c/net/+/778380 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com>
1 parent 210ed3c commit f865199

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

quic/conn_flow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (c *Conn) appendMaxDataFrame(w *packetWriter, pnum packetNumber, pto bool)
107107
if !w.appendMaxDataFrame(c.streams.inflow.newLimit) {
108108
return false
109109
}
110-
c.streams.inflow.sentLimit += c.streams.inflow.newLimit
110+
c.streams.inflow.sentLimit = c.streams.inflow.newLimit
111111
c.streams.inflow.sent.setSent(pnum)
112112
}
113113
return true

quic/conn_flow_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,19 @@ func testConnInflowMultipleStreams(t *testing.T) {
266266
packetType1RTT, debugFrameMaxData{
267267
max: 128 + 32 + 1 + 32 + 1,
268268
})
269+
270+
// Current limit is 194 (128 + 32 + 1 + 32 + 1).
271+
// Available window is 194 - 128 = 66 bytes.
272+
// Send 67 bytes on streams[0] to violate flow control.
273+
tc.writeFrames(packetType1RTT, debugFrameStream{
274+
id: streams[0].id,
275+
off: 32,
276+
data: make([]byte, 67),
277+
})
278+
tc.wantFrame("peer violates MAX_DATA limit",
279+
packetType1RTT, debugFrameConnectionCloseTransport{
280+
code: errFlowControl,
281+
})
269282
}
270283

271284
func TestConnOutflowBlocked(t *testing.T) {

0 commit comments

Comments
 (0)