Commit 2d30c35b authored by Julian Anastasov's avatar Julian Anastasov Committed by David S. Miller

[IPVS]: Simplify ip_vs_wrr_gcd_weight

parent 5cf49e47
...@@ -58,26 +58,18 @@ static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc) ...@@ -58,26 +58,18 @@ static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc)
{ {
struct ip_vs_dest *dest; struct ip_vs_dest *dest;
int weight; int weight;
int g = 1; int g = 0;
list_for_each_entry(dest, &svc->destinations, n_list) { list_for_each_entry(dest, &svc->destinations, n_list) {
weight = atomic_read(&dest->weight); weight = atomic_read(&dest->weight);
if (weight > 0) { if (weight > 0) {
if (g > 0)
g = gcd(weight, g);
else
g = weight; g = weight;
goto search_gcd;
}
} }
return g;
search_gcd:
list_for_each_entry(dest, &svc->destinations, n_list) {
weight = atomic_read(&dest->weight);
if (weight > 0)
g = gcd(weight, g);
} }
return g ? g : 1;
return g;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment