diff options
author | Thomas Graf <tgraf@suug.ch> | 2010-10-26 12:54:33 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-10-26 12:54:33 +0200 |
commit | 4c6d1c5dfb4f7e4a9392895f3da709b55c970e02 (patch) | |
tree | 9303851dcc87e2e3f9c25805ccf24f4a543fe23d /src/nl-qdisc-add.c | |
parent | b9d965b01b42103389b2a2c0cc3133293447a64d (diff) |
Unified TC attributes interface
So far all common tc atttributes were accessed via specific functions, i.e.
rtnl_class_set_parent(), rtnl_qdisc_set_parent(), rtnl_cls_set_parent()
which implied a lot of code duplication. Since all tc objects are derived
from struct rtnl_tc and these common attributes are already stored in there
this patch removes all type specific functions and makes rtnl_tc_* attribute
functions public.
rtnl_qdisc_set_parent(qdisc, 10);
becomes:
rtnl_tc_set_parent((struct rtnl_tc *) qdisc, 10);
This patch also adds the following new attributes to tc objects therefore
removing them as tc specific attributes:
- mtu
- mpu
- overhead
This allows for the rate table calculations to be unified as well taking into
account the new kernel behavior to take care of overhead automatically.
Diffstat (limited to 'src/nl-qdisc-add.c')
-rw-r--r-- | src/nl-qdisc-add.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nl-qdisc-add.c b/src/nl-qdisc-add.c index 739a6ed..57603b0 100644 --- a/src/nl-qdisc-add.c +++ b/src/nl-qdisc-add.c @@ -10,6 +10,7 @@ */ #include <netlink/cli/utils.h> +#include <netlink/cli/tc.h> #include <netlink/cli/qdisc.h> #include <netlink/cli/link.h> @@ -46,6 +47,7 @@ int main(int argc, char *argv[]) { struct nl_sock *sock; struct rtnl_qdisc *qdisc; + struct rtnl_tc *tc; struct nl_cache *link_cache; struct nl_dump_params dp = { .dp_type = NL_DUMP_DETAILS, @@ -62,6 +64,7 @@ int main(int argc, char *argv[]) link_cache = nl_cli_link_alloc_cache(sock); qdisc = nl_cli_qdisc_alloc(); + tc = (struct rtnl_tc *) qdisc; for (;;) { int c, optidx = 0; @@ -94,9 +97,9 @@ int main(int argc, char *argv[]) case 'q': quiet = 1; break; case 'h': print_usage(); break; case 'v': nl_cli_print_version(); break; - case 'd': nl_cli_qdisc_parse_dev(qdisc, link_cache, optarg); break; - case 'p': nl_cli_qdisc_parse_parent(qdisc, optarg); break; - case 'i': nl_cli_qdisc_parse_handle(qdisc, optarg); break; + case 'd': nl_cli_tc_parse_dev(tc, link_cache, optarg); break; + case 'p': nl_cli_tc_parse_parent(tc, optarg); break; + case 'i': nl_cli_tc_parse_handle(tc, optarg); break; case ARG_UPDATE: flags = NLM_F_CREATE; break; case ARG_REPLACE: flags = NLM_F_CREATE | NLM_F_REPLACE; break; case ARG_UPDATE_ONLY: flags = 0; break; @@ -107,10 +110,10 @@ int main(int argc, char *argv[]) if (optind >= argc) print_usage(); - if (!rtnl_qdisc_get_ifindex(qdisc)) + if (!rtnl_tc_get_ifindex(tc)) nl_cli_fatal(EINVAL, "You must specify a network device (--dev=XXX)"); - if (!rtnl_qdisc_get_parent(qdisc)) + if (!rtnl_tc_get_parent(tc)) nl_cli_fatal(EINVAL, "You must specify a parent"); kind = argv[optind++]; |