* [LARTC] [PATCH] TC: bug fixes to the "sample" clause
@ 2006-02-10 2:33 ` Russell Stuart
0 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-02-10 2:33 UTC (permalink / raw)
To: netdev, lartc, shemminger
PATCH 1
===
On my machine tc does not parse filter "sample" for the u32
filter. Eg:
tc filter add dev eth2 parent 1:0 protocol ip prio 1 u32 ht 801: \
classid 1:3 \
sample ip protocol 1 0xff match ip protocol 1 0xff
Illegal "sample"
The reason is a missing memset. This patch fixes it.
diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
--- iproute-20051007.keep/tc/f_u32.c 2005-01-19 08:11:58.000000000 +1000
+++ iproute-20051007/tc/f_u32.c 2006-01-12 17:12:43.000000000 +1000
@@ -878,6 +878,7 @@
struct tc_u32_sel sel;
struct tc_u32_key keys[4];
} sel2;
+ memset(&sel2, 0, sizeof(sel2));
NEXT_ARG();
if (parse_selector(&argc, &argv, &sel2.sel, n)) {
fprintf(stderr, "Illegal \"sample\"\n");
PATCH 2
===
In tc, the u32 sample clause uses the 2.4 hashing algorithm.
The hashing algorithm used by the kernel changed in 2.6,
consequently "sample" hasn't work since then.
This patch makes the sample clause work for both 2.4 and 2.6:
diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
--- iproute-20051007.keep/tc/f_u32.c 2006-01-12 17:34:37.000000000 +1000
+++ iproute-20051007/tc/f_u32.c 2006-02-07 17:10:29.000000000 +1000
@@ -17,6 +17,7 @@
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
+#include <sys/utsname.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
@@ -874,6 +875,7 @@
htid = (handle&0xFFFFF000);
} else if (strcmp(*argv, "sample") = 0) {
__u32 hash;
+ struct utsname utsname;
struct {
struct tc_u32_sel sel;
struct tc_u32_key keys[4];
@@ -889,8 +891,19 @@
return -1;
}
hash = sel2.sel.keys[0].val&sel2.sel.keys[0].mask;
- hash ^= hash>>16;
- hash ^= hash>>8;
+ uname(&utsname);
+ if (strncmp(utsname.release, "2.4.", 4) = 0) {
+ hash ^= hash>>16;
+ hash ^= hash>>8;
+ }
+ else {
+ __u32 mask = sel2.sel.keys[0].mask;
+ while (mask && !(mask & 1)) {
+ mask >>= 1;
+ hash >>= 1;
+ }
+ hash &= 0xFF;
+ }
htid = ((hash<<12)&0xFF000)|(htid&0xFFF00000);
sample_ok = 1;
continue;
PATCH 3
===
"tc" does not allow you to specify the divisor for the
"sample" clause, it always assumes a divisor of 256.
If the divisor isn't 256, (ie it is something less),
the kernel will usually whinge because the bucket given
to it by "tc" is typically too big.
This patch adds a "divisor" option to tc's "sample"
clause:
diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
--- iproute-20051007.keep/tc/f_u32.c 2006-02-10 11:40:16.000000000 +1000
+++ iproute-20051007/tc/f_u32.c 2006-02-10 11:47:14.000000000 +1000
@@ -35,7 +35,7 @@
fprintf(stderr, "or u32 divisor DIVISOR\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
- fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} | mark } SAMPLE_ARGS\n");
+ fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} | mark } SAMPLE_ARGS [divisor DIVISOR]\n");
fprintf(stderr, " FILTERID := X:Y:Z\n");
}
@@ -835,7 +835,7 @@
unsigned divisor;
NEXT_ARG();
if (get_unsigned(&divisor, *argv, 0) || divisor = 0 ||
- divisor > 0x100) {
+ divisor > 0x100 || (divisor - 1 & divisor)) {
fprintf(stderr, "Illegal \"divisor\"\n");
return -1;
}
@@ -875,6 +875,7 @@
htid = (handle&0xFFFFF000);
} else if (strcmp(*argv, "sample") = 0) {
__u32 hash;
+ unsigned divisor = 0x100;
struct utsname utsname;
struct {
struct tc_u32_sel sel;
@@ -890,6 +891,15 @@
fprintf(stderr, "\"sample\" must contain exactly ONE key.\n");
return -1;
}
+ if (*argv != 0 && strcmp(*argv, "divisor") = 0) {
+ NEXT_ARG();
+ if (get_unsigned(&divisor, *argv, 0) || divisor = 0 ||
+ divisor > 0x100 || (divisor - 1 & divisor)) {
+ fprintf(stderr, "Illegal sample \"divisor\"\n");
+ return -1;
+ }
+ NEXT_ARG();
+ }
hash = sel2.sel.keys[0].val&sel2.sel.keys[0].mask;
uname(&utsname);
if (strncmp(utsname.release, "2.4.", 4) = 0) {
@@ -904,7 +913,7 @@
}
hash &= 0xFF;
}
- htid = ((hash<<12)&0xFF000)|(htid&0xFFF00000);
+ htid = ((hash%divisor)<<12)|(htid&0xFFF00000);
sample_ok = 1;
continue;
} else if (strcmp(*argv, "indev") = 0) {
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread* [PATCH] TC: bug fixes to the "sample" clause
@ 2006-02-10 2:33 ` Russell Stuart
0 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-02-10 2:33 UTC (permalink / raw)
To: netdev, lartc, shemminger
PATCH 1
=======
On my machine tc does not parse filter "sample" for the u32
filter. Eg:
tc filter add dev eth2 parent 1:0 protocol ip prio 1 u32 ht 801: \
classid 1:3 \
sample ip protocol 1 0xff match ip protocol 1 0xff
Illegal "sample"
The reason is a missing memset. This patch fixes it.
diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
--- iproute-20051007.keep/tc/f_u32.c 2005-01-19 08:11:58.000000000 +1000
+++ iproute-20051007/tc/f_u32.c 2006-01-12 17:12:43.000000000 +1000
@@ -878,6 +878,7 @@
struct tc_u32_sel sel;
struct tc_u32_key keys[4];
} sel2;
+ memset(&sel2, 0, sizeof(sel2));
NEXT_ARG();
if (parse_selector(&argc, &argv, &sel2.sel, n)) {
fprintf(stderr, "Illegal \"sample\"\n");
PATCH 2
=======
In tc, the u32 sample clause uses the 2.4 hashing algorithm.
The hashing algorithm used by the kernel changed in 2.6,
consequently "sample" hasn't work since then.
This patch makes the sample clause work for both 2.4 and 2.6:
diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
--- iproute-20051007.keep/tc/f_u32.c 2006-01-12 17:34:37.000000000 +1000
+++ iproute-20051007/tc/f_u32.c 2006-02-07 17:10:29.000000000 +1000
@@ -17,6 +17,7 @@
#include <syslog.h>
#include <fcntl.h>
#include <sys/socket.h>
+#include <sys/utsname.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
@@ -874,6 +875,7 @@
htid = (handle&0xFFFFF000);
} else if (strcmp(*argv, "sample") == 0) {
__u32 hash;
+ struct utsname utsname;
struct {
struct tc_u32_sel sel;
struct tc_u32_key keys[4];
@@ -889,8 +891,19 @@
return -1;
}
hash = sel2.sel.keys[0].val&sel2.sel.keys[0].mask;
- hash ^= hash>>16;
- hash ^= hash>>8;
+ uname(&utsname);
+ if (strncmp(utsname.release, "2.4.", 4) == 0) {
+ hash ^= hash>>16;
+ hash ^= hash>>8;
+ }
+ else {
+ __u32 mask = sel2.sel.keys[0].mask;
+ while (mask && !(mask & 1)) {
+ mask >>= 1;
+ hash >>= 1;
+ }
+ hash &= 0xFF;
+ }
htid = ((hash<<12)&0xFF000)|(htid&0xFFF00000);
sample_ok = 1;
continue;
PATCH 3
=======
"tc" does not allow you to specify the divisor for the
"sample" clause, it always assumes a divisor of 256.
If the divisor isn't 256, (ie it is something less),
the kernel will usually whinge because the bucket given
to it by "tc" is typically too big.
This patch adds a "divisor" option to tc's "sample"
clause:
diff -Nur iproute-20051007.keep/tc/f_u32.c iproute-20051007/tc/f_u32.c
--- iproute-20051007.keep/tc/f_u32.c 2006-02-10 11:40:16.000000000 +1000
+++ iproute-20051007/tc/f_u32.c 2006-02-10 11:47:14.000000000 +1000
@@ -35,7 +35,7 @@
fprintf(stderr, "or u32 divisor DIVISOR\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where: SELECTOR := SAMPLE SAMPLE ...\n");
- fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} | mark } SAMPLE_ARGS\n");
+ fprintf(stderr, " SAMPLE := { ip | ip6 | udp | tcp | icmp | u{32|16|8} | mark } SAMPLE_ARGS [divisor DIVISOR]\n");
fprintf(stderr, " FILTERID := X:Y:Z\n");
}
@@ -835,7 +835,7 @@
unsigned divisor;
NEXT_ARG();
if (get_unsigned(&divisor, *argv, 0) || divisor == 0 ||
- divisor > 0x100) {
+ divisor > 0x100 || (divisor - 1 & divisor)) {
fprintf(stderr, "Illegal \"divisor\"\n");
return -1;
}
@@ -875,6 +875,7 @@
htid = (handle&0xFFFFF000);
} else if (strcmp(*argv, "sample") == 0) {
__u32 hash;
+ unsigned divisor = 0x100;
struct utsname utsname;
struct {
struct tc_u32_sel sel;
@@ -890,6 +891,15 @@
fprintf(stderr, "\"sample\" must contain exactly ONE key.\n");
return -1;
}
+ if (*argv != 0 && strcmp(*argv, "divisor") == 0) {
+ NEXT_ARG();
+ if (get_unsigned(&divisor, *argv, 0) || divisor == 0 ||
+ divisor > 0x100 || (divisor - 1 & divisor)) {
+ fprintf(stderr, "Illegal sample \"divisor\"\n");
+ return -1;
+ }
+ NEXT_ARG();
+ }
hash = sel2.sel.keys[0].val&sel2.sel.keys[0].mask;
uname(&utsname);
if (strncmp(utsname.release, "2.4.", 4) == 0) {
@@ -904,7 +913,7 @@
}
hash &= 0xFF;
}
- htid = ((hash<<12)&0xFF000)|(htid&0xFFF00000);
+ htid = ((hash%divisor)<<12)|(htid&0xFFF00000);
sample_ok = 1;
continue;
} else if (strcmp(*argv, "indev") == 0) {
^ permalink raw reply [flat|nested] 30+ messages in thread[parent not found: <1142082696.5184.53.camel@jzny2>]
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
[not found] ` <1142082696.5184.53.camel@jzny2>
@ 2006-03-13 4:44 ` Russell Stuart
2006-03-14 2:29 ` Russell Stuart
[not found] ` <1142085718.5184.73.camel@jzny2>
2 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-13 4:44 UTC (permalink / raw)
To: hadi; +Cc: netdev, lartc
On Sat, 2006-03-11 at 08:11 -0500, jamal wrote:
> > On my machine tc does not parse filter "sample" for the u32
> > filter. Eg:
> >
> > tc filter add dev eth2 parent 1:0 protocol ip prio 1 u32 ht 801: \
> > classid 1:3 \
> > sample ip protocol 1 0xff match ip protocol 1 0xff
> > Illegal "sample"
> >
>
> The syntax is correct but ht 801: must exist - that is why it is being
> rejected.. So there is absolutely categorically _no way in hell_ your
> memset would have fixed it ;-> Apologies for being overdramatic ;->
You are wrong on both counts.
Firstly, the error message came from tc when it parsed
the line. If tc gets an error talking to the kernel it
says, among other things:
"We have an error talking to the kernel"
Ergo, it hadn't given the command to the kernel yet.
This is significant, because the only place that
knows whether ht 801: has been created or not is
the kernel. So obviously the error message can't
depend on whether the table had been created.
As it happens I did create the ht before issuing the
prior command when I first struck the bug - but I
didn't show it in my example because it was not
relevant.
As for _no way in hell_ - there are apparently more ways
in hell then you are aware of. If you look at the
function pack_key() in tc/f_u32.c, you will see it
assumes the "sel" parameter it is passed is initialised.
Without the added "memset()" it isn't - it just contains
random crap. Of course on some machines (perhaps yours?)
that random crap might be 0, and then it would work.
That is why I said at the start of my patch "On my
machine tc does not ...". On other machines the bug
may not appear.
> sample never worked 100% of the time with that hash. It works _most_ of
> the time with 256 buckets. Infact it will work some of the time as it is
> right now with 2.6.x. Can you post the output of tc -s filter ls on 2.6
> with and without your user space change?
Re: "sample never worked 100% of the time with that
hash". Can you give an example? As far as I know it
always worked.
Re: "it will work some of the time as it is right now
with 2.6.x". Yes - it will work when you are sampling
one byte. I am sampling port numbers, which are two
bytes. It will not work in any case where there are
two non-zero bytes.
Re: "Can you post the output of tc -s filter ls on 2.6
with and without your user space change?". Here it is:
With my change:
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample tcp src 0x369 0xffff match tcp src 0x0369 0xffff
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:3:800 order 2048 key ht 801 bkt 3 flowid 1:
match 03690000/ffff0000 at nexthdr+0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
On the orginal "tc" shipped with debian "sarge":
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample tcp src 0x369 0xffff match tcp src 0x0369 0xffff
Illegal "sample"
Ooops. Looks like I can't get out of this without patching
and compiling:
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample tcp src 0x369 0xffff match tcp src 0x0369 0xffff
tc -s filter show dev eth0filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:6a:800 order 2048 key ht 801 bkt 6a flowid 1:
match 03690000/ffff0000 at nexthdr+0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
Note: this also answers you request in your other email re:
"can you give me an example that doesn't work".
> Heres how you should fix this:
> Patch1) fix kernel 2.4.x to be like 2.6.x
> patch 2) fix iproute2 to have the same syntax as for 2.6 and put a big
> bold note in the code that if anyone changes that part of the code to
> look at the kernel u32_hash_fold() routine.
> no need for the utsname check.
Why do it that way? If you want to put the 2.6 hashing
algorithm in 2.4 then go ahead - but that is a separate
decision which is not related to the issue of making tc
backwards compatible. Making tc work with all versions of
the kernel is what I am doing there. As an example of why
this is a good idea, Debian ships 2.4 and 2.6 kernels,
and one version of tc. That tc should work with both
kernels.
Finally, regarding which hashing algorithm is better,
your results differ from mine. First a bit of
background: I am trying make VOIP work over some 256/64
and 512/128 links that carry all sorts of other traffic.
The patches you see here are a result of me trying to
make that work over a range of sites (companies and
home setups). The end result is that it did work, better
than I expected it to. On a 512/128 ADSL link, I can:
a. Saturate the incoming direction with a large wget,
b. Saturate the outgoing direction with a large wget,
c. Hit the incoming direction with a "while :; do
wget http://www.google.com/ -O /dev/null; done".
d. Hit the outgoing direction with an external box
doing the same while loop.
While all that is going on, I can sustain 2 VOIP calls
with perfect clarity on that link. I wasn't expecting to
be able to pull that off. To pull it off I created the
u32 filter from hell. This long winded explanation is to
forestall the inevitable "why the hell you want want to do
that" flame when you see the script that follows.
You can find the shell script that creates the filter here:
http://www.stuart.id.au/russell/files/tc/setup-traffic-control.sh
The script itself is not that important. What is important
is that it is a real-life use of u32, and there are approx
1200 hashed u32 filter lines.
So how to means how good a job the hash is doing. The
easiest would seem to be to use a least squares fit, ie:
Number of elements to be hashed = E
Number of buckets = B (= 256)
Optimal number of elements per bucket = E/B
Hash function "goodness" metric = M sqrt(sum foreach bucket i: [ (NrOfElementsInBucket(i) - E/B)^2 ] / B)
For a good hash function M < 1. The bigger M is the
worse the hash function is. I wrote a python program to
compute M for my u32 filter. The python program can be
found here:
http://www.stuart.id.au/russell/files/tc/tc-ports
The dataset it operates on can be found here:
http://www.stuart.id.au/russell/files/tc/m.py
Results:
tcp 2.6: ES4 M=2.35
tcp 2.4: ES4 M=0.82
udp 2.6: Eq1 M=2.91
udp 2.4: Eq1 M=0.92
As you can probably tell, I see the new hash function in 2.6
as a backward step - not an improvement.
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 4:44 ` Russell Stuart
0 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-13 4:44 UTC (permalink / raw)
To: hadi; +Cc: netdev, lartc
On Sat, 2006-03-11 at 08:11 -0500, jamal wrote:
> > On my machine tc does not parse filter "sample" for the u32
> > filter. Eg:
> >
> > tc filter add dev eth2 parent 1:0 protocol ip prio 1 u32 ht 801: \
> > classid 1:3 \
> > sample ip protocol 1 0xff match ip protocol 1 0xff
> > Illegal "sample"
> >
>
> The syntax is correct but ht 801: must exist - that is why it is being
> rejected.. So there is absolutely categorically _no way in hell_ your
> memset would have fixed it ;-> Apologies for being overdramatic ;->
You are wrong on both counts.
Firstly, the error message came from tc when it parsed
the line. If tc gets an error talking to the kernel it
says, among other things:
"We have an error talking to the kernel"
Ergo, it hadn't given the command to the kernel yet.
This is significant, because the only place that
knows whether ht 801: has been created or not is
the kernel. So obviously the error message can't
depend on whether the table had been created.
As it happens I did create the ht before issuing the
prior command when I first struck the bug - but I
didn't show it in my example because it was not
relevant.
As for _no way in hell_ - there are apparently more ways
in hell then you are aware of. If you look at the
function pack_key() in tc/f_u32.c, you will see it
assumes the "sel" parameter it is passed is initialised.
Without the added "memset()" it isn't - it just contains
random crap. Of course on some machines (perhaps yours?)
that random crap might be 0, and then it would work.
That is why I said at the start of my patch "On my
machine tc does not ...". On other machines the bug
may not appear.
> sample never worked 100% of the time with that hash. It works _most_ of
> the time with 256 buckets. Infact it will work some of the time as it is
> right now with 2.6.x. Can you post the output of tc -s filter ls on 2.6
> with and without your user space change?
Re: "sample never worked 100% of the time with that
hash". Can you give an example? As far as I know it
always worked.
Re: "it will work some of the time as it is right now
with 2.6.x". Yes - it will work when you are sampling
one byte. I am sampling port numbers, which are two
bytes. It will not work in any case where there are
two non-zero bytes.
Re: "Can you post the output of tc -s filter ls on 2.6
with and without your user space change?". Here it is:
With my change:
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample tcp src 0x369 0xffff match tcp src 0x0369 0xffff
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:3:800 order 2048 key ht 801 bkt 3 flowid 1:
match 03690000/ffff0000 at nexthdr+0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
On the orginal "tc" shipped with debian "sarge":
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample tcp src 0x369 0xffff match tcp src 0x0369 0xffff
Illegal "sample"
Ooops. Looks like I can't get out of this without patching
and compiling:
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample tcp src 0x369 0xffff match tcp src 0x0369 0xffff
tc -s filter show dev eth0filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:6a:800 order 2048 key ht 801 bkt 6a flowid 1:
match 03690000/ffff0000 at nexthdr+0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
Note: this also answers you request in your other email re:
"can you give me an example that doesn't work".
> Heres how you should fix this:
> Patch1) fix kernel 2.4.x to be like 2.6.x
> patch 2) fix iproute2 to have the same syntax as for 2.6 and put a big
> bold note in the code that if anyone changes that part of the code to
> look at the kernel u32_hash_fold() routine.
> no need for the utsname check.
Why do it that way? If you want to put the 2.6 hashing
algorithm in 2.4 then go ahead - but that is a separate
decision which is not related to the issue of making tc
backwards compatible. Making tc work with all versions of
the kernel is what I am doing there. As an example of why
this is a good idea, Debian ships 2.4 and 2.6 kernels,
and one version of tc. That tc should work with both
kernels.
Finally, regarding which hashing algorithm is better,
your results differ from mine. First a bit of
background: I am trying make VOIP work over some 256/64
and 512/128 links that carry all sorts of other traffic.
The patches you see here are a result of me trying to
make that work over a range of sites (companies and
home setups). The end result is that it did work, better
than I expected it to. On a 512/128 ADSL link, I can:
a. Saturate the incoming direction with a large wget,
b. Saturate the outgoing direction with a large wget,
c. Hit the incoming direction with a "while :; do
wget http://www.google.com/ -O /dev/null; done".
d. Hit the outgoing direction with an external box
doing the same while loop.
While all that is going on, I can sustain 2 VOIP calls
with perfect clarity on that link. I wasn't expecting to
be able to pull that off. To pull it off I created the
u32 filter from hell. This long winded explanation is to
forestall the inevitable "why the hell you want want to do
that" flame when you see the script that follows.
You can find the shell script that creates the filter here:
http://www.stuart.id.au/russell/files/tc/setup-traffic-control.sh
The script itself is not that important. What is important
is that it is a real-life use of u32, and there are approx
1200 hashed u32 filter lines.
So how to means how good a job the hash is doing. The
easiest would seem to be to use a least squares fit, ie:
Number of elements to be hashed = E
Number of buckets = B (== 256)
Optimal number of elements per bucket = E/B
Hash function "goodness" metric = M =
sqrt(sum foreach bucket i: [ (NrOfElementsInBucket(i) - E/B)^2 ] / B)
For a good hash function M < 1. The bigger M is the
worse the hash function is. I wrote a python program to
compute M for my u32 filter. The python program can be
found here:
http://www.stuart.id.au/russell/files/tc/tc-ports
The dataset it operates on can be found here:
http://www.stuart.id.au/russell/files/tc/m.py
Results:
tcp 2.6: E=534 M=2.35
tcp 2.4: E=534 M=0.82
udp 2.6: E=711 M=2.91
udp 2.4: E=711 M=0.92
As you can probably tell, I see the new hash function in 2.6
as a backward step - not an improvement.
^ permalink raw reply [flat|nested] 30+ messages in thread[parent not found: <1142269090.5242.29.camel@jzny2>]
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
[not found] ` <1142269090.5242.29.camel@jzny2>
@ 2006-03-13 17:55 ` Patrick McHardy
0 siblings, 0 replies; 30+ messages in thread
From: Patrick McHardy @ 2006-03-13 17:55 UTC (permalink / raw)
To: hadi; +Cc: netdev, lartc
jamal wrote:
> On Mon, 2006-13-03 at 14:44 +1000, Russell Stuart wrote:
>
>>You are wrong on both counts.
>
>
> I am wrong on why it is being rejected - but what you are seeing is
> worse than i thought initially.
>
> Lets put it this way:
> The only you will _ever_ get that message is if you had made a syntax
> error (which you did not). Please look at the code on where that message
> appears and:
>
> a) tell me how you would have got that message to begin with using
> perfectly legal syntax.
> a) tell me how a memset would have fixed that.
He already told you, pack_key expects the selector to be initialized,
otherwise nkeys might contain a value >= 128, which would cause
exactly this error, if a matching key is not found within the
uninitialized memory by accident.
> Just send the memset fix to Stephen with a different reason. Your
> current reason is _wrong_ and i really dont have much time to have this
> kind of discussion.
> If you had said "I added that memset there because it looks like the
> right thing to do" then we would not have had this discussion.
>
> You made claims you fixed a bug. It cant possibly be the bug you fixed.
> Was it some other bug perhaps and you mixed up the two?
The patch as well as the description are perfectly fine.
BTW, running valgrind on tc shows lots of uses of uninitialized values,
it seems like a good idea if someone would go over these and fix them
up.
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 17:55 ` Patrick McHardy
0 siblings, 0 replies; 30+ messages in thread
From: Patrick McHardy @ 2006-03-13 17:55 UTC (permalink / raw)
To: hadi; +Cc: netdev, lartc
jamal wrote:
> On Mon, 2006-13-03 at 14:44 +1000, Russell Stuart wrote:
>
>>You are wrong on both counts.
>
>
> I am wrong on why it is being rejected - but what you are seeing is
> worse than i thought initially.
>
> Lets put it this way:
> The only you will _ever_ get that message is if you had made a syntax
> error (which you did not). Please look at the code on where that message
> appears and:
>
> a) tell me how you would have got that message to begin with using
> perfectly legal syntax.
> a) tell me how a memset would have fixed that.
He already told you, pack_key expects the selector to be initialized,
otherwise nkeys might contain a value >= 128, which would cause
exactly this error, if a matching key is not found within the
uninitialized memory by accident.
> Just send the memset fix to Stephen with a different reason. Your
> current reason is _wrong_ and i really dont have much time to have this
> kind of discussion.
> If you had said "I added that memset there because it looks like the
> right thing to do" then we would not have had this discussion.
>
> You made claims you fixed a bug. It cant possibly be the bug you fixed.
> Was it some other bug perhaps and you mixed up the two?
The patch as well as the description are perfectly fine.
BTW, running valgrind on tc shows lots of uses of uninitialized values,
it seems like a good idea if someone would go over these and fix them
up.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
2006-03-13 17:55 ` Patrick McHardy
@ 2006-03-13 18:04 ` Stephen Hemminger
-1 siblings, 0 replies; 30+ messages in thread
From: Stephen Hemminger @ 2006-03-13 18:04 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, hadi, lartc
On Mon, 13 Mar 2006 18:55:35 +0100
Patrick McHardy <kaber@trash.net> wrote:
> jamal wrote:
> > On Mon, 2006-13-03 at 14:44 +1000, Russell Stuart wrote:
> >
> >>You are wrong on both counts.
> >
> >
> > I am wrong on why it is being rejected - but what you are seeing is
> > worse than i thought initially.
> >
> > Lets put it this way:
> > The only you will _ever_ get that message is if you had made a syntax
> > error (which you did not). Please look at the code on where that message
> > appears and:
> >
> > a) tell me how you would have got that message to begin with using
> > perfectly legal syntax.
> > a) tell me how a memset would have fixed that.
>
> He already told you, pack_key expects the selector to be initialized,
> otherwise nkeys might contain a value >= 128, which would cause
> exactly this error, if a matching key is not found within the
> uninitialized memory by accident.
>
> > Just send the memset fix to Stephen with a different reason. Your
> > current reason is _wrong_ and i really dont have much time to have this
> > kind of discussion.
> > If you had said "I added that memset there because it looks like the
> > right thing to do" then we would not have had this discussion.
> >
> > You made claims you fixed a bug. It cant possibly be the bug you fixed.
> > Was it some other bug perhaps and you mixed up the two?
The memset fix is in current CVS. I just wasn't going to take the
patch that looked at utsname to decide what hash to use.
> The patch as well as the description are perfectly fine.
>
> BTW, running valgrind on tc shows lots of uses of uninitialized values,
> it seems like a good idea if someone would go over these and fix them
> up.
If we had a test script of commands (code coverage), that would help.
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 18:04 ` Stephen Hemminger
0 siblings, 0 replies; 30+ messages in thread
From: Stephen Hemminger @ 2006-03-13 18:04 UTC (permalink / raw)
To: Patrick McHardy; +Cc: netdev, hadi, lartc
On Mon, 13 Mar 2006 18:55:35 +0100
Patrick McHardy <kaber@trash.net> wrote:
> jamal wrote:
> > On Mon, 2006-13-03 at 14:44 +1000, Russell Stuart wrote:
> >
> >>You are wrong on both counts.
> >
> >
> > I am wrong on why it is being rejected - but what you are seeing is
> > worse than i thought initially.
> >
> > Lets put it this way:
> > The only you will _ever_ get that message is if you had made a syntax
> > error (which you did not). Please look at the code on where that message
> > appears and:
> >
> > a) tell me how you would have got that message to begin with using
> > perfectly legal syntax.
> > a) tell me how a memset would have fixed that.
>
> He already told you, pack_key expects the selector to be initialized,
> otherwise nkeys might contain a value >= 128, which would cause
> exactly this error, if a matching key is not found within the
> uninitialized memory by accident.
>
> > Just send the memset fix to Stephen with a different reason. Your
> > current reason is _wrong_ and i really dont have much time to have this
> > kind of discussion.
> > If you had said "I added that memset there because it looks like the
> > right thing to do" then we would not have had this discussion.
> >
> > You made claims you fixed a bug. It cant possibly be the bug you fixed.
> > Was it some other bug perhaps and you mixed up the two?
The memset fix is in current CVS. I just wasn't going to take the
patch that looked at utsname to decide what hash to use.
> The patch as well as the description are perfectly fine.
>
> BTW, running valgrind on tc shows lots of uses of uninitialized values,
> it seems like a good idea if someone would go over these and fix them
> up.
If we had a test script of commands (code coverage), that would help.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
2006-03-13 18:04 ` Stephen Hemminger
@ 2006-03-13 18:15 ` Patrick McHardy
-1 siblings, 0 replies; 30+ messages in thread
From: Patrick McHardy @ 2006-03-13 18:15 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
Stephen Hemminger wrote:
> The memset fix is in current CVS. I just wasn't going to take the
> patch that looked at utsname to decide what hash to use.
Yes, that sucks. We have another incompatibility, old iproute versions
(like the one shipped by Debian) show garbage statistics for HFSC. I
think it still works properly, but I wasn't able to track down the
cause. I have a feeling its somehow related to the gen_stats changes.
>>BTW, running valgrind on tc shows lots of uses of uninitialized values,
>>it seems like a good idea if someone would go over these and fix them
>>up.
>
>
> If we had a test script of commands (code coverage), that would help.
Getting good coverage looks like a lot of work, but I'll put it on
my TODO list for a boring day :)
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 18:15 ` Patrick McHardy
0 siblings, 0 replies; 30+ messages in thread
From: Patrick McHardy @ 2006-03-13 18:15 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
Stephen Hemminger wrote:
> The memset fix is in current CVS. I just wasn't going to take the
> patch that looked at utsname to decide what hash to use.
Yes, that sucks. We have another incompatibility, old iproute versions
(like the one shipped by Debian) show garbage statistics for HFSC. I
think it still works properly, but I wasn't able to track down the
cause. I have a feeling its somehow related to the gen_stats changes.
>>BTW, running valgrind on tc shows lots of uses of uninitialized values,
>>it seems like a good idea if someone would go over these and fix them
>>up.
>
>
> If we had a test script of commands (code coverage), that would help.
Getting good coverage looks like a lot of work, but I'll put it on
my TODO list for a boring day :)
^ permalink raw reply [flat|nested] 30+ messages in thread
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
2006-03-13 18:04 ` Stephen Hemminger
@ 2006-03-13 19:02 ` Patrick McHardy
-1 siblings, 0 replies; 30+ messages in thread
From: Patrick McHardy @ 2006-03-13 19:02 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
Stephen Hemminger wrote:
>>BTW, running valgrind on tc shows lots of uses of uninitialized values,
>>it seems like a good idea if someone would go over these and fix them
>>up.
>
>
> If we had a test script of commands (code coverage), that would help.
Actually the Coverity scanner is quite good at spotting these problems,
so I've requested iproute to be added to the list of regulary scanned
projects.
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 19:02 ` Patrick McHardy
0 siblings, 0 replies; 30+ messages in thread
From: Patrick McHardy @ 2006-03-13 19:02 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
Stephen Hemminger wrote:
>>BTW, running valgrind on tc shows lots of uses of uninitialized values,
>>it seems like a good idea if someone would go over these and fix them
>>up.
>
>
> If we had a test script of commands (code coverage), that would help.
Actually the Coverity scanner is quite good at spotting these problems,
so I've requested iproute to be added to the list of regulary scanned
projects.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
2006-03-13 18:04 ` Stephen Hemminger
@ 2006-03-13 21:43 ` Russell Stuart
-1 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-13 21:43 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
On Mon, 2006-03-13 at 10:04 -0800, Stephen Hemminger wrote:
> The memset fix is in current CVS. I just wasn't going to take the
> patch that looked at utsname to decide what hash to use.
Stephen, could you describe your objections to it please?
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 21:43 ` Russell Stuart
0 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-13 21:43 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
On Mon, 2006-03-13 at 10:04 -0800, Stephen Hemminger wrote:
> The memset fix is in current CVS. I just wasn't going to take the
> patch that looked at utsname to decide what hash to use.
Stephen, could you describe your objections to it please?
^ permalink raw reply [flat|nested] 30+ messages in thread
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
2006-03-13 21:43 ` Russell Stuart
@ 2006-03-13 21:50 ` Stephen Hemminger
-1 siblings, 0 replies; 30+ messages in thread
From: Stephen Hemminger @ 2006-03-13 21:50 UTC (permalink / raw)
To: Russell Stuart; +Cc: netdev, hadi, lartc
On Tue, 14 Mar 2006 07:43:57 +1000
Russell Stuart <russell-lartc@stuart.id.au> wrote:
> On Mon, 2006-03-13 at 10:04 -0800, Stephen Hemminger wrote:
> > The memset fix is in current CVS. I just wasn't going to take the
> > patch that looked at utsname to decide what hash to use.
>
> Stephen, could you describe your objections to it please?
>
Because it means that the API for netlink isn't being used properly.
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-13 21:50 ` Stephen Hemminger
0 siblings, 0 replies; 30+ messages in thread
From: Stephen Hemminger @ 2006-03-13 21:50 UTC (permalink / raw)
To: Russell Stuart; +Cc: netdev, hadi, lartc
On Tue, 14 Mar 2006 07:43:57 +1000
Russell Stuart <russell-lartc@stuart.id.au> wrote:
> On Mon, 2006-03-13 at 10:04 -0800, Stephen Hemminger wrote:
> > The memset fix is in current CVS. I just wasn't going to take the
> > patch that looked at utsname to decide what hash to use.
>
> Stephen, could you describe your objections to it please?
>
Because it means that the API for netlink isn't being used properly.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
2006-03-13 21:50 ` Stephen Hemminger
@ 2006-03-14 0:31 ` Russell Stuart
-1 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-14 0:31 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
On Mon, 2006-03-13 at 13:50 -0800, Stephen Hemminger wrote:
> On Tue, 14 Mar 2006 07:43:57 +1000
> Russell Stuart <russell-lartc@stuart.id.au> wrote:
>
> > On Mon, 2006-03-13 at 10:04 -0800, Stephen Hemminger wrote:
> > > The memset fix is in current CVS. I just wasn't going to take the
> > > patch that looked at utsname to decide what hash to use.
> >
> > Stephen, could you describe your objections to it please?
> >
>
> Because it means that the API for netlink isn't being used properly.
Do you mean the binary API between the kernel and the
applications has been broken; this is bad as it
transgresses some unwritten law; and the patch is
bad because it hides this problem rather than addressing
it?
Does the fact that the binary API changed during a
major kernel release (between 2.4 and 2.6) give us some
wriggle room here?
Anyway, jokes aside, the situation we have now is the
current "tc" doesn't work with the current kernel. This
situation can't be allowed to continue, I presume. Ergo,
here is a list of things we could do to fix this. All
you (plural) have to do is choose one, or some
combination:
1. Change the hashing algorithm back to the 2.4 way.
(IMHO, the 2.4 algorithm was better.) Disadvantage:
anybody who had a u32 filter that hashed on more
than one non-zero byte will have their u32 filters
suddenly break. However, since how the hashing
algorithm was never documented beyond "HOWTO's"
that showed how to hash on one byte, and every
example of hashing I have seen has been a copy &
paste of said HOWTO's, my guess is there are stuff
all people who will be effected. Another disadvantage:
people who are using older 2.6 kernels (eg me on
my production machines) won't have the problem fixed.
2. Change the hashing algorithm in "tc" to match the
current kernel. Disadvantage: "tc" will no longer
work with 2.4 kernels.
3. Change the hashing algorithm in "tc" to match the
current kernel, and change the 2.4 kernel's hashing
algorithm to match the 2.6 kernel. This is Jamal's
proposed solution. Disadvantage: 2.4 is a "stable"
kernel, produced when we made a real effort to
distinguish between between stable and development
kernels. This change would break API compatibility
in a stable series. Yuk!
4. Make "tc" look at the kernel version, and choose
the appropriate hashing function. This was my
solution, and everybody seems to hate it bar me
:(. Disadvantages: None, other than it hides a
violation of an "unwritten law".
5. A combination of 1 & 4. Change the hashing in 2.6
algorithm back to what it was in 2.4, and hide the
change by making "tc" check the kernel version and
choose the matching hash. Disadvantages: None,
other than now we have wilfully broken the unwritten
law twice.
My personal preference is to have a "tc" in CVS that
works with _all_ kernel versions. Yes - the netlink
interface has been broken. But is was done, and now
can't be undone. No matter why we do, there will
forever more be kernel versions with incompatible
netlink interfaces. We can't fix it. We just have
to limit the damage.
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-14 0:31 ` Russell Stuart
0 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-14 0:31 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, hadi, lartc
On Mon, 2006-03-13 at 13:50 -0800, Stephen Hemminger wrote:
> On Tue, 14 Mar 2006 07:43:57 +1000
> Russell Stuart <russell-lartc@stuart.id.au> wrote:
>
> > On Mon, 2006-03-13 at 10:04 -0800, Stephen Hemminger wrote:
> > > The memset fix is in current CVS. I just wasn't going to take the
> > > patch that looked at utsname to decide what hash to use.
> >
> > Stephen, could you describe your objections to it please?
> >
>
> Because it means that the API for netlink isn't being used properly.
Do you mean the binary API between the kernel and the
applications has been broken; this is bad as it
transgresses some unwritten law; and the patch is
bad because it hides this problem rather than addressing
it?
Does the fact that the binary API changed during a
major kernel release (between 2.4 and 2.6) give us some
wriggle room here?
Anyway, jokes aside, the situation we have now is the
current "tc" doesn't work with the current kernel. This
situation can't be allowed to continue, I presume. Ergo,
here is a list of things we could do to fix this. All
you (plural) have to do is choose one, or some
combination:
1. Change the hashing algorithm back to the 2.4 way.
(IMHO, the 2.4 algorithm was better.) Disadvantage:
anybody who had a u32 filter that hashed on more
than one non-zero byte will have their u32 filters
suddenly break. However, since how the hashing
algorithm was never documented beyond "HOWTO's"
that showed how to hash on one byte, and every
example of hashing I have seen has been a copy &
paste of said HOWTO's, my guess is there are stuff
all people who will be effected. Another disadvantage:
people who are using older 2.6 kernels (eg me on
my production machines) won't have the problem fixed.
2. Change the hashing algorithm in "tc" to match the
current kernel. Disadvantage: "tc" will no longer
work with 2.4 kernels.
3. Change the hashing algorithm in "tc" to match the
current kernel, and change the 2.4 kernel's hashing
algorithm to match the 2.6 kernel. This is Jamal's
proposed solution. Disadvantage: 2.4 is a "stable"
kernel, produced when we made a real effort to
distinguish between between stable and development
kernels. This change would break API compatibility
in a stable series. Yuk!
4. Make "tc" look at the kernel version, and choose
the appropriate hashing function. This was my
solution, and everybody seems to hate it bar me
:(. Disadvantages: None, other than it hides a
violation of an "unwritten law".
5. A combination of 1 & 4. Change the hashing in 2.6
algorithm back to what it was in 2.4, and hide the
change by making "tc" check the kernel version and
choose the matching hash. Disadvantages: None,
other than now we have wilfully broken the unwritten
law twice.
My personal preference is to have a "tc" in CVS that
works with _all_ kernel versions. Yes - the netlink
interface has been broken. But is was done, and now
can't be undone. No matter why we do, there will
forever more be kernel versions with incompatible
netlink interfaces. We can't fix it. We just have
to limit the damage.
^ permalink raw reply [flat|nested] 30+ messages in thread[parent not found: <1142303082.5219.16.camel@jzny2>]
* [LARTC] Re: [PATCH] TC: bug fixes to the "sample" clause
[not found] ` <1142082696.5184.53.camel@jzny2>
@ 2006-03-14 2:29 ` Russell Stuart
2006-03-14 2:29 ` Russell Stuart
[not found] ` <1142085718.5184.73.camel@jzny2>
2 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-14 2:29 UTC (permalink / raw)
To: hadi; +Cc: netdev, lartc
On Sat, 2006-03-11 at 08:11 -0500, jamal wrote:
> On Fri, 2006-10-02 at 12:33 +1000, Russell Stuart wrote:
> > This patch adds a "divisor" option to tc's "sample"
> > clause:
>
> While this looks right - can we have more test data with tc filter ls
> both before and after your fix? Specify divisor of 256 and 16 for
> example. Show that for the 256 it is the same as before and for 16 it
> does the right thing.
With patch, divisor 256:
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x01 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x0f 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x10 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xef 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xf0 0xff divisor 256 match u32 0 0
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:1:800 order 2048 key ht 801 bkt 1 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:800 order 2048 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:10:800 order 2048 key ht 801 bkt 10 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:ef:800 order 2048 key ht 801 bkt ef flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f0:800 order 2048 key ht 801 bkt f0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
Without patch, divisor 256:
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x01 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x0f 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x10 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xef 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xf0 0xff match u32 0 0
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:1:800 order 2048 key ht 801 bkt 1 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:800 order 2048 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:10:800 order 2048 key ht 801 bkt 10 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:ef:800 order 2048 key ht 801 bkt ef flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f0:800 order 2048 key ht 801 bkt f0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
With patch, divisor 16:
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 16
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x01 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x0f 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x10 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xef 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xf0 0xff divisor 16 match u32 0 0
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 16
filter parent 1: protocol ip pref 1 u32 fh 801::800 order 2048 key ht 801 bkt 0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801::801 order 2049 key ht 801 bkt 0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:1:800 order 2048 key ht 801 bkt 1 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:800 order 2048 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:801 order 2049 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
_______________________________________________
LARTC mailing list
LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
^ permalink raw reply [flat|nested] 30+ messages in thread* Re: [PATCH] TC: bug fixes to the "sample" clause
@ 2006-03-14 2:29 ` Russell Stuart
0 siblings, 0 replies; 30+ messages in thread
From: Russell Stuart @ 2006-03-14 2:29 UTC (permalink / raw)
To: hadi; +Cc: netdev, lartc
On Sat, 2006-03-11 at 08:11 -0500, jamal wrote:
> On Fri, 2006-10-02 at 12:33 +1000, Russell Stuart wrote:
> > This patch adds a "divisor" option to tc's "sample"
> > clause:
>
> While this looks right - can we have more test data with tc filter ls
> both before and after your fix? Specify divisor of 256 and 16 for
> example. Show that for the 256 it is the same as before and for 16 it
> does the right thing.
With patch, divisor 256:
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x01 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x0f 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x10 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xef 0xff divisor 256 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xf0 0xff divisor 256 match u32 0 0
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:1:800 order 2048 key ht 801 bkt 1 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:800 order 2048 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:10:800 order 2048 key ht 801 bkt 10 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:ef:800 order 2048 key ht 801 bkt ef flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f0:800 order 2048 key ht 801 bkt f0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
Without patch, divisor 256:
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 256
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x01 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x0f 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x10 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xef 0xff match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xf0 0xff match u32 0 0
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 256
filter parent 1: protocol ip pref 1 u32 fh 801:1:800 order 2048 key ht 801 bkt 1 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:800 order 2048 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:10:800 order 2048 key ht 801 bkt 10 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:ef:800 order 2048 key ht 801 bkt ef flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f0:800 order 2048 key ht 801 bkt f0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
With patch, divisor 16:
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb
tc filter add dev eth0 parent 1:0 prio 1 protocol ip u32 ht 801: divisor 16
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x01 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x0f 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0x10 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xef 0xff divisor 16 match u32 0 0
tc filter add dev eth0 parent 1:0 protocol ip prio 1 u32 ht 801: classid 1:0 sample u8 0xf0 0xff divisor 16 match u32 0 0
tc -s filter show dev eth0
filter parent 1: protocol ip pref 1 u32
filter parent 1: protocol ip pref 1 u32 fh 801: ht divisor 16
filter parent 1: protocol ip pref 1 u32 fh 801::800 order 2048 key ht 801 bkt 0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801::801 order 2049 key ht 801 bkt 0 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:1:800 order 2048 key ht 801 bkt 1 flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:800 order 2048 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 801:f:801 order 2049 key ht 801 bkt f flowid 1:
match 00000000/00000000 at 0
filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1
^ permalink raw reply [flat|nested] 30+ messages in thread
[parent not found: <1142085718.5184.73.camel@jzny2>]
end of thread, other threads:[~2006-03-20 3:11 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-10 2:33 [LARTC] [PATCH] TC: bug fixes to the "sample" clause Russell Stuart
2006-02-10 2:33 ` Russell Stuart
[not found] ` <1142082696.5184.53.camel@jzny2>
2006-03-13 4:44 ` [LARTC] " Russell Stuart
2006-03-13 4:44 ` Russell Stuart
[not found] ` <1142269090.5242.29.camel@jzny2>
2006-03-13 17:55 ` [LARTC] " Patrick McHardy
2006-03-13 17:55 ` Patrick McHardy
2006-03-13 18:04 ` [LARTC] " Stephen Hemminger
2006-03-13 18:04 ` Stephen Hemminger
2006-03-13 18:15 ` [LARTC] " Patrick McHardy
2006-03-13 18:15 ` Patrick McHardy
2006-03-13 19:02 ` [LARTC] " Patrick McHardy
2006-03-13 19:02 ` Patrick McHardy
2006-03-13 21:43 ` [LARTC] " Russell Stuart
2006-03-13 21:43 ` Russell Stuart
2006-03-13 21:50 ` [LARTC] " Stephen Hemminger
2006-03-13 21:50 ` Stephen Hemminger
2006-03-14 0:31 ` [LARTC] " Russell Stuart
2006-03-14 0:31 ` Russell Stuart
[not found] ` <1142303082.5219.16.camel@jzny2>
[not found] ` <1142306212.17608.178.camel@ras.pc.brisbane.lube>
[not found] ` <1142307572.5219.73.camel@jzny2>
[not found] ` <1142312708.17608.270.camel@ras.pc.brisbane.lube>
[not found] ` <1142436098.5346.3.camel@jzny2>
[not found] ` <1142470323.17608.341.camel@ras.pc.brisbane.lube>
[not found] ` <20060315165757.44bf1548@localhost.localdomain>
2006-03-16 1:43 ` [LARTC] " Russell Stuart
2006-03-16 1:43 ` Russell Stuart
[not found] ` <1142472481.5417.20.camel@jzny2>
[not found] ` <1142476647.17608.394.camel@ras.pc.brisbane.lube>
[not found] ` <1142478478.5417.46.camel@jzny2>
[not found] ` <1142488027.17608.485.camel@ras.pc.brisbane.lube>
[not found] ` <1142517116.5417.137.camel@jzny2>
2006-03-16 23:24 ` [LARTC] " Russell Stuart
2006-03-16 23:24 ` Russell Stuart
[not found] ` <1142606049.5322.89.camel@jzny2>
2006-03-18 5:10 ` [LARTC] " Russell Stuart
2006-03-18 5:10 ` Russell Stuart
2006-03-20 3:11 ` [LARTC] " Russell Stuart
2006-03-20 3:11 ` Russell Stuart
2006-03-14 2:29 ` [LARTC] " Russell Stuart
2006-03-14 2:29 ` Russell Stuart
[not found] ` <1142085718.5184.73.camel@jzny2>
[not found] ` <1142088594.4199.115.camel@ras.pc.stuart.local>
[not found] ` <1142092598.5184.93.camel@jzny2>
2006-03-14 2:45 ` [LARTC] " Russell Stuart
2006-03-14 2:45 ` Russell Stuart
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.