]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: implement support for terse dump
authorVlad Buslov <vladbu@mellanox.com>
Fri, 23 Oct 2020 14:55:36 +0000 (17:55 +0300)
committerDavid Ahern <dsahern@gmail.com>
Sat, 31 Oct 2020 15:15:15 +0000 (09:15 -0600)
Implement support for classifier/action terse dump using new TCA_DUMP_FLAGS
tlv with only available flag value TCA_DUMP_FLAGS_TERSE. Set the flag when
user requested it with following example CLI (-br for 'brief'):

$ tc -s -br filter show dev ens1f0 ingress
filter protocol ip pref 49151 flower chain 0
filter protocol ip pref 49151 flower chain 0 handle 0x1
  not_in_hw
        action order 1: gact    Action statistics:
        Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0

filter protocol ip pref 49152 flower chain 0
filter protocol ip pref 49152 flower chain 0 handle 0x1
  not_in_hw
        action order 1: gact    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
filter and action (handle, cookie, etc.) and stats, if requested by the
user. The intention is to significantly improve rule dump rate by omitting
all static data that do not change after rule is created.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
man/man8/tc.8
tc/tc.c
tc/tc_filter.c

index 7e9019f561ea506e81d5980b8ecbdd936ab2f663..e8622053df659dc86563a923368c2e9c98073e4a 100644 (file)
@@ -854,6 +854,12 @@ option for creating
 alias.
 .RE
 
+.TP
+.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.
+
 .SH "EXAMPLES"
 .PP
 tc -g class show dev eth0
diff --git a/tc/tc.c b/tc/tc.c
index 5d57054b45fbcabae538fb4ceab2ccdfa3139849..bdd5d4faf8867ec1f420b215f8743dbda99c2c00 100644 (file)
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -44,6 +44,7 @@ bool use_names;
 int json;
 int color;
 int oneline;
+int brief;
 
 static char *conf_file;
 
@@ -202,7 +203,8 @@ static void usage(void)
                "       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[aw] |\n"
                "                   -o[neline] | -j[son] | -p[retty] | -c[olor]\n"
                "                   -b[atch] [filename] | -n[etns] name | -N[umeric] |\n"
-               "                    -nm | -nam[es] | { -cf | -conf } path }\n");
+               "                    -nm | -nam[es] | { -cf | -conf } path\n"
+               "                    -br[ief] }\n");
 }
 
 static int do_cmd(int argc, char **argv)
@@ -336,6 +338,8 @@ int main(int argc, char **argv)
                        ++json;
                } else if (matches(argv[1], "-oneline") == 0) {
                        ++oneline;
+               }else if (matches(argv[1], "-brief") == 0) {
+                       ++brief;
                } else {
                        fprintf(stderr,
                                "Option \"%s\" is unknown, try \"tc -help\".\n",
index c591a19f31234c49470db3b03acd6235b75baac2..71be2e8119c9995357c8d1c825530b0c6daf95a5 100644 (file)
@@ -721,6 +721,15 @@ static int tc_filter_list(int cmd, int argc, char **argv)
        if (filter_chain_index_set)
                addattr32(&req.n, sizeof(req), TCA_CHAIN, chain_index);
 
+       if (brief) {
+               struct nla_bitfield32 flags = {
+                       .value = TCA_DUMP_FLAGS_TERSE,
+                       .selector = TCA_DUMP_FLAGS_TERSE
+               };
+
+               addattr_l(&req.n, MAX_MSG, TCA_DUMP_FLAGS, &flags, sizeof(flags));
+       }
+
        if (rtnl_dump_request_n(&rth, &req.n) < 0) {
                perror("Cannot send dump request");
                return 1;