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; }