From patchwork Wed Sep 30 16:59:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Buslov X-Patchwork-Id: 259822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03A1CC4727E for ; Wed, 30 Sep 2020 16:59:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AED89208B8 for ; Wed, 30 Sep 2020 16:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731337AbgI3Q7x (ORCPT ); Wed, 30 Sep 2020 12:59:53 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53820 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731313AbgI3Q7x (ORCPT ); Wed, 30 Sep 2020 12:59:53 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vladbu@nvidia.com) with SMTP; 30 Sep 2020 19:59:48 +0300 Received: from reg-r-vrt-018-180.mtr.labs.mlnx. (reg-r-vrt-018-180.mtr.labs.mlnx [10.215.1.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 08UGxm93001392; Wed, 30 Sep 2020 19:59:48 +0300 From: Vlad Buslov To: dsahern@gmail.com, stephen@networkplumber.org Cc: netdev@vger.kernel.org, davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, ivecera@redhat.com, Vlad Buslov Subject: [PATCH iproute2-next v2 2/2] tc: implement support for terse dump Date: Wed, 30 Sep 2020 19:59:24 +0300 Message-Id: <20200930165924.16404-3-vladbu@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200930165924.16404-1-vladbu@nvidia.com> References: <20200930165924.16404-1-vladbu@nvidia.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vlad Buslov 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 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 --- Notes: Changes V1 -> V2: - Invoke terse dump with tc command '-brief' option instead of filter-specific 'terse' flag. - Extend tc man and usage string with new option. man/man8/tc.8 | 6 ++++++ tc/tc.c | 6 +++++- tc/tc_filter.c | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/man/man8/tc.8 b/man/man8/tc.8 index 7e9019f561ea..e8622053df65 100644 --- a/man/man8/tc.8 +++ b/man/man8/tc.8 @@ -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 5d57054b45fb..bdd5d4faf886 100644 --- 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", diff --git a/tc/tc_filter.c b/tc/tc_filter.c index c591a19f3123..71be2e8119c9 100644 --- a/tc/tc_filter.c +++ b/tc/tc_filter.c @@ -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;