提交 96e74088 编写于 作者: P Pavel Emelyanov 提交者: David S. Miller

net: The dev->get_stats pointer is not NULL nowadays.

And so does the pointer is returns, but sysfs and netlinks still 
check for both cases.
Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 34ac2573
...@@ -242,11 +242,11 @@ static ssize_t netstat_show(const struct device *d, ...@@ -242,11 +242,11 @@ static ssize_t netstat_show(const struct device *d,
offset % sizeof(unsigned long) != 0); offset % sizeof(unsigned long) != 0);
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
if (dev_isalive(dev) && dev->get_stats && if (dev_isalive(dev)) {
(stats = (*dev->get_stats)(dev))) stats = dev->get_stats(dev);
ret = sprintf(buf, fmt_ulong, ret = sprintf(buf, fmt_ulong,
*(unsigned long *)(((u8 *) stats) + offset)); *(unsigned long *)(((u8 *) stats) + offset));
}
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
return ret; return ret;
} }
...@@ -457,8 +457,7 @@ int netdev_register_kobject(struct net_device *net) ...@@ -457,8 +457,7 @@ int netdev_register_kobject(struct net_device *net)
strlcpy(dev->bus_id, net->name, BUS_ID_SIZE); strlcpy(dev->bus_id, net->name, BUS_ID_SIZE);
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
if (net->get_stats) *groups++ = &netstat_group;
*groups++ = &netstat_group;
#ifdef CONFIG_WIRELESS_EXT #ifdef CONFIG_WIRELESS_EXT
if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats) if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
......
...@@ -606,6 +606,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, ...@@ -606,6 +606,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
{ {
struct ifinfomsg *ifm; struct ifinfomsg *ifm;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
struct net_device_stats *stats;
struct nlattr *attr;
nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags); nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
if (nlh == NULL) if (nlh == NULL)
...@@ -652,19 +654,13 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, ...@@ -652,19 +654,13 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
NLA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast); NLA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast);
} }
if (dev->get_stats) { attr = nla_reserve(skb, IFLA_STATS,
struct net_device_stats *stats = dev->get_stats(dev); sizeof(struct rtnl_link_stats));
if (stats) { if (attr == NULL)
struct nlattr *attr; goto nla_put_failure;
attr = nla_reserve(skb, IFLA_STATS, stats = dev->get_stats(dev);
sizeof(struct rtnl_link_stats)); copy_rtnl_link_stats(nla_data(attr), stats);
if (attr == NULL)
goto nla_put_failure;
copy_rtnl_link_stats(nla_data(attr), stats);
}
}
if (dev->rtnl_link_ops) { if (dev->rtnl_link_ops) {
if (rtnl_link_fill(skb, dev) < 0) if (rtnl_link_fill(skb, dev) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册