~ubuntu-branches/debian/sid/haproxy/sid

« back to all changes in this revision

Viewing changes to .pc/from-upstream/0003-BUG-MEDIUM-checks-fix-conflicts-between-agent-checks.patch/include/types/server.h

  • Committer: Package Import Robot
  • Author(s): Vincent Bernat
  • Date: 2014-12-07 11:11:21 UTC
  • Revision ID: package-import@ubuntu.com-20141207111121-qgifv7nl6eoi3lek
Tags: 1.5.8-2
* Cherry-pick the following patches from 1.5.9 release:
    - 8a0b93bde77e BUG/MAJOR: sessions: unlink session from list on out
                              of memory
    - bae03eaad40a BUG/MEDIUM: pattern: don't load more than once a pattern
                               list.
    - 93637b6e8503 BUG/MEDIUM: connection: sanitize PPv2 header length before
                               parsing address information
    - 8ba50128832b BUG/MAJOR: frontend: initialize capture pointers earlier
    - 1f96a87c4e14 BUG/MEDIUM: checks: fix conflicts between agent checks and
                               ssl healthchecks
    - 9bcc01ae2598 BUG/MEDIUM: ssl: force a full GC in case of memory shortage
    - 909514970089 BUG/MEDIUM: ssl: fix bad ssl context init can cause
                               segfault in case of OOM.
* Cherry-pick the following patches from future 1.5.10 release:
    - 1e89acb6be9b BUG/MEDIUM: payload: ensure that a request channel is
                               available
    - bad3c6f1b6d7 BUG/MEDIUM: patterns: previous fix was incomplete

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * include/types/server.h
 
3
 * This file defines everything related to servers.
 
4
 *
 
5
 * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
 
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
 */
 
21
 
 
22
#ifndef _TYPES_SERVER_H
 
23
#define _TYPES_SERVER_H
 
24
 
 
25
#include <netinet/in.h>
 
26
#include <arpa/inet.h>
 
27
 
 
28
#ifdef USE_OPENSSL
 
29
#include <openssl/ssl.h>
 
30
#endif
 
31
 
 
32
#include <common/config.h>
 
33
#include <common/mini-clist.h>
 
34
#include <eb32tree.h>
 
35
 
 
36
#include <types/connection.h>
 
37
#include <types/counters.h>
 
38
#include <types/freq_ctr.h>
 
39
#include <types/obj_type.h>
 
40
#include <types/proxy.h>
 
41
#include <types/queue.h>
 
42
#include <types/task.h>
 
43
#include <types/checks.h>
 
44
 
 
45
 
 
46
/* server states. Only SRV_ST_DOWN indicates a down server. */
 
47
enum srv_state {
 
48
        SRV_ST_STOPPED = 0,              /* the server is down. Please keep set to zero. */
 
49
        SRV_ST_STARTING,                 /* the server is warming up (up but throttled) */
 
50
        SRV_ST_RUNNING,                  /* the server is fully up */
 
51
        SRV_ST_STOPPING,                 /* the server is up but soft-stopping (eg: 404) */
 
52
};
 
53
 
 
54
/* Administrative status : a server runs in one of these 3 stats :
 
55
 *   - READY : normal mode
 
56
 *   - DRAIN : takes no new visitor, equivalent to weight == 0
 
57
 *   - MAINT : maintenance mode, no more traffic nor health checks.
 
58
 *
 
59
 * Each server may be in maintenance by itself or may inherit this status from
 
60
 * another server it tracks. It can also be in drain mode by itself or inherit
 
61
 * it from another server. Let's store these origins here as flags. These flags
 
62
 * are combined this way :
 
63
 *
 
64
 *      FMAINT  IMAINT  FDRAIN  IDRAIN  Resulting state
 
65
 *         0       0       0       0    READY
 
66
 *         0       0       0       1    DRAIN
 
67
 *         0       0       1       x    DRAIN
 
68
 *         0       1       x       x    MAINT
 
69
 *         1       x       x       x    MAINT
 
70
 *
 
71
 * This can be simplified this way :
 
72
 *
 
73
 *   state_str = (state & MAINT) ? "MAINT" : (state & DRAIN) : "DRAIN" : "READY"
 
74
 */
 
