All of lore.kernel.org
 help / color / mirror / Atom feed
* [HELP] for using class group classifier network controller
@ 2009-06-15  0:56 ` 김재열
  0 siblings, 0 replies; 8+ messages in thread
From: 김재열 @ 2009-06-15  0:56 UTC (permalink / raw)
  To: usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil, tgraf-wEGCiKHe2LqWVfeAwA7xHQ
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Hi.

 

I'm trying to use class group classifier network controller written by Thomas Graf.

But it doesn't work well.

I need a help to use this network classifier collectly

 

Below is the my testing environment

 

kernel : 2.6.29

iproute : iproute2-2.6.29-1 + net_cls patch

 

I compiled kernel in order to use control group classifier by enabling  CGROUPS and NET_CLS_CGROUPS and other cgroup related options.

And I operated like this.

 

mkdir -p /dev/cpuctl/

mount -t cgroup net_cls -onet_cls /dev/cpuctl

mkdir /dev/cpuctl/foo

mkdir /dev/cpuctl/bob

 

# classid 1:10

echo 0x1000A > /dev/cpuctl/foo/net_cls.classid

#classid 1:20

echo 0x10014 > /dev/cpuctl/bob/net_cls.classid

 

And I put two bashshell's pid into foo and bob group

 

echo $$ > /dev/cpuctl/foo/task

echo $$ > /dev/cpuctl/bob/task

 

And then I configured the kernel's traffic control policy

 

TC = /sbin/tc

$TC qdisc delete dev eth0 root

 

$TC qdisc add dev eth0 root handle 1: htb default 10 r2q 200

 

# add class 1:10 for foo group

$TC class add dev eth0 parent 1:0 classid 1:10 htb rate 50mbit

# add class 1:20 for bob group

$TC class add dev eth0 parent 1:0 classid 1:20 htb rate 30mbit

# default class

$TC class add dev eth0 parent 1:0 classid 1:30 htb rate 10mbit

 

# add net_cls filter for class foo and bob

$TC filter add dev eth0 parent 1: protocol ip prio 10 handle 100: cgroup

# default class filter
$TC filter add dev eth0 parent 1: protocol ip prio 20 basic classid 1:30

After finishing this configuration, I ran the iperf  for measuring the network BW.

Iperf showd about 10mbps in each group.

10mbps is the rate of class 1:30, default class.

 

When I send a data in group foo or group bob, the data rate is equal to default class 1:30 rate,

so I think kernel couldn't identify classified packet from normal packet.

What is wrong?

 

I expect your kindness.

 

- Cheiyol Kim

 

*************************************************************************************

 

This is the iproute patch

 

--- ./iproute2-2.6.29-1/tc/Makefile     2009-03-25 07:40:54.000000000 +0900
+++ ./iproute2-2.6.29-1-mod/tc/Makefile 2009-06-02 17:33:21.000000000 +0900
@@ -20,6 +20,7 @@
 TCMODULES += f_fw.o
 TCMODULES += f_basic.o
 TCMODULES += f_flow.o
+TCMODULES += f_cgroup.o
 TCMODULES += q_dsmark.o
 TCMODULES += q_gred.o
 TCMODULES += f_tcindex.o

--- ./iproute2-2.6.29-1/tc/NULL 1970-01-01 09:00:00.000000000 +0900
+++ ./iproute2-2.6.29-1-mod/tc/f_cgroup.c       2009-06-02 17:32:47.000000000 +0900
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "utils.h"
+#include "tc_util.h"
+#include "m_ematch.h"
+
+static void explain(void)
+{
+       fprintf(stderr, "Usage: ... cgroup [ match EMATCH_TREE ] [ police POLICE_SPEC ]\n");
+       fprintf(stderr, "                 [ action ACTION_SPEC ]\n");
+}
+
+static int cgroup_parse_opt(struct filter_util *qu, char *handle,
+                          int argc, char **argv, struct nlmsghdr *n) {
+       struct tcmsg *t = NLMSG_DATA(n);
+       struct rtattr *tail;
+       long h = 0;
+
+       if (handle) {
+               h = strtol(handle, NULL, 0);
+               if (h == LONG_MIN || h == LONG_MAX) {
+                       fprintf(stderr, "Illegal handle \"%s\", must be numeric.\n",
+                           handle);
+                       return -1;
+               }
+       }
+
+       t->tcm_handle = h;
+
+       tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+       addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
+
+       while (argc > 0) {
+               if (matches(*argv, "match") == 0) {
+                       NEXT_ARG();
+                       if (parse_ematch(&argc, &argv, TCA_CGROUP_EMATCHES, n)) {
+                               fprintf(stderr, "Illegal \"ematch\"\n");
+                               return -1;
+                       }
+                       continue;
+               } else if (matches(*argv, "action") == 0) {
+                       NEXT_ARG();
+                       if (parse_action(&argc, &argv, TCA_CGROUP_ACT, n)) {
+                               fprintf(stderr, "Illegal \"action\"\n");
+                               return -1;
+                       }
+                       continue;
+
+               } else if (matches(*argv, "police") == 0) {
+                       NEXT_ARG();
+                       if (parse_police(&argc, &argv, TCA_CGROUP_POLICE, n)) {
+                               fprintf(stderr, "Illegal \"police\"\n");
+                               return -1;
+                       }
+                       continue;
+               } else if (strcmp(*argv, "help") == 0) {
+                       explain();
+                       return -1;
+               } else {
+                       fprintf(stderr, "What is \"%s\"?\n", *argv);
+                       explain();
+                       return -1;
+               }
+               argc--; argv++;
+       }
+
+       tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+       return 0;
+}
+
+static int cgroup_print_opt(struct filter_util *qu, FILE *f,
+                          struct rtattr *opt, __u32 handle) {
+       struct rtattr *tb[TCA_CGROUP_MAX+1];
+
+       if (opt == NULL)
+               return 0;
+
+       parse_rtattr_nested(tb, TCA_CGROUP_MAX, opt);
+
+       if (handle)
+               fprintf(f, "handle 0x%x ", handle);
+
+       if (tb[TCA_CGROUP_EMATCHES])
+               print_ematch(f, tb[TCA_CGROUP_EMATCHES]);
+
+       if (tb[TCA_CGROUP_POLICE]) {
+               fprintf(f, "\n");
+               tc_print_police(f, tb[TCA_CGROUP_POLICE]);
+       }
+
+       if (tb[TCA_CGROUP_ACT])
+               tc_print_action(f, tb[TCA_CGROUP_ACT]);
+
+       return 0;
+}
+
+struct filter_util cgroup_filter_util = {
+       .id = "cgroup",
+       .parse_fopt = cgroup_parse_opt,
+       .print_fopt = cgroup_print_opt,
+};

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

* [HELP] for using class group classifier network controller
@ 2009-06-15  0:56 ` 김재열
  0 siblings, 0 replies; 8+ messages in thread
