[PATCH net v2] rtnetlink: fix frame size warning in rtnl_fill_ifinfo

2015-11-17 Thread Hannes Frederic Sowa
Fix the following warning:

  CC  net/core/rtnetlink.o
net/core/rtnetlink.c: In function ‘rtnl_fill_ifinfo’:
net/core/rtnetlink.c:1308:1: warning: the frame size of 2864 bytes is larger 
than 2048 bytes [-Wframe-larger-than=]
 }
 ^
by splitting up the huge rtnl_fill_ifinfo into some smaller ones, so we
don't have the huge frame allocations at the same time.

Cc: Eric Dumazet 
Signed-off-by: Hannes Frederic Sowa 
---
 net/core/rtnetlink.c | 274 ---
 1 file changed, 152 insertions(+), 122 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 504bd17..34ba7a0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1045,15 +1045,156 @@ static int rtnl_phys_switch_id_fill(struct sk_buff 
*skb, struct net_device *dev)
return 0;
 }
 
+static noinline_for_stack int rtnl_fill_stats(struct sk_buff *skb,
+ struct net_device *dev)
+{
+   const struct rtnl_link_stats64 *stats;
+   struct rtnl_link_stats64 temp;
+   struct nlattr *attr;
+
+   stats = dev_get_stats(dev, );
+
+   attr = nla_reserve(skb, IFLA_STATS,
+  sizeof(struct rtnl_link_stats));
+   if (!attr)
+   return -EMSGSIZE;
+
+   copy_rtnl_link_stats(nla_data(attr), stats);
+
+   attr = nla_reserve(skb, IFLA_STATS64,
+  sizeof(struct rtnl_link_stats64));
+   if (!attr)
+   return -EMSGSIZE;
+
+   copy_rtnl_link_stats64(nla_data(attr), stats);
+
+   return 0;
+}
+
+static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
+  struct net_device *dev,
+  int vfs_num,
+  struct nlattr *vfinfo)
+{
+   struct ifla_vf_rss_query_en vf_rss_query_en;
+   struct ifla_vf_link_state vf_linkstate;
+   struct ifla_vf_spoofchk vf_spoofchk;
+   struct ifla_vf_tx_rate vf_tx_rate;
+   struct ifla_vf_stats vf_stats;
+   struct ifla_vf_trust vf_trust;
+   struct ifla_vf_vlan vf_vlan;
+   struct ifla_vf_rate vf_rate;
+   struct nlattr *vf, *vfstats;
+   struct ifla_vf_mac vf_mac;
+   struct ifla_vf_info ivi;
+
+   /* Not all SR-IOV capable drivers support the
+* spoofcheck and "RSS query enable" query.  Preset to
+* -1 so the user space tool can detect that the driver
+* didn't report anything.
+*/
+   ivi.spoofchk = -1;
+   ivi.rss_query_en = -1;
+   ivi.trusted = -1;
+   memset(ivi.mac, 0, sizeof(ivi.mac));
+   /* The default value for VF link state is "auto"
+* IFLA_VF_LINK_STATE_AUTO which equals zero
+*/
+   ivi.linkstate = 0;
+   if (dev->netdev_ops->ndo_get_vf_config(dev, vfs_num, ))
+   return 0;
+
+   vf_mac.vf =
+   vf_vlan.vf =
+   vf_rate.vf =
+   vf_tx_rate.vf =
+   vf_spoofchk.vf =
+   vf_linkstate.vf =
+   vf_rss_query_en.vf =
+   vf_trust.vf = ivi.vf;
+
+   memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac));
+   vf_vlan.vlan = ivi.vlan;
+   vf_vlan.qos = ivi.qos;
+   vf_tx_rate.rate = ivi.max_tx_rate;
+   vf_rate.min_tx_rate = ivi.min_tx_rate;
+   vf_rate.max_tx_rate = ivi.max_tx_rate;
+   vf_spoofchk.setting = ivi.spoofchk;
+   vf_linkstate.link_state = ivi.linkstate;
+   vf_rss_query_en.setting = ivi.rss_query_en;
+   vf_trust.setting = ivi.trusted;
+   vf = nla_nest_start(skb, IFLA_VF_INFO);
+   if (!vf) {
+   nla_nest_cancel(skb, vfinfo);
+   return -EMSGSIZE;
+   }
+   if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), _mac) ||
+   nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), _vlan) ||
+   nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
+   _rate) ||
+   nla_put(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate),
+   _tx_rate) ||
+   nla_put(skb, IFLA_VF_SPOOFCHK, sizeof(vf_spoofchk),
+   _spoofchk) ||
+   nla_put(skb, IFLA_VF_LINK_STATE, sizeof(vf_linkstate),
+   _linkstate) ||
+   nla_put(skb, IFLA_VF_RSS_QUERY_EN,
+   sizeof(vf_rss_query_en),
+   _rss_query_en) ||
+   nla_put(skb, IFLA_VF_TRUST,
+   sizeof(vf_trust), _trust))
+   return -EMSGSIZE;
+   memset(_stats, 0, sizeof(vf_stats));
+   if (dev->netdev_ops->ndo_get_vf_stats)
+   dev->netdev_ops->ndo_get_vf_stats(dev, vfs_num,
+   _stats);
+   vfstats = nla_nest_start(skb, IFLA_VF_STATS);
+   if (!vfstats) {
+   nla_nest_cancel(skb, vf);
+   nla_nest_cancel(skb, vfinfo);
+   return -EMSGSIZE;
+   }
+   if 

Re: [PATCH net v2] rtnetlink: fix frame size warning in rtnl_fill_ifinfo

2015-11-17 Thread Eric Dumazet
On Tue, 2015-11-17 at 14:16 +0100, Hannes Frederic Sowa wrote:
> Fix the following warning:
> 
>   CC  net/core/rtnetlink.o
> net/core/rtnetlink.c: In function ‘rtnl_fill_ifinfo’:
> net/core/rtnetlink.c:1308:1: warning: the frame size of 2864 bytes is larger 
> than 2048 bytes [-Wframe-larger-than=]
>  }
>  ^
> by splitting up the huge rtnl_fill_ifinfo into some smaller ones, so we
> don't have the huge frame allocations at the same time.
> 
> Cc: Eric Dumazet 
> Signed-off-by: Hannes Frederic Sowa 
> ---
>  net/core/rtnetlink.c | 274 
> ---
>  1 file changed, 152 insertions(+), 122 deletions(-)
> 

LGTM, thanks Hannes !

Acked-by: Eric Dumazet 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net v2] rtnetlink: fix frame size warning in rtnl_fill_ifinfo

2015-11-17 Thread David Miller
From: Hannes Frederic Sowa 
Date: Tue, 17 Nov 2015 14:16:52 +0100

> Fix the following warning:
> 
>   CC  net/core/rtnetlink.o
> net/core/rtnetlink.c: In function ‘rtnl_fill_ifinfo’:
> net/core/rtnetlink.c:1308:1: warning: the frame size of 2864 bytes is larger 
> than 2048 bytes [-Wframe-larger-than=]
>  }
>  ^
> by splitting up the huge rtnl_fill_ifinfo into some smaller ones, so we
> don't have the huge frame allocations at the same time.
> 
> Cc: Eric Dumazet 
> Signed-off-by: Hannes Frederic Sowa 

Applied.