Net: Fix IPv4 fragmentation not working for larger payloads

We were masking the fragment offset bits incorrectly in the IPv4 header
sent out with fragments. This worked up to ~32KB but after that, things
would get very confused. :^)
This commit is contained in:
Andreas Kling 2020-07-28 20:33:24 +02:00
parent f5ac4da993
commit a2ad0ae5fc
Notes: sideshowbarker 2024-07-19 04:29:27 +09:00

View file

@ -81,7 +81,7 @@ public:
const void* payload() const { return this + 1; }
u16 flags_and_fragment() const { return m_flags_and_fragment; }
u16 fragment_offset() const { return ((u16)m_flags_and_fragment & 0x2fff); }
u16 fragment_offset() const { return ((u16)m_flags_and_fragment & 0x1fff); }
u16 flags() const { return (((u16)m_flags_and_fragment) & (((u16)IPv4PacketFlags::MoreFragments) | ((u16)IPv4PacketFlags::DontFragment))); }
void set_has_more_fragments(bool more_fragments)
@ -93,13 +93,13 @@ public:
}
void set_fragment_offset(u16 offset)
{
m_flags_and_fragment = flags() | (offset & 0x2fff);
m_flags_and_fragment = flags() | (offset & 0x1fff);
}
bool is_a_fragment() const
{
// either has More-Fragments set, or has a fragment offset
return (((u16)m_flags_and_fragment) & ((u16)IPv4PacketFlags::MoreFragments)) || ((u16)m_flags_and_fragment & 0x2fff);
return (((u16)m_flags_and_fragment) & ((u16)IPv4PacketFlags::MoreFragments)) || ((u16)m_flags_and_fragment & 0x1fff);
}
u16 payload_size() const { return m_length - sizeof(IPv4Packet); }