keepalived-1.2.2-libipvs-fix-backup-daemon.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 8c34d5a0d4c763db9b8f1e54be0c6c3ded6c54e0 Mon Sep 17 00:00:00 2001
  2. From: Alexander Holler <alexander.holler@1und1.de>
  3. Date: Mon, 9 Jan 2012 13:16:55 +0100
  4. Subject: [PATCH] libipvs: Fix reporting of the state of the backup-daemon.
  5. ipvsadm -l --daemon didn't report a running ipvs-backup-daemon
  6. (if no master-daemon was run).
  7. It seems there was some misunderstanding of
  8. how the daemons got reported (without using netlink). The state of
  9. the backup-daemon is always reported (by the kernel) in the second
  10. element of type ip_vs_daemon_user which is returned by the kernel
  11. through IP_VS_SO_GET_DAEMON or IPVS_CMD_GET_DAEMON.
  12. ---
  13. keepalived/libipvs-2.6/libipvs.c | 11 ++++++-----
  14. 1 files changed, 6 insertions(+), 5 deletions(-)
  15. diff --git a/keepalived/libipvs-2.6/libipvs.c b/keepalived/libipvs-2.6/libipvs.c
  16. index ea5e851..6bee837 100644
  17. --- a/keepalived/libipvs-2.6/libipvs.c
  18. +++ b/keepalived/libipvs-2.6/libipvs.c
  19. @@ -1003,12 +1003,9 @@ static int ipvs_daemon_parse_cb(struct nl_msg *msg, void *arg)
  20. struct nlattr *attrs[IPVS_CMD_ATTR_MAX + 1];
  21. struct nlattr *daemon_attrs[IPVS_DAEMON_ATTR_MAX + 1];
  22. ipvs_daemon_t *u = (ipvs_daemon_t *)arg;
  23. + __u32 state;
  24. int i = 0;
  25. - /* We may get two daemons. If we've already got one, this is the second */
  26. - if (u[0].state)
  27. - i = 1;
  28. -
  29. if (genlmsg_parse(nlh, 0, attrs, IPVS_CMD_ATTR_MAX, ipvs_cmd_policy) != 0)
  30. return -1;
  31. @@ -1021,7 +1018,11 @@ static int ipvs_daemon_parse_cb(struct nl_msg *msg, void *arg)
  32. daemon_attrs[IPVS_DAEMON_ATTR_SYNC_ID]))
  33. return -1;
  34. - u[i].state = nla_get_u32(daemon_attrs[IPVS_DAEMON_ATTR_STATE]);
  35. + state = nla_get_u32(daemon_attrs[IPVS_DAEMON_ATTR_STATE]);
  36. + /* The second element is used for the state of the backup daemon. */
  37. + if (state == IP_VS_STATE_BACKUP)
  38. + i = 1;
  39. + u[i].state = state;
  40. strncpy(u[i].mcast_ifn,
  41. nla_get_string(daemon_attrs[IPVS_DAEMON_ATTR_MCAST_IFN]),
  42. IP_VS_IFNAME_MAXLEN);
  43. --
  44. 1.7.6.5