1 /* 2 * include/haproxy/global-t.h 3 * Global types and macros. Please avoid adding more stuff here! 4 * 5 * Copyright (C) 2000-2020 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 _HAPROXY_GLOBAL_T_H 23 #define _HAPROXY_GLOBAL_T_H 24 25 #include <haproxy/api-t.h> 26 #include <haproxy/buf-t.h> 27 #include <haproxy/freq_ctr-t.h> 28 #include <haproxy/vars-t.h> 29 30 /* modes of operation (global.mode) */ 31 #define MODE_DEBUG 0x01 32 #define MODE_DAEMON 0x02 33 #define MODE_QUIET 0x04 34 #define MODE_CHECK 0x08 35 #define MODE_VERBOSE 0x10 36 #define MODE_STARTING 0x20 37 #define MODE_FOREGROUND 0x40 38 #define MODE_MWORKER 0x80 /* Master Worker */ 39 #define MODE_MWORKER_WAIT 0x100 /* Master Worker wait mode */ 40 #define MODE_ZERO_WARNING 0x200 /* warnings cause a failure */ 41 42 /* list of last checks to perform, depending on config options */ 43 #define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */ 44 #define LSTCHK_NETADM 0x00000002 /* check that we have CAP_NET_ADMIN */ 45 46 /* Global tuning options */ 47 /* available polling mechanisms */ 48 #define GTUNE_USE_SELECT (1<<0) 49 #define GTUNE_USE_POLL (1<<1) 50 #define GTUNE_USE_EPOLL (1<<2) 51 #define GTUNE_USE_KQUEUE (1<<3) 52 /* platform-specific options */ 53 #define GTUNE_USE_SPLICE (1<<4) 54 #define GTUNE_USE_GAI (1<<5) 55 #define GTUNE_USE_REUSEPORT (1<<6) 56 #define GTUNE_RESOLVE_DONTFAIL (1<<7) 57 58 #define GTUNE_SOCKET_TRANSFER (1<<8) 59 #define GTUNE_NOEXIT_ONFAILURE (1<<9) 60 #define GTUNE_USE_SYSTEMD (1<<10) 61 62 #define GTUNE_BUSY_POLLING (1<<11) 63 #define GTUNE_LISTENER_MQ (1<<12) 64 #define GTUNE_SET_DUMPABLE (1<<13) 65 #define GTUNE_USE_EVPORTS (1<<14) 66 #define GTUNE_STRICT_LIMITS (1<<15) 67 #define GTUNE_INSECURE_FORK (1<<16) 68 #define GTUNE_INSECURE_SETUID (1<<17) 69 #define GTUNE_FD_ET (1<<18) 70 #define GTUNE_SCHED_LOW_LATENCY (1<<19) 71 #define GTUNE_IDLE_POOL_SHARED (1<<20) 72 73 /* SSL server verify mode */ 74 enum { 75 SSL_SERVER_VERIFY_NONE = 0, 76 SSL_SERVER_VERIFY_REQUIRED = 1, 77 }; 78 79 /* bit values to go with "warned" above */ 80 #define WARN_ANY 0x00000001 /* any warning was emitted */ 81 #define WARN_FORCECLOSE_DEPRECATED 0x00000002 82 #define WARN_EXEC_PATH 0x00000004 /* executable path already reported */ 83 84 /* put there the forward declarations needed for global.h */ 85 struct proxy; 86 87 /* FIXME : this will have to be redefined correctly */ 88 struct global { 89 int uid; 90 int gid; 91 int external_check; 92 int nbproc; 93 int nbthread; 94 unsigned int hard_stop_after; /* maximum time allowed to perform a soft-stop */ 95 int maxconn, hardmaxconn; 96 int maxsslconn; 97 int ssl_session_max_cost; /* how many bytes an SSL session may cost */ 98 int ssl_handshake_max_cost; /* how many bytes an SSL handshake may use */ 99 int ssl_used_frontend; /* non-zero if SSL is used in a frontend */ 100 int ssl_used_backend; /* non-zero if SSL is used in a backend */ 101 int ssl_used_async_engines; /* number of used async engines */ 102 unsigned int ssl_server_verify; /* default verify mode on servers side */ 103 struct freq_ctr conn_per_sec; 104 struct freq_ctr sess_per_sec; 105 struct freq_ctr ssl_per_sec; 106 struct freq_ctr ssl_fe_keys_per_sec; 107 struct freq_ctr ssl_be_keys_per_sec; 108 struct freq_ctr comp_bps_in; /* bytes per second, before http compression */ 109 struct freq_ctr comp_bps_out; /* bytes per second, after http compression */ 110 struct freq_ctr out_32bps; /* #of 32-byte blocks emitted per second */ 111 unsigned long long out_bytes; /* total #of bytes emitted */ 112 int cps_lim, cps_max; 113 int sps_lim, sps_max; 114 int ssl_lim, ssl_max; 115 int ssl_fe_keys_max, ssl_be_keys_max; 116 unsigned int shctx_lookups, shctx_misses; 117 int comp_rate_lim; /* HTTP compression rate limit */ 118 int maxpipes; /* max # of pipes */ 119 int maxsock; /* max # of sockets */ 120 int rlimit_nofile; /* default ulimit-n value : 0=unset */ 121 int rlimit_memmax_all; /* default all-process memory limit in megs ; 0=unset */ 122 int rlimit_memmax; /* default per-process memory limit in megs ; 0=unset */ 123 long maxzlibmem; /* max RAM for zlib in bytes */ 124 int mode; 125 unsigned int req_count; /* request counter (HTTP or TCP session) for logs and unique_id */ 126 int last_checks; 127 int spread_checks; 128 int max_spread_checks; 129 int max_syslog_len; 130 char *chroot; 131 char *pidfile; 132 char *node, *desc; /* node name & description */ 133 int localpeer_cmdline; /* whether or not the commandline "-L" was set */ 134 struct buffer log_tag; /* name for syslog */ 135 struct list logsrvs; 136 char *log_send_hostname; /* set hostname in syslog header */ 137 char *server_state_base; /* path to a directory where server state files can be found */ 138 char *server_state_file; /* path to the file where server states are loaded from */ 139 struct { 140 int maxpollevents; /* max number of poll events at once */ 141 int maxaccept; /* max number of consecutive accept() */ 142 int options; /* various tuning options */ 143 int runqueue_depth;/* max number of tasks to run at once */ 144 int recv_enough; /* how many input bytes at once are "enough" */ 145 int bufsize; /* buffer size in bytes, defaults to BUFSIZE */ 146 int maxrewrite; /* buffer max rewrite size in bytes, defaults to MAXREWRITE */ 147 int reserved_bufs; /* how many buffers can only be allocated for response */ 148 int buf_limit; /* if not null, how many total buffers may only be allocated */ 149 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 */ 153 int pipesize; /* pipe size in bytes, system defaults if zero */ 154 int max_http_hdr; /* max number of HTTP headers, use MAX_HTTP_HDR if zero */ 155 int requri_len; /* max len of request URI, use REQURI_LEN if zero */ 156 int cookie_len; /* max length of cookie captures */ 157 int pattern_cache; /* max number of entries in the pattern cache. */ 158 int sslcachesize; /* SSL cache size in session, defaults to 20000 */ 159 int comp_maxlevel; /* max HTTP compression level */ 160 int pool_low_ratio; /* max ratio of FDs used before we stop using new idle connections */ 161 int pool_high_ratio; /* max ratio of FDs used before we start killing idle connections when creating new connections */ 162 int pool_low_count; /* max number of opened fd before we stop using new idle connections */ 163 int pool_high_count; /* max number of opened fd before we start killing idle connections when creating new connections */ 164 unsigned short idle_timer; /* how long before an empty buffer is considered idle (ms) */ 165 } tune; 166 struct { 167 char *prefix; /* path prefix of unix bind socket */ 168 struct { /* UNIX socket permissions */ 169 uid_t uid; /* -1 to leave unchanged */ 170 gid_t gid; /* -1 to leave unchanged */ 171 mode_t mode; /* 0 to leave unchanged */ 172 } ux; 173 } unix_bind; 174 struct proxy *stats_fe; /* the frontend holding the stats settings */ 175 struct vars vars; /* list of variables for the process scope. */ 176 #ifdef USE_CPU_AFFINITY 177 struct { 178 unsigned long proc[MAX_PROCS]; /* list of CPU masks for the 32/64 first processes */ 179 unsigned long proc_t1[MAX_PROCS]; /* list of CPU masks for the 1st thread of each process */ 180 unsigned long thread[MAX_THREADS]; /* list of CPU masks for the 32/64 first threads of the 1st process */ 181 } cpu_map; 182 #endif 183 }; 184 185 #endif /* _HAPROXY_GLOBAL_T_H */ 186 187 /* 188 * Local variables: 189 * c-indent-level: 8 190 * c-basic-offset: 8 191 * End: 192 */ 193