LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCH] ipvsadm: fix list_daemon to handle master/backup status in e

To: Ryan O'Hara <rohara@xxxxxxxxxx>
Subject: Re: [PATCH] ipvsadm: fix list_daemon to handle master/backup status in either position
Cc: lvs-devel@xxxxxxxxxxxxxxx
From: Alexander Holler <holler@xxxxxxxxxxxxx>
Date: Thu, 09 Feb 2012 18:42:07 +0100
Am 09.02.2012 16:50, schrieb Ryan O'Hara:
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.

Ryan

I've fixed that through letting the netlink-api reporting the same as without netlink.

Don't know what solutions should be prefered.

Regards,

Alexander

---
 keepalived/libipvs-2.6/libipvs.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/keepalived/libipvs-2.6/libipvs.c b/keepalived/libipvs-2.6/libipvs.c
index ea5e851..6bee837 100644
--- a/keepalived/libipvs-2.6/libipvs.c
+++ b/keepalived/libipvs-2.6/libipvs.c
@@ -1003,12 +1003,9 @@ static int ipvs_daemon_parse_cb(struct nl_msg *msg, void *arg)
        struct nlattr *attrs[IPVS_CMD_ATTR_MAX + 1];
        struct nlattr *daemon_attrs[IPVS_DAEMON_ATTR_MAX + 1];
        ipvs_daemon_t *u = (ipvs_daemon_t *)arg;
+       __u32 state;
        int i = 0;

- /* We may get two daemons. If we've already got one, this is the second */
-       if (u[0].state)
-               i = 1;
-
if (genlmsg_parse(nlh, 0, attrs, IPVS_CMD_ATTR_MAX, ipvs_cmd_policy) != 0)
                return -1;
        
@@ -1021,7 +1018,11 @@ static int ipvs_daemon_parse_cb(struct nl_msg *msg, void *arg)
              daemon_attrs[IPVS_DAEMON_ATTR_SYNC_ID]))
                return -1;

-       u[i].state = nla_get_u32(daemon_attrs[IPVS_DAEMON_ATTR_STATE]);
+       state = nla_get_u32(daemon_attrs[IPVS_DAEMON_ATTR_STATE]);
+       /* The second element is used for the state of the backup daemon. */
+       if (state == IP_VS_STATE_BACKUP)
+               i = 1;
+       u[i].state = state;
        strncpy(u[i].mcast_ifn,
                nla_get_string(daemon_attrs[IPVS_DAEMON_ATTR_MCAST_IFN]),
                IP_VS_IFNAME_MAXLEN);
--
1.7.6.5

--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

<Prev in Thread] Current Thread [Next in Thread>