From: 김재열 @ 2009-06-15  0:56 UTC (permalink / raw)
  To: usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil, tgraf-wEGCiKHe2LqWVfeAwA7xHQ
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

Hi.

 

I'm trying to use class group classifier network controller written by Thomas Graf.

But it doesn't work well.

I need a help to use this network classifier collectly

 

Below is the my testing environment

 

kernel : 2.6.29

iproute : iproute2-2.6.29-1 + net_cls patch

 

I compiled kernel in order to use control group classifier by enabling  CGROUPS and NET_CLS_CGROUPS and other cgroup related options.

And I operated like this.

 

mkdir -p /dev/cpuctl/

mount -t cgroup net_cls -onet_cls /dev/cpuctl

mkdir /dev/cpuctl/foo

mkdir /dev/cpuctl/bob

 

# classid 1:10

echo 0x1000A > /dev/cpuctl/foo/net_cls.classid

#classid 1:20

echo 0x10014 > /dev/cpuctl/bob/net_cls.classid

 

And I put two bashshell's pid into foo and bob group

 

echo $$ > /dev/cpuctl/foo/task

echo $$ > /dev/cpuctl/bob/task

 

And then I configured the kernel's traffic control policy

 

TC = /sbin/tc

$TC qdisc delete dev eth0 root

 

$TC qdisc add dev eth0 root handle 1: htb default 10 r2q 200

 

# add class 1:10 for foo group

$TC class add dev eth0 parent 1:0 classid 1:10 htb rate 50mbit

# add class 1:20 for bob group

$TC class add dev eth0 parent 1:0 classid 1:20 htb rate 30mbit

# default class

$TC class add dev eth0 parent 1:0 classid 1:30 htb rate 10mbit

 

# add net_cls filter for class foo and bob

$TC filter add dev eth0 parent 1: protocol ip prio 10 handle 100: cgroup

# default class filter
$TC filter add dev eth0 parent 1: protocol ip prio 20 basic classid 1:30

