Also clamp MSS on IPv6

Some routers erratically drop "Packet too big" icmp messages, and PMTU
discovery then doesn't work. We can however easily clamp MSS on IPv6 too.
This commit is contained in:
Samuel Thibault 2023-11-05 17:21:14 +01:00
parent 7514eecf68
commit 3667bdfe80
3 changed files with 42 additions and 10 deletions

10
ppp.c
View file

@ -1803,7 +1803,7 @@ void processipin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
{
int ihl = (p[0] & 0xf) * 4; // length of IP header
if (l >= ihl + 20 && (p[ihl + 13] & TCP_FLAG_SYN) && ((p[ihl + 12] >> 4) > 5))
adjust_tcp_mss(s, t, p, l, p + ihl);
adjust_tcp4_mss(s, t, p, l, p + ihl);
}
// Add on the tun header
@ -2284,6 +2284,14 @@ void processipv6in(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
return;
}
// adjust MSS on SYN and SYN,ACK packets with options
if (p[6] == IPPROTO_TCP)
{
int ihl = 40; // length of IPv6 header
if (l >= ihl + 20 && (p[ihl + 13] & TCP_FLAG_SYN) && ((p[ihl + 12] >> 4) > 5))
adjust_tcp6_mss(s, t, p, l, p + ihl);
}
// Check if it's a Router Solicition message.
if (*(p + 6) == 58 && *(p + 7) == 255 && *(p + 24) == 0xFF && *(p + 25) == 2 &&
*(uint32_t *)(p + 26) == 0 && *(uint32_t *)(p + 30) == 0 &&