]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: q_red: Implement has_block for RED
authorPetr Machata <petrm@mellanox.com>
Thu, 16 Jul 2020 16:47:08 +0000 (19:47 +0300)
committerDavid Ahern <dsahern@kernel.org>
Mon, 20 Jul 2020 16:34:49 +0000 (16:34 +0000)
In order for "tc filter show block X" to find a given block, implement the
has_block callback.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
tc/q_red.c

index 97856f039c9721848e60989537867a291326efcd..dfef1bf8663c59bc6e9300373a83dd22b9d7b421 100644 (file)
@@ -264,10 +264,27 @@ static int red_print_xstats(struct qdisc_util *qu, FILE *f, struct rtattr *xstat
        return 0;
 }
 
+static int red_has_block(struct qdisc_util *qu, struct rtattr *opt, __u32 block_idx, bool *p_has)
+{
+       struct rtattr *tb[TCA_RED_MAX + 1];
+
+       if (opt == NULL)
+               return 0;
+
+       parse_rtattr_nested(tb, TCA_RED_MAX, opt);
+
+       qevents_init(qevents);
+       if (qevents_read(qevents, tb))
+               return -1;
+
+       *p_has = qevents_have_block(qevents, block_idx);
+       return 0;
+}
 
 struct qdisc_util red_qdisc_util = {
        .id             = "red",
        .parse_qopt     = red_parse_opt,
        .print_qopt     = red_print_opt,
        .print_xstats   = red_print_xstats,
+       .has_block      = red_has_block,
 };