blob: 1e8cabaa7a25f8e71e8fbed792517080b3135275 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau8096de92010-02-26 11:12:27 +01002 * include/types/global.h
3 * Global variables.
4 *
Willy Tarreaue9f49e72012-11-11 17:42:00 +01005 * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
Willy Tarreau8096de92010-02-26 11:12:27 +01006 *
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 Tarreaubaaee002006-06-26 02:48:02 +020021
22#ifndef _TYPES_GLOBAL_H
23#define _TYPES_GLOBAL_H
24
25#include <netinet/in.h>
26
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020027#include <common/config.h>
Willy Tarreau65d805f2014-07-15 18:05:58 +020028#include <common/standard.h>
Willy Tarreauba3dd2b2015-06-01 15:38:33 +020029#include <import/da.h>
Willy Tarreauc7e42382012-08-24 19:22:53 +020030#include <types/freq_ctr.h>
Willy Tarreaud1d54542012-09-12 22:58:11 +020031#include <types/listener.h>
Willy Tarreau89a63132009-08-16 17:41:45 +020032#include <types/proxy.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020033#include <types/task.h>
34
Thomas Holmeseef3f9f2015-05-12 15:47:24 +010035#ifdef USE_51DEGREES
Dragan Dosen93b38d92015-06-29 16:43:25 +020036#include <import/51d.h>
Thomas Holmeseef3f9f2015-05-12 15:47:24 +010037#endif
38
scientiamobiled0027ed2016-11-04 10:55:08 +010039#ifdef USE_WURFL
40#include <import/wurfl.h>
41#endif
42
Emeric Brunc8e8d122012-10-02 18:42:10 +020043#ifndef UNIX_MAX_PATH
44#define UNIX_MAX_PATH 108
45#endif
46
Willy Tarreaubaaee002006-06-26 02:48:02 +020047/* modes of operation (global.mode) */
Willy Tarreaufbee7132007-10-18 13:53:22 +020048#define MODE_DEBUG 0x01
49#define MODE_DAEMON 0x02
50#define MODE_QUIET 0x04
51#define MODE_CHECK 0x08
52#define MODE_VERBOSE 0x10
53#define MODE_STARTING 0x20
54#define MODE_FOREGROUND 0x40
Marc-Antoine Perennou992709b2013-02-12 10:53:52 +010055#define MODE_SYSTEMD 0x80
Willy Tarreaubaaee002006-06-26 02:48:02 +020056
Willy Tarreau77074d52006-11-12 23:57:19 +010057/* list of last checks to perform, depending on config options */
58#define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */
Willy Tarreau29fbe512015-08-20 19:35:14 +020059#define LSTCHK_NETADM 0x00000002 /* check that we have CAP_NET_ADMIN */
Willy Tarreaubaaee002006-06-26 02:48:02 +020060
Willy Tarreau43b78992009-01-25 15:42:27 +010061/* Global tuning options */
62/* available polling mechanisms */
63#define GTUNE_USE_SELECT (1<<0)
64#define GTUNE_USE_POLL (1<<1)
65#define GTUNE_USE_EPOLL (1<<2)
66#define GTUNE_USE_KQUEUE (1<<3)
Willy Tarreau3ab68cf2009-01-25 16:03:28 +010067/* platform-specific options */
Willy Tarreaue9f49e72012-11-11 17:42:00 +010068#define GTUNE_USE_SPLICE (1<<4)
Nenad Merdanovic88afe032014-04-14 15:56:58 +020069#define GTUNE_USE_GAI (1<<5)
Lukas Tribusa0bcbdc2016-09-12 21:42:20 +000070#define GTUNE_USE_REUSEPORT (1<<6)
Willy Tarreau43b78992009-01-25 15:42:27 +010071
Willy Tarreau6162db22009-10-10 17:13:00 +020072/* Access level for a stats socket */
73#define ACCESS_LVL_NONE 0
74#define ACCESS_LVL_USER 1
75#define ACCESS_LVL_OPER 2
76#define ACCESS_LVL_ADMIN 3
Willy Tarreau43b78992009-01-25 15:42:27 +010077
Emeric Brun850efd52014-01-29 12:24:34 +010078/* SSL server verify mode */
79enum {
80 SSL_SERVER_VERIFY_NONE = 0,
81 SSL_SERVER_VERIFY_REQUIRED = 1,
82};
83
Willy Tarreaubaaee002006-06-26 02:48:02 +020084/* FIXME : this will have to be redefined correctly */
85struct global {
Emeric Brunc8e8d122012-10-02 18:42:10 +020086#ifdef USE_OPENSSL
87 char *crt_base; /* base directory path for certificates */
88 char *ca_base; /* base directory path for CAs and CRLs */
89#endif
Willy Tarreau77074d52006-11-12 23:57:19 +010090 int uid;
91 int gid;
Simon Horman98637e52014-06-20 12:30:16 +090092 int external_check;
Willy Tarreau77074d52006-11-12 23:57:19 +010093 int nbproc;
Willy Tarreau91886b62011-09-07 14:38:31 +020094 int maxconn, hardmaxconn;
Willy Tarreau403edff2012-09-06 11:58:37 +020095 int maxsslconn;
Willy Tarreaud92aa5c2015-01-15 21:34:39 +010096 int ssl_session_max_cost; /* how many bytes an SSL session may cost */
97 int ssl_handshake_max_cost; /* how many bytes an SSL handshake may use */
Willy Tarreaufce03112015-01-15 21:32:40 +010098 int ssl_used_frontend; /* non-zero if SSL is used in a frontend */
99 int ssl_used_backend; /* non-zero if SSL is used in a backend */
100#ifdef USE_OPENSSL
Emeric Brun76d88952012-10-05 15:47:31 +0200101 char *listen_default_ciphers;
102 char *connect_default_ciphers;
Emeric Brun2c86cbf2014-10-30 15:56:50 +0100103 int listen_default_ssloptions;
104 int connect_default_ssloptions;
Willy Tarreau403edff2012-09-06 11:58:37 +0200105#endif
Emeric Brun850efd52014-01-29 12:24:34 +0100106 unsigned int ssl_server_verify; /* default verify mode on servers side */
Willy Tarreau81c25d02011-09-07 15:17:21 +0200107 struct freq_ctr conn_per_sec;
Willy Tarreau93e7c002013-10-07 18:51:07 +0200108 struct freq_ctr sess_per_sec;
Willy Tarreaue43d5322013-10-07 20:01:52 +0200109 struct freq_ctr ssl_per_sec;
Willy Tarreau0c9c2722014-05-28 12:28:58 +0200110 struct freq_ctr ssl_fe_keys_per_sec;
111 struct freq_ctr ssl_be_keys_per_sec;
William Lallemandd85f9172012-11-09 17:05:39 +0100112 struct freq_ctr comp_bps_in; /* bytes per second, before http compression */
113 struct freq_ctr comp_bps_out; /* bytes per second, after http compression */
Willy Tarreau81c25d02011-09-07 15:17:21 +0200114 int cps_lim, cps_max;
Willy Tarreau93e7c002013-10-07 18:51:07 +0200115 int sps_lim, sps_max;
Willy Tarreaue43d5322013-10-07 20:01:52 +0200116 int ssl_lim, ssl_max;
Willy Tarreau0c9c2722014-05-28 12:28:58 +0200117 int ssl_fe_keys_max, ssl_be_keys_max;
Willy Tarreauce3f9132014-05-28 16:47:01 +0200118 unsigned int shctx_lookups, shctx_misses;
William Lallemandd85f9172012-11-09 17:05:39 +0100119 int comp_rate_lim; /* HTTP compression rate limit */
Willy Tarreau3ec79b92009-01-18 20:39:42 +0100120 int maxpipes; /* max # of pipes */
Willy Tarreau77074d52006-11-12 23:57:19 +0100121 int maxsock; /* max # of sockets */
122 int rlimit_nofile; /* default ulimit-n value : 0=unset */
Willy Tarreau70060452015-12-14 12:46:07 +0100123 int rlimit_memmax_all; /* default all-process memory limit in megs ; 0=unset */
124 int rlimit_memmax; /* default per-process memory limit in megs ; 0=unset */
William Lallemande3a7d992012-11-20 11:25:20 +0100125 long maxzlibmem; /* max RAM for zlib in bytes */
Willy Tarreau77074d52006-11-12 23:57:19 +0100126 int mode;
Willy Tarreau1f0da242014-01-25 11:01:50 +0100127 unsigned int req_count; /* request counter (HTTP or TCP session) for logs and unique_id */
Willy Tarreau77074d52006-11-12 23:57:19 +0100128 int last_checks;
Krzysztof Oledzkib304dc72007-10-14 23:40:01 +0200129 int spread_checks;
Willy Tarreau1746eec2014-04-25 10:46:47 +0200130 int max_spread_checks;
Willy Tarreau18324f52014-06-27 18:10:07 +0200131 int max_syslog_len;
Willy Tarreau77074d52006-11-12 23:57:19 +0100132 char *chroot;
133 char *pidfile;
Krzysztof Piotr Oledzki48cb2ae2009-10-02 22:51:14 +0200134 char *node, *desc; /* node name & description */
Dragan Dosen43885c72015-10-01 13:18:13 +0200135 struct chunk log_tag; /* name for syslog */
William Lallemand0f99e342011-10-12 17:50:54 +0200136 struct list logsrvs;
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100137 char *log_send_hostname; /* set hostname in syslog header */
Baptiste Assmann6bc89362015-08-23 09:22:25 +0200138 char *server_state_base; /* path to a directory where server state files can be found */
Baptiste Assmanne0882262015-08-23 09:54:31 +0200139 char *server_state_file; /* path to the file where server states are loaded from */
Willy Tarreau1db37712007-06-03 17:16:49 +0200140 struct {
141 int maxpollevents; /* max number of poll events at once */
Willy Tarreaua0250ba2008-01-06 11:22:57 +0100142 int maxaccept; /* max number of consecutive accept() */
Willy Tarreau43b78992009-01-25 15:42:27 +0100143 int options; /* various tuning options */
Willy Tarreau6f4a82c2009-03-21 20:43:57 +0100144 int recv_enough; /* how many input bytes at once are "enough" */
Willy Tarreau27a674e2009-08-17 07:23:33 +0200145 int bufsize; /* buffer size in bytes, defaults to BUFSIZE */
146 int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */
Willy Tarreaua24adf02014-11-27 01:11:56 +0100147 int reserved_bufs; /* how many buffers can only be allocated for response */
Willy Tarreau33cb0652014-12-23 22:52:37 +0100148 int buf_limit; /* if not null, how many total buffers may only be allocated */
Willy Tarreaue803de22010-01-21 17:43:04 +0100149 int client_sndbuf; /* set client sndbuf to this value if not null */
150 int client_rcvbuf; /* set client rcvbuf to this value if not null */
151 int server_sndbuf; /* set server sndbuf to this value if not null */
152 int server_rcvbuf; /* set server rcvbuf to this value if not null */
Willy Tarreau43961d52010-10-04 20:39:20 +0200153 int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
Willy Tarreaubd9a0a72011-10-23 21:14:29 +0200154 int pipesize; /* pipe size in bytes, system defaults if zero */
Willy Tarreauac1932d2011-10-24 19:14:41 +0200155 int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */
Willy Tarreau193b8c62012-11-22 00:17:38 +0100156 int cookie_len; /* max length of cookie captures */
Willy Tarreauf3045d22015-04-29 16:24:50 +0200157 int pattern_cache; /* max number of entries in the pattern cache. */
Emeric Brunfc32aca2012-09-03 12:10:29 +0200158 int sslcachesize; /* SSL cache size in session, defaults to 20000 */
Willy Tarreaufce03112015-01-15 21:32:40 +0100159#ifdef USE_OPENSSL
Emeric Brun8dc60392014-05-09 13:52:00 +0200160 int sslprivatecache; /* Force to use a private session cache even if nbproc > 1 */
Emeric Brun4f65bff2012-11-16 15:11:00 +0100161 unsigned int ssllifetime; /* SSL session lifetime in seconds */
Willy Tarreaubfd59462013-02-21 07:46:09 +0100162 unsigned int ssl_max_record; /* SSL max record size */
Remi Gacognef46cd6e2014-06-12 14:58:40 +0200163 unsigned int ssl_default_dh_param; /* SSL maximum DH parameter size */
Christopher Faulet31af49d2015-06-09 17:29:50 +0200164 int ssl_ctx_cache; /* max number of entries in the ssl_ctx cache. */
Emeric Brunfc32aca2012-09-03 12:10:29 +0200165#endif
William Lallemanda509e4c2012-11-07 16:54:34 +0100166#ifdef USE_ZLIB
167 int zlibmemlevel; /* zlib memlevel */
168 int zlibwindowsize; /* zlib window size */
169#endif
William Lallemandf3747832012-11-09 12:33:10 +0100170 int comp_maxlevel; /* max HTTP compression level */
Willy Tarreau7e312732014-02-12 16:35:14 +0100171 unsigned short idle_timer; /* how long before an empty buffer is considered idle (ms) */
Willy Tarreau1db37712007-06-03 17:16:49 +0200172 } tune;
Emeric Bruned760922010-10-22 17:59:25 +0200173 struct {
174 char *prefix; /* path prefix of unix bind socket */
175 struct { /* UNIX socket permissions */
176 uid_t uid; /* -1 to leave unchanged */
177 gid_t gid; /* -1 to leave unchanged */
178 mode_t mode; /* 0 to leave unchanged */
Emeric Bruned760922010-10-22 17:59:25 +0200179 } ux;
180 } unix_bind;
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100181#ifdef USE_CPU_AFFINITY
Willy Tarreaua9db57e2013-01-18 11:29:29 +0100182 unsigned long cpu_map[LONGBITS]; /* list of CPU masks for the 32/64 first processes */
Willy Tarreaufc6c0322012-11-16 16:12:27 +0100183#endif
Willy Tarreau89a63132009-08-16 17:41:45 +0200184 struct proxy *stats_fe; /* the frontend holding the stats settings */
David Carlier88d13cb2015-06-01 13:53:01 +0200185#ifdef USE_DEVICEATLAS
186 struct {
187 void *atlasimgptr;
188 char *jsonpath;
David Carlier5801a822015-09-25 14:13:44 +0100189 char *cookiename;
190 size_t cookienamelen;
David Carlier88d13cb2015-06-01 13:53:01 +0200191 da_atlas_t atlas;
192 da_evidence_id_t useragentid;
193 da_severity_t loglevel;
194 char separator;
David Carlier5801a822015-09-25 14:13:44 +0100195 unsigned char daset:1;
David Carlier88d13cb2015-06-01 13:53:01 +0200196 } deviceatlas;
197#endif
Thomas Holmeseef3f9f2015-05-12 15:47:24 +0100198#ifdef USE_51DEGREES
Dragan Dosen93b38d92015-06-29 16:43:25 +0200199 struct {
200 char property_separator; /* the separator to use in the response for the values. this is taken from 51degrees-property-separator from config. */
201 struct list property_names; /* list of properties to load into the data set. this is taken from 51degrees-property-name-list from config. */
202 char *data_file_path;
James Rosewell10790962015-09-18 17:13:47 +0100203 int header_count; /* number of HTTP headers related to device detection. */
204 struct chunk *header_names; /* array of HTTP header names. */
ben51degrees1f077eb2016-07-06 12:07:21 +0100205 fiftyoneDegreesDataSet data_set; /* data set used with the pattern and trie detection methods. */
Thomas Holmes4d441a72015-05-29 12:54:25 +0100206#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
James Rosewell10790962015-09-18 17:13:47 +0100207 fiftyoneDegreesWorksetPool *pool; /* pool of worksets to avoid creating a new one for each request. */
208#endif
209#ifdef FIFTYONEDEGREES_H_TRIE_INCLUDED
210 int32_t *header_offsets; /* offsets to the HTTP header name string. */
211 fiftyoneDegreesDeviceOffsets device_offsets; /* Memory used for device offsets. */
Thomas Holmes4d441a72015-05-29 12:54:25 +0100212#endif
Dragan Dosen105c8e62015-06-29 16:43:26 +0200213 int cache_size;
Dragan Dosen93b38d92015-06-29 16:43:25 +0200214 } _51degrees;
Thomas Holmeseef3f9f2015-05-12 15:47:24 +0100215#endif
scientiamobiled0027ed2016-11-04 10:55:08 +0100216#ifdef USE_WURFL
217 struct {
218 char *data_file; /* the WURFL data file */
219 char *cache_size; /* the WURFL cache parameters */
220 int engine_mode; /* the WURFL engine mode */
221 int useragent_priority; /* the WURFL ua priority */
222 struct list patch_file_list; /* the list of WURFL patch file to use */
223 char information_list_separator; /* the separator used in request to separate values */
224 struct list information_list; /* the list of WURFL data to return into request */
225 wurfl_handle handle; /* the handle to WURFL engine */
226 struct eb_root btree; /* btree containing info (name/type) on WURFL data to return */
227 } wurfl;
228#endif
Willy Tarreaubaaee002006-06-26 02:48:02 +0200229};
230
231extern struct global global;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200232extern int pid; /* current process id */
Willy Tarreaudcd47712007-11-04 23:35:08 +0100233extern int relative_pid; /* process id starting at 1 */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200234extern int actconn; /* # of active sessions */
Willy Tarreauaf7ad002010-08-31 15:39:26 +0200235extern int listeners;
236extern int jobs; /* # of active jobs */
Willy Tarreau19d14ef2012-10-29 16:51:55 +0100237extern struct chunk trash;
Willy Tarreau8096de92010-02-26 11:12:27 +0100238extern char *swap_buffer;
Willy Tarreaubb545b42010-08-25 12:58:59 +0200239extern int nb_oldpids; /* contains the number of old pids found */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200240extern const int zero;
241extern const int one;
Alexandre Cassen87ea5482007-10-11 20:48:58 +0200242extern const struct linger nolinger;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200243extern int stopping; /* non zero means stopping in progress */
Willy Tarreau3ad6a762009-08-16 10:08:02 +0200244extern char hostname[MAX_HOSTNAME_LEN];
Emeric Brun2b920a12010-09-23 18:30:22 +0200245extern char localpeer[MAX_HOSTNAME_LEN];
Willy Tarreau08ceb102011-07-24 22:58:00 +0200246extern struct list global_listener_queue; /* list of the temporarily limited listeners */
Willy Tarreaue9b26022011-08-01 20:57:55 +0200247extern struct task *global_listener_queue_task;
Willy Tarreauff055502014-04-28 22:27:06 +0200248extern unsigned int warned; /* bitfield of a few warnings to emit just once */
Baptiste Assmann325137d2015-04-13 23:40:55 +0200249extern struct list dns_resolvers;
Willy Tarreauff055502014-04-28 22:27:06 +0200250
251/* bit values to go with "warned" above */
Willy Tarreaude9d2d72014-04-28 22:28:02 +0200252#define WARN_BLOCK_DEPRECATED 0x00000001
Willy Tarreau98d04852015-05-26 12:18:29 +0200253/* unassigned : 0x00000002 */
Willy Tarreaua3c504c2014-04-28 22:37:32 +0200254#define WARN_REDISPATCH_DEPRECATED 0x00000004
Willy Tarreaued446492014-04-28 22:56:38 +0200255#define WARN_CLITO_DEPRECATED 0x00000008
256#define WARN_SRVTO_DEPRECATED 0x00000010
257#define WARN_CONTO_DEPRECATED 0x00000020
Willy Tarreauff055502014-04-28 22:27:06 +0200258
259/* to be used with warned and WARN_* */
260static inline int already_warned(unsigned int warning)
261{
262 if (warned & warning)
263 return 1;
264 warned |= warning;
265 return 0;
266}
Willy Tarreaubaaee002006-06-26 02:48:02 +0200267
268#endif /* _TYPES_GLOBAL_H */
269
270/*
271 * Local variables:
272 * c-indent-level: 8
273 * c-basic-offset: 8
274 * End:
275 */