diff options
author | Thomas Graf <tgraf@suug.ch> | 2011-03-21 14:51:52 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2011-03-21 14:51:52 (GMT) |
commit | 8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4 (patch) | |
tree | 0fec48d114edbb535bd234f2684acccf81447d13 /lib/cli/qdisc | |
parent | 5dc897d5de9f54078221b241e0122713207f5e0c (diff) | |
download | libnl-8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4.zip libnl-8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4.tar.gz libnl-8eb5b5532eae985a5f0911dccf2db8cb4e0a5de4.tar.bz2 |
Unified TC API
Finally got rid of all the qdisc/class/cls code duplication in
the tc module API. The API takes care of allocation/freeing the
tc object specific data.
I hope I got it right this time.
Diffstat (limited to 'lib/cli/qdisc')
-rw-r--r-- | lib/cli/qdisc/bfifo.c | 18 | ||||
-rw-r--r-- | lib/cli/qdisc/blackhole.c | 17 | ||||
-rw-r--r-- | lib/cli/qdisc/htb.c | 32 | ||||
-rw-r--r-- | lib/cli/qdisc/pfifo.c | 19 |
4 files changed, 52 insertions, 34 deletions
diff --git a/lib/cli/qdisc/bfifo.c b/lib/cli/qdisc/bfifo.c index 2f74659..710d6c4 100644 --- a/lib/cli/qdisc/bfifo.c +++ b/lib/cli/qdisc/bfifo.c @@ -6,11 +6,11 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch> */ #include <netlink/cli/utils.h> -#include <netlink/cli/qdisc.h> +#include <netlink/cli/tc.h> #include <netlink/route/sch/fifo.h> static void print_usage(void) @@ -27,8 +27,9 @@ static void print_usage(void) " nl-qdisc-add --dev=eth1 --parent=root bfifo --limit=4096\n"); } -static void bfifo_parse_argv(struct rtnl_qdisc *qdisc, int argc, char **argv) +static void bfifo_parse_argv(struct rtnl_tc *tc, int argc, char **argv) { + struct rtnl_qdisc *qdisc = (struct rtnl_qdisc *) tc; int limit; for (;;) { @@ -64,18 +65,19 @@ static void bfifo_parse_argv(struct rtnl_qdisc *qdisc, int argc, char **argv) } } -static struct nl_cli_qdisc_module bfifo_module = +static struct nl_cli_tc_module bfifo_module = { - .qm_name = "bfifo", - .qm_parse_qdisc_argv = bfifo_parse_argv, + .tm_name = "bfifo", + .tm_type = RTNL_TC_TYPE_QDISC, + .tm_parse_argv = bfifo_parse_argv, }; static void __init bfifo_init(void) { - nl_cli_qdisc_register(&bfifo_module); + nl_cli_tc_register(&bfifo_module); } static void __exit bfifo_exit(void) { - nl_cli_qdisc_unregister(&bfifo_module); + nl_cli_tc_unregister(&bfifo_module); } diff --git a/lib/cli/qdisc/blackhole.c b/lib/cli/qdisc/blackhole.c index 1eebb32..af9dc6d 100644 --- a/lib/cli/qdisc/blackhole.c +++ b/lib/cli/qdisc/blackhole.c @@ -6,11 +6,11 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch> */ #include <netlink/cli/utils.h> -#include <netlink/cli/qdisc.h> +#include <netlink/cli/tc.h> static void print_usage(void) { @@ -25,7 +25,7 @@ static void print_usage(void) " nl-qdisc-add --dev=eth1 --parent=root blackhole\n"); } -static void blackhole_parse_argv(struct rtnl_qdisc *qdisc, int argc, char **argv) +static void blackhole_parse_argv(struct rtnl_tc *tc, int argc, char **argv) { for (;;) { int c, optidx = 0; @@ -46,18 +46,19 @@ static void blackhole_parse_argv(struct rtnl_qdisc *qdisc, int argc, char **argv } } -static struct nl_cli_qdisc_module blackhole_module = +static struct nl_cli_tc_module blackhole_module = { - .qm_name = "blackhole", - .qm_parse_qdisc_argv = blackhole_parse_argv, + .tm_name = "blackhole", + .tm_type = RTNL_TC_TYPE_QDISC, + .tm_parse_argv = blackhole_parse_argv, }; static void __init blackhole_init(void) { - nl_cli_qdisc_register(&blackhole_module); + nl_cli_tc_register(&blackhole_module); } static void __exit blackhole_exit(void) { - nl_cli_qdisc_unregister(&blackhole_module); + nl_cli_tc_unregister(&blackhole_module); } diff --git a/lib/cli/qdisc/htb.c b/lib/cli/qdisc/htb.c index febf429..32ed272 100644 --- a/lib/cli/qdisc/htb.c +++ b/lib/cli/qdisc/htb.c @@ -6,11 +6,11 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch> */ #include <netlink/cli/utils.h> -#include <netlink/cli/qdisc.h> +#include <netlink/cli/tc.h> #include <netlink/route/sch/htb.h> static void print_qdisc_usage(void) @@ -28,8 +28,10 @@ static void print_qdisc_usage(void) " nl-qdisc-add --dev=eth1 --parent=root --handle=1: htb --default=10\n"); } -static void htb_parse_qdisc_argv(struct rtnl_qdisc *qdisc, int argc, char **argv) +static void htb_parse_qdisc_argv(struct rtnl_tc *tc, int argc, char **argv) { + struct rtnl_qdisc *qdisc = (struct rtnl_qdisc *) tc; + for (;;) { int c, optidx = 0; enum { @@ -82,8 +84,9 @@ static void print_class_usage(void) " nl-class-add --dev=eth1 --parent=1: --classid=1:1 htb --rate=20mbit\n"); } -static void htb_parse_class_argv(struct rtnl_class *class, int argc, char **argv) +static void htb_parse_class_argv(struct rtnl_tc *tc, int argc, char **argv) { + struct rtnl_class *class = (struct rtnl_class *) tc; long rate; for (;;) { @@ -173,19 +176,28 @@ static void htb_parse_class_argv(struct rtnl_class *class, int argc, char **argv } } -static struct nl_cli_qdisc_module htb_module = +static struct nl_cli_tc_module htb_qdisc_module = +{ + .tm_name = "htb", + .tm_type = RTNL_TC_TYPE_QDISC, + .tm_parse_argv = htb_parse_qdisc_argv, +}; + +static struct nl_cli_tc_module htb_class_module = { - .qm_name = "htb", - .qm_parse_qdisc_argv = htb_parse_qdisc_argv, - .qm_parse_class_argv = htb_parse_class_argv, + .tm_name = "htb", + .tm_type = RTNL_TC_TYPE_CLASS, + .tm_parse_argv = htb_parse_class_argv, }; static void __init htb_init(void) { - nl_cli_qdisc_register(&htb_module); + nl_cli_tc_register(&htb_qdisc_module); + nl_cli_tc_register(&htb_class_module); } static void __exit htb_exit(void) { - nl_cli_qdisc_unregister(&htb_module); + nl_cli_tc_unregister(&htb_class_module); + nl_cli_tc_unregister(&htb_qdisc_module); } diff --git a/lib/cli/qdisc/pfifo.c b/lib/cli/qdisc/pfifo.c index 38cc97a..946aba6 100644 --- a/lib/cli/qdisc/pfifo.c +++ b/lib/cli/qdisc/pfifo.c @@ -7,11 +7,11 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2010 Thomas Graf <tgraf@suug.ch> + * Copyright (c) 2010-2011 Thomas Graf <tgraf@suug.ch> */ #include <netlink/cli/utils.h> -#include <netlink/cli/qdisc.h> +#include <netlink/cli/tc.h> #include <netlink/route/sch/fifo.h> static void print_usage(void) @@ -28,8 +28,10 @@ static void print_usage(void) " nl-qdisc-add --dev=eth1 --parent=root pfifo --limit=32\n"); } -static void pfifo_parse_argv(struct rtnl_qdisc *qdisc, int argc, char **argv) +static void pfifo_parse_argv(struct rtnl_tc *tc, int argc, char **argv) { + struct rtnl_qdisc *qdisc = (struct rtnl_qdisc *) tc; + for (;;) { int c, optidx = 0; enum { @@ -57,18 +59,19 @@ static void pfifo_parse_argv(struct rtnl_qdisc *qdisc, int argc, char **argv) } } -static struct nl_cli_qdisc_module pfifo_module = +static struct nl_cli_tc_module pfifo_module = { - .qm_name = "pfifo", - .qm_parse_qdisc_argv = pfifo_parse_argv, + .tm_name = "pfifo", + .tm_type = RTNL_TC_TYPE_QDISC, + .tm_parse_argv = pfifo_parse_argv, }; static void __init pfifo_init(void) { - nl_cli_qdisc_register(&pfifo_module); + nl_cli_tc_register(&pfifo_module); } static void __exit pfifo_exit(void) { - nl_cli_qdisc_unregister(&pfifo_module); + nl_cli_tc_unregister(&pfifo_module); } |