Fix PMTU discovery via datagram SPTPS.
In send_sptps_data(), the len variable contains the length of the whole datagram that needs to be sent to the peer, including the overhead from SPTPS itself.
This commit is contained in:
parent
c35bfa18ec
commit
66f325f467
2 changed files with 6 additions and 1 deletions
|
@ -767,7 +767,7 @@ bool send_sptps_data(void *handle, uint8_t type, const char *data, size_t len) {
|
|||
|
||||
/* Send it via TCP if it is a handshake packet, TCPOnly is in use, or this packet is larger than the MTU. */
|
||||
|
||||
if(type >= SPTPS_HANDSHAKE || ((myself->options | to->options) & OPTION_TCPONLY) || (type != PKT_PROBE && len > to->minmtu)) {
|
||||
if(type >= SPTPS_HANDSHAKE || ((myself->options | to->options) & OPTION_TCPONLY) || (type != PKT_PROBE && (len - SPTPS_DATAGRAM_OVERHEAD) > to->minmtu)) {
|
||||
char buf[len * 4 / 3 + 5];
|
||||
b64encode(data, buf, len);
|
||||
/* If no valid key is known yet, send the packets using ANS_KEY requests,
|
||||
|
@ -792,6 +792,8 @@ bool send_sptps_data(void *handle, uint8_t type, const char *data, size_t len) {
|
|||
|
||||
if(sendto(listen_socket[sock].udp.fd, data, len, 0, &sa->sa, SALEN(sa->sa)) < 0 && !sockwouldblock(sockerrno)) {
|
||||
if(sockmsgsize(sockerrno)) {
|
||||
// Compensate for SPTPS overhead
|
||||
len -= SPTPS_DATAGRAM_OVERHEAD;
|
||||
if(to->maxmtu >= len)
|
||||
to->maxmtu = len - 1;
|
||||
if(to->mtu >= len)
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#define SPTPS_SIG 3 // Waiting for a SIGnature record
|
||||
#define SPTPS_ACK 4 // Waiting for an ACKnowledgement record
|
||||
|
||||
// Overhead for datagrams
|
||||
#define SPTPS_DATAGRAM_OVERHEAD 21
|
||||
|
||||
typedef bool (*send_data_t)(void *handle, uint8_t type, const char *data, size_t len);
|
||||
typedef bool (*receive_record_t)(void *handle, uint8_t type, const char *data, uint16_t len);
|
||||
|
||||
|
|
Loading…
Reference in a new issue