From patchwork Sat Jan 23 04:53:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 12041105 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=-17.9 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 98048C433E0 for ; Sat, 23 Jan 2021 04:54:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AC6823AA1 for ; Sat, 23 Jan 2021 04:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbhAWEy5 (ORCPT ); Fri, 22 Jan 2021 23:54:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbhAWEyw (ORCPT ); Fri, 22 Jan 2021 23:54:52 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A885BC061793 for ; Fri, 22 Jan 2021 20:53:57 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id g15so5211767pgu.9 for ; Fri, 22 Jan 2021 20:53:57 -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=iifPFpUiPAIGGGpKVyrqMYbWgW37mzS8FqtqoApIEJQ=; b=GRq/ID3RwkTvTt1ar2RuYgtRwt5mDFT7N1tPl4GMocEsQNKLTtCocDFmHclVTFo7c/ j78PYnOHPD5ngZ7KCH1krUibf3uQa8lr8+uEw+vgb1r7TBoJth/oUmI7mH6s87TyLAT0 2xR140jbwRjSycX7RwE40E4tWPtMe5D0fsmtA= 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=iifPFpUiPAIGGGpKVyrqMYbWgW37mzS8FqtqoApIEJQ=; b=GQNS0L2CC4S5gaYMiZLAOSQe5x47usSE2GUMtgpn0aUghGSLHpR4y50ZTYNWfV0XZG zMloa3qgAtoVkQEnt7uPxgvY06yBdNSLW5MWN+K+CeZMGwo12EP0LjyqxKuOwdJjIubr 6QzzHp96/XjUoLgAa7u0BlFzy4KQqJhF1dK4fd5GLtwkjvWcw4B4D/XjcIHS7tT2Hlgn rAgt9UDqXeVB9Q0ZPIepdnj0ThDjy0LS3GkWFIC65JO4Tb1g3w62UwjiK5quEk0bODq8 8GaqiyTg2wARdeKa60afDKCaGcJzNyVjwtn5wRtkYQIJ6rAAvdOxO9pEOdOGXkvdvHcW p7Cg== X-Gm-Message-State: AOAM530p6t6+d4NzJbmIKZhMnbDuLnm5yZ4RTP0SoGslErWDXklbUkPF ctjEIpzm7d+7zqxV/B6HghjzmH3P4TBf+ox4BprWCodcMBw1Ea8fn7eLTOjnfMID6TiayOprGG4 /zXT6xM+Ozd38fGWmg77+pH+gqQiB7/gDRA5+tehdJ4m+LSw88IBnqhTcL2weuvVIjsDubsZI X-Google-Smtp-Source: ABdhPJxcksPXuHqTjhNaDKLvItS8HDzYo/LE4gnNjYp6zfIwzxbWK+rtwkDHO4Term2kOhUSrejtDg== X-Received: by 2002:a62:5a03:0:b029:1ae:7e1f:7f1 with SMTP id o3-20020a625a030000b02901ae7e1f07f1mr8508221pfb.9.1611377636381; Fri, 22 Jan 2021 20:53:56 -0800 (PST) Received: from hex.swdvt.lab.broadcom.net ([2600:8802:d04:de02::77c]) by smtp.gmail.com with ESMTPSA id k3sm9675743pgm.94.2021.01.22.20.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 20:53:55 -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 1/4] uapi: update kernel headers from upstream Date: Fri, 22 Jan 2021 20:53:48 -0800 Message-Id: <20210123045351.2797433-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 This primarily pulls in the ABI changes needed to detect truncated lists of netlink attributes as well as the bits necessary to elevate IFLA_VF_INFO stats out of IFLA_VFINFO_LIST. Unrelated changes in the affected files were also synced. Signed-off-by: Edwin Peer --- include/uapi/linux/if_link.h | 2 ++ include/uapi/linux/netlink.h | 1 + include/uapi/linux/rtnetlink.h | 1 + 3 files changed, 4 insertions(+) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 97a95cf7e4f9..2889897bc2bb 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -341,6 +341,7 @@ enum { IFLA_ALT_IFNAME, /* Alternative ifname */ IFLA_PERM_ADDRESS, IFLA_PROTO_DOWN_REASON, + IFLA_VFSTATS_LIST, __IFLA_MAX }; @@ -807,6 +808,7 @@ enum { IFLA_GTP_FD1, IFLA_GTP_PDP_HASHSIZE, IFLA_GTP_ROLE, + IFLA_GTP_COLLECT_METADATA, __IFLA_GTP_MAX, }; #define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1) diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h index 5024c5435749..1cab84506eaf 100644 --- a/include/uapi/linux/netlink.h +++ b/include/uapi/linux/netlink.h @@ -57,6 +57,7 @@ struct nlmsghdr { #define NLM_F_ECHO 0x08 /* Echo this request */ #define NLM_F_DUMP_INTR 0x10 /* Dump was inconsistent due to sequence change */ #define NLM_F_DUMP_FILTERED 0x20 /* Dump was filtered as requested */ +#define NLM_F_NEST_TRUNCATED 0x40 /* Message contains truncated nested attribute */ /* Modifiers to GET request */ #define NLM_F_ROOT 0x100 /* specify tree root */ diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h index c66fd247d90a..b31afc8f70a4 100644 --- a/include/uapi/linux/rtnetlink.h +++ b/include/uapi/linux/rtnetlink.h @@ -787,6 +787,7 @@ enum { #define RTEXT_FILTER_MRP (1 << 4) #define RTEXT_FILTER_CFM_CONFIG (1 << 5) #define RTEXT_FILTER_CFM_STATUS (1 << 6) +#define RTEXT_FILTER_VF_SEPARATE_STATS (1 << 7) /* End of information exported to user level */ From patchwork Sat Jan 23 04:53:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 12041107 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=-18.9 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, 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 35A61C433E0 for ; Sat, 23 Jan 2021 04:55:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0D4B23AA1 for ; Sat, 23 Jan 2021 04:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726822AbhAWEzB (ORCPT ); Fri, 22 Jan 2021 23:55:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726754AbhAWEyw (ORCPT ); Fri, 22 Jan 2021 23:54:52 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7101C061794 for ; Fri, 22 Jan 2021 20:53:59 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id 11so5180263pfu.4 for ; Fri, 22 Jan 2021 20:53: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:in-reply-to:references :mime-version; bh=LI6HKM/0jE7QF0K+h0o5q3QojmaF5bUVzmQHTFlOYdk=; b=GkL0M0V/Jfs/BUU9I9u7abs/+DHik3sM/GkLr+7gxHX38Nrr9OgL6Oij/m9UZlAdFM CmUeqRWO/U7KkEOJQ9fs7NA1Ly91/RO4IYMUQlGK4sR4Z5Xk2jyF33+DDh4F5as27Zyx cLA7UiezGIKCvIRPszJsH9cLMS93wUk+uf9/E= 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=LI6HKM/0jE7QF0K+h0o5q3QojmaF5bUVzmQHTFlOYdk=; b=jqIiPHfX0bPdcQO1UuNwtNzhdBoYoRKfbEf778eoqJQoF4r1i+SHiPOK5Eev1uMmxd 9PKVqG0QEcRhQU4EXfm+bLiJMThHVwTCXmXNVv1wSOu5oAzonNUBlpY4/etrOwmmxJA2 GviIzFOPYicZIbZxcWtJAuRHe1UfRaVADBmoFp0IskCpVbw7TJ1teMgYq5Exz5/89dcU 0k+D//PiyTzTrUL5r+7SYnBSvvVja9gI7YDexsgCGE4/gnc/XEDVihVavD4XYj2NvqGW UfvVaeo1lAkg4eaczscrg9fv1rlGcj2OPEPsW6fXJUguWdOQxx29CAJ+i4YlTksE5dnw UVWg== X-Gm-Message-State: AOAM53266wvQclhNiPI/1SUgOH/y31EyQ7RkoiF3vwrHxOBNcmotGDZf aZ7JilUVF243KSwYstwGbEg2k0gyh31tBszaUgBu2M3uoxvLW1bbIQSSJsO9U2O0MvVZQX/VkAm UpivoawFWf+h5zArxpw6Hm4ne75nRKgVpHSlaefHOtgZqGglEqodsn1+uwZC7N2U9NZr97PiI X-Google-Smtp-Source: ABdhPJxpZWybz67XNnA04/l/wnN39xhCGxsaecNgaEx4vqTN1ucp4QMmlEdlh2u7wGs8DGlPcxeFRw== X-Received: by 2002:a62:31c7:0:b029:1b8:4194:8982 with SMTP id x190-20020a6231c70000b02901b841948982mr8354488pfx.33.1611377638639; Fri, 22 Jan 2021 20:53:58 -0800 (PST) Received: from hex.swdvt.lab.broadcom.net ([2600:8802:d04:de02::77c]) by smtp.gmail.com with ESMTPSA id k3sm9675743pgm.94.2021.01.22.20.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 20:53: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 2/4] lib: iplink: print warnings for missing data Date: Fri, 22 Jan 2021 20:53:49 -0800 Message-Id: <20210123045351.2797433-2-edwin.peer@broadcom.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210123045351.2797433-1-edwin.peer@broadcom.com> References: <20210123045351.2797433-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 The kernel might truncate VF info in IFLA_VFINFO_LIST. Sufficiently new kernels will provide NLM_F_NEST_TRUNCATED in these cases, but this flag has limited resolution, as it pertains to the entire netlink message. A better approach is to 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 ++++++++- lib/libnetlink.c | 12 ++++++++++++ 2 files changed, 20 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; } diff --git a/lib/libnetlink.c b/lib/libnetlink.c index c958aa57d0cd..b1f07d4570cf 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -833,6 +833,9 @@ static int rtnl_dump_filter_l(struct rtnl_handle *rth, if (h->nlmsg_flags & NLM_F_DUMP_INTR) dump_intr = 1; + if (h->nlmsg_flags & NLM_F_NEST_TRUNCATED) + fprintf(stderr, "Incomplete data: truncated attribute list\n"); + if (h->nlmsg_type == NLMSG_DONE) { err = rtnl_dump_done(h); if (err < 0) { @@ -978,6 +981,9 @@ next: continue; } + if (h->nlmsg_flags & NLM_F_NEST_TRUNCATED) + fprintf(stderr, "Incomplete data: truncated attribute list\n"); + if (h->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(h); int error = err->error; @@ -1156,6 +1162,9 @@ int rtnl_listen(struct rtnl_handle *rtnl, exit(1); } + if (h->nlmsg_flags & NLM_F_NEST_TRUNCATED) + fprintf(stderr, "Incomplete data: truncated attribute list\n"); + err = handler(&ctrl, h, jarg); if (err < 0) return err; @@ -1206,6 +1215,9 @@ int rtnl_from_file(FILE *rtnl, rtnl_listen_filter_t handler, return -1; } + if (h->nlmsg_flags & NLM_F_NEST_TRUNCATED) + fprintf(stderr, "Incomplete data: truncated attribute list\n"); + status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); if (status != NLMSG_ALIGN(l)) { From patchwork Sat Jan 23 04:53:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 12041109 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=-18.9 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, 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 779EFC433E0 for ; Sat, 23 Jan 2021 04:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46A4423A84 for ; Sat, 23 Jan 2021 04:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbhAWEzG (ORCPT ); Fri, 22 Jan 2021 23:55:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726779AbhAWEyy (ORCPT ); Fri, 22 Jan 2021 23:54:54 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E3DC061797 for ; Fri, 22 Jan 2021 20:54:01 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id m5so5141566pjv.5 for ; Fri, 22 Jan 2021 20:54:01 -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=ijQyXmtUqboHOtjn+T8pA+UT/7phNjo4BxqNiVOV+YU=; b=MTIurxjAMBXk+CtNRSuOUou/Ws70uqIAHtx09VbjjCOXsVga3AkRGCSWQYhF5A1vMk aTPfJJVT8lw7xSLtMPAgaAenDsgOCl4sdxovb8svOLFJb4f5/REgPT76AUTFeuCk5ieM 8pZrENca21NxPF8SarKi13ckMDHteRVcbXtLU= 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=ijQyXmtUqboHOtjn+T8pA+UT/7phNjo4BxqNiVOV+YU=; b=Mhe4Av292mc9fQXpk96SPA8Xj7OYpmivygIg4PzJ+w66ezvr7sh6MD3WoZpfTBo2/5 1a6e3nLiXwC5qZtI9ChiROKbprHNNCf3pUoo7T/qMdPFOQwpRZfMgOFrYVuBD3ZQoPib MlXRSS5cH1CS6YdztyQn4V/+1UvCKpExLFB3kMxk9RoKHC1XxU9Q/5OuJGpnCm3n0fDX x5lVSO5/PonT6JTl4y4RoqSIZEMapKvDp1T59/+xIbWfGxxJ8QoAdqAKt6+USheQfEAv /KjQl/UfqmUeQzZrXUQF3wIc78akK1aMr9jluYNb2ocHdfoix+cAtdX0b2SRDeMxWT7C uNTw== X-Gm-Message-State: AOAM5339GPObh4AG6FCv+1QvbB13E241qaln0O4pH7A+cAgdt+WSdLnh AEY8Wzry53D5qVdyIBBF7QbDaMZ4DwyHSFf9KnTed9JLHdVpOfTKBc7R4UiCmOpxgdeA2dl39Au RB4VRwUog5xN1rsA4AnCgS0Fhe7IbPeE0RlNUPgQdT5ALdUi2w2wWx5krS1saOZMp45K4HbnI X-Google-Smtp-Source: ABdhPJybMlpHFpPi1L9MwKWnN6qPTXFy2ENv0fDe25zFoj8PhVksnpx0CzMbh2VO6Ssjp7pmGELa3w== X-Received: by 2002:a17:90a:eacf:: with SMTP id ev15mr9400480pjb.209.1611377640598; Fri, 22 Jan 2021 20:54:00 -0800 (PST) Received: from hex.swdvt.lab.broadcom.net ([2600:8802:d04:de02::77c]) by smtp.gmail.com with ESMTPSA id k3sm9675743pgm.94.2021.01.22.20.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 20:53:59 -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 3/4] iplink: filter stats using RTEXT_FILTER_SKIP_STATS Date: Fri, 22 Jan 2021 20:53:50 -0800 Message-Id: <20210123045351.2797433-3-edwin.peer@broadcom.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210123045351.2797433-1-edwin.peer@broadcom.com> References: <20210123045351.2797433-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 is a step towards avoiding a truncated IFLA_VFINFO_LIST. It also avoids fetching unnecessary data, reducing netlink traffic. 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) From patchwork Sat Jan 23 04:53:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edwin Peer X-Patchwork-Id: 12041111 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=-18.9 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 51880C433E0 for ; Sat, 23 Jan 2021 04:55:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E2B223AA1 for ; Sat, 23 Jan 2021 04:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbhAWEz0 (ORCPT ); Fri, 22 Jan 2021 23:55:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726781AbhAWEyy (ORCPT ); Fri, 22 Jan 2021 23:54:54 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756E1C0617A7 for ; Fri, 22 Jan 2021 20:54:03 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id a20so2110435pjs.1 for ; Fri, 22 Jan 2021 20:54:03 -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=2HiPQbERNmDJsN7tLgdcD8TxeTumghftwa9JpFzrsGw=; b=IABNyNRTOlckv/zPzdqeMTlVKQFHP/wNME7+ExBFDp7V8jmAl4e/YcHwU/IBBpdDlR lKKr/7xuOZsqUTC2Kg1ZMi6hjrz6gxSuAKZuVkNstURCeicZHQxgFFx4xfHLrqxOAdX3 EYBGXUY/fSa9dUrGJbtsEeE+uCevaH4oYhtCo= 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=2HiPQbERNmDJsN7tLgdcD8TxeTumghftwa9JpFzrsGw=; b=HM/4lIkShcLdqGWOXRd3U/SH2yAdgrpPlXXIzNtL3L6yuZeUX3HAjFU5tt8aVgyfwq ctU0Nzyg6phfGdCeRq95yqEA1dAq/Qln1acvdnwMqajqClyreKOtsrz1nFcPS9ZYLudy rhQQ8gLiCae2JCWzUFEhaGe2Yjhfna0sMJzRAJ0C8zUVNbD9m67INib77zGnGL4Vvtml FeNn5ycimPnVHH1/R7i89JYXtjdWF7cyx+mXdnfus1d6Z/IZqpJ8R4c1NagpQw1GISys ZFqgO8Y+6F++io8iefExN5lZOwKtSonkHfkr6KTUoabYCDp4Ba/y+M19ea0/qOGtuZug narQ== X-Gm-Message-State: AOAM53124MdtiKzWWhFn21PTB1xEPKjGt+e9aqigsuwikN35iye56ogB wyUkwBS+X7yYtvu87MlnIrve8GB96UBa/LIneszoFhukNpi36NmkdoBaBd8zYaoCYXr3gakSOiT lxBTWiAZVuy8juyGt6gw14yPr9wRoLM+gVE/4VUghntyxXLZZYuBYqvABZJdSZXzomhov8vLU X-Google-Smtp-Source: ABdhPJz53qIoW4PMu7VJuoVvc9aV3hRpjMR7/ySPOnd5YTTlDdmeFWok0s8Cp3iQynzsL2EhQ1Kx7A== X-Received: by 2002:a17:90a:c82:: with SMTP id v2mr9217635pja.171.1611377642233; Fri, 22 Jan 2021 20:54:02 -0800 (PST) Received: from hex.swdvt.lab.broadcom.net ([2600:8802:d04:de02::77c]) by smtp.gmail.com with ESMTPSA id k3sm9675743pgm.94.2021.01.22.20.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 20:54:01 -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 4/4] iplink: render IFLA_VF_STATS from IFLA_VFSTATS_LIST Date: Fri, 22 Jan 2021 20:53:51 -0800 Message-Id: <20210123045351.2797433-4-edwin.peer@broadcom.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210123045351.2797433-1-edwin.peer@broadcom.com> References: <20210123045351.2797433-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 The maximum possible length of a netlink attribute is 64KB, but the IFLA_VFINFO_LIST exceeds this when stats are included and more than about 220 VFs are present (each VF consumes approximately 300 bytes, depending on alignment and optional fields). Exceeding the limit will cause the list to be truncated by the kernel's nla_nest_end(). A recent ABI fix moves the VF stats into an independent list when requested, thus avoiding the problem. Send requests using the new RTEXT_FILTER_VF_SEPARATE_STATS filter and render the stats from the alternate list instead. Signed-off-by: Edwin Peer --- ip/ipaddress.c | 14 +++++++++++--- ip/iplink.c | 1 + lib/libnetlink.c | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 75511881050d..a048b3db601c 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -1200,12 +1200,20 @@ 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), count = 0; + struct rtattr *j, *vfstats = tb[IFLA_VFSTATS_LIST]; + int rem_stats, rem = RTA_PAYLOAD(vflist), count = 0; + j = vfstats ? RTA_DATA(vfstats) : NULL; + rem_stats = vfstats ? RTA_PAYLOAD(vfstats) : 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); + if (show_stats && j) { + print_vf_stats64(fp, j); + j = RTA_OK(j, rem_stats) ? + RTA_NEXT(j, rem_stats) : NULL; + } close_json_object(); count++; } @@ -1885,7 +1893,7 @@ static int iplink_filter_req(struct nlmsghdr *nlh, int reqlen) __u32 filt_mask; int err; - filt_mask = RTEXT_FILTER_VF; + filt_mask = RTEXT_FILTER_VF | RTEXT_FILTER_VF_SEPARATE_STATS; if (!show_stats) filt_mask |= RTEXT_FILTER_SKIP_STATS; err = addattr32(nlh, reqlen, IFLA_EXT_MASK, filt_mask); @@ -1923,7 +1931,7 @@ static int ipaddr_link_get(int index, struct nlmsg_chain *linfo) .i.ifi_family = filter.family, .i.ifi_index = index, }; - __u32 filt_mask = RTEXT_FILTER_VF; + __u32 filt_mask = RTEXT_FILTER_VF | RTEXT_FILTER_VF_SEPARATE_STATS; struct nlmsghdr *answer; if (!show_stats) diff --git a/ip/iplink.c b/ip/iplink.c index 6a973213dc11..3cce8aa2a0b7 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -1117,6 +1117,7 @@ int iplink_get(char *name, __u32 filt_mask) name, strlen(name) + 1); } + filt_mask |= RTEXT_FILTER_VF_SEPARATE_STATS; if (!show_stats) filt_mask |= RTEXT_FILTER_SKIP_STATS; addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filt_mask); diff --git a/lib/libnetlink.c b/lib/libnetlink.c index b1f07d4570cf..b4aa9d16b446 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -486,7 +486,8 @@ static int __rtnl_linkdump_req(struct rtnl_handle *rth, int family) int rtnl_linkdump_req(struct rtnl_handle *rth, int family) { if (family == AF_UNSPEC) - return rtnl_linkdump_req_filter(rth, family, RTEXT_FILTER_VF); + return rtnl_linkdump_req_filter(rth, family, RTEXT_FILTER_VF | + RTEXT_FILTER_VF_SEPARATE_STATS); return __rtnl_linkdump_req(rth, family); }