From: Petr Machata Date: Thu, 16 Jul 2020 16:47:08 +0000 (+0300) Subject: tc: q_red: Implement has_block for RED X-Git-Tag: v5.9.0~30^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02dce2fdcec14161807b25a4cf25c91dd454c8b7;p=thirdparty%2Fiproute2.git tc: q_red: Implement has_block for RED In order for "tc filter show block X" to find a given block, implement the has_block callback. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko Signed-off-by: David Ahern --- diff --git a/tc/q_red.c b/tc/q_red.c index 97856f039..dfef1bf86 100644 --- a/tc/q_red.c +++ b/tc/q_red.c @@ -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, };