Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 5ab04ec | 2011-03-20 10:32:26 +0100 | [diff] [blame] | 2 | * include/types/server.h |
| 3 | * This file defines everything related to servers. |
| 4 | * |
Willy Tarreau | f09c660 | 2012-02-13 17:12:08 +0100 | [diff] [blame] | 5 | * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu |
Willy Tarreau | 5ab04ec | 2011-03-20 10:32:26 +0100 | [diff] [blame] | 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 21 | |
| 22 | #ifndef _TYPES_SERVER_H |
| 23 | #define _TYPES_SERVER_H |
| 24 | |
| 25 | #include <netinet/in.h> |
| 26 | #include <arpa/inet.h> |
| 27 | |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 28 | #ifdef USE_OPENSSL |
| 29 | #include <openssl/ssl.h> |
Emmanuel Hocdet | 5db33cb | 2017-03-30 19:19:37 +0200 | [diff] [blame] | 30 | #include <types/ssl_sock.h> |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 31 | #endif |
| 32 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 33 | #include <common/config.h> |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 34 | #include <common/mini-clist.h> |
Christopher Faulet | 29f77e8 | 2017-06-08 14:04:45 +0200 | [diff] [blame] | 35 | #include <common/hathreads.h> |
| 36 | |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 37 | #include <eb32tree.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 38 | |
Willy Tarreau | da92e2f | 2012-07-06 09:40:59 +0200 | [diff] [blame] | 39 | #include <types/connection.h> |
Krzysztof Piotr Oledzki | 052d4fd | 2009-10-04 14:52:57 +0200 | [diff] [blame] | 40 | #include <types/counters.h> |
Thierry Fournier | ada3484 | 2016-02-17 21:25:09 +0100 | [diff] [blame] | 41 | #include <types/dns.h> |
Willy Tarreau | 7f062c4 | 2009-03-05 18:43:00 +0100 | [diff] [blame] | 42 | #include <types/freq_ctr.h> |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 43 | #include <types/obj_type.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 44 | #include <types/proxy.h> |
| 45 | #include <types/queue.h> |
| 46 | #include <types/task.h> |
Krzysztof Piotr Oledzki | 0960541 | 2009-09-23 22:09:24 +0200 | [diff] [blame] | 47 | #include <types/checks.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 48 | |
| 49 | |
Godbach | f2dd68d | 2014-12-10 10:21:30 +0800 | [diff] [blame] | 50 | /* server states. Only SRV_ST_STOPPED indicates a down server. */ |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 51 | enum srv_state { |
Willy Tarreau | 892337c | 2014-05-13 23:41:20 +0200 | [diff] [blame] | 52 | SRV_ST_STOPPED = 0, /* the server is down. Please keep set to zero. */ |
| 53 | SRV_ST_STARTING, /* the server is warming up (up but throttled) */ |
| 54 | SRV_ST_RUNNING, /* the server is fully up */ |
| 55 | SRV_ST_STOPPING, /* the server is up but soft-stopping (eg: 404) */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 56 | } __attribute__((packed)); |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 57 | |
Willy Tarreau | bfc7b7a | 2014-05-22 16:14:34 +0200 | [diff] [blame] | 58 | /* Administrative status : a server runs in one of these 3 stats : |
| 59 | * - READY : normal mode |
| 60 | * - DRAIN : takes no new visitor, equivalent to weight == 0 |
| 61 | * - MAINT : maintenance mode, no more traffic nor health checks. |
| 62 | * |
| 63 | * Each server may be in maintenance by itself or may inherit this status from |
| 64 | * another server it tracks. It can also be in drain mode by itself or inherit |
| 65 | * it from another server. Let's store these origins here as flags. These flags |
| 66 | * are combined this way : |
| 67 | * |
| 68 | * FMAINT IMAINT FDRAIN IDRAIN Resulting state |
| 69 | * 0 0 0 0 READY |
| 70 | * 0 0 0 1 DRAIN |
| 71 | * 0 0 1 x DRAIN |
| 72 | * 0 1 x x MAINT |
| 73 | * 1 x x x MAINT |
| 74 | * |
| 75 | * This can be simplified this way : |
| 76 | * |
| 77 | * state_str = (state & MAINT) ? "MAINT" : (state & DRAIN) : "DRAIN" : "READY" |
Willy Tarreau | 2012521 | 2014-05-13 19:44:56 +0200 | [diff] [blame] | 78 | */ |
| 79 | enum srv_admin { |
Baptiste Assmann | 9f5ada3 | 2015-08-08 15:49:13 +0200 | [diff] [blame] | 80 | SRV_ADMF_FMAINT = 0x01, /* the server was explicitly forced into maintenance */ |
| 81 | SRV_ADMF_IMAINT = 0x02, /* the server has inherited the maintenance status from a tracked server */ |
Baptiste Assmann | 89aa7f3 | 2016-11-02 21:31:27 +0100 | [diff] [blame] | 82 | SRV_ADMF_MAINT = 0x23, /* mask to check if any maintenance flag is present */ |
Baptiste Assmann | 9f5ada3 | 2015-08-08 15:49:13 +0200 | [diff] [blame] | 83 | SRV_ADMF_CMAINT = 0x04, /* the server is in maintenance because of the configuration */ |
Baptiste Assmann | 9f5ada3 | 2015-08-08 15:49:13 +0200 | [diff] [blame] | 84 | SRV_ADMF_FDRAIN = 0x08, /* the server was explicitly forced into drain state */ |
| 85 | SRV_ADMF_IDRAIN = 0x10, /* the server has inherited the drain status from a tracked server */ |
| 86 | SRV_ADMF_DRAIN = 0x18, /* mask to check if any drain flag is present */ |
Baptiste Assmann | 89aa7f3 | 2016-11-02 21:31:27 +0100 | [diff] [blame] | 87 | SRV_ADMF_RMAINT = 0x20, /* the server is down because of an IP address resolution failure */ |
Frédéric Lécaille | b418c12 | 2017-04-26 11:24:02 +0200 | [diff] [blame] | 88 | SRV_ADMF_HMAINT = 0x40, /* the server FQDN has been set from socket stats */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 89 | } __attribute__((packed)); |
Willy Tarreau | 2012521 | 2014-05-13 19:44:56 +0200 | [diff] [blame] | 90 | |
Baptiste Assmann | 2593827 | 2016-09-21 20:26:16 +0200 | [diff] [blame] | 91 | /* options for servers' "init-addr" parameter |
| 92 | * this parameter may be used to drive HAProxy's behavior when parsing a server |
| 93 | * address at start up time. |
| 94 | * These values are stored as a list into an integer ordered from first to last |
| 95 | * starting with the lowest to highest bits. SRV_IADDR_END (0) is used to |
| 96 | * indicate the end of the list. 3 bits are enough to store each value. |
| 97 | */ |
| 98 | enum srv_initaddr { |
| 99 | SRV_IADDR_END = 0, /* end of the list */ |
| 100 | SRV_IADDR_NONE = 1, /* the server won't have any address at start up */ |
| 101 | SRV_IADDR_LIBC = 2, /* address set using the libc DNS resolver */ |
| 102 | SRV_IADDR_LAST = 3, /* we set the IP address found in state-file for this server */ |
Willy Tarreau | 4310d36 | 2016-11-02 15:05:56 +0100 | [diff] [blame] | 103 | SRV_IADDR_IP = 4, /* we set an arbitrary IP address to the server */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 104 | } __attribute__((packed)); |
Baptiste Assmann | 2593827 | 2016-09-21 20:26:16 +0200 | [diff] [blame] | 105 | |
Baptiste Assmann | 41472f4 | 2015-05-08 23:34:06 +0200 | [diff] [blame] | 106 | /* server-state-file version */ |
| 107 | #define SRV_STATE_FILE_VERSION 1 |
| 108 | #define SRV_STATE_FILE_VERSION_MIN 1 |
| 109 | #define SRV_STATE_FILE_VERSION_MAX 1 |
Frédéric Lécaille | b418c12 | 2017-04-26 11:24:02 +0200 | [diff] [blame] | 110 | #define SRV_STATE_FILE_FIELD_NAMES \ |
| 111 | "be_id " \ |
| 112 | "be_name " \ |
| 113 | "srv_id " \ |
| 114 | "srv_name " \ |
| 115 | "srv_addr " \ |
| 116 | "srv_op_state " \ |
| 117 | "srv_admin_state " \ |
| 118 | "srv_uweight " \ |
| 119 | "srv_iweight " \ |
| 120 | "srv_time_since_last_change " \ |
| 121 | "srv_check_status " \ |
| 122 | "srv_check_result " \ |
| 123 | "srv_check_health " \ |
| 124 | "srv_check_state " \ |
| 125 | "srv_agent_state " \ |
| 126 | "bk_f_forced_id " \ |
| 127 | "srv_f_forced_id " \ |
Frédéric Lécaille | 3169471 | 2017-08-01 08:47:19 +0200 | [diff] [blame] | 128 | "srv_fqdn " \ |
Baptiste Assmann | 6d0f38f | 2018-07-02 17:00:54 +0200 | [diff] [blame] | 129 | "srv_port " \ |
| 130 | "srvrecord" |
Frédéric Lécaille | b418c12 | 2017-04-26 11:24:02 +0200 | [diff] [blame] | 131 | |
Baptiste Assmann | 6d0f38f | 2018-07-02 17:00:54 +0200 | [diff] [blame] | 132 | #define SRV_STATE_FILE_MAX_FIELDS 20 |
| 133 | #define SRV_STATE_FILE_NB_FIELDS_VERSION_1 19 |
Baptiste Assmann | 41472f4 | 2015-05-08 23:34:06 +0200 | [diff] [blame] | 134 | #define SRV_STATE_LINE_MAXLEN 512 |
| 135 | |
Willy Tarreau | c075256 | 2017-01-23 21:38:57 +0100 | [diff] [blame] | 136 | /* server flags -- 32 bits */ |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 137 | #define SRV_F_BACKUP 0x0001 /* this server is a backup server */ |
| 138 | #define SRV_F_MAPPORTS 0x0002 /* this server uses mapped ports */ |
| 139 | #define SRV_F_NON_STICK 0x0004 /* never add connections allocated to this server to a stick table */ |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 140 | #define SRV_F_USE_NS_FROM_PP 0x0008 /* use namespace associated with connection if present */ |
Baptiste Assmann | 7cc419a | 2015-07-07 22:02:20 +0200 | [diff] [blame] | 141 | #define SRV_F_FORCED_ID 0x0010 /* server's ID was forced in the configuration */ |
Baptiste Assmann | 6b453f1 | 2016-08-11 23:12:18 +0200 | [diff] [blame] | 142 | #define SRV_F_CHECKADDR 0x0020 /* this server has a check addr configured */ |
| 143 | #define SRV_F_CHECKPORT 0x0040 /* this server has a check port configured */ |
| 144 | #define SRV_F_AGENTADDR 0x0080 /* this server has a agent addr configured */ |
Olivier Houchard | 4e69404 | 2017-03-14 20:01:29 +0100 | [diff] [blame] | 145 | #define SRV_F_COOKIESET 0x0100 /* this server has a cookie configured, so don't generate dynamic cookies */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 146 | |
David S | afb7683 | 2014-05-08 23:42:08 -0400 | [diff] [blame] | 147 | /* configured server options for send-proxy (server->pp_opts) */ |
Emmanuel Hocdet | fa8d0f1 | 2018-02-01 15:53:52 +0100 | [diff] [blame] | 148 | #define SRV_PP_V1 0x0001 /* proxy protocol version 1 */ |
| 149 | #define SRV_PP_V2 0x0002 /* proxy protocol version 2 */ |
| 150 | #define SRV_PP_V2_SSL 0x0004 /* proxy protocol version 2 with SSL */ |
| 151 | #define SRV_PP_V2_SSL_CN 0x0008 /* proxy protocol version 2 with CN */ |
| 152 | #define SRV_PP_V2_SSL_KEY_ALG 0x0010 /* proxy protocol version 2 with cert key algorithm */ |
| 153 | #define SRV_PP_V2_SSL_SIG_ALG 0x0020 /* proxy protocol version 2 with cert signature algorithm */ |
| 154 | #define SRV_PP_V2_SSL_CIPHER 0x0040 /* proxy protocol version 2 with cipher used */ |
Emmanuel Hocdet | 253c3b7 | 2018-02-01 18:29:59 +0100 | [diff] [blame] | 155 | #define SRV_PP_V2_AUTHORITY 0x0080 /* proxy protocol version 2 with authority */ |
Emmanuel Hocdet | 4399c75 | 2018-02-05 15:26:43 +0100 | [diff] [blame] | 156 | #define SRV_PP_V2_CRC32C 0x0100 /* proxy protocol version 2 with crc32c */ |
David S | afb7683 | 2014-05-08 23:42:08 -0400 | [diff] [blame] | 157 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 158 | /* function which act on servers need to return various errors */ |
| 159 | #define SRV_STATUS_OK 0 /* everything is OK. */ |
| 160 | #define SRV_STATUS_INTERNAL 1 /* other unrecoverable errors. */ |
| 161 | #define SRV_STATUS_NOSRV 2 /* no server is available */ |
| 162 | #define SRV_STATUS_FULL 3 /* the/all server(s) are saturated */ |
| 163 | #define SRV_STATUS_QUEUED 4 /* the/all server(s) are saturated but the connection was queued */ |
| 164 | |
Willy Tarreau | b698f0f | 2007-12-02 11:01:23 +0100 | [diff] [blame] | 165 | /* various constants */ |
| 166 | #define SRV_UWGHT_RANGE 256 |
Godbach | a34bdc0 | 2013-07-22 07:44:53 +0800 | [diff] [blame] | 167 | #define SRV_UWGHT_MAX (SRV_UWGHT_RANGE) |
Willy Tarreau | b698f0f | 2007-12-02 11:01:23 +0100 | [diff] [blame] | 168 | #define SRV_EWGHT_RANGE (SRV_UWGHT_RANGE * BE_WEIGHT_SCALE) |
| 169 | #define SRV_EWGHT_MAX (SRV_UWGHT_MAX * BE_WEIGHT_SCALE) |
| 170 | |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 171 | #ifdef USE_OPENSSL |
| 172 | /* server ssl options */ |
| 173 | #define SRV_SSL_O_NONE 0x0000 |
Emeric Brun | f9c5c47 | 2012-10-11 15:28:34 +0200 | [diff] [blame] | 174 | #define SRV_SSL_O_NO_TLS_TICKETS 0x0100 /* disable session resumption tickets */ |
Willy Tarreau | 2a3fb1c | 2015-02-05 16:47:07 +0100 | [diff] [blame] | 175 | #define SRV_SSL_O_NO_REUSE 0x200 /* disable session reuse */ |
Olivier Houchard | 522eea7 | 2017-11-03 16:27:47 +0100 | [diff] [blame] | 176 | #define SRV_SSL_O_EARLY_DATA 0x400 /* Allow using early data */ |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 177 | #endif |
| 178 | |
Simon Horman | 98637e5 | 2014-06-20 12:30:16 +0900 | [diff] [blame] | 179 | struct pid_list { |
| 180 | struct list list; |
| 181 | pid_t pid; |
| 182 | struct task *t; |
| 183 | int status; |
| 184 | int exited; |
| 185 | }; |
| 186 | |
Willy Tarreau | 6b2e11b | 2009-10-01 07:52:15 +0200 | [diff] [blame] | 187 | /* A tree occurrence is a descriptor of a place in a tree, with a pointer back |
| 188 | * to the server itself. |
| 189 | */ |
| 190 | struct server; |
| 191 | struct tree_occ { |
| 192 | struct server *server; |
| 193 | struct eb32_node node; |
| 194 | }; |
| 195 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 196 | struct server { |
Willy Tarreau | 3fdb366 | 2012-11-12 00:42:33 +0100 | [diff] [blame] | 197 | enum obj_type obj_type; /* object type == OBJ_TYPE_SERVER */ |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 198 | enum srv_state next_state, cur_state; /* server state among SRV_ST_* */ |
| 199 | enum srv_admin next_admin, cur_admin; /* server maintenance status : SRV_ADMF_* */ |
Emmanuel Hocdet | 4952985 | 2018-03-19 18:14:02 +0100 | [diff] [blame] | 200 | unsigned char use_ssl; /* ssl enabled */ |
Emmanuel Hocdet | 4399c75 | 2018-02-05 15:26:43 +0100 | [diff] [blame] | 201 | unsigned int pp_opts; /* proxy protocol options (SRV_PP_*) */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 202 | struct server *next; |
Krzysztof Piotr Oledzki | 0960541 | 2009-09-23 22:09:24 +0200 | [diff] [blame] | 203 | int cklen; /* the len of the cookie, to speed up checks */ |
Willy Tarreau | 21d2af3 | 2008-02-14 20:25:24 +0100 | [diff] [blame] | 204 | int rdr_len; /* the length of the redirection prefix */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 205 | char *cookie; /* the id set in the cookie */ |
Willy Tarreau | 21d2af3 | 2008-02-14 20:25:24 +0100 | [diff] [blame] | 206 | char *rdr_pfx; /* the redirection prefix */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 207 | |
| 208 | struct proxy *proxy; /* the proxy this server belongs to */ |
Willy Tarreau | 3fbea1d | 2018-12-02 13:08:34 +0100 | [diff] [blame] | 209 | const struct mux_proto_list *mux_proto; /* the mux to use for all outgoing connections (specified by the "proto" keyword) */ |
Willy Tarreau | 7c669d7 | 2008-06-20 15:04:11 +0200 | [diff] [blame] | 210 | int served; /* # of active sessions currently being served (ie not pending) */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 211 | int cur_sess; /* number of currently active sessions (including syn_sent) */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 212 | unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 213 | int nbpend; /* number of pending connections */ |
Patrick Hemmer | da282f4 | 2018-05-11 12:52:31 -0400 | [diff] [blame] | 214 | unsigned int queue_idx; /* count of pending connections which have been de-queued */ |
Elijah Epifanov | acafc5f | 2007-10-25 20:15:38 +0200 | [diff] [blame] | 215 | int maxqueue; /* maximum number of pending connections allowed */ |
Willy Tarreau | 7b81563 | 2011-10-21 18:51:57 +0200 | [diff] [blame] | 216 | struct freq_ctr sess_per_sec; /* sessions per second on this server */ |
Willy Tarreau | ae9bea0 | 2016-11-25 14:44:52 +0100 | [diff] [blame] | 217 | struct be_counters counters; /* statistics counters */ |
Willy Tarreau | ac68c5d | 2009-10-04 23:12:44 +0200 | [diff] [blame] | 218 | |
Patrick Hemmer | 0355dab | 2018-05-11 12:52:31 -0400 | [diff] [blame] | 219 | struct eb_root pendconns; /* pending connections */ |
Simon Horman | af51495 | 2011-06-21 14:34:57 +0900 | [diff] [blame] | 220 | struct list actconns; /* active connections */ |
Christopher Faulet | 40a007c | 2017-07-03 15:41:01 +0200 | [diff] [blame] | 221 | struct list *priv_conns; /* private idle connections attached to stream interfaces */ |
| 222 | struct list *idle_conns; /* sharable idle connections attached or not to a stream interface */ |
| 223 | struct list *safe_conns; /* safe idle connections attached to stream interfaces, shared */ |
Olivier Houchard | 0c18a6f | 2018-12-02 14:11:41 +0100 | [diff] [blame] | 224 | struct list *idle_orphan_conns; /* Orphan connections idling */ |
Olivier Houchard | b7b3faa | 2018-12-14 18:15:36 +0100 | [diff] [blame] | 225 | unsigned int pool_purge_delay; /* Delay before starting to purge the idle conns pool */ |
Olivier Houchard | 006e310 | 2018-12-10 18:30:32 +0100 | [diff] [blame] | 226 | unsigned int max_idle_conns; /* Max number of connection allowed in the orphan connections list */ |
| 227 | unsigned int curr_idle_conns; /* Current number of orphan idling connections */ |
Olivier Houchard | f131481 | 2019-02-18 16:41:17 +0100 | [diff] [blame] | 228 | unsigned int *curr_idle_thr; /* Current number of orphan idling connections per thread */ |
Willy Tarreau | 9c538e0 | 2019-01-23 10:21:49 +0100 | [diff] [blame] | 229 | int max_reuse; /* Max number of requests on a same connection */ |
Olivier Houchard | 9ea5d36 | 2019-02-14 18:29:09 +0100 | [diff] [blame] | 230 | struct eb32_node idle_node; /* When to next do cleanup in the idle connections */ |
Willy Tarreau | 2e99390 | 2011-10-31 11:53:20 +0100 | [diff] [blame] | 231 | struct task *warmup; /* the task dedicated to the warmup when slowstart is set */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 232 | |
Willy Tarreau | ef9a360 | 2012-12-08 22:29:20 +0100 | [diff] [blame] | 233 | struct conn_src conn_src; /* connection source settings */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 234 | |
Willy Tarreau | 1a53a3a | 2013-12-11 15:27:05 +0100 | [diff] [blame] | 235 | struct server *track; /* the server we're currently tracking, if any */ |
| 236 | struct server *trackers; /* the list of servers tracking us, if any */ |
| 237 | struct server *tracknext; /* next server tracking <track> in <track>'s trackers list */ |
Krzysztof Piotr Oledzki | c8b16fc | 2008-02-18 01:26:35 +0100 | [diff] [blame] | 238 | char *trackit; /* temporary variable to make assignment deferrable */ |
Krzysztof Piotr Oledzki | 97f07b8 | 2009-12-15 22:31:24 +0100 | [diff] [blame] | 239 | int consecutive_errors; /* current number of consecutive errors */ |
Krzysztof Piotr Oledzki | 97f07b8 | 2009-12-15 22:31:24 +0100 | [diff] [blame] | 240 | int consecutive_errors_limit; /* number of consecutive errors that triggers an event */ |
| 241 | short observe, onerror; /* observing mode: one of HANA_OBS_*; what to do on error: on of ANA_ONERR_* */ |
Justin Karneges | eb2c24a | 2012-05-24 15:28:52 -0700 | [diff] [blame] | 242 | short onmarkeddown; /* what to do when marked down: one of HANA_ONMARKEDDOWN_* */ |
| 243 | short onmarkedup; /* what to do when marked up: one of HANA_ONMARKEDUP_* */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 244 | unsigned int flags; /* server flags (SRV_F_*) */ |
Willy Tarreau | 9909fc1 | 2007-11-30 17:42:05 +0100 | [diff] [blame] | 245 | int slowstart; /* slowstart time in seconds (ms in the conf) */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 246 | |
| 247 | char *id; /* just for identification */ |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 248 | unsigned iweight,uweight, cur_eweight; /* initial weight, user-specified weight, and effective weight */ |
Willy Tarreau | 417fae0 | 2007-03-25 21:16:40 +0200 | [diff] [blame] | 249 | unsigned wscore; /* weight score, used during srv map computation */ |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 250 | unsigned next_eweight; /* next pending eweight to commit */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 251 | unsigned rweight; /* remainer of weight in the current LB tree */ |
Andrew Rodland | 13d5ebb | 2016-10-25 12:49:45 -0400 | [diff] [blame] | 252 | unsigned cumulative_weight; /* weight of servers prior to this one in the same group, for chash balancing */ |
Willy Tarreau | b625a08 | 2007-11-26 01:15:43 +0100 | [diff] [blame] | 253 | unsigned npos, lpos; /* next and last positions in the LB tree */ |
| 254 | struct eb32_node lb_node; /* node used for tree-based load balancing */ |
| 255 | struct eb_root *lb_tree; /* we want to know in what tree the server is */ |
| 256 | struct server *next_full; /* next server in the temporary full list */ |
Willy Tarreau | 6b2e11b | 2009-10-01 07:52:15 +0200 | [diff] [blame] | 257 | unsigned lb_nodes_tot; /* number of allocated lb_nodes (C-HASH) */ |
| 258 | unsigned lb_nodes_now; /* number of lb_nodes placed in the tree (C-HASH) */ |
| 259 | struct tree_occ *lb_nodes; /* lb_nodes_tot * struct tree_occ */ |
Willy Tarreau | 91b6f32 | 2007-03-25 21:03:01 +0200 | [diff] [blame] | 260 | |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 261 | const struct netns_entry *netns; /* contains network namespace name or NULL. Network namespace comes from configuration */ |
Willy Tarreau | 7b81563 | 2011-10-21 18:51:57 +0200 | [diff] [blame] | 262 | /* warning, these structs are huge, keep them at the bottom */ |
Willy Tarreau | 04276f3 | 2017-01-06 17:41:29 +0100 | [diff] [blame] | 263 | struct sockaddr_storage addr; /* the address to connect to, doesn't include the port */ |
Willy Tarreau | f7bc57c | 2012-10-03 00:19:48 +0200 | [diff] [blame] | 264 | struct xprt_ops *xprt; /* transport-layer operations */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 265 | unsigned int svc_port; /* the port to connect to (for relevant families) */ |
Krzysztof Oledzki | 8513094 | 2007-10-22 16:21:10 +0200 | [diff] [blame] | 266 | unsigned down_time; /* total time the server was down */ |
| 267 | time_t last_change; /* last time, when the state was changed */ |
| 268 | |
Willy Tarreau | f09c660 | 2012-02-13 17:12:08 +0100 | [diff] [blame] | 269 | int puid; /* proxy-unique server ID, used for SNMP, and "first" LB algo */ |
Willy Tarreau | 163d462 | 2015-10-13 16:16:41 +0200 | [diff] [blame] | 270 | int tcp_ut; /* for TCP, user timeout */ |
Krzysztof Piotr Oledzki | 052d4fd | 2009-10-04 14:52:57 +0200 | [diff] [blame] | 271 | |
Frédéric Lécaille | 65aa356 | 2017-03-14 11:20:13 +0100 | [diff] [blame] | 272 | int do_check; /* temporary variable used during parsing to denote if health checks must be enabled */ |
Frédéric Lécaille | 6e0843c | 2017-03-21 16:39:15 +0100 | [diff] [blame] | 273 | int do_agent; /* temporary variable used during parsing to denote if an auxiliary agent check must be enabled */ |
Simon Horman | 6618300 | 2013-02-23 10:16:43 +0900 | [diff] [blame] | 274 | struct check check; /* health-check specific configuration */ |
Simon Horman | d60d691 | 2013-11-25 10:46:36 +0900 | [diff] [blame] | 275 | struct check agent; /* agent specific configuration */ |
Nick Chalk | 57b1bf7 | 2010-03-16 15:50:46 +0000 | [diff] [blame] | 276 | |
Baptiste Assmann | 201c07f | 2017-05-22 15:17:15 +0200 | [diff] [blame] | 277 | struct dns_requester *dns_requester; /* used to link a server to its DNS resolution */ |
Baptiste Assmann | a68ca96 | 2015-04-14 01:15:08 +0200 | [diff] [blame] | 278 | char *resolvers_id; /* resolvers section used by this server */ |
Baptiste Assmann | 4274637 | 2017-05-03 12:12:02 +0200 | [diff] [blame] | 279 | struct dns_resolvers *resolvers; /* pointer to the resolvers structure used by this server */ |
Baptiste Assmann | 83cbaa5 | 2016-11-02 15:34:05 +0100 | [diff] [blame] | 280 | char *lastaddr; /* the address string provided by the server-state file */ |
Thierry Fournier | ada3484 | 2016-02-17 21:25:09 +0100 | [diff] [blame] | 281 | struct dns_options dns_opts; |
Joseph Herlant | 4446682 | 2018-11-15 08:57:51 -0800 | [diff] [blame] | 282 | int hostname_dn_len; /* sting length of the server hostname in Domain Name format */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 283 | char *hostname_dn; /* server hostname in Domain Name format */ |
| 284 | char *hostname; /* server hostname */ |
Willy Tarreau | 4310d36 | 2016-11-02 15:05:56 +0100 | [diff] [blame] | 285 | struct sockaddr_storage init_addr; /* plain IP address specified on the init-addr line */ |
Baptiste Assmann | 2593827 | 2016-09-21 20:26:16 +0200 | [diff] [blame] | 286 | unsigned int init_addr_methods; /* initial address setting, 3-bit per method, ends at 0, enough to store 10 entries */ |
Baptiste Assmann | a68ca96 | 2015-04-14 01:15:08 +0200 | [diff] [blame] | 287 | |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 288 | #ifdef USE_OPENSSL |
Frédéric Lécaille | 9a146de | 2017-03-20 14:54:41 +0100 | [diff] [blame] | 289 | char *sni_expr; /* Temporary variable to store a sample expression for SNI */ |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 290 | struct { |
| 291 | SSL_CTX *ctx; |
Olivier Houchard | e6060c5 | 2017-11-16 17:42:52 +0100 | [diff] [blame] | 292 | struct { |
| 293 | unsigned char *ptr; |
| 294 | int size; |
| 295 | int allocated_size; |
| 296 | } * reused_sess; |
Willy Tarreau | d7aacbf | 2012-09-03 23:34:19 +0200 | [diff] [blame] | 297 | char *ciphers; /* cipher suite to use if non-null */ |
Dirkjan Bussink | 415150f | 2018-09-14 11:14:21 +0200 | [diff] [blame] | 298 | #if (OPENSSL_VERSION_NUMBER >= 0x10101000L && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER) |
| 299 | char *ciphersuites; /* TLS 1.3 cipher suite to use if non-null */ |
| 300 | #endif |
Emeric Brun | 8967549 | 2012-10-05 13:48:26 +0200 | [diff] [blame] | 301 | int options; /* ssl options */ |
Emeric Brun | ef42d92 | 2012-10-11 16:11:36 +0200 | [diff] [blame] | 302 | int verify; /* verify method (set of SSL_VERIFY_* flags) */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 303 | struct tls_version_filter methods; /* ssl methods */ |
Evan Broder | be55431 | 2013-06-27 00:05:25 -0700 | [diff] [blame] | 304 | char *verify_host; /* hostname of certificate must match this host */ |
Emeric Brun | ef42d92 | 2012-10-11 16:11:36 +0200 | [diff] [blame] | 305 | char *ca_file; /* CAfile to use on verify */ |
| 306 | char *crl_file; /* CRLfile to use on verify */ |
Emeric Brun | a7aa309 | 2012-10-26 12:58:00 +0200 | [diff] [blame] | 307 | char *client_crt; /* client certificate to send */ |
Willy Tarreau | 732eac4 | 2015-07-09 11:40:25 +0200 | [diff] [blame] | 308 | struct sample_expr *sni; /* sample expression for SNI */ |
Olivier Houchard | c756600 | 2018-11-20 23:33:50 +0100 | [diff] [blame] | 309 | #ifdef OPENSSL_NPN_NEGOTIATED |
| 310 | char *npn_str; /* NPN protocol string */ |
| 311 | int npn_len; /* NPN protocol string length */ |
| 312 | #endif |
| 313 | #ifdef TLSEXT_TYPE_application_layer_protocol_negotiation |
| 314 | char *alpn_str; /* ALPN protocol string */ |
| 315 | int alpn_len; /* ALPN protocol string length */ |
| 316 | #endif |
Emeric Brun | c6545ac | 2012-05-18 15:46:21 +0200 | [diff] [blame] | 317 | } ssl_ctx; |
| 318 | #endif |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 319 | struct dns_srvrq *srvrq; /* Pointer representing the DNS SRV requeest, if any */ |
Christopher Faulet | 9dcf9b6 | 2017-11-13 10:34:01 +0100 | [diff] [blame] | 320 | __decl_hathreads(HA_SPINLOCK_T lock); |
Willy Tarreau | 90a570f | 2009-10-04 20:54:54 +0200 | [diff] [blame] | 321 | struct { |
| 322 | const char *file; /* file where the section appears */ |
Willy Tarreau | 53fb4ae | 2009-10-04 23:04:08 +0200 | [diff] [blame] | 323 | struct eb32_node id; /* place in the tree of used IDs */ |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 324 | int line; /* line where the section appears */ |
Willy Tarreau | 90a570f | 2009-10-04 20:54:54 +0200 | [diff] [blame] | 325 | } conf; /* config information */ |
Frédéric Lécaille | b82f742 | 2017-04-13 18:24:23 +0200 | [diff] [blame] | 326 | /* Template information used only for server objects which |
| 327 | * serve as template filled at parsing time and used during |
| 328 | * server allocations from server templates. |
| 329 | */ |
| 330 | struct { |
| 331 | char *prefix; |
| 332 | int nb_low; |
| 333 | int nb_high; |
| 334 | } tmpl_info; |
Emeric Brun | 5a13351 | 2017-10-19 14:42:30 +0200 | [diff] [blame] | 335 | struct { |
Emeric Brun | 5a13351 | 2017-10-19 14:42:30 +0200 | [diff] [blame] | 336 | long duration; |
Willy Tarreau | d7e33bb | 2017-11-26 07:26:48 +0100 | [diff] [blame] | 337 | short status, code; |
| 338 | char reason[128]; |
Emeric Brun | 5a13351 | 2017-10-19 14:42:30 +0200 | [diff] [blame] | 339 | } op_st_chg; /* operational status change's reason */ |
Joseph Herlant | 4446682 | 2018-11-15 08:57:51 -0800 | [diff] [blame] | 340 | char adm_st_chg_cause[48]; /* administrative status change's cause */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 341 | }; |
| 342 | |
Willy Tarreau | 21faa91 | 2012-10-10 08:27:36 +0200 | [diff] [blame] | 343 | /* Descriptor for a "server" keyword. The ->parse() function returns 0 in case of |
| 344 | * success, or a combination of ERR_* flags if an error is encountered. The |
| 345 | * function pointer can be NULL if not implemented. The function also has an |
| 346 | * access to the current "server" config line. The ->skip value tells the parser |
| 347 | * how many words have to be skipped after the keyword. If the function needs to |
| 348 | * parse more keywords, it needs to update cur_arg. |
| 349 | */ |
| 350 | struct srv_kw { |
| 351 | const char *kw; |
| 352 | int (*parse)(char **args, int *cur_arg, struct proxy *px, struct server *srv, char **err); |
| 353 | int skip; /* nb min of args to skip, for use when kw is not handled */ |
| 354 | int default_ok; /* non-zero if kw is supported in default-server section */ |
| 355 | }; |
| 356 | |
| 357 | /* |
| 358 | * A keyword list. It is a NULL-terminated array of keywords. It embeds a |
| 359 | * struct list in order to be linked to other lists, allowing it to easily |
| 360 | * be declared where it is needed, and linked without duplicating data nor |
| 361 | * allocating memory. It is also possible to indicate a scope for the keywords. |
| 362 | */ |
| 363 | struct srv_kw_list { |
| 364 | const char *scope; |
| 365 | struct list list; |
| 366 | struct srv_kw kw[VAR_ARRAY]; |
| 367 | }; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 368 | |
| 369 | #endif /* _TYPES_SERVER_H */ |
| 370 | |
| 371 | /* |
| 372 | * Local variables: |
| 373 | * c-indent-level: 8 |
| 374 | * c-basic-offset: 8 |
| 375 | * End: |
| 376 | */ |