aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan O'Hara <rohara@redhat.com>2012-02-09 09:50:32 -0600
committerSimon Horman <horms@verge.net.au>2013-05-22 15:29:20 +0900
commit5454f52a0fee343b0d4764b0e808597d94203333 (patch)
treecea7f1ba48875f0226e17e6aeafe66414a94f453
parentf48e93c1dedee316532a1a9a758c4705c7ac43d6 (diff)
downloadipvsadm-5454f52a0fee343b0d4764b0e808597d94203333.tar.gz
ipvsadm: fix list_daemon to handle master/backup status in either position
Attached is a patch that fixes the list_daemon function such that it does not assume that the master sync daemon status is always in the first position and master sync daemon status is always in the second position. If libipvs uses the netlink interface to retrieve sync daemon status, the results are not guaranteed to follow this ordering. As explained in a previous email, if libipvs uses the netlink interface to retrieve sync daemon status while only a backup sync daemon is running, the backup sync daemon status will but in the first position (index 0). This differs from the getsockopt interface, which would always put master sync daemon status in first position and backup sync daemon status in the second position, even when only backup sync daemon exists. Solution is to make ipvsadm check both elements of the array for master and backup. Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--ipvsadm.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ipvsadm.c b/ipvsadm.c
index 9afd125..d13524f 100644
--- a/ipvsadm.c
+++ b/ipvsadm.c
@@ -1631,16 +1631,19 @@ void list_timeout(void)
static void list_daemon(void)
{
ipvs_daemon_t *u;
+ int i;
if (!(u = ipvs_get_daemon()))
exit(1);
- if (u[0].state & IP_VS_STATE_MASTER)
- printf("master sync daemon (mcast=%s, syncid=%d)\n",
- u[0].mcast_ifn, u[0].syncid);
- if (u[1].state & IP_VS_STATE_BACKUP)
- printf("backup sync daemon (mcast=%s, syncid=%d)\n",
- u[1].mcast_ifn, u[1].syncid);
+ for (i = 0; i < 2; i++) {
+ if (u[i].state & IP_VS_STATE_MASTER)
+ printf("master sync daemon (mcast=%s, syncid=%d)\n",
+ u[i].mcast_ifn, u[i].syncid);
+ if (u[i].state & IP_VS_STATE_MASTER)
+ printf("master sync daemon (mcast=%s, syncid=%d)\n",
+ u[i].mcast_ifn, u[i].syncid);
+ }
free(u);
}