When the MTU on a network adapter is greater than PAGE_SIZE a special case in ip_fragment() can kick in to optimise the payloads.
Setup:
MTU = 5K
PAGE_SIZE = 4K
Send a ping packet of 7K.
The receive of the network adapter can use multiple MBUFs to receive a 7K payload, for example:
2k + 4k + 1k
When the packet gets echoed back, we end up in ip_fragment() which the split the packets oddly, because it assumes that each MBUF in the m_next chain ends on an MTU, which is not a requirement?!
This patch fixes the computation, so that the resulting transmitted packet chain will look like:
4k + 3k