wire: apply the default value for the active_connection_id_limit (#3806)

This commit is contained in:
Marten Seemann 2023-05-28 21:45:46 +03:00 committed by GitHub
parent 1951878816
commit fce0261c34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 9 deletions

View file

@ -312,9 +312,14 @@ var newConnection = func(
DisableActiveMigration: true, DisableActiveMigration: true,
StatelessResetToken: &statelessResetToken, StatelessResetToken: &statelessResetToken,
OriginalDestinationConnectionID: origDestConnID, OriginalDestinationConnectionID: origDestConnID,
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs, // For interoperability with quic-go versions before May 2023, this value must be set to a value
InitialSourceConnectionID: srcConnID, // different from protocol.DefaultActiveConnectionIDLimit.
RetrySourceConnectionID: retrySrcConnID, // If set to the default value, it will be omitted from the transport parameters, which will make
// old quic-go versions interpret it as 0, instead of the default value of 2.
// See https://github.com/quic-go/quic-go/pull/3806.
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs,
InitialSourceConnectionID: srcConnID,
RetrySourceConnectionID: retrySrcConnID,
} }
if s.config.EnableDatagrams { if s.config.EnableDatagrams {
params.MaxDatagramFrameSize = protocol.MaxDatagramFrameSize params.MaxDatagramFrameSize = protocol.MaxDatagramFrameSize
@ -426,8 +431,13 @@ var newClientConnection = func(
MaxAckDelay: protocol.MaxAckDelayInclGranularity, MaxAckDelay: protocol.MaxAckDelayInclGranularity,
AckDelayExponent: protocol.AckDelayExponent, AckDelayExponent: protocol.AckDelayExponent,
DisableActiveMigration: true, DisableActiveMigration: true,
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs, // For interoperability with quic-go versions before May 2023, this value must be set to a value
InitialSourceConnectionID: srcConnID, // different from protocol.DefaultActiveConnectionIDLimit.
// If set to the default value, it will be omitted from the transport parameters, which will make
// old quic-go versions interpret it as 0, instead of the default value of 2.
// See https://github.com/quic-go/quic-go/pull/3806.
ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs,
InitialSourceConnectionID: srcConnID,
} }
if s.config.EnableDatagrams { if s.config.EnableDatagrams {
params.MaxDatagramFrameSize = protocol.MaxDatagramFrameSize params.MaxDatagramFrameSize = protocol.MaxDatagramFrameSize

View file

@ -77,6 +77,9 @@ const MinConnectionIDLenInitial = 8
// DefaultAckDelayExponent is the default ack delay exponent // DefaultAckDelayExponent is the default ack delay exponent
const DefaultAckDelayExponent = 3 const DefaultAckDelayExponent = 3
// DefaultActiveConnectionIDLimit is the default active connection ID limit
const DefaultActiveConnectionIDLimit = 2
// MaxAckDelayExponent is the maximum ack delay exponent // MaxAckDelayExponent is the maximum ack delay exponent
const MaxAckDelayExponent = 20 const MaxAckDelayExponent = 20

View file

@ -289,15 +289,16 @@ var _ = Describe("Transport Parameters", func() {
Expect(float32(dataLen) / num).To(BeNumerically("~", float32(defaultLen)/num+float32(entryLen), 1)) Expect(float32(dataLen) / num).To(BeNumerically("~", float32(defaultLen)/num+float32(entryLen), 1))
}) })
It("sets the default value for the ack_delay_exponent, when no value was sent", func() { It("sets the default value for the ack_delay_exponent and max_active_connection_id_limit, when no values were sent", func() {
data := (&TransportParameters{ data := (&TransportParameters{
AckDelayExponent: protocol.DefaultAckDelayExponent, AckDelayExponent: protocol.DefaultAckDelayExponent,
StatelessResetToken: &protocol.StatelessResetToken{}, StatelessResetToken: &protocol.StatelessResetToken{},
ActiveConnectionIDLimit: 2, ActiveConnectionIDLimit: protocol.DefaultActiveConnectionIDLimit,
}).Marshal(protocol.PerspectiveServer) }).Marshal(protocol.PerspectiveServer)
p := &TransportParameters{} p := &TransportParameters{}
Expect(p.Unmarshal(data, protocol.PerspectiveServer)).To(Succeed()) Expect(p.Unmarshal(data, protocol.PerspectiveServer)).To(Succeed())
Expect(p.AckDelayExponent).To(BeEquivalentTo(protocol.DefaultAckDelayExponent)) Expect(p.AckDelayExponent).To(BeEquivalentTo(protocol.DefaultAckDelayExponent))
Expect(p.ActiveConnectionIDLimit).To(BeEquivalentTo(protocol.DefaultActiveConnectionIDLimit))
}) })
It("errors when the varint value has the wrong length", func() { It("errors when the varint value has the wrong length", func() {

View file

@ -118,6 +118,7 @@ func (p *TransportParameters) unmarshal(r *bytes.Reader, sentBy protocol.Perspec
var ( var (
readOriginalDestinationConnectionID bool readOriginalDestinationConnectionID bool
readInitialSourceConnectionID bool readInitialSourceConnectionID bool
readActiveConnectionIDLimit bool
) )
p.AckDelayExponent = protocol.DefaultAckDelayExponent p.AckDelayExponent = protocol.DefaultAckDelayExponent
@ -139,6 +140,9 @@ func (p *TransportParameters) unmarshal(r *bytes.Reader, sentBy protocol.Perspec
} }
parameterIDs = append(parameterIDs, paramID) parameterIDs = append(parameterIDs, paramID)
switch paramID { switch paramID {
case activeConnectionIDLimitParameterID:
readActiveConnectionIDLimit = true
fallthrough
case maxIdleTimeoutParameterID, case maxIdleTimeoutParameterID,
maxUDPPayloadSizeParameterID, maxUDPPayloadSizeParameterID,
initialMaxDataParameterID, initialMaxDataParameterID,
@ -148,7 +152,6 @@ func (p *TransportParameters) unmarshal(r *bytes.Reader, sentBy protocol.Perspec
initialMaxStreamsBidiParameterID, initialMaxStreamsBidiParameterID,
initialMaxStreamsUniParameterID, initialMaxStreamsUniParameterID,
maxAckDelayParameterID, maxAckDelayParameterID,
activeConnectionIDLimitParameterID,
maxDatagramFrameSizeParameterID, maxDatagramFrameSizeParameterID,
ackDelayExponentParameterID: ackDelayExponentParameterID:
if err := p.readNumericTransportParameter(r, paramID, int(paramLen)); err != nil { if err := p.readNumericTransportParameter(r, paramID, int(paramLen)); err != nil {
@ -196,6 +199,9 @@ func (p *TransportParameters) unmarshal(r *bytes.Reader, sentBy protocol.Perspec
} }
} }
if !readActiveConnectionIDLimit {
p.ActiveConnectionIDLimit = protocol.DefaultActiveConnectionIDLimit
}
if !fromSessionTicket { if !fromSessionTicket {
if sentBy == protocol.PerspectiveServer && !readOriginalDestinationConnectionID { if sentBy == protocol.PerspectiveServer && !readOriginalDestinationConnectionID {
return errors.New("missing original_destination_connection_id") return errors.New("missing original_destination_connection_id")
@ -402,7 +408,9 @@ func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte {
} }
} }
// active_connection_id_limit // active_connection_id_limit
b = p.marshalVarintParam(b, activeConnectionIDLimitParameterID, p.ActiveConnectionIDLimit) if p.ActiveConnectionIDLimit != protocol.DefaultActiveConnectionIDLimit {
b = p.marshalVarintParam(b, activeConnectionIDLimitParameterID, p.ActiveConnectionIDLimit)
}
// initial_source_connection_id // initial_source_connection_id
b = quicvarint.Append(b, uint64(initialSourceConnectionIDParameterID)) b = quicvarint.Append(b, uint64(initialSourceConnectionIDParameterID))
b = quicvarint.Append(b, uint64(p.InitialSourceConnectionID.Len())) b = quicvarint.Append(b, uint64(p.InitialSourceConnectionID.Len()))