aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bridge/br_device.c24
-rw-r--r--net/bridge/br_input.c2
-rw-r--r--net/bridge/br_private.h10
3 files changed, 23 insertions, 13 deletions
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 6f3a9279be30..edf639e96281 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -38,8 +38,10 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
38 } 38 }
39#endif 39#endif
40 40
41 u64_stats_update_begin(&brstats->syncp);
41 brstats->tx_packets++; 42 brstats->tx_packets++;
42 brstats->tx_bytes += skb->len; 43 brstats->tx_bytes += skb->len;
44 u64_stats_update_end(&brstats->syncp);
43 45
44 BR_INPUT_SKB_CB(skb)->brdev = dev; 46 BR_INPUT_SKB_CB(skb)->brdev = dev;
45 47
@@ -96,21 +98,25 @@ static int br_dev_stop(struct net_device *dev)
96 return 0; 98 return 0;
97} 99}
98 100
99static struct net_device_stats *br_get_stats(struct net_device *dev) 101static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev)
100{ 102{
101 struct net_bridge *br = netdev_priv(dev); 103 struct net_bridge *br = netdev_priv(dev);
102 struct net_device_stats *stats = &dev->stats; 104 struct rtnl_link_stats64 *stats = &dev->stats64;
103 struct br_cpu_netstats sum = { 0 }; 105 struct br_cpu_netstats tmp, sum = { 0 };
104 unsigned int cpu; 106 unsigned int cpu;
105 107
106 for_each_possible_cpu(cpu) { 108 for_each_possible_cpu(cpu) {
109 unsigned int start;
107 const struct br_cpu_netstats *bstats 110 const struct br_cpu_netstats *bstats
108 = per_cpu_ptr(br->stats, cpu); 111 = per_cpu_ptr(br->stats, cpu);
109 112 do {
110 sum.tx_bytes += bstats->tx_bytes; 113 start = u64_stats_fetch_begin(&bstats->syncp);
111 sum.tx_packets += bstats->tx_packets; 114 memcpy(&tmp, bstats, sizeof(tmp));
112 sum.rx_bytes += bstats->rx_bytes; 115 } while (u64_stats_fetch_retry(&bstats->syncp, start));
113 sum.rx_packets += bstats->rx_packets; 116 sum.tx_bytes += tmp.tx_bytes;
117 sum.tx_packets += tmp.tx_packets;
118 sum.rx_bytes += tmp.rx_bytes;
119 sum.rx_packets += tmp.rx_packets;
114 } 120 }
115 121
116 stats->tx_bytes = sum.tx_bytes; 122 stats->tx_bytes = sum.tx_bytes;
@@ -300,7 +306,7 @@ static const struct net_device_ops br_netdev_ops = {
300 .ndo_open = br_dev_open, 306 .ndo_open = br_dev_open,
301 .ndo_stop = br_dev_stop, 307 .ndo_stop = br_dev_stop,
302 .ndo_start_xmit = br_dev_xmit, 308 .ndo_start_xmit = br_dev_xmit,
303 .ndo_get_stats = br_get_stats, 309 .ndo_get_stats64 = br_get_stats64,
304 .ndo_set_mac_address = br_set_mac_address, 310 .ndo_set_mac_address = br_set_mac_address,
305 .ndo_set_multicast_list = br_dev_set_multicast_list, 311 .ndo_set_multicast_list = br_dev_set_multicast_list,
306 .ndo_change_mtu = br_change_mtu, 312 .ndo_change_mtu = br_change_mtu,
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index f076c9d79d5e..5fc1c5b1c360 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -27,8 +27,10 @@ static int br_pass_frame_up(struct sk_buff *skb)
27 struct net_bridge *br = netdev_priv(brdev); 27 struct net_bridge *br = netdev_priv(brdev);
28 struct br_cpu_netstats *brstats = this_cpu_ptr(br->stats); 28 struct br_cpu_netstats *brstats = this_cpu_ptr(br->stats);
29 29
30 u64_stats_update_begin(&brstats->syncp);
30 brstats->rx_packets++; 31 brstats->rx_packets++;
31 brstats->rx_bytes += skb->len; 32 brstats->rx_bytes += skb->len;
33 u64_stats_update_end(&brstats->syncp);
32 34
33 indev = skb->dev; 35 indev = skb->dev;
34 skb->dev = brdev; 36 skb->dev = brdev;
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 07cf57b373fe..3f0678fd1fd0 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -16,6 +16,7 @@
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/if_bridge.h> 17#include <linux/if_bridge.h>
18#include <linux/netpoll.h> 18#include <linux/netpoll.h>
19#include <linux/u64_stats_sync.h>
19#include <net/route.h> 20#include <net/route.h>
20 21
21#define BR_HASH_BITS 8 22#define BR_HASH_BITS 8
@@ -156,10 +157,11 @@ struct net_bridge_port
156#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) 157#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
157 158
158struct br_cpu_netstats { 159struct br_cpu_netstats {
159 unsigned long rx_packets; 160 u64 rx_packets;
160 unsigned long rx_bytes; 161 u64 rx_bytes;
161 unsigned long tx_packets; 162 u64 tx_packets;
162 unsigned long tx_bytes; 163 u64 tx_bytes;
164 struct u64_stats_sync syncp;
163}; 165};
164 166
165struct net_bridge 167struct net_bridge