]> git.karo-electronics.de Git - linux-beck.git/commitdiff
net: fix race condition in several drivers when reading stats
authorKevin Groeneveld <kgroeneveld@gmail.com>
Sat, 21 Jul 2012 06:30:50 +0000 (06:30 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 22 Jul 2012 19:12:32 +0000 (12:12 -0700)
Fix race condition in several network drivers when reading stats on 32bit
UP architectures.  These drivers update their stats in a BH context and
therefore should use u64_stats_fetch_begin_bh/u64_stats_fetch_retry_bh
instead of u64_stats_fetch_begin/u64_stats_fetch_retry when reading the
stats.

Signed-off-by: Kevin Groeneveld <kgroeneveld@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dummy.c
drivers/net/ethernet/neterion/vxge/vxge-main.c
drivers/net/loopback.c
drivers/net/virtio_net.c
net/bridge/br_device.c

index 9d6a0677466b518e0dd52154a007121111cd2e10..c260af5411d0ff06685487b8781de707562f7e28 100644 (file)
@@ -63,10 +63,10 @@ static struct rtnl_link_stats64 *dummy_get_stats64(struct net_device *dev,
 
                dstats = per_cpu_ptr(dev->dstats, i);
                do {
-                       start = u64_stats_fetch_begin(&dstats->syncp);
+                       start = u64_stats_fetch_begin_bh(&dstats->syncp);
                        tbytes = dstats->tx_bytes;
                        tpackets = dstats->tx_packets;
-               } while (u64_stats_fetch_retry(&dstats->syncp, start));
+               } while (u64_stats_fetch_retry_bh(&dstats->syncp, start));
                stats->tx_bytes += tbytes;
                stats->tx_packets += tpackets;
        }
index 4e20c5f02712bafba1a77a8d6e0e2a6d0f1e5d6c..de219044351063b1a9e2e400d4a823357c050b32 100644 (file)
@@ -3131,12 +3131,12 @@ vxge_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
                u64 packets, bytes, multicast;
 
                do {
-                       start = u64_stats_fetch_begin(&rxstats->syncp);
+                       start = u64_stats_fetch_begin_bh(&rxstats->syncp);
 
                        packets   = rxstats->rx_frms;
                        multicast = rxstats->rx_mcast;
                        bytes     = rxstats->rx_bytes;
-               } while (u64_stats_fetch_retry(&rxstats->syncp, start));
+               } while (u64_stats_fetch_retry_bh(&rxstats->syncp, start));
 
                net_stats->rx_packets += packets;
                net_stats->rx_bytes += bytes;
@@ -3146,11 +3146,11 @@ vxge_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *net_stats)
                net_stats->rx_dropped += rxstats->rx_dropped;
 
                do {
-                       start = u64_stats_fetch_begin(&txstats->syncp);
+                       start = u64_stats_fetch_begin_bh(&txstats->syncp);
 
                        packets = txstats->tx_frms;
                        bytes   = txstats->tx_bytes;
-               } while (u64_stats_fetch_retry(&txstats->syncp, start));
+               } while (u64_stats_fetch_retry_bh(&txstats->syncp, start));
 
                net_stats->tx_packets += packets;
                net_stats->tx_bytes += bytes;
index 32eb94ece6c1b258497f9b12334c680729f48dc7..e2a06fd996d51409ed711fb360105d7f423f27a8 100644 (file)
@@ -107,10 +107,10 @@ static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev,
 
                lb_stats = per_cpu_ptr(dev->lstats, i);
                do {
-                       start = u64_stats_fetch_begin(&lb_stats->syncp);
+                       start = u64_stats_fetch_begin_bh(&lb_stats->syncp);
                        tbytes = lb_stats->bytes;
                        tpackets = lb_stats->packets;
-               } while (u64_stats_fetch_retry(&lb_stats->syncp, start));
+               } while (u64_stats_fetch_retry_bh(&lb_stats->syncp, start));
                bytes   += tbytes;
                packets += tpackets;
        }
index 1db445b2ecc77e84f8f75cee44c33f49f2fb5300..83d2b0c34c5e63045eaeb63c3e40b14ab68e7875 100644 (file)
@@ -704,16 +704,16 @@ static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev,
                u64 tpackets, tbytes, rpackets, rbytes;
 
                do {
-                       start = u64_stats_fetch_begin(&stats->tx_syncp);
+                       start = u64_stats_fetch_begin_bh(&stats->tx_syncp);
                        tpackets = stats->tx_packets;
                        tbytes   = stats->tx_bytes;
-               } while (u64_stats_fetch_retry(&stats->tx_syncp, start));
+               } while (u64_stats_fetch_retry_bh(&stats->tx_syncp, start));
 
                do {
-                       start = u64_stats_fetch_begin(&stats->rx_syncp);
+                       start = u64_stats_fetch_begin_bh(&stats->rx_syncp);
                        rpackets = stats->rx_packets;
                        rbytes   = stats->rx_bytes;
-               } while (u64_stats_fetch_retry(&stats->rx_syncp, start));
+               } while (u64_stats_fetch_retry_bh(&stats->rx_syncp, start));
 
                tot->rx_packets += rpackets;
                tot->tx_packets += tpackets;
index f4be1bbfef26cbfd0e36d83c141e0819752d70cb..3334845376005cdba3a3b6b2d0b4013da4617446 100644 (file)
@@ -127,9 +127,9 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,
                const struct br_cpu_netstats *bstats
                        = per_cpu_ptr(br->stats, cpu);
                do {
-                       start = u64_stats_fetch_begin(&bstats->syncp);
+                       start = u64_stats_fetch_begin_bh(&bstats->syncp);
                        memcpy(&tmp, bstats, sizeof(tmp));
-               } while (u64_stats_fetch_retry(&bstats->syncp, start));
+               } while (u64_stats_fetch_retry_bh(&bstats->syncp, start));
                sum.tx_bytes   += tmp.tx_bytes;
                sum.tx_packets += tmp.tx_packets;
                sum.rx_bytes   += tmp.rx_bytes;