Skip to content

Commit

Permalink
ipvs: fix issue in reload process when using virtual server groups
Browse files Browse the repository at this point in the history
issue: when using virtual server groups, remove vs entry in configure
file and then do reload, vs entry can not be removed. And add vs entry
in configure file and the do reload, rs with 0 port will be set.

fix: in reload process do the same action with ipvs_group_cmd. set rs
port with vs port and update live state

Original patch Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn>
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
  • Loading branch information
pqarmitage committed Sep 19, 2023
1 parent a7c4085 commit d07d122
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions keepalived/check/ipvswrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,20 @@ ipvs_group_sync_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge)
ipvs_set_drule(IP_VS_SO_SET_ADDDEST, &drule, rs);
drule.user.weight = rs->inhibit && !rs->alive ? 0 : real_weight(rs->effective_weight);

if (rs->forwarding_method != IP_VS_CONN_F_MASQ)
drule.user.port = inet_sockaddrport(&vsge->addr);
else
drule.user.port = inet_sockaddrport(&rs->addr);

/* Set vs rule */
if (srule.user.fwmark) {
/* Talk to the IPVS channel */
ipvs_talk(IP_VS_SO_SET_ADDDEST, &srule, &drule, NULL, false);
}
else
ipvs_group_range_cmd(IP_VS_SO_SET_ADDDEST, &srule, &drule, vsge);

ipvs_set_vsge_alive_state(IP_VS_SO_SET_ADDDEST, vsge, vs);
}
}
}
Expand Down Expand Up @@ -718,13 +725,18 @@ ipvs_group_remove_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge
else
srule.user.port = inet_sockaddrport(&vsge->addr);

if (global_data->lvs_flush_on_stop == LVS_NO_FLUSH) {
/* Process realserver queue */
list_for_each_entry(rs, &vs->rs, e_list) {
if (rs->alive) {
/* Process realserver queue */
list_for_each_entry(rs, &vs->rs, e_list) {
if (rs->alive) {
if (global_data->lvs_flush_on_stop == LVS_NO_FLUSH) {
/* Setting IPVS drule */
ipvs_set_drule(IP_VS_SO_SET_DELDEST, &drule, rs);

if (rs->forwarding_method != IP_VS_CONN_F_MASQ)
drule.user.port = inet_sockaddrport(&vsge->addr);
else
drule.user.port = inet_sockaddrport(&rs->addr);

/* Delete rs rule */
if (srule.user.fwmark) {
/* Talk to the IPVS channel */
Expand All @@ -733,6 +745,8 @@ ipvs_group_remove_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge
else
ipvs_group_range_cmd(IP_VS_SO_SET_DELDEST, &srule, &drule, vsge);
}

ipvs_set_vsge_alive_state(IP_VS_SO_SET_DELDEST, vsge, vs);
}
}

Expand Down

0 comments on commit d07d122

Please sign in to comment.