[PATCH 4/6] net: fix ip_len in reassembled IP datagram

Tom Rini trini at konsulko.com
Mon Nov 28 20:51:29 CET 2022


On Fri, Oct 14, 2022 at 07:43:40PM +0200, Rasmus Villemoes wrote:

> For some reason, the ip_len field in a reassembled IP datagram is set
> to just the size of the payload, but it should be set to the value it
> would have had if the datagram had never been fragmented in the first
> place, i.e. size of payload plus size of IP header.
> 
> That latter value is currently returned correctly via the "len"
> variable. And before entering net_defragment(), len does have the
> value ntohs(ip->ip_len), so if we're not dealing with a
> fragment (so net_defragment leaves *len alone), that relationship of
> course also holds after the net_defragment() call.
> 
> The only use I can find of ip->ip_len after the net_defragment call is
> the ntohs(ip->udp_len) > ntohs(ip->ip_len) sanity check - none of the
> functions that are passed the "ip" pointer themselves inspect ->ip_len
> but instead use the passed len.
> 
> But that sanity check is a bit odd, since the RHS really should be
> "ntohs(ip->ip_len) - 20", i.e. the IP payload size.
> 
> Now that we've fixed things so that len == ntohs(ip->ip_len) in all
> cases, change that sanity check to use len-20 as the RHS.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20221128/a2018a1d/attachment.sig>


More information about the U-Boot mailing list