Skip to content

Commit 42b48c1

Browse files
fix issuing of connection IDs when dialing a 0-RTT connections
When dialing a 0-RTT connection, the client first restores the transport parameters from the original connection, and then applies the transport parameters provided by the server on the new connections.
1 parent 2c45f2b commit 42b48c1

File tree

3 files changed

+394
-356
lines changed

3 files changed

+394
-356
lines changed

conn_id_generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (m *connIDGenerator) SetMaxActiveConnIDs(limit uint64) error {
6363
// transport parameter.
6464
// We currently don't send the preferred_address transport parameter,
6565
// so we can issue (limit - 1) connection IDs.
66-
for i := uint64(1); i < utils.MinUint64(limit, protocol.MaxIssuedConnectionIDs); i++ {
66+
for i := uint64(len(m.activeSrcConnIDs)); i < utils.MinUint64(limit, protocol.MaxIssuedConnectionIDs); i++ {
6767
if err := m.issueNewConnID(); err != nil {
6868
return err
6969
}

conn_id_generator_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,37 @@ var _ = Describe("Connection ID Generator", func() {
7979
Expect(queuedFrames).To(HaveLen(protocol.MaxIssuedConnectionIDs - 1))
8080
})
8181

82+
// SetMaxActiveConnIDs is called twice when we dialing a 0-RTT connection:
83+
// once for the restored from the old connections, once when we receive the transport parameters
84+
Context("dealing with 0-RTT", func() {
85+
It("doesn't issue new connection IDs when SetMaxActiveConnIDs is called with the same value", func() {
86+
Expect(g.SetMaxActiveConnIDs(4)).To(Succeed())
87+
Expect(queuedFrames).To(HaveLen(3))
88+
queuedFrames = nil
89+
Expect(g.SetMaxActiveConnIDs(4)).To(Succeed())
90+
Expect(queuedFrames).To(BeEmpty())
91+
})
92+
93+
It("issues more connection IDs if the server allows a higher limit on the resumed connection", func() {
94+
Expect(g.SetMaxActiveConnIDs(3)).To(Succeed())
95+
Expect(queuedFrames).To(HaveLen(2))
96+
queuedFrames = nil
97+
Expect(g.SetMaxActiveConnIDs(6)).To(Succeed())
98+
Expect(queuedFrames).To(HaveLen(3))
99+
})
100+
101+
It("issues more connection IDs if the server allows a higher limit on the resumed connection, when connection IDs were retired in between", func() {
102+
Expect(g.SetMaxActiveConnIDs(3)).To(Succeed())
103+
Expect(queuedFrames).To(HaveLen(2))
104+
queuedFrames = nil
105+
g.Retire(1, protocol.ConnectionID{})
106+
Expect(queuedFrames).To(HaveLen(1))
107+
queuedFrames = nil
108+
Expect(g.SetMaxActiveConnIDs(6)).To(Succeed())
109+
Expect(queuedFrames).To(HaveLen(3))
110+
})
111+
})
112+
82113
It("errors if the peers tries to retire a connection ID that wasn't yet issued", func() {
83114
Expect(g.Retire(1, protocol.ConnectionID{})).To(MatchError("PROTOCOL_VIOLATION: tried to retire connection ID 1. Highest issued: 0"))
84115
})

0 commit comments

Comments
 (0)