After finishing this configuration, I ran the iperf  for measuring the network BW.

Iperf showd about 10mbps in each group.

10mbps is the rate of class 1:30, default class.

 

When I send a data in group foo or group bob, the data rate is equal to default class 1:30 rate,

so I think kernel couldn't identify classified packet from normal packet.

What is wrong?

 

I expect your kindness.

 

- Cheiyol Kim

 

*************************************************************************************

 

This is the iproute patch

 

--- ./iproute2-2.6.29-1/tc/Makefile     2009-03-25 07:40:54.000000000 +0900
+++ ./iproute2-2.6.29-1-mod/tc/Makefile 2009-06-02 17:33:21.000000000 +0900
@@ -20,6 +20,7 @@
 TCMODULES += f_fw.o
 TCMODULES += f_basic.o
 TCMODULES += f_flow.o
+TCMODULES += f_cgroup.o
 TCMODULES += q_dsmark.o
 TCMODULES += q_gred.o
 TCMODULES += f_tcindex.o

--- ./iproute2-2.6.29-1/tc/NULL 1970-01-01 09:00:00.000000000 +0900
+++ ./iproute2-2.6.29-1-mod/tc/f_cgroup.c       2009-06-02 17:32:47.000000000 +0900
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "utils.h"
+#include "tc_util.h"
+#include "m_ematch.h"
+
+static void explain(void)
+{
+       fprintf(stderr, "Usage: ... cgroup [ match EMATCH_TREE ] [ police POLICE_SPEC ]\n");
+       fprintf(stderr, "                 [ action ACTION_SPEC ]\n");
+}
+
+static int cgroup_parse_opt(struct filter_util *qu, char *handle,
+                          int argc, char **argv, struct nlmsghdr *n) {
+       struct tcmsg *t = NLMSG_DATA(n);
+       struct rtattr *tail;
+       long h = 0;
+
+       if (handle) {
+               h = strtol(handle, NULL, 0);
+               if (h == LONG_MIN || h == LONG_MAX) {
+                       fprintf(stderr, "Illegal handle \"%s\", must be numeric.\n",
+                           handle);
+                       return -1;
+               }
+       }
+
+       t->tcm_handle = h;
+
+       tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len));
+       addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);
+
+       while (argc > 0) {
+               if (matches(*argv, "match") == 0) {
+                       NEXT_ARG();
+                       if (parse_ematch(&argc, &argv, TCA_CGROUP_EMATCHES, n)) {
+                               fprintf(stderr, "Illegal \"ematch\"\n");
+                               return -1;
+                       }
+                       continue;
+               } else if (matches(*argv, "action") == 0) {
+                       NEXT_ARG();
+                       if (parse_action(&argc, &argv, TCA_CGROUP_ACT, n)) {
+                               fprintf(stderr, "Illegal \"action\"\n");
+                               return -1;
+                       }
+                       continue;
+
+               } else if (matches(*argv, "police") == 0) {
+                       NEXT_ARG();
+                       if (parse_police(&argc, &argv, TCA_CGROUP_POLICE, n)) {
+                               fprintf(stderr, "Illegal \"police\"\n");
+                               return -1;
+                       }
+                       continue;
+               } else if (strcmp(*argv, "help") == 0) {
+                       explain();
+                       return -1;
+               } else {
+                       fprintf(stderr, "What is \"%s\"?\n", *argv);
+                       explain();
+                       return -1;
+               }
+               argc--; argv++;
+       }
+
+       tail->rta_len = (((void*)n)+n->nlmsg_len) - (void*)tail;
+       return 0;
+}
+
+static int cgroup_print_opt(struct filter_util *qu, FILE *f,
+                          struct rtattr *opt, __u32 handle) {
+       struct rtattr *tb[TCA_CGROUP_MAX+1];
+
+       if (opt == NULL)
+               return 0;
+
+       parse_rtattr_nested(tb, TCA_CGROUP_MAX, opt);
+
+       if (handle)
+               fprintf(f, "handle 0x%x ", handle);
+
+       if (tb[TCA_CGROUP_EMATCHES])
+               print_ematch(f, tb[TCA_CGROUP_EMATCHES]);
+
+       if (tb[TCA_CGROUP_POLICE]) {
+               fprintf(f, "\n");
+               tc_print_police(f, tb[TCA_CGROUP_POLICE]);
+       }
+
+       if (tb[TCA_CGROUP_ACT])
+               tc_print_action(f, tb[TCA_CGROUP_ACT]);
+
+       return 0;
+}
+
+struct filter_util cgroup_filter_util = {
+       .id = "cgroup",
+       .parse_fopt = cgroup_parse_opt,
+       .print_fopt = cgroup_print_opt,
+};

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

