File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -443,12 +443,25 @@ class Session : ProtoContextCallbackInterface,
443443 if (buf.size ())
444444 {
445445 const ProtoContext::ProtoConfig &c = proto_context.conf ();
446+
447+ bool df = true ;
448+
449+ // Check if the packet is IPv4
450+ if (IPCommon::version (buf[0 ]) == IPCommon::IPv4 && buf.size () >= sizeof (struct IPv4Header ))
451+ {
452+ // The Flags field is in the 6th byte (starting from index 6) of the IPv4 header
453+ uint16_t flags_and_fragment_offset = ntohs (*(uint16_t *)&buf[6 ]);
454+
455+ df = (flags_and_fragment_offset & IPv4Header::DF) != 0 ;
456+ }
457+
446458 // when calculating mss, we take IPv4 and TCP headers into account
447459 // here we need to add it back since we check the whole IP packet size, not just TCP payload
448460 constexpr size_t MinTcpHeader = 20 ;
449461 constexpr size_t MinIpHeader = 20 ;
450462 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)
463+
464+ if (df && c.mss_fix > 0 && buf.size () > mss_no_tcp_ip_encap)
452465 {
453466 Ptb::generate_icmp_ptb (buf, clamp_to_typerange<unsigned short >(mss_no_tcp_ip_encap));
454467 tun->tun_send (buf);
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ struct IPv4Header
5252 enum
5353 {
5454 OFFMASK = 0x1fff ,
55+ DF = 0x4000 ,
5556 };
5657 std::uint16_t frag_off;
5758
You can’t perform that action at this time.
0 commit comments