75
enum srv_admin {
 
76
        SRV_ADMF_FMAINT    = 0x1,        /* the server was explicitly forced into maintenance */
 
77
        SRV_ADMF_IMAINT    = 0x2,        /* the server has inherited the maintenance status from a tracked server */
 
78
        SRV_ADMF_MAINT     = 0x3,        /* mask to check if any maintenance flag is present */
 
79
        SRV_ADMF_FDRAIN    = 0x4,        /* the server was explicitly forced into drain state */
 
80
        SRV_ADMF_IDRAIN    = 0x8,        /* the server has inherited the drain status from a tracked server */
 
81
        SRV_ADMF_DRAIN     = 0xC,        /* mask to check if any drain flag is present */
 
82
};
 
83
 
 
84
/* server flags */
 
85
#define SRV_F_BACKUP       0x0001        /* this server is a backup server */
 
86
#define SRV_F_MAPPORTS     0x0002        /* this server uses mapped ports */
 
87
#define SRV_F_NON_STICK    0x0004        /* never add connections allocated to this server to a stick table */
 
88
 
 
89
/* configured server options for send-proxy (server->pp_opts) */
 
90
#define SRV_PP_V1          0x0001        /* proxy protocol version 1 */
 
91
#define SRV_PP_V2          0x0002        /* proxy protocol version 2 */
 
92
#define SRV_PP_V2_SSL      0x0004        /* proxy protocol version 2 with SSL*/
 
93
#define SRV_PP_V2_SSL_CN   0x0008        /* proxy protocol version 2 with SSL and CN*/
 
94
 
 
95
/* function which act on servers need to return various errors */
 
96
#define SRV_STATUS_OK       0   /* everything is OK. */
 
97
#define SRV_STATUS_INTERNAL 1   /* other unrecoverable errors. */
 
98
#define SRV_STATUS_NOSRV    2   /* no server is available */
 
99
#define SRV_STATUS_FULL     3   /* the/all server(s) are saturated */
 
100
#define SRV_STATUS_QUEUED   4   /* the/all server(s) are saturated but the connection was queued */
 
101
 
 
102
/* various constants */
 
103
#define SRV_UWGHT_RANGE 256
 
104
#define SRV_UWGHT_MAX   (SRV_UWGHT_RANGE)
 
105
#define SRV_EWGHT_RANGE (SRV_UWGHT_RANGE * BE_WEIGHT_SCALE)
 
106
#define SRV_EWGHT_MAX   (SRV_UWGHT_MAX   * BE_WEIGHT_SCALE)
 
107
 
 
108
#ifdef USE_OPENSSL
 
109
/* server ssl options */
 
110
#define SRV_SSL_O_NONE         0x0000
 
111
#define SRV_SSL_O_NO_VMASK     0x000F /* force version mask */
 
112
#define SRV_SSL_O_NO_SSLV3     0x0001 /* disable SSLv3 */
 
113
#define SRV_SSL_O_NO_TLSV10    0x0002 /* disable TLSv1.0 */
 
114
#define SRV_SSL_O_NO_TLSV11    0x0004 /* disable TLSv1.1 */
 
115
#define SRV_SSL_O_NO_TLSV12    0x0008 /* disable TLSv1.2 */
 
116
/* 0x000F reserved for 'no' protocol version options */
 
117
#define SRV_SSL_O_USE_VMASK    0x00F0 /* force version mask */
 
118
#define SRV_SSL_O_USE_SSLV3    0x0010 /* force SSLv3 */
 
119
#define SRV_SSL_O_USE_TLSV10   0x0020 /* force TLSv1.0 */
 
120
#define SRV_SSL_O_USE_TLSV11   0x0040 /* force TLSv1.1 */
 
