Skip to contentSkip to conversation

net/netfilter/ipvs/ip_vs_wrr.c: use lib/gcd.c

PATCH In review Florian Fainelli 2 participants 2 messages Jun 4, 2009 – Jun 7, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 3/8 net/netfilter/ipvs/ip_vs_wrr.c: use lib/gcd.c

This patch removes the open-coded version of the greatest common divider to use lib/gcd.c, the latter also implementing the a < b case.

---

net/netfilter/ipvs/Kconfig +1 -0
index 79a6980..5b37675 100644
@@ -113,6 +113,7 @@ config	IP_VS_RR
  
 config	IP_VS_WRR
         tristate "weighted round-robin scheduling" 
+	select GCD
 	---help---
 	  The weighted robin-robin scheduling algorithm directs network
 	  connections to different real servers based on server weights
net/netfilter/ipvs/ip_vs_wrr.c +1 -14
index f7d74ef..8701212 100644
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/net.h>
+#include <linux/gcd.h>
 
 #include <net/ip_vs.h>
 
@@ -35,20 +36,6 @@ struct ip_vs_wrr_mark {
 };
 
 
-/*
- *    Get the gcd of server weights
- */
-static int gcd(int a, int b)
-{
-	int c;
-
-	while ((c = a % b)) {
-		a = b;
-		b = c;
-	}
-	return b;
-}
-
 static int ip_vs_wrr_gcd_weight(struct ip_vs_service *svc)
 {
 	struct ip_vs_dest *dest;