rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO
Subsystems (2)
PATCH 1/1 rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO
From: Edwin Peer <[email protected]>
This filter already exists for excluding IPv6 SNMP stats. Extend its definition to also exclude IFLA_VF_INFO stats in RTM_GETLINK.
This patch constitutes a partial fix for a netlink attribute nesting overflow bug in IFLA_VFINFO_LIST. By excluding the stats when the requester doesn't need them, the truncation of the VF list is avoided.
While it was technically only the stats added in commit c5a9f6f0ab40 ("net/core: Add drop counters to VF statistics") breaking the camel's back, the appreciable size of the stats data should never have been included without due consideration for the maximum number of VFs supported by PCI.
---
Following our discussion in:
https://lore.kernel.org/netdev/[email protected]/
I've rebased and testesd this single patch by Edwin.
It is only a partial "fix", but increases the number of VFs presented before the truncation occurs.
--- net/core/rtnetlink.c | 96 +++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 45 deletions(-)
net/core/rtnetlink.c +51 -45
@@ -961,24 +961,27 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,nla_total_size (sizeof (struct ifla_vf_rate )) +nla_total_size (sizeof (struct ifla_vf_link_state )) +nla_total_size (sizeof (struct ifla_vf_rss_query_en )) + -nla_total_size (0 ) +/* nest IFLA_VF_STATS */ -/* IFLA_VF_STATS_RX_PACKETS */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_TX_PACKETS */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_RX_BYTES */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_TX_BYTES */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_BROADCAST */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_MULTICAST */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_RX_DROPPED */ -nla_total_size_64bit (sizeof (__u64)) + -/* IFLA_VF_STATS_TX_DROPPED */ -nla_total_size_64bit (sizeof (__u64)) + nla_total_size(sizeof(struct ifla_vf_trust))); +if (~ext_filter_mask &RTEXT_FILTER_SKIP_STATS ) { + size += num_vfs * + (nla_total_size (0 ) +/* nest IFLA_VF_STATS */ +/* IFLA_VF_STATS_RX_PACKETS */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_TX_PACKETS */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_RX_BYTES */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_TX_BYTES */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_BROADCAST */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_MULTICAST */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_RX_DROPPED */ +nla_total_size_64bit (sizeof (__u64)) + +/* IFLA_VF_STATS_TX_DROPPED */ +nla_total_size_64bit (sizeof (__u64))); + }return size; }else return 0 ;
@@ -1270,7 +1273,8 @@ static noinline_for_stack int rtnl_fill_stats(struct sk_buff *skb, static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,struct net_device *dev,int vfs_num, -struct nlattr *vfinfo) +struct nlattr *vfinfo, +u32 ext_filter_mask) {struct ifla_vf_rss_query_en vf_rss_query_en;struct nlattr *vf, *vfstats, *vfvlanlist;
@@ -1376,33 +1380,35 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, goto nla_put_vf_failure; }nla_nest_end (skb, vfvlanlist); -memset (&vf_stats,0 ,sizeof (vf_stats)); -if (dev->netdev_ops->ndo_get_vf_stats) - dev->netdev_ops->ndo_get_vf_stats (dev, vfs_num, - &vf_stats); - vfstats =nla_nest_start_noflag (skb,IFLA_VF_STATS ); -if (!vfstats) - goto nla_put_vf_failure; -if (nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_PACKETS , - vf_stats.rx_packets,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_PACKETS , - vf_stats.tx_packets,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_BYTES , - vf_stats.rx_bytes,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_BYTES , - vf_stats.tx_bytes,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_BROADCAST , - vf_stats.broadcast,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_MULTICAST , - vf_stats.multicast,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_DROPPED , - vf_stats.rx_dropped,IFLA_VF_STATS_PAD ) || -nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_DROPPED , - vf_stats.tx_dropped,IFLA_VF_STATS_PAD )) { -nla_nest_cancel (skb, vfstats); - goto nla_put_vf_failure; +if (~ext_filter_mask &RTEXT_FILTER_SKIP_STATS ) { +memset (&vf_stats,0 ,sizeof (vf_stats)); +if (dev->netdev_ops->ndo_get_vf_stats) + dev->netdev_ops->ndo_get_vf_stats (dev, vfs_num, + &vf_stats); + vfstats =nla_nest_start_noflag (skb,IFLA_VF_STATS ); +if (!vfstats) + goto nla_put_vf_failure; +if (nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_PACKETS , + vf_stats.rx_packets,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_PACKETS , + vf_stats.tx_packets,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_BYTES , + vf_stats.rx_bytes,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_BYTES , + vf_stats.tx_bytes,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_BROADCAST , + vf_stats.broadcast,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_MULTICAST , + vf_stats.multicast,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_RX_DROPPED , + vf_stats.rx_dropped,IFLA_VF_STATS_PAD ) || +nla_put_u64_64bit (skb,IFLA_VF_STATS_TX_DROPPED , + vf_stats.tx_dropped,IFLA_VF_STATS_PAD )) { +nla_nest_cancel (skb, vfstats); + goto nla_put_vf_failure; + } +nla_nest_end (skb, vfstats); } -nla_nest_end (skb, vfstats);nla_nest_end (skb, vf);return 0 ;
@@ -1435,7 +1441,7 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,return -EMSGSIZE ;for (i =0 ; i < num_vfs; i++) { -if (rtnl_fill_vfinfo (skb, dev, i, vfinfo)) +if (rtnl_fill_vfinfo (skb, dev, i, vfinfo, ext_filter_mask))return -EMSGSIZE ; }
Signature · 1 line
2.39.1
Quoted 15 lines · On Sun, 11 Jun 2023 13:51:08 +0300 Gal Pressman <[email protected]> wrote:
From: Edwin Peer <[email protected]>
This filter already exists for excluding IPv6 SNMP stats. Extend its definition to also exclude
IFLA_VF_INFOstats inRTM_GETLINK.This patch constitutes a partial fix for a netlink attribute nesting overflow bug in
IFLA_VFINFO_LIST. By excluding the stats when the requester doesn't need them, the truncation of the VF list is avoided.While it was technically only the stats added in commit
c5a9f6f0ab40("net/core: Add drop counters to VF statistics") breaking the camel's back, the appreciable size of the stats data should never have been included without due consideration for the maximum number of VFs supported by PCI.
Quoted 6 lines
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 <[email protected]>Cc Edwin Peer <[email protected]>Signed-off-by Gal Pressman <[email protected]>---
Better but it is still possible to create too many VF's that the response won't fit.
Quoted 25 lines · Stephen Hemminger
Quoted 15 lines · On Sun, 11 Jun 2023 13:51:08 +0300 Gal Pressman <[email protected]> wrote:
From: Edwin Peer <[email protected]>
This filter already exists for excluding IPv6 SNMP stats. Extend its definition to also exclude
IFLA_VF_INFOstats inRTM_GETLINK.This patch constitutes a partial fix for a netlink attribute nesting overflow bug in
IFLA_VFINFO_LIST. By excluding the stats when the requester doesn't need them, the truncation of the VF list is avoided.While it was technically only the stats added in commit
c5a9f6f0ab40("net/core: Add drop counters to VF statistics") breaking the camel's back, the appreciable size of the stats data should never have been included without due consideration for the maximum number of VFs supported by PCI.Quoted 6 lines
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 <[email protected]>Cc Edwin Peer <[email protected]>Signed-off-by Gal Pressman <[email protected]>---
Quoted 2 lines
Better but it is still possible to create too many VF's that the response won't fit.
Correct, no argues here.
It allowed me to see around ~200 VFs instead of ~70, a step in the right direction.
Quoted 40 lines
-----Original Message-----
From: Gal Pressman <[email protected]>
Sent: Sunday, June 11, 2023 10:59 AM
To: Stephen Hemminger <[email protected]>
Cc: David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; David Ahern <[email protected]>; Michal Kubecek <[email protected]>; [email protected]; Edwin Peer <[email protected]>; Edwin Peer <[email protected]>
Subject: Re: [PATCH net-next] rtnetlink: extendRTEXT_FILTER_SKIP_STATStoIFLA_VF_INFOQuoted 12 lines · Stephen Hemminger
Quoted 9 lines · On Sun, 11 Jun 2023 13:51:08 +0300 Gal Pressman <[email protected]> wrote:
From: Edwin Peer <[email protected]>
This filter already exists for excluding IPv6 SNMP stats. Extend its definition to also exclude
IFLA_VF_INFOstats inRTM_GETLINK.This patch constitutes a partial fix for a netlink attribute nesting overflow bug in
IFLA_VFINFO_LIST. By excluding the stats when the requester doesn't need them, the truncation of the VF list is avoided.Quoted 7 lines
Quoted 7 lines
While it was technically only the stats added in commit
c5a9f6f0ab40("net/core: Add drop counters to VF statistics") breaking the camel's back, the appreciable size of the stats data should never have been included without due consideration for the maximum number of VFs supported by PCI.Fixes 3b766cd83232 ("net/core: Add reading VF statistics through the PFnetdevice")
Quoted 6 lines
Quoted 5 lines
Fixes c5a9f6f0ab40 ("net/core: Add drop counters to VF statistics")Signed-off-by Edwin Peer <[email protected]>Cc Edwin Peer <[email protected]>Signed-off-by Gal Pressman <[email protected]>---
Quoted 6 lines
Quoted 2 lines
Better but it is still possible to create too many VF's that the response won't fit.
Correct, no argues here.
It allowed me to see around ~200 VFs instead of ~70, a step in the right direction.
I remember investigating this a few years ago and we hit limits of ~200 that were essentially unfixable without creating a new API that can separate the reply over more than one message. The VF info data was not designed in the current op to allow processing over multiple messages. It also (unfortunately) doesn't report errors so it ends up just truncating instead of producing an error.
Fixing this completely is non-trivial.
Thanks,
Jake
Paolo Abeni
maintainerQuoted 16 lines · Jacob E
Quoted 16 lines
-----Original Message-----
From: Gal Pressman <[email protected]>
Sent: Sunday, June 11, 2023 10:59 AM
To: Stephen Hemminger <[email protected]>
Cc: David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; David Ahern <[email protected]>; Michal Kubecek <[email protected]>; [email protected]; Edwin Peer <[email protected]>; Edwin Peer <[email protected]>
Subject: Re: [PATCH net-next] rtnetlink: extendRTEXT_FILTER_SKIP_STATStoIFLA_VF_INFOQuoted 2 lines · Stephen Hemminger
Better but it is still possible to create too many VF's that the response won't fit.
Quoted 7 lines
Quoted 3 lines
Correct, no argues here.
It allowed me to see around ~200 VFs instead of ~70, a step in the right direction.I remember investigating this a few years ago and we hit limits of ~200 that were essentially unfixable without creating a new API that can separate the reply over more than one message. The VF info data was not designed in the current op to allow processing over multiple messages. It also (unfortunately) doesn't report errors so it ends up just truncating instead of producing an error.
Fixing this completely is non-trivial.
As it looks like the is substantial agreement on this approach being a step in the right direction and I can't think of anything better, I suggest to merge this as is, unless someone voices concerns very soon, very loudly.
Thanks!
Paolo
Quoted 21 lines · Paolo Abeni
Quoted 20 lines · Jacob E
Quoted 19 lines
-----Original Message-----
From: Gal Pressman <[email protected]>
Sent: Sunday, June 11, 2023 10:59 AM
To: Stephen Hemminger <[email protected]>
Cc: David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>; David Ahern <[email protected]>; Michal Kubecek <[email protected]>; [email protected]; Edwin Peer <[email protected]>; Edwin Peer <[email protected]>
Subject: Re: [PATCH net-next] rtnetlink: extendRTEXT_FILTER_SKIP_STATStoIFLA_VF_INFOQuoted 2 lines · Stephen Hemminger
Better but it is still possible to create too many VF's that the response won't fit.
Correct, no argues here.
It allowed me to see around ~200 VFs instead of ~70, a step in the right direction.
Quoted 9 lines
Quoted 3 lines
I remember investigating this a few years ago and we hit limits of ~200 that were essentially unfixable without creating a new API that can separate the reply over more than one message. The VF info data was not designed in the current op to allow processing over multiple messages. It also (unfortunately) doesn't report errors so it ends up just truncating instead of producing an error.
Fixing this completely is non-trivial.
As it looks like the is substantial agreement on this approach being a step in the right direction and I can't think of anything better, I suggest to merge this as is, unless someone voices concerns very soon, very loudly.
My only concern is that this "hot potato" stays in the air longer. This problem has been around for years, and someone needs to step up and propose an API.
Jakub Kicinski
maintainerQuoted 8 lines · On Wed, 14 Jun 2023 08:17:44 -0700 David Ahern wrote:
Quoted 4 lines
As it looks like the is substantial agreement on this approach being a step in the right direction and I can't think of anything better, I suggest to merge this as is, unless someone voices concerns very soon, very loudly.
My only concern is that this "hot potato" stays in the air longer. This problem has been around for years, and someone needs to step up and propose an API.
The functionality is fully covered by devlink and tc. We're not accepting any new drivers/implementations of the old SR-IOV NDOs at all.
We try to put this potato in the grave and it keeps trying to grow :(
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Sun, 11 Jun 2023 13:51:08 +0300 you wrote:
From: Edwin Peer <[email protected]>
This filter already exists for excluding IPv6 SNMP stats. Extend its definition to also exclude
IFLA_VF_INFOstats inRTM_GETLINK.This patch constitutes a partial fix for a netlink attribute nesting overflow bug in
IFLA_VFINFO_LIST. By excluding the stats when the requester doesn't need them, the truncation of the VF list is avoided.[...]
Here is the summary with links:
- [net-next] rtnetlink: extend RTEXT_FILTER_SKIP_STATS to IFLA_VF_INFO
https://git.kernel.org/netdev/net-next/c/fa0e21fa4443
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html