You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
4.0 KiB

  1. From 1f96a87c4e1412ccdc6cfe81bfd6f20a1782886a Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Cyril=20Bont=C3=A9?= <cyril.bonte@free.fr>
  3. Date: Sat, 15 Nov 2014 22:41:27 +0100
  4. Subject: [PATCH 4/6] BUG/MEDIUM: checks: fix conflicts between agent checks
  5. and ssl healthchecks
  6. Lasse Birnbaum Jensen reported an issue when agent checks are used at the same
  7. time as standard healthchecks when SSL is enabled on the server side.
  8. The symptom is that agent checks try to communicate in SSL while it should
  9. manage raw data. This happens because the transport layer is shared between all
  10. kind of checks.
  11. To fix the issue, the transport layer is now stored in each check type,
  12. allowing to use SSL healthchecks when required, while an agent check should
  13. always use the raw_sock implementation.
  14. The fix must be backported to 1.5.
  15. (cherry picked from commit 9ce1311ebc834e20addc7a8392c0fc4e4ad687b7)
  16. ---
  17. include/types/checks.h | 3 ++-
  18. include/types/server.h | 1 -
  19. src/checks.c | 2 +-
  20. src/server.c | 2 +-
  21. src/ssl_sock.c | 2 +-
  22. 5 files changed, 5 insertions(+), 5 deletions(-)
  23. diff --git a/include/types/checks.h b/include/types/checks.h
  24. index a50043b..42b7b07 100644
  25. --- a/include/types/checks.h
  26. +++ b/include/types/checks.h
  27. @@ -125,6 +125,7 @@ enum {
  28. };
  29. struct check {
  30. + struct xprt_ops *xprt; /* transport layer operations for health checks */
  31. struct connection *conn; /* connection state for health checks */
  32. unsigned short port; /* the port to use for the health checks */
  33. struct buffer *bi, *bo; /* input and output buffers to send/recv check */
  34. @@ -132,7 +133,7 @@ struct check {
  35. struct timeval start; /* last health check start time */
  36. long duration; /* time in ms took to finish last health check */
  37. short status, code; /* check result, check code */
  38. - char desc[HCHK_DESC_LEN]; /* health check descritpion */
  39. + char desc[HCHK_DESC_LEN]; /* health check description */
  40. int use_ssl; /* use SSL for health checks */
  41. int send_proxy; /* send a PROXY protocol header with checks */
  42. struct tcpcheck_rule *current_step; /* current step when using tcpcheck */
  43. diff --git a/include/types/server.h b/include/types/server.h
  44. index 313f58d..c419b40 100644
  45. --- a/include/types/server.h
  46. +++ b/include/types/server.h
  47. @@ -194,7 +194,6 @@ struct server {
  48. struct { /* configuration used by health-check and agent-check */
  49. struct protocol *proto; /* server address protocol for health checks */
  50. - struct xprt_ops *xprt; /* transport layer operations for health checks */
  51. struct sockaddr_storage addr; /* the address to check, if different from <addr> */
  52. } check_common;
  53. diff --git a/src/checks.c b/src/checks.c
  54. index 5318f35..84bf0e5 100644
  55. --- a/src/checks.c
  56. +++ b/src/checks.c
  57. @@ -1413,7 +1413,7 @@ static int connect_chk(struct task *t)
  58. /* prepare a new connection */
  59. conn_init(conn);
  60. - conn_prepare(conn, s->check_common.proto, s->check_common.xprt);
  61. + conn_prepare(conn, s->check_common.proto, check->xprt);
  62. conn_attach(conn, check, &check_conn_cb);
  63. conn->target = &s->obj_type;
  64. diff --git a/src/server.c b/src/server.c
  65. index fdb63cc..94a31b6 100644
  66. --- a/src/server.c
  67. +++ b/src/server.c
  68. @@ -929,7 +929,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
  69. newsrv->addr = *sk;
  70. newsrv->proto = newsrv->check_common.proto = protocol_by_family(newsrv->addr.ss_family);
  71. - newsrv->xprt = newsrv->check_common.xprt = &raw_sock;
  72. + newsrv->xprt = newsrv->check.xprt = newsrv->agent.xprt = &raw_sock;
  73. if (!newsrv->proto) {
  74. Alert("parsing [%s:%d] : Unknown protocol family %d '%s'\n",
  75. diff --git a/src/ssl_sock.c b/src/ssl_sock.c
  76. index f50efe5..b73d6f9 100644
  77. --- a/src/ssl_sock.c
  78. +++ b/src/ssl_sock.c
  79. @@ -1812,7 +1812,7 @@ int ssl_sock_prepare_srv_ctx(struct server *srv, struct proxy *curproxy)
  80. if (srv->use_ssl)
  81. srv->xprt = &ssl_sock;
  82. if (srv->check.use_ssl)
  83. - srv->check_common.xprt = &ssl_sock;
  84. + srv->check.xprt = &ssl_sock;
  85. srv->ssl_ctx.ctx = SSL_CTX_new(SSLv23_client_method());
  86. if (!srv->ssl_ctx.ctx) {
  87. --
  88. 2.0.4