]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: implement support for action terse dump
authorVlad Buslov <vlad@buslov.dev>
Mon, 30 Nov 2020 19:32:50 +0000 (21:32 +0200)
committerDavid Ahern <dsahern@gmail.com>
Thu, 3 Dec 2020 03:51:06 +0000 (03:51 +0000)
Implement support for action terse dump using new TCA_ACT_FLAG_TERSE_DUMP
value of TCA_ROOT_FLAGS tlv. Set the flag when user requested it with
following example CLI (-br for 'brief'):

$ tc -s -br actions ls action tunnel_key
total acts 2

        action order 0: tunnel_key       index 1
        Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

        action order 1: tunnel_key       index 2
        Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

In terse mode dump only outputs essential data needed to identify the
action (kind, index) and stats, if requested by the user.

Signed-off-by: Vlad Buslov <vlad@buslov.dev>
Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
man/man8/tc.8
tc/m_action.c

index e8622053df659dc86563a923368c2e9c98073e4a..4338572a36f31cbae0bfffb14f46a7e8d1e73dcc 100644 (file)
@@ -858,7 +858,7 @@ alias.
 .BR "\-br" , " \-brief"
 Print only essential data needed to identify the filter and action (handle,
 cookie, etc.) and stats. This option is currently only supported by
-.BR "tc filter show " command.
+.BR "tc filter show " and " tc actions ls " commands.
 
 .SH "EXAMPLES"
 .PP
index 77ff4a8d4126791778fd05f51841c0151efb3cf9..b16882a345dc0414f72fa1cd2926f41a9848a07e 100644 (file)
@@ -374,6 +374,11 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
        if (err < 0)
                return err;
 
+       if (brief && tb[TCA_ACT_INDEX]) {
+               print_uint(PRINT_ANY, "index", "\t index %u",
+                          rta_getattr_u32(tb[TCA_ACT_INDEX]));
+               print_nl();
+       }
        if (show_stats && tb[TCA_ACT_STATS]) {
                print_string(PRINT_FP, NULL, "\tAction statistics:", NULL);
                print_nl();
@@ -737,6 +742,10 @@ static int tc_act_list_or_flush(int *argc_p, char ***argv_p, int event)
        tail3 = NLMSG_TAIL(&req.n);
        flag_select.value |= TCA_ACT_FLAG_LARGE_DUMP_ON;
        flag_select.selector |= TCA_ACT_FLAG_LARGE_DUMP_ON;
+       if (brief) {
+               flag_select.value |= TCA_ACT_FLAG_TERSE_DUMP;
+               flag_select.selector |= TCA_ACT_FLAG_TERSE_DUMP;
+       }
        addattr_l(&req.n, MAX_MSG, TCA_ROOT_FLAGS, &flag_select,
                  sizeof(struct nla_bitfield32));
        tail3->rta_len = (void *) NLMSG_TAIL(&req.n) - (void *) tail3;