ipvs: unify the formula to estimate the overhead of processing connections
[firefly-linux-kernel-4.4.55.git] / net / netfilter / ipvs / ip_vs_wlc.c
index bbddfdb10db2b1afc026618456f2bc99a8698c48..bc1bfc48a17fcc2c01024dadc80592ded11b27f3 100644 (file)
 
 #include <net/ip_vs.h>
 
-
-static inline unsigned int
-ip_vs_wlc_dest_overhead(struct ip_vs_dest *dest)
-{
-       /*
-        * We think the overhead of processing active connections is 256
-        * times higher than that of inactive connections in average. (This
-        * 256 times might not be accurate, we will change it later) We
-        * use the following formula to estimate the overhead now:
-        *                dest->activeconns*256 + dest->inactconns
-        */
-       return (atomic_read(&dest->activeconns) << 8) +
-               atomic_read(&dest->inactconns);
-}
-
-
 /*
  *     Weighted Least Connection scheduling
  */
@@ -71,11 +55,11 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
                    atomic_read(&dest->weight) > 0) {
                        least = dest;
-                       loh = ip_vs_wlc_dest_overhead(least);
+                       loh = ip_vs_dest_conn_overhead(least);
                        goto nextstage;
                }
        }
-       IP_VS_ERR_RL("WLC: no destination available\n");
+       ip_vs_scheduler_err(svc, "no destination available");
        return NULL;
 
        /*
@@ -85,7 +69,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        list_for_each_entry_continue(dest, &svc->destinations, n_list) {
                if (dest->flags & IP_VS_DEST_F_OVERLOAD)
                        continue;
-               doh = ip_vs_wlc_dest_overhead(dest);
+               doh = ip_vs_dest_conn_overhead(dest);
                if (loh * atomic_read(&dest->weight) >
                    doh * atomic_read(&least->weight)) {
                        least = dest;