netfilter: ipvs: Keep latest weight of destination
authorInju Song <inju.song@navercorp.com>
Tue, 27 Mar 2018 14:14:40 +0000 (23:14 +0900)
committerSimon Horman <horms@verge.net.au>
Mon, 9 Apr 2018 07:10:55 +0000 (10:10 +0300)
The hashing table in scheduler such as source hash or maglev hash
should ignore the changed weight to 0 and allow changing the weight
from/to non-0 values. So, struct ip_vs_dest needs to keep weight
with latest non-0 weight.

Signed-off-by: Inju Song <inju.song@navercorp.com>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
include/net/ip_vs.h
net/netfilter/ipvs/ip_vs_ctl.c

index eb0bec0..0ac795b 100644 (file)
@@ -668,6 +668,7 @@ struct ip_vs_dest {
        volatile unsigned int   flags;          /* dest status flags */
        atomic_t                conn_flags;     /* flags to copy to conn */
        atomic_t                weight;         /* server weight */
+       atomic_t                last_weight;    /* server latest weight */
 
        refcount_t              refcnt;         /* reference counter */
        struct ip_vs_stats      stats;          /* statistics */
index 5ebde4b..b91bb70 100644 (file)
@@ -821,6 +821,10 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
        if (add && udest->af != svc->af)
                ipvs->mixed_address_family_dests++;
 
+       /* keep the last_weight with latest non-0 weight */
+       if (add || udest->weight != 0)
+               atomic_set(&dest->last_weight, udest->weight);
+
        /* set the weight and the flags */
        atomic_set(&dest->weight, udest->weight);
        conn_flags = udest->conn_flags & IP_VS_CONN_F_DEST_MASK;