mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 20:59:58 +00:00
TUN-8667: Add datagram v3 session manager
New session manager leverages similar functionality that was previously provided with datagram v2, with the distinct difference that the sessions are registered via QUIC Datagrams and unregistered via timeouts only; the sessions will no longer attempt to unregister sessions remotely with the edge service. The Session Manager is shared across all QUIC connections that cloudflared uses to connect to the edge (typically 4). This will help cloudflared be able to monitor all sessions across the connections and help correlate in the future if sessions migrate across connections. The UDP payload size is still limited to 1280 bytes across all OS's. Any UDP packet that provides a payload size of greater than 1280 will cause cloudflared to report (as it currently does) a log error and drop the packet. Closes TUN-8667
This commit is contained in:
@@ -24,7 +24,7 @@ const (
|
||||
datagramTypeLen = 1
|
||||
|
||||
// 1280 is the default datagram packet length used before MTU discovery: https://github.com/quic-go/quic-go/blob/v0.45.0/internal/protocol/params.go#L12
|
||||
maxDatagramLen = 1280
|
||||
maxDatagramPayloadLen = 1280
|
||||
)
|
||||
|
||||
func parseDatagramType(data []byte) (DatagramType, error) {
|
||||
@@ -100,10 +100,10 @@ func (s *UDPSessionRegistrationDatagram) MarshalBinary() (data []byte, err error
|
||||
}
|
||||
var maxPayloadLen int
|
||||
if ipv6 {
|
||||
maxPayloadLen = maxDatagramLen - sessionRegistrationIPv6DatagramHeaderLen
|
||||
maxPayloadLen = maxDatagramPayloadLen + sessionRegistrationIPv6DatagramHeaderLen
|
||||
flags |= sessionRegistrationFlagsIPMask
|
||||
} else {
|
||||
maxPayloadLen = maxDatagramLen - sessionRegistrationIPv4DatagramHeaderLen
|
||||
maxPayloadLen = maxDatagramPayloadLen + sessionRegistrationIPv4DatagramHeaderLen
|
||||
}
|
||||
// Make sure that the payload being bundled can actually fit in the payload destination
|
||||
if len(s.Payload) > maxPayloadLen {
|
||||
@@ -195,7 +195,7 @@ const (
|
||||
datagramPayloadHeaderLen = datagramTypeLen + datagramRequestIdLen
|
||||
|
||||
// The maximum size that a proxied UDP payload can be in a [UDPSessionPayloadDatagram]
|
||||
maxPayloadPlusHeaderLen = maxDatagramLen - datagramPayloadHeaderLen
|
||||
maxPayloadPlusHeaderLen = maxDatagramPayloadLen + datagramPayloadHeaderLen
|
||||
)
|
||||
|
||||
// The datagram structure for UDPSessionPayloadDatagram is:
|
||||
@@ -270,7 +270,7 @@ const (
|
||||
datagramSessionRegistrationResponseLen = datagramTypeLen + datagramRespTypeLen + datagramRequestIdLen + datagramRespErrMsgLen
|
||||
|
||||
// The maximum size that an error message can be in a [UDPSessionRegistrationResponseDatagram].
|
||||
maxResponseErrorMessageLen = maxDatagramLen - datagramSessionRegistrationResponseLen
|
||||
maxResponseErrorMessageLen = maxDatagramPayloadLen - datagramSessionRegistrationResponseLen
|
||||
)
|
||||
|
||||
// SessionRegistrationResp represents all of the responses that a UDP session registration response
|
||||
|
Reference in New Issue
Block a user