121
#define SRV_SSL_O_USE_TLSV12   0x0080 /* force TLSv1.2 */
 
122
/* 0x00F0 reserved for 'force' protocol version options */
 
123
#define SRV_SSL_O_NO_TLS_TICKETS 0x0100 /* disable session resumption tickets */
 
124
#endif
 
125
 
 
126
/* A tree occurrence is a descriptor of a place in a tree, with a pointer back
 
127
 * to the server itself.
 
128
 */
 
129
struct server;
 
130
struct tree_occ {
 
131
        struct server *server;
 
132
        struct eb32_node node;
 
133
};
 
134
 
 
135
struct server {
 
136
        enum obj_type obj_type;                 /* object type == OBJ_TYPE_SERVER */
 
137
        enum srv_state state, prev_state;       /* server state among SRV_ST_* */
 
138
        enum srv_admin admin, prev_admin;       /* server maintenance status : SRV_ADMF_* */
 
139
        unsigned char flags;                    /* server flags (SRV_F_*) */
 
140
        struct server *next;
 
141
        int cklen;                              /* the len of the cookie, to speed up checks */
 
142
        int rdr_len;                            /* the length of the redirection prefix */
 
143
        char *cookie;                           /* the id set in the cookie */
 
144
        char *rdr_pfx;                          /* the redirection prefix */
 
145
        int pp_opts;                            /* proxy protocol options (SRV_PP_*) */
 
146
 
 
147
        struct proxy *proxy;                    /* the proxy this server belongs to */
 
148
        int served;                             /* # of active sessions currently being served (ie not pending) */
 
149
        int cur_sess;                           /* number of currently active sessions (including syn_sent) */
 
150
        unsigned maxconn, minconn;              /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
 
151
        int nbpend;                             /* number of pending connections */
 
152
        int maxqueue;                           /* maximum number of pending connections allowed */
 
153
        struct freq_ctr sess_per_sec;           /* sessions per second on this server */
 
154
        struct srvcounters counters;            /* statistics counters */
 
155
 
 
156
        struct list pendconns;                  /* pending connections */
 
157
        struct list actconns;                   /* active connections */
 
158
        struct task *warmup;                    /* the task dedicated to the warmup when slowstart is set */
 
159
 
 
160
        struct conn_src conn_src;               /* connection source settings */
 
161
 
 
162
        struct server *track;                   /* the server we're currently tracking, if any */
 
163
        struct server *trackers;                /* the list of servers tracking us, if any */
 
164
        struct server *tracknext;               /* next server tracking <track> in <track>'s trackers list */
 
165
        char *trackit;                          /* temporary variable to make assignment deferrable */
 
166
        int consecutive_errors;                 /* current number of consecutive errors */
 
167
        int consecutive_errors_limit;           /* number of consecutive errors that triggers an event */
 
168
        short observe, onerror;                 /* observing mode: one of HANA_OBS_*; what to do on error: on of ANA_ONERR_* */
 
169
        short onmarkeddown;                     /* what to do when marked down: one of HANA_ONMARKEDDOWN_* */
 
170
        short onmarkedup;                       /* what to do when marked up: one of HANA_ONMARKEDUP_* */
 
171
        int slowstart;                          /* slowstart time in seconds (ms in the conf) */
 
172
 
 
173
        char *id;                               /* just for identification */
 
174
        unsigned iweight,uweight, eweight;      /* initial weight, user-specified weight, and effective weight */
 
175
        unsigned wscore;                        /* weight score, used during srv map computation */
 
176
        unsigned prev_eweight;                  /* eweight before last change */
 
177
        unsigned rweight;                       /* remainer of weight in the current LB tree */
 
178
        unsigned npos, lpos;                    /* next and last positions in the LB tree */
 
179
        struct eb32_node lb_node;               /* node used for tree-based load balancing */
 
180
        struct eb_root *lb_tree;                /* we want to know in what tree the server is */
 
181
        struct server *next_full;               /* next server in the temporary full list */
 
182
        unsigned lb_nodes_tot;                  /* number of allocated lb_nodes (C-HASH) */
 
183
        unsigned lb_nodes_now;                  /* number of lb_nodes placed in the tree (C-HASH) */
 
184
        struct tree_occ *lb_nodes;              /* lb_nodes_tot * struct tree_occ */
 
185
 
 
186
        /* warning, these structs are huge, keep them at the bottom */
 
187
        struct sockaddr_storage addr;           /* the address to connect to */
 
188
        struct protocol *proto;                 /* server address protocol */
 
189
        struct xprt_ops *xprt;                  /* transport-layer operations */
 
190
        unsigned down_time;                     /* total time the server was down */
 
191
        time_t last_change;                     /* last time, when the state was changed */
 
192
 
 
193
        int puid;                               /* proxy-unique server ID, used for SNMP, and "first" LB algo */
 
194
 
 
195
        struct {                                /* configuration  used by health-check and agent-check */
 
196
                struct protocol *proto;         /* server address protocol for health checks */
 
197
                struct xprt_ops *xprt;          /* transport layer operations for health checks */
 
198
                struct sockaddr_storage addr;   /* the address to check, if different from <addr> */
 
199
        } check_common;
 
200
 
 
201
        struct check check;                     /* health-check specific configuration */
 
202
        struct check agent;                     /* agent specific configuration */
 
203
 
 
204
#ifdef USE_OPENSSL
 
205
        int use_ssl;                            /* ssl enabled */
 
206
        struct {
 
207
                SSL_CTX *ctx;
 
208
                SSL_SESSION *reused_sess;
 
209
                char *ciphers;                  /* cipher suite to use if non-null */
 
210
                int options;                    /* ssl options */
 
211
                int verify;                     /* verify method (set of SSL_VERIFY_* flags) */
 
212
                char *verify_host;              /* hostname of certificate must match this host */
 
213
                char *ca_file;                  /* CAfile to use on verify */
 
214
                char *crl_file;                 /* CRLfile to use on verify */
 
215
                char *client_crt;               /* client certificate to send */
 
216
        } ssl_ctx;
 
217
#endif
 
218
        struct {
 
219
                const char *file;               /* file where the section appears */
 
220
                int line;                       /* line where the section appears */
 
221
                struct eb32_node id;            /* place in the tree of used IDs */
 
222
        } conf;                                 /* config information */
 
223
};
 