* Re: [HELP] for using class group classifier network controller
  2009-06-15  0:56 ` 김재열
  (?)
  (?)
@ 2009-06-15  2:36 ` Minoru Usui
  -1 siblings, 0 replies; 8+ messages in thread
From: Minoru Usui @ 2009-06-15  2:36 UTC (permalink / raw)
  To: 김재열
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	tgraf-wEGCiKHe2LqWVfeAwA7xHQ

Hi, Cheiyol

> # classid 1:10
> 
> echo 0x1000A > /dev/cpuctl/foo/net_cls.classid
> 
> #classid 1:20
> 
> echo 0x10014 > /dev/cpuctl/bob/net_cls.classid

(snip)

> # add class 1:10 for foo group
> 
> $TC class add dev eth0 parent 1:0 classid 1:10 htb rate 50mbit
> 
> # add class 1:20 for bob group
> 
> $TC class add dev eth0 parent 1:0 classid 1:20 htb rate 30mbit
> 
> # default class
> 
> $TC class add dev eth0 parent 1:0 classid 1:30 htb rate 10mbit

In class ID to use TC, both a major number and a minor number are hexadecimal.
So 1:10 equals 0x00010010.

I think, you should set 0x10010 to net_cls.classid if you classify to 1:10.
-- 
Minoru Usui <usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>

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

* Re: [HELP] for using class group classifier network controller
  2009-06-15  0:56 ` 김재열
  (?)
@ 2009-06-15  2:36 ` Minoru Usui
  2009-06-15 10:30   ` Thomas Graf
       [not found]   ` <20090615113609.db5c0613.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
  -1 siblings, 2 replies; 8+ messages in thread
From: Minoru Usui @ 2009-06-15  2:36 UTC (permalink / raw)
  To: 김재열; +Cc: tgraf, netdev, containers

Hi, Cheiyol

> # classid 1:10
> 
> echo 0x1000A > /dev/cpuctl/foo/net_cls.classid
> 
> #classid 1:20
> 
> echo 0x10014 > /dev/cpuctl/bob/net_cls.classid

(snip)

> # add class 1:10 for foo group
> 
> $TC class add dev eth0 parent 1:0 classid 1:10 htb rate 50mbit
> 
> # add class 1:20 for bob group
> 
> $TC class add dev eth0 parent 1:0 classid 1:20 htb rate 30mbit
> 
> # default class
> 
> $TC class add dev eth0 parent 1:0 classid 1:30 htb rate 10mbit

In class ID to use TC, both a major number and a minor number are hexadecimal.
So 1:10 equals 0x00010010.

I think, you should set 0x10010 to net_cls.classid if you classify to 1:10.
-- 
Minoru Usui <usui@mxm.nes.nec.co.jp>

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

* Re: [HELP] for using class group classifier network controller
       [not found]   ` <20090615113609.db5c0613.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
@ 2009-06-15 10:30     ` Thomas Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Graf @ 2009-06-15 10:30 UTC (permalink / raw)
  To: Minoru Usui
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On Mon, Jun 15, 2009 at 11:36:09AM +0900, Minoru Usui wrote:
> Hi, Cheiyol
> 
> > # classid 1:10
> > 
> > echo 0x1000A > /dev/cpuctl/foo/net_cls.classid
> > 
> > #classid 1:20
> > 
> > echo 0x10014 > /dev/cpuctl/bob/net_cls.classid
> 
> (snip)
> 
> > # add class 1:10 for foo group
> > 
> > $TC class add dev eth0 parent 1:0 classid 1:10 htb rate 50mbit
> > 
> > # add class 1:20 for bob group
> > 
> > $TC class add dev eth0 parent 1:0 classid 1:20 htb rate 30mbit
> > 
> > # default class
> > 
> > $TC class add dev eth0 parent 1:0 classid 1:30 htb rate 10mbit
> 
> In class ID to use TC, both a major number and a minor number are hexadecimal.
> So 1:10 equals 0x00010010.
> 
> I think, you should set 0x10010 to net_cls.classid if you classify to 1:10.

That's right, both net_cls.classid and tc use integers in hexadecimal form
for both, printing and parsing.

10:10 -> 0x100010
10:20 -> 0x100020

