Skip to content

Commit a2c09ac

Browse files
inju-songhorms
authored andcommitted
netfilter: ipvs: Keep latest weight of destination
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 <[email protected]> Signed-off-by: Julian Anastasov <[email protected]> Signed-off-by: Simon Horman <[email protected]>
1 parent 535101e commit a2c09ac

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/net/ip_vs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ struct ip_vs_dest {
668668
volatile unsigned int flags; /* dest status flags */
669669
atomic_t conn_flags; /* flags to copy to conn */
670670
atomic_t weight; /* server weight */
671+
atomic_t last_weight; /* server latest weight */
671672

672673
refcount_t refcnt; /* reference counter */
673674
struct ip_vs_stats stats; /* statistics */

net/netfilter/ipvs/ip_vs_ctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,10 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
821821
if (add && udest->af != svc->af)
822822
ipvs->mixed_address_family_dests++;
823823

824+
/* keep the last_weight with latest non-0 weight */
825+
if (add || udest->weight != 0)
826+
atomic_set(&dest->last_weight, udest->weight);
827+
824828
/* set the weight and the flags */
825829
atomic_set(&dest->weight, udest->weight);
826830
conn_flags = udest->conn_flags & IP_VS_CONN_F_DEST_MASK;

0 commit comments

Comments
 (0)