<br><tt><font size=2>Eric Blake <eblake@redhat.com> wrote on 08/13/2010
03:56:12 PM:<br>
<br>
> [image removed] </font></tt>
<br>
<br><tt><font size=2>> <br>
> On 08/13/2010 01:45 PM, Stefan Berger wrote:<br>
> >>> -                
   // skip eth. bcast and mcast addresses,<br>
> >>> +                
   // skip eth. bcast and mcast addresses (224.0.0.0 <br>
> > -<br>
> >>> +                
   // 239.255.255.255), class E (255.*)<br>
> >>>                
     // and zero address in DHCP Requests<br>
> >>> -                
   if ((ntohl(vmaddr) & 0xc0000000) || vmaddr == 0) <br>
> <br>
> > </font></tt><a href=http://en.wikipedia.org/wiki/Classful_network><tt><font size=2>http://en.wikipedia.org/wiki/Classful_network</font></tt></a><tt><font size=2><br>
> > <br>
> > Class D addresses have highest bits with pattern 1110 0000 ->
0xe0<br>
> > Class E addresses have highest bits with pattern 1111 0000 ->
0xf0<br>
> > <br>
> > I think my masks are fine and the masking with 0xf0 00 00 00
should also <br>
> > include 254.*  =  0xfe.*  .<br>
> <br>
> In that case, the comments are wrong.  Class E is more than 255.*,
it is<br>
> 240.0.0.0-255.255.255.255.  And in that case, the bit operations
can be<br>
> simplified:<br>
> <br>
> if ((ntohl(vmaddr) & 0xc0000000) == 0xc0000000) || vmaddr == 0)<br>
> <br>
> In other words, the logic bug is that we were rejecting IP addresses<br>
> that had 1 or 2, but not all three, of the top three bits set.  The<br>
> desired action is to reject IP packets if all three of the top bits
are<br>
> simultaneously set.</font></tt>
<br>
<br><tt><font size=2>Right, the comment was not correct. I think the simplified
if should be</font></tt>
<br>
<br><tt><font size=2>if ((ntohl(vmaddr) & 0xe0000000) == 0xe0000000)
|| vmaddr == 0)<br>
</font></tt>
<br><tt><font size=2>That then covers class D and E since this mask then
covers 0xe0.00.00.00 - 0xff.ff.ff.ff = 225.0.0.0 - 255.255.255.255.</font></tt>
<br><tt><font size=2><br>
> <br>
> Let's see a v2 that gets the comments right, and uses the simpler
logic.</font></tt>
<br>
<br><tt><font size=2>Coming soon.</font></tt>
<br>
<br><tt><font size=2>   Stefan</font></tt>
<br>