mirror of https://gitee.com/openkylin/linux.git
vlan: unnecessary to check if vlan_pcpu_stats is NULL
if allocating memory for vlan_pcpu_stats failed, the device can not be operated Signed-off-by: Li RongQing <roy.qing.li@gmail.com> Cc: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e25578777f
commit
5a4ae5f6e7
|
@ -706,38 +706,36 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
|
||||||
|
|
||||||
static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
|
||||||
{
|
{
|
||||||
|
struct vlan_pcpu_stats *p;
|
||||||
|
u32 rx_errors = 0, tx_dropped = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (vlan_dev_priv(dev)->vlan_pcpu_stats) {
|
for_each_possible_cpu(i) {
|
||||||
struct vlan_pcpu_stats *p;
|
u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
|
||||||
u32 rx_errors = 0, tx_dropped = 0;
|
unsigned int start;
|
||||||
int i;
|
|
||||||
|
|
||||||
for_each_possible_cpu(i) {
|
p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
|
||||||
u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
|
do {
|
||||||
unsigned int start;
|
start = u64_stats_fetch_begin_irq(&p->syncp);
|
||||||
|
rxpackets = p->rx_packets;
|
||||||
|
rxbytes = p->rx_bytes;
|
||||||
|
rxmulticast = p->rx_multicast;
|
||||||
|
txpackets = p->tx_packets;
|
||||||
|
txbytes = p->tx_bytes;
|
||||||
|
} while (u64_stats_fetch_retry_irq(&p->syncp, start));
|
||||||
|
|
||||||
p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
|
stats->rx_packets += rxpackets;
|
||||||
do {
|
stats->rx_bytes += rxbytes;
|
||||||
start = u64_stats_fetch_begin_irq(&p->syncp);
|
stats->multicast += rxmulticast;
|
||||||
rxpackets = p->rx_packets;
|
stats->tx_packets += txpackets;
|
||||||
rxbytes = p->rx_bytes;
|
stats->tx_bytes += txbytes;
|
||||||
rxmulticast = p->rx_multicast;
|
/* rx_errors & tx_dropped are u32 */
|
||||||
txpackets = p->tx_packets;
|
rx_errors += p->rx_errors;
|
||||||
txbytes = p->tx_bytes;
|
tx_dropped += p->tx_dropped;
|
||||||
} while (u64_stats_fetch_retry_irq(&p->syncp, start));
|
|
||||||
|
|
||||||
stats->rx_packets += rxpackets;
|
|
||||||
stats->rx_bytes += rxbytes;
|
|
||||||
stats->multicast += rxmulticast;
|
|
||||||
stats->tx_packets += txpackets;
|
|
||||||
stats->tx_bytes += txbytes;
|
|
||||||
/* rx_errors & tx_dropped are u32 */
|
|
||||||
rx_errors += p->rx_errors;
|
|
||||||
tx_dropped += p->tx_dropped;
|
|
||||||
}
|
|
||||||
stats->rx_errors = rx_errors;
|
|
||||||
stats->tx_dropped = tx_dropped;
|
|
||||||
}
|
}
|
||||||
|
stats->rx_errors = rx_errors;
|
||||||
|
stats->tx_dropped = tx_dropped;
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue