On Tue, 23 Oct 2007 12:10:21 -0000, anshul makkar
<(E-Mail Removed)> wrote:
>Hi,
>I tried to apply the above given logic on the range 49930 - 50175, but
>it did'nt work.
>2^16 = 65536.
>65536 -1 = 65535 = 0xffff. = mask value
>
>Now I need to match (50175 - 49930) = 245 = 0xF5 values.
>
>Thus the modified mask value = 0xffff - 0xf5 = 0xff0a.
This mask is problematic because it does not end with one or more
zeros. Mostly only port numbers ending with binary 1010 are going to
match. I'd like to replace "mostly" with "only" but the problem here
is that only ports where that rightmost 1 bit is set are going to
match your mask.
These are valid with u32. Ignore the hyphens, they are here so that
counting ones is easier:
1111-1111-0000-0000 = 0xFF00
1111-1111-1000-0000 = 0xFF80
1111-1111-1100-0000 = 0xFFC0
1111-1111-1110-0000 = 0xFFE0
1111-1111-1111-0000 = 0xFFF0
1111-1111-1111-1000 = 0xFFF8
If you set the mask to 0xFF00 then you will expand the port range
beyond what you want. If you set it to 0xff80 the opposite... But
both of these masks IN BINARY switch from a string of contiguous ones
to a string of contiguous zeros, and that is what works for a u32
match.
If you Just Gotta Have the specified port range, think about marking
your desired port range with iptables and then set your tc match to
match the mark. Perhaps 2 filter lines will accomplish what you want.
I am not able to find it now, but there was recently in the LARTC
mailing list a link to an excellent write up for filters. Maybe this
is it:
http://www.stuart.id.au/russell/file...tc/cls_u32.txt
--
buck