From patchwork Tue Jan 26 17:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 12049599 X-Patchwork-Delegate: stephen@networkplumber.org 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=-18.1 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,MIME_NO_TEXT, 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 52555C433E0 for ; Wed, 27 Jan 2021 10:13:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1535C20723 for ; Wed, 27 Jan 2021 10:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S314352AbhAZXFc (ORCPT ); Tue, 26 Jan 2021 18:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392974AbhAZRlk (ORCPT ); Tue, 26 Jan 2021 12:41:40 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EB7DC0613D6 for ; Tue, 26 Jan 2021 09:40:59 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id w18so10842617pfu.9 for ; Tue, 26 Jan 2021 09:40:59 -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:mime-version; bh=4ygLgTsrz5e/YwxcVWmQzRYL2Z5QWQ13xMq8BfFh4G8=; b=HTyGanCmhLkuQjR9KyXdtHyPHHdn2ug3syavrl5z/d9klIlm20bCOiWEtXr+bzNGka 21uSpkObtkvgpGbCzfXfYBX3Xcn0Sh7y2XgxptXy1D9oDWEw3EC5WoCwumeYZbPhSC5d T9dhZiHg5YtsBZqpnRm0JM+7/x3dNbPoXmFaQ= 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:mime-version; bh=4ygLgTsrz5e/YwxcVWmQzRYL2Z5QWQ13xMq8BfFh4G8=; b=tLu664+83rMMHvkS1bTUKC11oKthgmy+6c0V4ilPhYvCvqc4jynm2Ig3NAPKz0nXf/ q7FvRstfgK3zquRR4SI5mzIGjvw16mbbO3GIxcKur007pQAhgZpMHv1K5IedFEH3cWuw 6maftg+Qm+VT9UqCGXv8UvLzIytAz9TNTaAczOpDabqDWtZLOp/adKXEGDEfPBMxDp3a CLX+w5aDke9tHr8/B+AKTO5ehgLLs20VzpI4/nQfE6mUxhLAr5AkwW1R/r3oB09atLOi 9zu4CCL/2HYyqEfwPoW512bQQbhxq74G+xja1KTff3bkFZ8LKdxAlVrfSP3t/+kiWsyG yufw== X-Gm-Message-State: AOAM533dU93CE99LIPwt8zMeRP1dx7gk7HSc/2ycAeVVUtEBzI/gQJbm zw1T2Is54fecmNvx89tSSt5z3DWLYywEQVmADPj+KDBTzoaDTpRLOhXfzD6UtBiVYpsI2y1h+Hr IPTz7qjcoPwUfVahCEdBjkIGHR8JzPDXw0FzsgmRX7trxE4prU4bLd+EIqt2KwtJHw/79jssF X-Google-Smtp-Source: ABdhPJyvp0wpc9yYzGtjb6ePUEcmNV/z4UPrTLxRQKVNyG3nS7nheB77wu6172Oy7KLdyfn9ly/J2g== X-Received: by 2002:a63:c911:: with SMTP id o17mr6137611pgg.102.1611682858577; Tue, 26 Jan 2021 09:40:58 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 09:40:57 -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 1/2] iplink: print warning for missing VF data Date: Tue, 26 Jan 2021 09:40:53 -0800 Message-Id: <20210126174054.185084-1-edwin.peer@broadcom.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com The kernel might truncate VF info in IFLA_VFINFO_LIST. Compare the expected number of VFs in IFLA_NUM_VF to how many were found in the list and warn accordingly. Signed-off-by: Edwin Peer --- ip/ipaddress.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 571346b15cc3..0bbcee2b3bb2 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -922,6 +922,7 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) const char *name; unsigned int m_flag = 0; SPRINT_BUF(b1); + bool truncated_vfs = false; if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK) return 0; @@ -1199,15 +1200,18 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) if ((do_link || show_details) && tb[IFLA_VFINFO_LIST] && tb[IFLA_NUM_VF]) { struct rtattr *i, *vflist = tb[IFLA_VFINFO_LIST]; - int rem = RTA_PAYLOAD(vflist); + int rem = RTA_PAYLOAD(vflist), count = 0; open_json_array(PRINT_JSON, "vfinfo_list"); for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) { open_json_object(NULL); print_vfinfo(fp, ifi, i); close_json_object(); + count++; } close_json_array(PRINT_JSON, NULL); + if (count != rta_getattr_u32(tb[IFLA_NUM_VF])) + truncated_vfs = true; } if (tb[IFLA_PROP_LIST]) { @@ -1228,6 +1232,9 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) print_string(PRINT_FP, NULL, "%s", "\n"); fflush(fp); + /* prettier here if stderr and stdout go to the same place */ + if (truncated_vfs) + fprintf(stderr, "Truncated VF list: %s\n", name); return 1; } 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)