224
 
 
225
/* Descriptor for a "server" keyword. The ->parse() function returns 0 in case of
 
226
 * success, or a combination of ERR_* flags if an error is encountered. The
 
227
 * function pointer can be NULL if not implemented. The function also has an
 
228
 * access to the current "server" config line. The ->skip value tells the parser
 
229
 * how many words have to be skipped after the keyword. If the function needs to
 
230
 * parse more keywords, it needs to update cur_arg.
 
231
 */
 
232
struct srv_kw {
 
233
        const char *kw;
 
234
        int (*parse)(char **args, int *cur_arg, struct proxy *px, struct server *srv, char **err);
 
235
        int skip; /* nb min of args to skip, for use when kw is not handled */
 
236
        int default_ok; /* non-zero if kw is supported in default-server section */
 
237
};
 
238
 
 
239
/*
 
240
 * A keyword list. It is a NULL-terminated array of keywords. It embeds a
 
241
 * struct list in order to be linked to other lists, allowing it to easily
 
242
 * be declared where it is needed, and linked without duplicating data nor
 
243
 * allocating memory. It is also possible to indicate a scope for the keywords.
 
244
 */
 
245
struct srv_kw_list {
 
246
        const char *scope;
 
247
        struct list list;
 
248
        struct srv_kw kw[VAR_ARRAY];
 
249
};
 
250
 
 
251
#endif /* _TYPES_SERVER_H */
 
252
 
 
253
/*
 
254
 * Local variables:
 
255
 *  c-indent-level: 8
 
256
 *  c-basic-offset: 8
 
257
 * End:
 
258
 */