Skip to content

Commit 583cb2e

Browse files
committed
tun_recv: removed mssfix limit for IPv4 traffic if DF is not set
Signed-off-by: Marco Baffo <[email protected]>
1 parent 9cafba7 commit 583cb2e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

openvpn/client/cliproto.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,21 @@ class Session : ProtoContextCallbackInterface,
443443
if (buf.size())
444444
{
445445
const ProtoContext::ProtoConfig &c = proto_context.conf();
446+
447+
bool df = true;
448+
449+
if (IPCommon::version(buf[0]) == IPCommon::IPv4 && buf.size() >= sizeof(struct IPv4Header))
450+
{
451+
df = IPv4Header::is_df_set(buf.c_data());
452+
}
453+
446454
// when calculating mss, we take IPv4 and TCP headers into account
447455
// here we need to add it back since we check the whole IP packet size, not just TCP payload
448456
constexpr size_t MinTcpHeader = 20;
449457
constexpr size_t MinIpHeader = 20;
450458
size_t mss_no_tcp_ip_encap = c.mss_fix + (MinTcpHeader + MinIpHeader);
451-
if (c.mss_fix > 0 && buf.size() > mss_no_tcp_ip_encap)
459+
460+
if (df && c.mss_fix > 0 && buf.size() > mss_no_tcp_ip_encap)
452461
{
453462
Ptb::generate_icmp_ptb(buf, clamp_to_typerange<unsigned short>(mss_no_tcp_ip_encap));
454463
tun->tun_send(buf);

openvpn/ip/ip4.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ struct IPv4Header
4343
return static_cast<uint8_t>(((len >> 2) & 0x0F) | (version & 0x0F) << 4);
4444
}
4545

46+
static bool is_df_set(const unsigned char *data)
47+
{
48+
auto *hdr = reinterpret_cast<const IPv4Header *>(data);
49+
return ntohs(hdr->frag_off) & IPv4Header::DF;
50+
}
51+
4652
std::uint8_t version_len;
4753

4854
std::uint8_t tos;
@@ -52,6 +58,7 @@ struct IPv4Header
5258
enum
5359
{
5460
OFFMASK = 0x1fff,
61+
DF = 0x4000,
5562
};
5663
std::uint16_t frag_off;
5764

0 commit comments

Comments
 (0)