]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/tc_qdisc.c
tc: parse attributes with NLA_F_NESTED flag
[mirror_iproute2.git] / tc / tc_qdisc.c
index c5da5b5c1ed5164b4a2bb7e4514242aada193749..181fe2f0403f5bc5b3f2c009a5912f550c9d0d7c 100644 (file)
 
 static int usage(void)
 {
-       fprintf(stderr, "Usage: tc qdisc [ add | del | replace | change | show ] dev STRING\n");
-       fprintf(stderr, "       [ handle QHANDLE ] [ root | ingress | clsact | parent CLASSID ]\n");
-       fprintf(stderr, "       [ estimator INTERVAL TIME_CONSTANT ]\n");
-       fprintf(stderr, "       [ stab [ help | STAB_OPTIONS] ]\n");
-       fprintf(stderr, "       [ ingress_block BLOCK_INDEX ] [ egress_block BLOCK_INDEX ]\n");
-       fprintf(stderr, "       [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n");
-       fprintf(stderr, "\n");
-       fprintf(stderr, "       tc qdisc show [ dev STRING ] [ ingress | clsact ] [ invisible ]\n");
-       fprintf(stderr, "Where:\n");
-       fprintf(stderr, "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n");
-       fprintf(stderr, "OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help\n");
-       fprintf(stderr, "STAB_OPTIONS := ... try tc qdisc add stab help\n");
+       fprintf(stderr,
+               "Usage: tc qdisc [ add | del | replace | change | show ] dev STRING\n"
+               "       [ handle QHANDLE ] [ root | ingress | clsact | parent CLASSID ]\n"
+               "       [ estimator INTERVAL TIME_CONSTANT ]\n"
+               "       [ stab [ help | STAB_OPTIONS] ]\n"
+               "       [ ingress_block BLOCK_INDEX ] [ egress_block BLOCK_INDEX ]\n"
+               "       [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n"
+               "\n"
+               "       tc qdisc show [ dev STRING ] [ ingress | clsact ] [ invisible ]\n"
+               "Where:\n"
+               "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n"
+               "OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help\n"
+               "STAB_OPTIONS := ... try tc qdisc add stab help\n");
        return -1;
 }
 
@@ -234,7 +235,7 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
        if (filter_ifindex && filter_ifindex != t->tcm_ifindex)
                return 0;
 
-       parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
+       parse_rtattr_flags(tb, TCA_MAX, TCA_RTA(t), len, NLA_F_NESTED);
 
        if (tb[TCA_KIND] == NULL) {
                fprintf(stderr, "print_qdisc: NULL kind\n");
@@ -312,16 +313,15 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
                if (q)
                        q->print_qopt(q, fp, tb[TCA_OPTIONS]);
                else
-                       print_string(PRINT_FP, NULL,
-                                    "[cannot parse qdisc parameters]", NULL);
+                       fprintf(stderr, "Cannot parse qdisc parameters\n");
        }
        close_json_object();
 
-       print_string(PRINT_FP, NULL, "\n", NULL);
+       print_nl();
 
        if (show_details && tb[TCA_STAB]) {
                print_size_table(fp, " ", tb[TCA_STAB]);
-               print_string(PRINT_FP, NULL, "\n", NULL);
+               print_nl();
        }
 
        if (show_stats) {
@@ -329,12 +329,12 @@ int print_qdisc(struct nlmsghdr *n, void *arg)
 
                if (tb[TCA_STATS] || tb[TCA_STATS2] || tb[TCA_XSTATS]) {
                        print_tcstats_attr(fp, tb, " ", &xstats);
-                       print_string(PRINT_FP, NULL, "\n", NULL);
+                       print_nl();
                }
 
                if (q && xstats && q->print_xstats) {
                        q->print_xstats(q, fp, xstats);
-                       print_string(PRINT_FP, NULL, "\n", NULL);
+                       print_nl();
                }
        }
        close_json_object();
@@ -461,7 +461,7 @@ static int tc_qdisc_block_exists_cb(struct nlmsghdr *n, void *arg)
        if (len < 0)
                return -1;
 
-       parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
+       parse_rtattr_flags(tb, TCA_MAX, TCA_RTA(t), len, NLA_F_NESTED);
 
        if (tb[TCA_KIND] == NULL)
                return -1;