summaryrefslogtreecommitdiffstats
path: root/net/netfilter/ipvs/ip_vs_wrr.c
diff options
context:
space:
mode:
authorSimon Horman2009-08-31 14:18:48 +0200
committerPatrick McHardy2009-08-31 14:18:48 +0200
commit1e66dafc75f40a08b2addb82779987b269b4ca23 (patch)
tree8e8804cb6ffdd05e5ac7758d0559d4698026dd65 /net/netfilter/ipvs/ip_vs_wrr.c
parentnetfilter: nfnetlink: constify message attributes and headers (diff)
downloadkernel-qcow2-linux-1e66dafc75f40a08b2addb82779987b269b4ca23.tar.gz
kernel-qcow2-linux-1e66dafc75f40a08b2addb82779987b269b4ca23.tar.xz
kernel-qcow2-linux-1e66dafc75f40a08b2addb82779987b269b4ca23.zip
ipvs: Use atomic operations atomicly
A pointed out by Shin Hong, IPVS doesn't always use atomic operations in an atomic manner. While this seems unlikely to be manifest in strange behaviour, it seems appropriate to clean this up. Cc: shin hong <hongshin@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/netfilter/ipvs/ip_vs_wrr.c')
-rw-r--r--net/netfilter/ipvs/ip_vs_wrr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/netfilter/ipvs/ip_vs_wrr.c b/net/netfilter/ipvs/ip_vs_wrr.c
index 70ff82cda57d..6182e8ea0be7 100644
--- a/net/netfilter/ipvs/ip_vs_wrr.c
+++ b/net/netfilter/ipvs/ip_vs_wrr.c
@@ -77,11 +77,12 @@ static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc)
static int ip_vs_wrr_max_weight(struct ip_vs_service *svc)
{
struct ip_vs_dest *dest;
- int weight = 0;
+ int new_weight, weight = 0;
list_for_each_entry(dest, &svc->destinations, n_list) {
- if (atomic_read(&dest->weight) > weight)
- weight = atomic_read(&dest->weight);
+ new_weight = atomic_read(&dest->weight);
+ if (new_weight > weight)
+ weight = new_weight;
}
return weight;