This seems to be the weak point regarding usability that's why I like
Minoru Usui's patch so much. It would no longer be necessary to really
understand the internals of classids etc.

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

* Re: [HELP] for using class group classifier network controller
  2009-06-15  2:36 ` Minoru Usui
@ 2009-06-15 10:30   ` Thomas Graf
       [not found]     ` <20090615103020.GA8894-PfSpb0PWhxZc2C7mugBRk2EX/6BAtgUQ@public.gmane.org>
  2009-06-22 18:05     ` Paul Menage
       [not found]   ` <20090615113609.db5c0613.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
  1 sibling, 2 replies; 8+ messages in thread
From: Thomas Graf @ 2009-06-15 10:30 UTC (permalink / raw)
  To: Minoru Usui; +Cc: 김재열, netdev, containers

On Mon, Jun 15, 2009 at 11:36:09AM +0900, Minoru Usui wrote:
> Hi, Cheiyol
> 
> > # classid 1:10
> > 
> > echo 0x1000A > /dev/cpuctl/foo/net_cls.classid
> > 
> > #classid 1:20
> > 
> > echo 0x10014 > /dev/cpuctl/bob/net_cls.classid
> 
> (snip)
> 
> > # add class 1:10 for foo group
> > 
> > $TC class add dev eth0 parent 1:0 classid 1:10 htb rate 50mbit
> > 
> > # add class 1:20 for bob group
> > 
> > $TC class add dev eth0 parent 1:0 classid 1:20 htb rate 30mbit
> > 
> > # default class
> > 
> > $TC class add dev eth0 parent 1:0 classid 1:30 htb rate 10mbit
> 
> In class ID to use TC, both a major number and a minor number are hexadecimal.
> So 1:10 equals 0x00010010.
> 
> I think, you should set 0x10010 to net_cls.classid if you classify to 1:10.

That's right, both net_cls.classid and tc use integers in hexadecimal form
for both, printing and parsing.

10:10 -> 0x100010
10:20 -> 0x100020

This seems to be the weak point regarding usability that's why I like
Minoru Usui's patch so much. It would no longer be necessary to really
understand the internals of classids etc.

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

* Re: [Devel] Re: [HELP] for using class group classifier network controller
       [not found]     ` <20090615103020.GA8894-PfSpb0PWhxZc2C7mugBRk2EX/6BAtgUQ@public.gmane.org>
@ 2009-06-22 18:05       ` Paul Menage
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Menage @ 2009-06-22 18:05 UTC (permalink / raw)
  To: Minoru Usui, 김재열,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On Mon, Jun 15, 2009 at 3:30 AM, Thomas Graf<tgraf-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> wrote:
>
> That's right, both net_cls.classid and tc use integers in hexadecimal form
> for both, printing and parsing.

net_cls.classid accepts integers in hexadecimal or decimal, and
reports in decimal.

Paul

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

* Re: [Devel] Re: [HELP] for using class group classifier network controller
  2009-06-15 10:30   ` Thomas Graf
       [not found]     ` <20090615103020.GA8894-PfSpb0PWhxZc2C7mugBRk2EX/6BAtgUQ@public.gmane.org>
@ 2009-06-22 18:05     ` Paul Menage
  1 sibling, 0 replies; 8+ messages in thread
From: Paul Menage @ 2009-06-22 18:05 UTC (permalink / raw)
  To: Minoru Usui, 김재열, netdev, containers

On Mon, Jun 15, 2009 at 3:30 AM, Thomas Graf<tgraf@infradead.org> wrote:
>
> That's right, both net_cls.classid and tc use integers in hexadecimal form
> for both, printing and parsing.

net_cls.classid accepts integers in hexadecimal or decimal, and
reports in decimal.

Paul

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

end of thread, other threads:[~2009-06-22 18:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15  0:56 [HELP] for using class group classifier network controller 김재열
2009-06-15  0:56 ` 김재열
2009-06-15  2:36 ` Minoru Usui
2009-06-15 10:30   ` Thomas Graf
     [not found]     ` <20090615103020.GA8894-PfSpb0PWhxZc2C7mugBRk2EX/6BAtgUQ@public.gmane.org>
2009-06-22 18:05       ` [Devel] " Paul Menage
2009-06-22 18:05     ` Paul Menage
     [not found]   ` <20090615113609.db5c0613.usui-vEbCzmPPqHe45+QrQBaojngSJqDPrsil@public.gmane.org>
2009-06-15 10:30     ` Thomas Graf
2009-06-15  2:36 ` Minoru Usui

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.