All of lore.kernel.org
 help / color / mirror / Atom feed
* [LARTC] use 3rd octet as hashkey
@ 2003-11-24  4:34 Venkatesh. K
  2003-11-24 18:07 ` Martin Volf
  2003-11-25  9:27 ` Venkatesh. K
  0 siblings, 2 replies; 3+ messages in thread
From: Venkatesh. K @ 2003-11-24  4:34 UTC (permalink / raw)
  To: lartc

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

Hi,

I want to use 3rd octet in the ip address for creating hashng filters ?

How do I do it?

Venkatesh K

[-- Attachment #2: Type: text/html, Size: 620 bytes --]

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

* Re: [LARTC] use 3rd octet as hashkey
  2003-11-24  4:34 [LARTC] use 3rd octet as hashkey Venkatesh. K
@ 2003-11-24 18:07 ` Martin Volf
  2003-11-25  9:27 ` Venkatesh. K
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Volf @ 2003-11-24 18:07 UTC (permalink / raw)
  To: lartc

On Mon, 24 Nov 2003 09:52:30 +0530
"Venkatesh. K" <venkatesh@cbayscribe.com> wrote:

> Hi,
> 
> I want to use 3rd octet in the ip address for creating hashng filters?
> 
> How do I do it?

Hi,

what about this (two level hashing with the 3rd and the 4th octet):


FILTER_ADD="/sbin/tc filter add dev imq0 parent 1:0 protocol ip"

# 1st level - 3rd octet (mask 0x0000ff00)
$FILTER_ADD handle 2: u32 divisor 256
$FILTER_ADD u32 ht 800:: match ip dst 0/0 \
	hashkey mask 0x0000ff00 at 16 link 2:

# 2nd level - 4th octet (mask 0x000000ff)
for i in $(seq 0 255); do
	n=$(printf "%x" $i)
	$FILTER_ADD handle $n: u32 divisor 256
	$FILTER_ADD u32 ht 2:$n match ip dst 0/0 \
		hashkey mask 0x000000ff at 16 link $n:
done

# hexa 10.11.12.13 -> c:d
hexa()
{
	local IFS='.'
	set $1
	printf "%x:%x" $3 $4
}

# example: put 10.11.12.13 into the class 1:42
ip\x10.11.12.13
$FILTER_ADD u32 ht $(hexa $ip) match ip dst $ip flowid 1:42


Something like that is working for me for about half a year. If you need "match ip src", use "at 12" instead of "at 16".

HTH

-- 
Martin Volf
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

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

* Re: [LARTC] use 3rd octet as hashkey
  2003-11-24  4:34 [LARTC] use 3rd octet as hashkey Venkatesh. K
  2003-11-24 18:07 ` Martin Volf
@ 2003-11-25  9:27 ` Venkatesh. K
  1 sibling, 0 replies; 3+ messages in thread
From: Venkatesh. K @ 2003-11-25  9:27 UTC (permalink / raw)
  To: lartc

----- Original Message ----- 
From: "Martin Volf" <mv@inv.cz>
To: <lartc@mailman.ds9a.nl>
Sent: Monday, November 24, 2003 11:37 PM
Subject: Re: [LARTC] use 3rd octet as hashkey


> On Mon, 24 Nov 2003 09:52:30 +0530
> "Venkatesh. K" <venkatesh@cbayscribe.com> wrote:
>
> > Hi,
> >
> > I want to use 3rd octet in the ip address for creating hashng filters?
> >
> > How do I do it?
>
> Hi,
>
> what about this (two level hashing with the 3rd and the 4th octet):
>
>
> FILTER_ADD="/sbin/tc filter add dev imq0 parent 1:0 protocol ip"
>
> # 1st level - 3rd octet (mask 0x0000ff00)
> $FILTER_ADD handle 2: u32 divisor 256
> $FILTER_ADD u32 ht 800:: match ip dst 0/0 \
> hashkey mask 0x0000ff00 at 16 link 2:

I had thought about the above line. I have not been able understand
hashkey/mask of u32 filter fully as very little documentation is available.

I will try this out.

Thanks for the tip.

Venkatesh K

_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

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

end of thread, other threads:[~2003-11-25  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-24  4:34 [LARTC] use 3rd octet as hashkey Venkatesh. K
2003-11-24 18:07 ` Martin Volf
2003-11-25  9:27 ` Venkatesh. K

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.