From: Edwin Peer <edwin.peer@broadcom•com>
To: netdev@vger•kernel.org
Cc: Edwin Peer <edwin.peer@broadcom•com>,
Jakub Kicinski <kuba@kernel•org>,
Andrew Gospodarek <andrew.gospodarek@broadcom•com>,
Michael Chan <michael.chan@broadcom•com>,
Stephen Hemminger <stephen@networkplumber•org>,
Michal Kubecek <mkubecek@suse•cz>,
David Ahern <dsahern@gmail•com>
Subject: [PATCH net-next 4/4] rtnetlink: promote IFLA_VF_STATS to same level as IFLA_VF_INFO
Date: Fri, 22 Jan 2021 20:53:21 -0800 [thread overview]
Message-ID: <20210123045321.2797360-5-edwin.peer@broadcom.com> (raw)
In-Reply-To: <20210123045321.2797360-1-edwin.peer@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 3636 bytes --]
Separating the VF stats out of IFLA_VF_INFO appears to be the least
impact way of resolving the nlattr overflow bug in IFLA_VFINFO_LIST.
Since changing the hierarchy does constitute an ABI change, it must
be explicitly requested via RTEXT_FILTER_VF_SEPARATE_STATS. Otherwise,
the old location is maintained for compatibility.
A new container type, namely IFLA_VFSTATS_LIST, is introduced to group
the stats objects into an ordered list that corresponds with the order
of VFs in IFLA_VFINFO_LIST.
Fixes: 3b766cd83232 ("net/core: Add reading VF statistics through the PF netdevice")
Fixes: c5a9f6f0ab40 ("net/core: Add drop counters to VF statistics")
Signed-off-by: Edwin Peer <edwin.peer@broadcom•com>
---
include/uapi/linux/if_link.h | 1 +
include/uapi/linux/rtnetlink.h | 1 +
net/core/rtnetlink.c | 24 +++++++++++++++++++++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 2bd0d8bbcdb2..db12ffd2bffd 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
};
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index b841caa4657e..f2f4f9b4d595 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -789,6 +789,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 */
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 95564fd12f24..cddd3945bc11 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -933,6 +933,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,
nla_total_size(sizeof(struct ifla_vf_rss_query_en)) +
nla_total_size(sizeof(struct ifla_vf_trust)));
if (~ext_filter_mask & RTEXT_FILTER_SKIP_STATS) {
+ if (ext_filter_mask & RTEXT_FILTER_VF_SEPARATE_STATS)
+ size += nla_total_size(0); /* IFLA_VFSTATS_LIST */
size += num_vfs *
(nla_total_size(0) + /* nest IFLA_VF_STATS */
/* IFLA_VF_STATS_RX_PACKETS */
@@ -1368,7 +1370,8 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
goto nla_put_vf_failure;
}
nla_nest_end(skb, vfvlanlist);
- if (~ext_filter_mask & RTEXT_FILTER_SKIP_STATS) {
+ if (~ext_filter_mask & RTEXT_FILTER_SKIP_STATS &&
+ ~ext_filter_mask & RTEXT_FILTER_VF_SEPARATE_STATS) {
if (rtnl_fill_vfstats(skb, dev, vfs_num))
goto nla_put_vf_failure;
}
@@ -1386,7 +1389,7 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,
struct net_device *dev,
u32 ext_filter_mask)
{
- struct nlattr *vfinfo;
+ struct nlattr *vfinfo, *vfstats;
int i, num_vfs;
if (!dev->dev.parent || ((ext_filter_mask & RTEXT_FILTER_VF) == 0))
@@ -1407,8 +1410,23 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,
if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask))
return -EMSGSIZE;
}
-
nla_nest_end(skb, vfinfo);
+
+ if (~ext_filter_mask & RTEXT_FILTER_SKIP_STATS &&
+ ext_filter_mask & RTEXT_FILTER_VF_SEPARATE_STATS) {
+ vfstats = nla_nest_start_noflag(skb, IFLA_VFSTATS_LIST);
+ if (!vfstats)
+ return -EMSGSIZE;
+
+ for (i = 0; i < num_vfs; i++) {
+ if (rtnl_fill_vfstats(skb, dev, i)) {
+ nla_nest_cancel(skb, vfstats);
+ return -EMSGSIZE;
+ }
+ }
+ nla_nest_end(skb, vfstats);
+ }
+
return 0;
}
--
2.30.0
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4160 bytes --]
next prev parent reply other threads:[~2021-01-23 4:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-23 4:53 [PATCH net-next 0/4] support for 256 VFs in RTM_GETLINK Edwin Peer
2021-01-23 4:53 ` [PATCH net-next 1/4] netlink: truncate overlength attribute list in nla_nest_end() Edwin Peer
2021-01-23 19:14 ` David Ahern
2021-01-23 20:42 ` Edwin Peer
2021-01-23 21:03 ` Edwin Peer
2021-01-26 4:56 ` David Ahern
2021-01-26 17:51 ` Edwin Peer
2023-06-05 7:28 ` Gal Pressman
2023-06-05 18:58 ` Jakub Kicinski
2023-06-05 19:27 ` Edwin Peer
2023-06-06 8:01 ` Gal Pressman
2023-06-06 16:17 ` Jakub Kicinski
2023-06-07 13:31 ` Gal Pressman
2023-06-07 16:33 ` Jakub Kicinski
2023-06-07 16:52 ` Stephen Hemminger
2023-06-07 17:29 ` Jakub Kicinski
2021-01-26 4:50 ` David Ahern
2021-01-26 1:43 ` Jakub Kicinski
2021-01-23 4:53 ` [PATCH net-next 2/4] rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO Edwin Peer
2021-01-26 1:55 ` Jakub Kicinski
2021-01-26 22:48 ` Edwin Peer
2021-01-23 4:53 ` [PATCH net-next 3/4] rtnetlink: refactor IFLA_VF_INFO stats into rtnl_fill_vfstats() Edwin Peer
2021-01-23 4:53 ` Edwin Peer [this message]
2021-01-26 2:01 ` [PATCH net-next 4/4] rtnetlink: promote IFLA_VF_STATS to same level as IFLA_VF_INFO Jakub Kicinski
2021-01-26 14:50 ` Edwin Peer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210123045321.2797360-5-edwin.peer@broadcom.com \
--to=edwin.peer@broadcom$(echo .)com \
--cc=andrew.gospodarek@broadcom$(echo .)com \
--cc=dsahern@gmail$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=michael.chan@broadcom$(echo .)com \
--cc=mkubecek@suse$(echo .)cz \
--cc=netdev@vger$(echo .)kernel.org \
--cc=stephen@networkplumber$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox