Fill lookup table with dests based on their weight.
- They are assigned by considering weight as the relative
frequency of the backends’ turn.
Signed-off-by: Inju Song <inju.song@xxxxxxxxxxxxx>
---
net/netfilter/ipvs/ip_vs_mh.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_mh.c b/net/netfilter/ipvs/ip_vs_mh.c
index bb20b96..d1bf50a 100644
--- a/net/netfilter/ipvs/ip_vs_mh.c
+++ b/net/netfilter/ipvs/ip_vs_mh.c
@@ -109,7 +109,7 @@ static inline int ip_vs_mh_permutate(struct ip_vs_mh_state
*s,
static inline int
ip_vs_mh_populate(struct ip_vs_mh_state *s, struct ip_vs_service *svc)
{
- int i, ret;
+ int i, ret, dw_count;
unsigned int *next;
unsigned int **pmt;
struct ip_vs_mh_lookup *entry, *l;
@@ -134,18 +134,20 @@ static inline int ip_vs_mh_permutate(struct
ip_vs_mh_state *s,
for (i = 0; i < IP_VS_MH_LOOKUP_SIZE; i++)
RCU_INIT_POINTER(entry[i].dest, NULL);
- n = 0;
p = &svc->destinations;
empty = list_empty(p);
if (empty)
goto out;
+ n = 0;
+ dw_count = 0;
pmt = s->permutation;
while (n < IP_VS_MH_LOOKUP_SIZE) {
- for (i = 0; i < svc->num_dests; i++) {
- if (p == &svc->destinations)
- p = p->next;
+ if (p == &svc->destinations)
+ p = p->next;
+ i = 0;
+ while (p != &svc->destinations) {
c = pmt[i][next[i]];
while (entry[c].dest) {
@@ -161,7 +163,11 @@ static inline int ip_vs_mh_permutate(struct ip_vs_mh_state
*s,
if (n == IP_VS_MH_LOOKUP_SIZE)
break;
- p = p->next;
+ if (++dw_count >= atomic_read(&dest->weight)) {
+ p = p->next;
+ dw_count = 0;
+ i++;
+ }
}
}
--
1.8.3.1
--
Inju Song
NAVER Corporation
--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
|