forked from quic-go/quic-go
wire: write configured value of max_udp_payload_size transport parameter (#4501)
This commit is contained in:
@@ -299,6 +299,7 @@ var newConnection = func(
|
||||
MaxUniStreamNum: protocol.StreamNum(s.config.MaxIncomingUniStreams),
|
||||
MaxAckDelay: protocol.MaxAckDelayInclGranularity,
|
||||
AckDelayExponent: protocol.AckDelayExponent,
|
||||
MaxUDPPayloadSize: protocol.MaxPacketBufferSize,
|
||||
DisableActiveMigration: true,
|
||||
StatelessResetToken: &statelessResetToken,
|
||||
OriginalDestinationConnectionID: origDestConnID,
|
||||
@@ -410,6 +411,7 @@ var newClientConnection = func(
|
||||
MaxBidiStreamNum: protocol.StreamNum(s.config.MaxIncomingStreams),
|
||||
MaxUniStreamNum: protocol.StreamNum(s.config.MaxIncomingUniStreams),
|
||||
MaxAckDelay: protocol.MaxAckDelayInclGranularity,
|
||||
MaxUDPPayloadSize: protocol.MaxPacketBufferSize,
|
||||
AckDelayExponent: protocol.AckDelayExponent,
|
||||
DisableActiveMigration: true,
|
||||
// For interoperability with quic-go versions before May 2023, this value must be set to a value
|
||||
|
||||
@@ -28,7 +28,7 @@ func getRandomValueUpTo(max int64) uint64 {
|
||||
}
|
||||
|
||||
func getRandomValue() uint64 {
|
||||
return getRandomValueUpTo(math.MaxInt64)
|
||||
return getRandomValueUpTo(quicvarint.Max)
|
||||
}
|
||||
|
||||
var _ = Describe("Transport Parameters", func() {
|
||||
@@ -102,7 +102,8 @@ var _ = Describe("Transport Parameters", func() {
|
||||
RetrySourceConnectionID: &rcid,
|
||||
AckDelayExponent: 13,
|
||||
MaxAckDelay: 42 * time.Millisecond,
|
||||
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(math.MaxInt64-2),
|
||||
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(quicvarint.Max-2),
|
||||
MaxUDPPayloadSize: 1200 + protocol.ByteCount(getRandomValueUpTo(quicvarint.Max-1200)),
|
||||
MaxDatagramFrameSize: protocol.ByteCount(getRandomValue()),
|
||||
}
|
||||
data := params.Marshal(protocol.PerspectiveServer)
|
||||
@@ -124,6 +125,7 @@ var _ = Describe("Transport Parameters", func() {
|
||||
Expect(p.AckDelayExponent).To(Equal(uint8(13)))
|
||||
Expect(p.MaxAckDelay).To(Equal(42 * time.Millisecond))
|
||||
Expect(p.ActiveConnectionIDLimit).To(Equal(params.ActiveConnectionIDLimit))
|
||||
Expect(p.MaxUDPPayloadSize).To(Equal(params.MaxUDPPayloadSize))
|
||||
Expect(p.MaxDatagramFrameSize).To(Equal(params.MaxDatagramFrameSize))
|
||||
})
|
||||
|
||||
@@ -176,13 +178,13 @@ var _ = Describe("Transport Parameters", func() {
|
||||
}))
|
||||
})
|
||||
|
||||
It("errors when the max_packet_size is too small", func() {
|
||||
It("errors when the max_udp_payload_size is too small", func() {
|
||||
b := quicvarint.Append(nil, uint64(maxUDPPayloadSizeParameterID))
|
||||
b = quicvarint.Append(b, uint64(quicvarint.Len(1199)))
|
||||
b = quicvarint.Append(b, 1199)
|
||||
Expect((&TransportParameters{}).Unmarshal(b, protocol.PerspectiveServer)).To(MatchError(&qerr.TransportError{
|
||||
ErrorCode: qerr.TransportParameterError,
|
||||
ErrorMessage: "invalid value for max_packet_size: 1199 (minimum 1200)",
|
||||
ErrorMessage: "invalid value for max_udp_payload_size: 1199 (minimum 1200)",
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -499,7 +501,7 @@ var _ = Describe("Transport Parameters", func() {
|
||||
InitialMaxData: protocol.ByteCount(getRandomValue()),
|
||||
MaxBidiStreamNum: protocol.StreamNum(getRandomValueUpTo(int64(protocol.MaxStreamCount))),
|
||||
MaxUniStreamNum: protocol.StreamNum(getRandomValueUpTo(int64(protocol.MaxStreamCount))),
|
||||
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(math.MaxInt64-2),
|
||||
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(quicvarint.Max-2),
|
||||
MaxDatagramFrameSize: protocol.ByteCount(getRandomValueUpTo(int64(MaxDatagramSize))),
|
||||
}
|
||||
Expect(params.ValidFor0RTT(params)).To(BeTrue())
|
||||
@@ -748,7 +750,7 @@ func benchmarkTransportParameters(b *testing.B, withPreferredAddress bool) {
|
||||
RetrySourceConnectionID: &rcid,
|
||||
AckDelayExponent: 13,
|
||||
MaxAckDelay: 42 * time.Millisecond,
|
||||
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(math.MaxInt64-2),
|
||||
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(quicvarint.Max-2),
|
||||
MaxDatagramFrameSize: protocol.ByteCount(getRandomValue()),
|
||||
}
|
||||
var token2 protocol.StatelessResetToken
|
||||
|
||||
@@ -302,7 +302,7 @@ func (p *TransportParameters) readNumericTransportParameter(b []byte, paramID tr
|
||||
p.MaxIdleTimeout = max(protocol.MinRemoteIdleTimeout, time.Duration(val)*time.Millisecond)
|
||||
case maxUDPPayloadSizeParameterID:
|
||||
if val < 1200 {
|
||||
return fmt.Errorf("invalid value for max_packet_size: %d (minimum 1200)", val)
|
||||
return fmt.Errorf("invalid value for max_udp_payload_size: %d (minimum 1200)", val)
|
||||
}
|
||||
p.MaxUDPPayloadSize = protocol.ByteCount(val)
|
||||
case ackDelayExponentParameterID:
|
||||
@@ -357,8 +357,10 @@ func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte {
|
||||
b = p.marshalVarintParam(b, initialMaxStreamsUniParameterID, uint64(p.MaxUniStreamNum))
|
||||
// idle_timeout
|
||||
b = p.marshalVarintParam(b, maxIdleTimeoutParameterID, uint64(p.MaxIdleTimeout/time.Millisecond))
|
||||
// max_packet_size
|
||||
b = p.marshalVarintParam(b, maxUDPPayloadSizeParameterID, uint64(protocol.MaxPacketBufferSize))
|
||||
// max_udp_payload_size
|
||||
if p.MaxUDPPayloadSize > 0 {
|
||||
b = p.marshalVarintParam(b, maxUDPPayloadSizeParameterID, uint64(p.MaxUDPPayloadSize))
|
||||
}
|
||||
// max_ack_delay
|
||||
// Only send it if is different from the default value.
|
||||
if p.MaxAckDelay != protocol.DefaultMaxAckDelay {
|
||||
|
||||
Reference in New Issue
Block a user