From patchwork Tue Jan 26 17:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 12048599 X-Patchwork-Delegate: dsahern@gmail.com 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=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 B93FCC43381 for ; Tue, 26 Jan 2021 23:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B48820663 for ; Tue, 26 Jan 2021 23:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731857AbhAZXFf (ORCPT ); Tue, 26 Jan 2021 18:05:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392976AbhAZRln (ORCPT ); Tue, 26 Jan 2021 12:41:43 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9A15C0613ED for ; Tue, 26 Jan 2021 09:41:02 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id o7so1854935pgl.1 for ; Tue, 26 Jan 2021 09:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=C/z9ptdtKEiOCIOlw4A1avcdfbMhLFCC68M4oYJBUyM=; b=DiPwh+qBc48WVnSmYxr/iocT8UwugQIOaZsueNcidO1/p9YVcemrC7wFQqBlfY8rRz 1yrYe/7+8bEePKviKmGyi/46dnBAHiI7SOI21M6DDOjxEs4qMYq880kUSD4CSwCsQYGq MczT9/8KilE9Ws7TBidCic8Q6NS6Yp0CvUSeU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=C/z9ptdtKEiOCIOlw4A1avcdfbMhLFCC68M4oYJBUyM=; b=UtD4UG0qj6MFc8S1pGZ533BE+ERHcPsqu61Vq8ItCJDMVsUsKKH4N/62phYZWN3ghD 9zFWP49ravme6lxSBFJFXMPnmZSxNTaOJOALzNyckU8ReSlC1QXxcj6ju9i3EU2U5yzt AOMdowq9xfSs2omVhfW7jEGwiWo1Q+9y2lpiCGiJSHMeLyiXI26oO7G7HGq/V8KEsgp5 4O9ZIqxI8xfzsmLQaKTh4FEVCeUnhwz+ex8o8Mu4FbcL12DiI+0LZDF8DzRdH7mS3mC2 iyf1pfWoSEx906w7lQfjUZ7y9d4DsdIQWhtSNTnHiSzi3UN1QgwjsbHT9H1+JkNFRPAy 220Q== X-Gm-Message-State: AOAM5336g/AM3ehF9XWl3a2kqfDLdt3Ucgs5AFbcM2aEjYavvlP30Gi2 BhluKFmUy8H1NX5kqSOWipYf8bnjD8hUwx09j4dRLlnhNrTg6K+1a8Zf0B+3HYfgNKYiJ6K3ig8 HfzePD3J91cWzDn3SVmmcSuI0zBuP6RpFqX5ZaGkMA48Sl0iK6naoI0a5TWJqr/Z6WhB7u4qr X-Google-Smtp-Source: ABdhPJzkoQgHFThBjl3NZsFZS8THothdbkE1vpHP58S0Od9cXj9JvB5PrQ6Wgpm5HLufrHzl7nGevA== X-Received: by 2002:a05:6a00:1506:b029:1bc:6f53:8eb8 with SMTP id q6-20020a056a001506b02901bc6f538eb8mr6388773pfu.36.1611682861342; Tue, 26 Jan 2021 09:41:01 -0800 (PST) Received: from hex.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id w66sm19595647pfd.48.2021.01.26.09.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 09:41:00 -0800 (PST) From: Edwin Peer To: netdev@vger.kernel.org Cc: Edwin Peer , Jakub Kicinski , Andrew Gospodarek , Michael Chan , Stephen Hemminger , Michal Kubecek , David Ahern Subject: [PATCH iproute2-next v2 2/2] iplink: filter stats using RTEXT_FILTER_SKIP_STATS Date: Tue, 26 Jan 2021 09:40:54 -0800 Message-Id: <20210126174054.185084-2-edwin.peer@broadcom.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126174054.185084-1-edwin.peer@broadcom.com> References: <20210126174054.185084-1-edwin.peer@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Don't request statistics we do not intend to render. This avoids the possibility of a truncated IFLA_VFINFO_LIST when statistics are not requested as well as the fetching of unnecessary data. Signed-off-by: Edwin Peer --- ip/ipaddress.c | 6 +++++- ip/iplink.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 0bbcee2b3bb2..75511881050d 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -1882,9 +1882,13 @@ static int ipaddr_flush(void) static int iplink_filter_req(struct nlmsghdr *nlh, int reqlen) { + __u32 filt_mask; int err; - err = addattr32(nlh, reqlen, IFLA_EXT_MASK, RTEXT_FILTER_VF); + filt_mask = RTEXT_FILTER_VF; + if (!show_stats) + filt_mask |= RTEXT_FILTER_SKIP_STATS; + err = addattr32(nlh, reqlen, IFLA_EXT_MASK, filt_mask); if (err) return err; diff --git a/ip/iplink.c b/ip/iplink.c index 27c9be442a7a..6a973213dc11 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -1116,6 +1116,9 @@ int iplink_get(char *name, __u32 filt_mask) !check_ifname(name) ? IFLA_IFNAME : IFLA_ALT_IFNAME, name, strlen(name) + 1); } + + if (!show_stats) + filt_mask |= RTEXT_FILTER_SKIP_STATS; addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filt_mask); if (rtnl_talk(&rth, &req.n, &answer) < 0)