netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* question about frag_can_reassemble()
@ 2012-03-30 20:02 Dan Carpenter
  2012-03-31  8:52 ` Marek Lindner
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-03-30 20:02 UTC (permalink / raw)
  To: Sven Eckelmann
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r

Hi Sven,

I had a question about the code in frag_can_reassemble().

net/batman-adv/unicast.h
    51  
    52          merged_size = (skb->len - sizeof(*unicast_packet)) * 2;
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    53          merged_size += sizeof(struct unicast_packet) + uneven_correction;
    54  
    55          return merged_size <= mtu;
    56  }

Can the skb->len be less than sizeof(*unicast_packet) (ie 20 bytes)?
If "len" is less than 10 then we would return false but if it's
over 10 then we would return true.  Roughly.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: question about frag_can_reassemble()
  2012-03-30 20:02 question about frag_can_reassemble() Dan Carpenter
@ 2012-03-31  8:52 ` Marek Lindner
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2012-03-31  8:52 UTC (permalink / raw)
  To: b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Dan Carpenter


Dan,

> I had a question about the code in frag_can_reassemble().
> 
> net/batman-adv/unicast.h
>     51
>     52          merged_size = (skb->len - sizeof(*unicast_packet)) * 2;
>                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     53          merged_size += sizeof(struct unicast_packet) +
> uneven_correction; 54
>     55          return merged_size <= mtu;
>     56  }
> 
> Can the skb->len be less than sizeof(*unicast_packet) (ie 20 bytes)?
> If "len" is less than 10 then we would return false but if it's
> over 10 then we would return true.  Roughly.

the calling function checks for an existing unicast header. The call tree 
looks like this: 
recv_ucast_frag_packet() -> route_unicast_packet() -> frag_can_reassemble()
The first function does a unicast length check by calling 
check_unicast_packet(). As a result we ensure that we at least have the length 
of the unicast header in our packet unless we overlooked something ?

Regards,
Marek

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-31  8:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-30 20:02 question about frag_can_reassemble() Dan Carpenter
2012-03-31  8:52 ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).