commit e2b4d108d68ada3af8ad437e2e291fcac1fd0ff7 Author: Quentin Armitage Date: Tue Oct 20 11:24:48 2020 +0100 ipvs: Allow real servers to be specified with a weight of 0 This currently only really makes sense when also having a FILE_CHECK with non-zero weight configured, or a MISC_CHECK with "misc_dynamic", since otherwise there is no way that the weight of the real server can be changed to be non-zero. Signed-off-by: Quentin Armitage diff --git a/keepalived/check/ipwrapper.c b/keepalived/check/ipwrapper.c index a4c40d6c..4b9ccb6f 100644 --- a/keepalived/check/ipwrapper.c +++ b/keepalived/check/ipwrapper.c @@ -410,8 +410,8 @@ init_service_rs(virtual_server_t *vs) rs->num_failed_checkers++; } - if (rs->effective_weight < 1) - rs->weight = 1; + if (rs->effective_weight < 0) + rs->weight = 0; else if (rs->effective_weight > IPVS_WEIGHT_MAX - 1) rs->weight = IPVS_WEIGHT_MAX - 1; else @@ -667,9 +667,8 @@ update_svr_wgt(int weight, virtual_server_t * vs, real_server_t * rs { rs->effective_weight = weight; -/* TODO - handle weight = 0 - ? affects quorum */ - if (weight <= 0) - weight = 1; + if (weight < 0) + weight = 0; #if IPVS_WEIGHT_MAX != INT_MAX else if (weight > IPVS_WEIGHT_MAX) weight = IPVS_WEIGHT_MAX;