summaryrefslogtreecommitdiff
path: root/include/haproxy/proxy.h
Commit message (Collapse)AuthorAgeFilesLines
* MINOR: proxy: factorize send rate measurementAmaury Denoyelle2023-04-281-0/+17
| | | | | Implement a new dedicated function increment_send_rate() which can be call anywhere new bytes must be accounted for global total sent.
* MINOR: proxy: make proxy_type_str() recognize peers sectionsWilly Tarreau2023-04-231-0/+2
| | | | | Now proxy_type_str() will emit "peers section" when the mode is set to peers, so as to ease sharing more code between peers and proxies.
* MINOR: proxy: add findserver_unique_id() and findserver_unique_name()Aurelien DARRAGON2023-04-051-0/+2
| | | | | | | | | | | | | | | | | | | | Adding alternative findserver() functions to be able to perform an unique match based on name or puid and by leveraging revision id (rid) to make sure the function won't match with a new server reusing the same name or puid of the "potentially deleted" server we were initially looking for. For example, if you were in the position of finding a server based on a given name provided to you by a different context: Since dynamic servers were implemented, between the time the name was picked and the time you will perform the findserver() call some dynamic server deletion/additions could've been performed in the mean time. In such cases, findserver() could return a new server that re-uses the name of a previously deleted server. Depending on your needs, it could be perfectly fine, but there are some cases where you want to lookup the original server that was provided to you (if it still exists).
* MINOR: stats: add by HTTP version cumulated number of sessions and requestsFrédéric Lécaille2023-02-031-4/+26
| | | | | | | | | | | | | | | | | | | | | | | Add cum_sess_ver[] new array of counters to count the number of cumulated HTTP sessions by version (h1, h2 or h3). Implement proxy_inc_fe_cum_sess_ver_ctr() to increment these counter. This function is called each a HTTP mux is correctly initialized. The QUIC must before verify the application operations for the mux is for h3 before calling proxy_inc_fe_cum_sess_ver_ctr(). ST_F_SESS_OTHER stat field for the cumulated of sessions others than HTTP sessions is deduced from ->cum_sess_ver counter (for all the session, not only HTTP sessions) from which the HTTP sessions counters are substracted. Add cum_req[] new array of counters to count the number of cumulated HTTP requests by version and others than HTTP requests. This new member replace ->cum_req. Modify proxy_inc_fe_req_ctr() which increments these counters to pass an HTTP version, 0 special values meaning "other than an HTTP request". This is the case for instance for syslog.c from which proxy_inc_fe_req_ctr() is called with 0 as version parameter. ST_F_REQ_TOT stat field compputing for the cumulated number of requests is modified to count the sum of all the cum_req[] counters. As this patch is useful for QUIC, it must be backported to 2.7.
* MINOR: proxy/listener: support for additional PAUSED stateAurelien DARRAGON2022-09-091-0/+2
| | | | | | | | | This patch is a prerequisite for #1626. Adding PAUSED state to the list of available proxy states. The flag is set when the proxy is paused at runtime (pause_listener()). It is cleared when the proxy is resumed (resume_listener()). It should be backported to 2.6, 2.5 and 2.4
* MINOR: proxy: Be able to reference the defaults section used by a proxyChristopher Faulet2021-10-151-1/+3
| | | | | | | | | | | | | A proxy may now references the defaults section it is used. To do so, a pointer on the default proxy was added in the proxy structure. And a refcount must be used to track proxies using a default proxy. A default proxy is destroyed iff its refcount is equal to zero and when it drops to zero. All this stuff must be performed during init/deinit staged for now. All unreferenced default proxies are removed after the configuration parsing. This patch is mandatory to support TCP/HTTP rules in defaults sections.
* CLEANUP: tree-wide: remove unneeded include time.h in ~20 filesWilly Tarreau2021-10-071-1/+0
| | | | | | 20 files used to have haproxy/time.h included only for now_ms, and two were missing it for other things but used to inherit from it via other files.
* CLEANUP: tree-wide: fix prototypes for functions taking no arguments.Tim Duesterhus2021-09-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "f(void)" is the correct and preferred form for a function taking no argument, while some places use the older "f()". These were reported by clang's -Wmissing-prototypes, for example: src/cpuset.c:111:5: warning: no previous prototype for function 'ha_cpuset_size' [-Wmissing-prototypes] int ha_cpuset_size() include/haproxy/cpuset.h:42:5: note: this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function int ha_cpuset_size(); ^ void This aggregate patch fixes this for the following functions: ha_backtrace_to_stderr(), ha_cpuset_size(), ha_panic(), ha_random64(), ha_thread_dump_all_to_trash(), get_exec_path(), check_config_validity(), mworker_child_nb(), mworker_cli_proxy_(create|stop)(), mworker_cleantasks(), mworker_cleanlisteners(), mworker_ext_launch_all(), mworker_reload(), mworker_(env|proc_list)_to_(proc_list|env)(), mworker_(un|)block_signals(), proxy_adjust_all_maxconn(), proxy_destroy_all_defaults(), get_tainted(), pool_total_(allocated|used)(), thread_isolate(_full|)(), thread(_sync|)_release(), thread_harmless_till_end(), thread_cpu_mask_forced(), dequeue_all_listeners(), next_timer_expiry(), wake_expired_tasks(), process_runnable_tasks(), init_acl(), init_buffer(), (de|)init_log_buffers(), (de|)init_pollers(), fork_poller(), pool_destroy_all(), pool_evict_from_local_caches(), pool_total_failures(), dump_pools_to_trash(), cfg_run_diagnostics(), tv_init_(process|thread)_date(), __signal_process_queue(), deinit_signals(), haproxy_unblock_signals()
* CLEANUP: atomic/tree-wide: replace single increments/decrements with inc/decWilly Tarreau2021-04-071-7/+7
| | | | | | This patch replaces roughly all occurrences of an HA_ATOMIC_ADD(&foo, 1) or HA_ATOMIC_SUB(&foo, 1) with the equivalent HA_ATOMIC_INC(&foo) and HA_ATOMIC_DEC(&foo) respectively. These are 507 changes over 45 files.
* MINOR: proxy: implement a free_proxy functionAmaury Denoyelle2021-03-261-0/+2
| | | | | | | | Move all liberation code related to a proxy in a dedicated function free_proxy in proxy.c. For now, this function is only called in haproxy.c. In the future, it will be used to free the lua proxy. This helps to clean up haproxy.c.
* REORG: split proxy allocation functionsAmaury Denoyelle2021-03-261-2/+5
| | | | | | | | | | Create a new function parse_new_proxy specifically designed to allocate a new proxy from the configuration file and copy settings from the default proxy. The function alloc_new_proxy is reduced to a minimal allocation. It is used for default proxy allocation and could also be used for internal proxies such as the lua Socket proxy.
* MINOR: cfgparse/proxy: also support spelling fixes on optionsWilly Tarreau2021-03-151-0/+1
| | | | | | | | | Some are not always easy to spot with "chk" vs "check" or hyphens at some places and not at others. Now entering "option http-close" properly suggests "httpclose" and "option tcp-chk" suggests "tcp-check". There's no need to consider the proxy's capabilities, what matters is to figure what related word the user tried to spell, and there are not that many options anyway.
* BUG/MINOR: proxy/session: Be sure to have a listener to increment its countersChristopher Faulet2021-03-121-3/+3
| | | | | | | | | | | | It is possible to have a session without a listener. It happens for applets on the client side. Thus all accesses to the listener info from the session must be guarded. It was the purpose of the commit 36119de18 ("BUG/MEDIUM: session: NULL dereference possible when accessing the listener"). However, some tests on the session's listener existence are missing in proxy_inc_* functions. This patch should fix the issues #1171, #1172, #1173, #1174 and #1175. It must be backported with the above commit as far as 1.8.
* MEDIUM: task: extend the state field to 32 bitsWilly Tarreau2021-03-051-1/+1
| | | | | | | | | | | | | | It's been too short for quite a while now and is now full. It's still time to extend it to 32-bits since we have room for this without wasting any space, so we now gained 16 new bits for future flags. The values were not reassigned just in case there would be a few hidden u16 or short somewhere in which these flags are placed (as it used to be the case with stream->pending_events). The patch is tagged MEDIUM because this required to update the task's process() prototype to use an int instead of a short, that's quite a bunch of places.
* MEDIUM: proxy: store the default proxies in a tree by nameWilly Tarreau2021-02-121-0/+1
| | | | | | | | | | | | | Now default proxies are stored into a dedicated tree, sorted by name. Only unnamed entries are not kept upon new section creation. The very first call to cfg_parse_listen() will automatically allocate a dummy defaults section which corresponds to the previous static one, since the code requires to have one at a few places. The first immediately visible benefit is that it allows to reuse alloc_new_proxy() to allocate a defaults section instead of doing it by hand. And the secret goal is to allow to keep multiple named defaults section in memory to reuse them from various proxies.
* MINOR: proxy: support storing defaults sections into their own treeWilly Tarreau2021-02-121-0/+1
| | | | | | | Now we'll have a tree of named defaults sections. The regular insertion and lookup functions take care of the capability in order to select the appropriate tree. A new function proxy_destroy_defaults() removes a proxy from this tree and frees it entirely.
* MINOR: proxy: move the defproxy freeing code to proxy.cWilly Tarreau2021-02-121-0/+1
| | | | | | | | | | | This used to be open-coded in cfgparse-listen.c when facing a "defaults" keyword. Let's move this into proxy_free_defaults(). This code is ugly and doesn't even reset the just freed pointers. Let's not change this yet. This code should probably be merged with a generic proxy deinit function called from deinit(). However there's a catch on uri_auth which cannot be freed because it might be used by one or several proxies. We definitely need refcounts there!
* REORG: proxy: centralize the proxy allocation code into alloc_new_proxy()Willy Tarreau2021-02-121-0/+2
| | | | | | | | | | | | | This new function takes over the old open-coding that used to be done for too long in cfg_parse_listen() and it now does everything at once in a proxy-centric function. The function does all the job of allocating the structure, initializing it, presetting its defaults from the default proxy and checking for errors. The code was almost unchanged except for defproxy being passed as a pointer, and the error message being passed using memprintf(). This change will be needed to ease reuse of multiple default proxies, or to create dynamic backends in a distant future.
* REORG: move init_default_instance() to proxy.c and pass it the defproxy pointerWilly Tarreau2021-02-121-0/+1
| | | | | | | | | | init_default_instance() was still left in cfgparse.c which is not the best place to pre-initialize a proxy. Let's place it in proxy.c just after init_new_proxy(), take this opportunity for renaming it to proxy_preset_defaults() and taking out init_new_proxy() from it, and let's pass it the pointer to the default proxy to be initialized instead of implicitly assuming defproxy. We'll soon be able to exploit this. Only two call places had to be updated.
* MINOR: stream: Add level 7 retries on http error 401, 403Julien Pivotto2020-11-231-0/+4
| | | | | | | | | | | Level-7 retries are only possible with a restricted number of HTTP return codes. While it is usually not safe to retry on 401 and 403, I came up with an authentication backend which was not synchronizing authentication of users. While not perfect, being allowed to also retry on those return codes is really helpful and acts as a hotfix until we can fix the backend. Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
* MEDIUM: proxy: centralize proxy status update and reportingWilly Tarreau2020-10-091-0/+1
| | | | | | | | | There are multiple ways a proxy may switch to the disabled state, but now it's essentially once it loses its last listener. Instead of keeping duplicate code around and reporting the state change before actually seeing it, we now report it at the moment it's performed (from the last listener leaving) which allows to remove the message from all other places.
* CLEANUP: proxy: remove the now unused pause_proxies() and resume_proxies()Willy Tarreau2020-10-091-2/+0
| | | | | They're not used anymore, delete them before someone thinks about using them again!
* MEDIUM: proxy: merge zombify_proxy() with stop_proxy()Willy Tarreau2020-10-091-1/+0
| | | | | | | The two functions don't need to be distinguished anymore since they have all the necessary info to act as needed on their listeners. Let's just pass via stop_proxy() and make it check for each listener which one to close or not.
* MEDIUM: proxy: remove start_proxies()Willy Tarreau2020-10-091-1/+0
| | | | | | | | | | | | Its sole remaining purpose was to display "proxy foo started", which has little benefit and pollutes output for those with plenty of proxies. Let's remove it now. The VTCs were updated to reflect this, because many of them had explicit counts of dropped lines to match this message. This is tagged as MEDIUM because some users may be surprized by the loss of this quite old message.
* MINOR: stats: inc req counter on listeners.Emeric Brun2020-10-071-1/+3
| | | | | This patch enables count of requests for listeners if listener's counters are enabled.
* MAJOR: init: start all listeners via protocols and not via proxies anymoreWilly Tarreau2020-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Ever since the protocols were added in 1.3.13, listeners used to be started twice: - once by start_proxies(), which iteratees over all proxies then all listeners ; - once by protocol_bind_all() which iterates over all protocols then all listeners ; It's a real mess because error reporting is not even consistent, and more importantly now that some protocols do not appear in regular proxies (peers, logs), there is no way to retry their binding should it fail on the last step. What this patch does is to make sure that listeners are exclusively started by protocols. The failure to start a listener now causes the emission of an error indicating the proxy's name (as it used to be the case per proxy), and retryable failures are silently ignored during all but last attempts. The start_proxies() function was kept solely for setting the proxy's state to READY and emitting the "Proxy started" message and log that some have likely got used to seeking in their logs.
* CLEANUP: include: tree-wide alphabetical sort of include filesWilly Tarreau2020-06-111-1/+1
| | | | | | This patch fixes all the leftovers from the include cleanup campaign. There were not that many (~400 entries in ~150 files) but it was definitely worth doing it as it revealed a few duplicates.
* REORG: include: move server.h to haproxy/server{,-t}.hWilly Tarreau2020-06-111-1/+1
| | | | | | | extern struct dict server_name_dict was moved from the type file to the main file. A handful of inlined functions were moved at the bottom of the file. Call places were updated to use server-t.h when relevant, or to simply drop the entry when not needed.
* REORG: include: move proxy.h to haproxy/proxy{,-t}.hWilly Tarreau2020-06-111-0/+201
This one is particularly difficult to split because it provides all the functions used to manipulate a proxy state and to retrieve names or IDs for error reporting, and as such, it was included in 73 files (down to 68 after cleanup). It would deserve a small cleanup though the cut points are not obvious at the moment given the number of structs involved in the struct proxy itself.