]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
9 years agoDOC: typo: req.uri is now replaced by capture.req.uri
Baptiste Assmann [Sun, 6 Mar 2016 22:42:52 +0000 (23:42 +0100)] 
DOC: typo: req.uri is now replaced by capture.req.uri

A configuration example was not updated after the switch from req.uri to
capture.req.uri.

backport: 1.5 and above

9 years agoDOC: regsub: parser limitation about the inability to use closing square brackets
Baptiste Assmann [Sun, 6 Mar 2016 22:36:48 +0000 (23:36 +0100)] 
DOC: regsub: parser limitation about the inability to use closing square brackets

We can't match range in regsub, since the closing bracket is evaluated
by the configuration parser.

backport: 1.6 and above

9 years agoDOC: typo: maxconn paragraph is wrong due to a wrong buffer size
Baptiste Assmann [Sun, 6 Mar 2016 22:34:31 +0000 (23:34 +0100)] 
DOC: typo: maxconn paragraph is wrong due to a wrong buffer size

HAProxy allocates 2 tune.bufsize, which is by default 16kB.

backport: 1.4 and above

9 years agoDOC: typo: ACL subdir match
Baptiste Assmann [Sun, 6 Mar 2016 22:32:10 +0000 (23:32 +0100)] 
DOC: typo: ACL subdir match

ACL subdir match is "-m dir"

backport: 1.5 and above

9 years agoDOC: stick-table: amend paragraph blaming the loss of table upon reload
Baptiste Assmann [Sun, 6 Mar 2016 22:29:28 +0000 (23:29 +0100)] 
DOC: stick-table: amend paragraph blaming the loss of table upon reload

This statement is not true anymore since we have the peers in HAProxy.

backport: 1.6 and above

9 years agoDOC: typo on stick-store response
Baptiste Assmann [Sun, 6 Mar 2016 22:27:24 +0000 (23:27 +0100)] 
DOC: typo on stick-store response

It is used to store responses, and not requests.

backport: 1.5 and above

9 years agoDOC: timeout client: pointers to timeout http-request
Baptiste Assmann [Sun, 6 Mar 2016 22:24:12 +0000 (23:24 +0100)] 
DOC: timeout client: pointers to timeout http-request

It worth mentionning "timeout http-request" in the "timeout client"
documentation paragraph, to ensure nobody misses this important setting.

backport: 1.5 and above

9 years agoDOC: "addr" parameter applies to both health and agent checks
Baptiste Assmann [Sun, 6 Mar 2016 22:14:36 +0000 (23:14 +0100)] 
DOC: "addr" parameter applies to both health and agent checks

It was not obvious in the documentation that the server's "addr"
parameter applies to both the agent and the health check.

backport: 1.5 and above

9 years agoMINOR: lua: convert field to lua type
Thierry Fournier [Wed, 16 Mar 2016 17:29:13 +0000 (18:29 +0100)] 
MINOR: lua: convert field to lua type

This function converts a field used by stats in lua type.

9 years agoMINOR: lua: Add internal function which strip spaces
Thierry Fournier [Wed, 24 Feb 2016 07:06:32 +0000 (08:06 +0100)] 
MINOR: lua: Add internal function which strip spaces

Some internal HAproxy error message are provided with a final '\n'.
Its typically for the integration in the CLI. Sometimes, these messages
are returned as Lua string. These string must be without "\n" or final
spaces.

This patch adds a function whoch removes unrequired parameters.

9 years agoMINOR: lua: post initialization
Thierry Fournier [Fri, 19 Feb 2016 19:53:30 +0000 (20:53 +0100)] 
MINOR: lua: post initialization

This patch adds a Lua post initialisation wrapper. It already exists for
pure Lua function, now it executes also C. It is useful for doing things
when the configuration is ready to use. For example we can can browse and
register all the proxies.

9 years agoMINOR: lua: precise message when a critical error is catched
Thierry Fournier [Fri, 19 Feb 2016 18:57:23 +0000 (19:57 +0100)] 
MINOR: lua: precise message when a critical error is catched

This patch try to find error message when the safe execution wrapper
function catch a critical error.

9 years agoMINOR: lua: refactor the Lua object registration
Thierry Fournier [Fri, 19 Feb 2016 17:34:46 +0000 (18:34 +0100)] 
MINOR: lua: refactor the Lua object registration

All the HAProxy Lua object are declared with the same pattern:
 - Add the function __tosting which dumps the object name
 - Register the name in the Lua REGISTRY
 - Register the reference ID

These action are refactored in on function. This remove some
lines of code.

9 years agoCLEANUP: lua: Remove two same functions
Thierry Fournier [Mon, 22 Feb 2016 07:40:02 +0000 (08:40 +0100)] 
CLEANUP: lua: Remove two same functions

The function hlua_array_add_fcn() is exactly the same than the function
hlua_class_function(), so this patch removes the first one.

9 years agoMINOR: lua: remove some useless checks
Thierry Fournier [Mon, 22 Feb 2016 18:07:12 +0000 (19:07 +0100)] 
MINOR: lua: remove some useless checks

The modified function are declared in the safe environment, so
they must called from safe environement. As the environement is
safe, its useles to check the stack size.

9 years agoMINOR: lua: move class registration facilities
Thierry Fournier [Mon, 22 Feb 2016 18:52:08 +0000 (19:52 +0100)] 
MINOR: lua: move class registration facilities

The functions
 - hlua_class_const_int()
 - hlua_class_const_str()
 - hlua_class_function()
are use for common class registration actions.

The function 'hlua_dump_object()' is generic dump name function.

These functions can be used by all the HAProxy objects, so I move
it into the safe functions file.

9 years agoCLEANUP: map: it seems that the map were planed to be chained
Thierry Fournier [Wed, 2 Mar 2016 07:36:14 +0000 (08:36 +0100)] 
CLEANUP: map: it seems that the map were planed to be chained

It seems that the map were planed to be chained, but obviously
it is not the case. This patch remove the struct which should
be used gor the chain

9 years agoBUG/MINOR: prevent the dump of uninitialized vars
Thierry Fournier [Fri, 25 Mar 2016 07:43:46 +0000 (08:43 +0100)] 
BUG/MINOR: prevent the dump of uninitialized vars

Some vars are not initialized when the dumps of variables
are called. This patch prevent the dereferencement of
uninitialized pointers.

9 years agoBUG/MINOR: lua: can't load external libraries
Thierry Fournier [Sat, 26 Mar 2016 12:19:21 +0000 (13:19 +0100)] 
BUG/MINOR: lua: can't load external libraries

Libraries requires the export of embedded Lua symbols. If a library
is loaded by HAProxy or by an Lua program, an error like the following
error raises:

   [ALERT] 085/135722 (7224) : parsing [test.cfg:8] : lua runtime error: error loading module 'test' from file './test.so':
        ./test.so: undefined symbol: lua_createtable

This patch modify the Makefile, and allow exports of the Lua symbols.

This patch must be backported in version 1.6

9 years agoBUG/MAJOR: Fix crash in http_get_fhdr with exactly MAX_HDR_HISTORY headers
Nenad Merdanovic [Tue, 29 Mar 2016 11:14:30 +0000 (13:14 +0200)] 
BUG/MAJOR: Fix crash in http_get_fhdr with exactly MAX_HDR_HISTORY headers

Similar issue was fixed in 67dad27, but the fix is incomplete. Crash still
happened when utilizing req.fhdr() and sending exactly MAX_HDR_HISTORY
headers.

This fix needs to be backported to 1.5 and 1.6.

Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
9 years agoBUG/MEDIUM: Fix RFC5077 resumption when more than TLS_TICKETS_NO are present
Nenad Merdanovic [Fri, 25 Mar 2016 21:16:57 +0000 (22:16 +0100)] 
BUG/MEDIUM: Fix RFC5077 resumption when more than TLS_TICKETS_NO are present

Olivier Doucet reported the issue on the ML and tested that when using
more than TLS_TICKETS_NO keys in the file, the CPU usage is much higeher
than expected.

Lukas Tribus then provided a test case which showed that resumption doesn't
work at all in that case.

This fix needs to be backported to 1.6.

Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
9 years agoBUG/MEDIUM: peers: fix incorrect age in frequency counters
Willy Tarreau [Fri, 25 Mar 2016 17:17:47 +0000 (18:17 +0100)] 
BUG/MEDIUM: peers: fix incorrect age in frequency counters

The frequency counters's window start is sent as "now - freq.date",
which is a positive age compared to the current date. But on receipt,
this age was added to the current date instead of subtracted. So
since the date was always in the future, they were always expired if
the activity changed side in less than the counter's measuring period
(eg: 10s).

This bug was reported by Christian Ruppert who also provided an easy
reproducer.

It needs to be backported to 1.6.

9 years agoCLEANUP: connection: fix double negation on memcmp()
David CARLIER [Thu, 24 Mar 2016 09:22:36 +0000 (09:22 +0000)] 
CLEANUP: connection: fix double negation on memcmp()

Nothing harmful in here, just clarify that it applies to the whole
expression.

9 years agoCLEANUP: chunk: adding NULL check to chunk_dup allocation.
David Carlier [Wed, 23 Mar 2016 17:50:57 +0000 (17:50 +0000)] 
CLEANUP: chunk: adding NULL check to chunk_dup allocation.

Avoiding harmful memcpy call if the allocation failed.
Resetting the size which avoids further harmful freeing
invalid pointer. Closer to the comment behavior description.

9 years agoDOC: Clarify tunes.vars.xxx-max-size settings
Daniel Schneller [Mon, 21 Mar 2016 19:46:57 +0000 (20:46 +0100)] 
DOC: Clarify tunes.vars.xxx-max-size settings

Adds a little more clarity to the description of the maximum sizes of
the different variable scopes and adds a note about what happens when
the space allocated for variables is too small.

Also fixes some typos and grammar/spelling issues re/ variables and
their naming conventions, copied throughout the document.

9 years agoBUG/MINOR: conf: "listener id" expects integer, but its not checked
Thierry Fournier [Fri, 26 Feb 2016 07:45:58 +0000 (08:45 +0100)] 
BUG/MINOR: conf: "listener id" expects integer, but its not checked

The listener id was converted with a simple atol, so conversion
error are unchecked. This patch uses strtol and checks the
conversion status.

9 years agoDOC: add encoding to json converter example
Mac Browning [Mon, 14 Mar 2016 18:46:01 +0000 (14:46 -0400)] 
DOC: add encoding to json converter example

Without the encoding `log-format` will issue a warning like:

$ haproxy -c -f /etc/haproxy/haproxy.cfg
[WARNING] 073/180933 (179) : parsing [/etc/haproxy/haproxy.cfg:46] :
'log-format' : sample fetch <capture.req.hdr(1),json> failed with : missing
args for conv method 'json'

9 years agoMINOR: da: Using ARG12 macro for the sample fetch and the convertor.
David Carlier [Wed, 16 Mar 2016 10:09:55 +0000 (10:09 +0000)] 
MINOR: da: Using ARG12 macro for the sample fetch and the convertor.

Regarding the minor update introduced in the
cd6c3c7cb4fdc9cf694b62241840e3fea30e03dd commit, the DeviceAtlas
module is now able to use up to 12 device properties via the
new ARG12 macro.

9 years agoBUILD: namespaces: fix a potential build warning in namespaces.c
Willy Tarreau [Thu, 17 Mar 2016 04:39:53 +0000 (05:39 +0100)] 
BUILD: namespaces: fix a potential build warning in namespaces.c

I just met this warning today making me realize that haproxy's
headers were included prior to the system ones, so all #ifndefs
are taken first then the system redefines them. Simply move
haproxy includes after the system's. This should be backported
to 1.6 as well.

In file included from /usr/include/bits/fcntl.h:61:0,
                 from /usr/include/fcntl.h:35,
                 from src/namespace.c:13:
/usr/include/bits/fcntl-linux.h:203:0: warning: "F_SETPIPE_SZ" redefined [enabled by default]
In file included from include/common/config.h:26:0,
                 from include/proto/log.h:29,
                 from src/namespace.c:7:
include/common/compat.h:81:0: note: this is the location of the previous definition

9 years agoBUG/MINOR: log: Don't use strftime() which can clobber timezone if chrooted
Benoit GARNIER [Sun, 27 Mar 2016 01:04:16 +0000 (03:04 +0200)] 
BUG/MINOR: log: Don't use strftime() which can clobber timezone if chrooted

The strftime() function can call tzset() internally on some platforms.
When haproxy is chrooted, the /etc/localtime file is not found, and some
implementations will clobber the content of the current timezone.

The GMT offset is computed by diffing the times returned by gmtime_r() and
localtime_r(). These variants are guaranteed to not call tzset() and were
already used in haproxy while chrooted, so they should be safe.

This patch must be backported to 1.6 and 1.5.

9 years agoMINOR: sample: Moves ARGS underlying type from 32 to 64 bits.
David Carlier [Tue, 15 Mar 2016 19:00:35 +0000 (19:00 +0000)] 
MINOR: sample: Moves ARGS underlying type from 32 to 64 bits.

ARG# macros allow to create a list up to 7 in theory but 5 in
practice. The change to a guaranteed 64 bits type increase to
up to 12.

9 years ago[RELEASE] Released version 1.7-dev2 v1.7-dev2
Willy Tarreau [Sun, 13 Mar 2016 23:10:05 +0000 (00:10 +0100)] 
[RELEASE] Released version 1.7-dev2

Released version 1.7-dev2 with the following main changes :
    - DOC: lua: fix lua API
    - DOC: mailers: typo in 'hostname' description
    - DOC: compression: missing mention of libslz for compression algorithm
    - BUILD/MINOR: regex: missing header
    - BUG/MINOR: stream: bad return code
    - DOC: lua: fix somme errors and add implicit types
    - MINOR: lua: add set/get priv for applets
    - BUG/MINOR: http: fix several off-by-one errors in the url_param parser
    - BUG/MINOR: http: Be sure to process all the data received from a server
    - MINOR: filters/http: Use a wrapper function instead of stream_int_retnclose
    - BUG/MINOR: chunk: make chunk_dup() always check and set dst->size
    - DOC: ssl: fixed some formatting errors in crt tag
    - MINOR: chunks: ensure that chunk_strcpy() adds a trailing zero
    - MINOR: chunks: add chunk_strcat() and chunk_newstr()
    - MINOR: chunk: make chunk_initstr() take a const string
    - MEDIUM: tools: add csv_enc_append() to preserve the original chunk
    - MINOR: tools: make csv_enc_append() always start at the first byte of the chunk
    - MINOR: lru: new function to delete <nb> least recently used keys
    - DOC: add Ben Shillito as the maintainer of 51d
    - BUG/MINOR: 51d: Ensures a unique domain for each configuration
    - BUG/MINOR: 51d: Aligns Pattern cache implementation with HAProxy best practices.
    - BUG/MINOR: 51d: Releases workset back to pool.
    - BUG/MINOR: 51d: Aligned const pointers to changes in 51Degrees.
    - CLEANUP: 51d: Aligned if statements with HAProxy best practices and removed casts from malloc.
    - MINOR: rename master process name in -Ds (systemd mode)
    - DOC: fix a few spelling mistakes
    - DOC: fix "workaround" spelling
    - BUG/MINOR: examples: Fixing haproxy.spec to remove references to .cfg files
    - MINOR: fix the return type for dns_response_get_query_id() function
    - MINOR: server state: missing LF (\n) on error message printed when parsing server state file
    - BUG/MEDIUM: dns: no DNS resolution happens if no ports provided to the nameserver
    - BUG/MAJOR: servers state: server port is erased when dns resolution is enabled on a server
    - BUG/MEDIUM: servers state: server port is used uninitialized
    - BUG/MEDIUM: config: Adding validation to stick-table expire value.
    - BUG/MEDIUM: sample: http_date() doesn't provide the right day of the week
    - BUG/MEDIUM: channel: fix miscalculation of available buffer space.
    - MEDIUM: pools: add a new flag to avoid rounding pool size up
    - BUG/MEDIUM: buffers: do not round up buffer size during allocation
    - BUG/MINOR: stream: don't force retries if the server is DOWN
    - BUG/MINOR: counters: make the sc-inc-gpc0 and sc-set-gpt0 touch the table
    - MINOR: unix: don't mention free ports on EAGAIN
    - BUG/CLEANUP: CLI: report the proper field states in "show sess"
    - MINOR: stats: send content-length with the redirect to allow keep-alive
    - BUG: stream_interface: Reuse connection even if the output channel is empty
    - DOC: remove old tunnel mode assumptions
    - BUG/MAJOR: http-reuse: fix risk of orphaned connections
    - BUG/MEDIUM: http-reuse: do not share private connections across backends
    - BUG/MINOR: ssl: Be sure to use unique serial for regenerated certificates
    - BUG/MINOR: stats: fix missing comma in stats on agent drain
    - MAJOR: filters: Add filters support
    - MINOR: filters: Do not reset stream analyzers if the client is gone
    - REORG: filters: Prepare creation of the HTTP compression filter
    - MAJOR: filters/http: Rewrite the HTTP compression as a filter
    - MEDIUM: filters: Use macros to call filters callbacks to speed-up processing
    - MEDIUM: filters: remove http_start_chunk, http_last_chunk and http_chunk_end
    - MEDIUM: filters: Replace filter_http_headers callback by an analyzer
    - MEDIUM: filters/http: Move body parsing of HTTP messages in dedicated functions
    - MINOR: filters: Add stream_filters structure to hide filters info
    - MAJOR: filters: Require explicit registration to filter HTTP body and TCP data
    - MINOR: filters: Remove unused or useless stuff and do small optimizations
    - MEDIUM: filters: Optimize the HTTP compression for chunk encoded response
    - MINOR: filters/http: Slightly update the parsing of chunks
    - MINOR: filters/http: Forward remaining data when a channel has no "data" filters
    - MINOR: filters: Add an filter example
    - MINOR: filters: Extract proxy stuff from the struct filter
    - MINOR: map: Add regex matching replacement
    - BUG/MINOR: lua: unsafe initialization
    - DOC: lua: fix somme errors
    - MINOR: lua: file dedicated to unsafe functions
    - MINOR: lua: add "now" time function
    - MINOR: standard: add RFC HTTP date parser
    - MINOR: lua: Add date functions
    - MINOR: lua: move common function
    - MINOR: lua: merge function
    - MINOR: lua: Add concat class
    - MINOR: standard: add function "escape_chunk"
    - MEDIUM: log: add a new log format flag "E"
    - DOC: add server name at rate-limit sessions example
    - BUG/MEDIUM: ssl: fix off-by-one in ALPN list allocation
    - BUG/MEDIUM: ssl: fix off-by-one in NPN list allocation
    - DOC: LUA: fix some typos and syntax errors
    - MINOR: cli: add a new "show env" command
    - MEDIUM: config: allow to manipulate environment variables in the global section
    - MEDIUM: cfgparse: reject incorrect 'timeout retry' keyword spelling in resolvers
    - MINOR: mailers: increase default timeout to 10 seconds
    - MINOR: mailers: use <CRLF> for all line endings
    - BUG/MAJOR: lua: segfault using Concat object
    - DOC: lua: copyrights
    - MINOR: common: mask conversion
    - MEDIUM: dns: extract options
    - MEDIUM: dns: add a "resolve-net" option which allow to prefer an ip in a network
    - MINOR: mailers: make it possible to configure the connection timeout
    - BUG/MAJOR: lua: applets can't sleep.
    - BUG/MINOR: server: some prototypes are renamed
    - BUG/MINOR: lua: Useless copy
    - BUG/MEDIUM: stats: stats bind-process doesn't propagate the process mask correctly
    - BUG/MINOR: server: fix the format of the warning on address change
    - CLEANUP: server: add "const" to some message strings
    - MINOR: server: generalize the "updater" source
    - BUG/MEDIUM: chunks: always reject negative-length chunks
    - BUG/MINOR: systemd: ensure we don't miss signals
    - BUG/MINOR: systemd: report the correct signal in debug message output
    - BUG/MINOR: systemd: propagate the correct signal to haproxy
    - MINOR: systemd: ensure a reload doesn't mask a stop
    - BUG/MEDIUM: cfgparse: wrong argument offset after parsing server "sni" keyword
    - CLEANUP: stats: Avoid computation with uninitialized bits.
    - CLEANUP: pattern: Ignore unknown samples in pat_match_ip().
    - CLEANUP: map: Avoid memory leak in out-of-memory condition.
    - BUG/MINOR: tcpcheck: fix incorrect list usage resulting in failure to load certain configs
    - BUG/MAJOR: samples: check smp->strm before using it
    - MINOR: sample: add a new helper to initialize the owner of a sample
    - MINOR: sample: always set a new sample's owner before evaluating it
    - BUG/MAJOR: vars: always retrieve the stream and session from the sample
    - CLEANUP: payload: remove useless and confusing nullity checks for channel buffer
    - BUG/MINOR: ssl: fix usage of the various sample fetch functions
    - MINOR: stats: create fields types suitable for all CSV output data
    - MINOR: stats: add all the "show info" fields in a table
    - MEDIUM: stats: fill all the show info elements prior to displaying them
    - MINOR: stats: add a function to emit fields into a chunk
    - MINOR: stats: add stats_dump_info_fields() to dump one field per line
    - MEDIUM: stats: make use of stats_dump_info_fields() for "show info"
    - MINOR: stats: add a declaration of all stats fields
    - MINOR: stats: don't hard-code the CSV fields list anymore
    - MINOR: stats: create stats fields storage and CSV dump function
    - MEDIUM: stats: convert stats_dump_fe_stats() to use stats_dump_fields_csv()
    - MEDIUM: stats: make stats_dump_fe_stats() use stats fields for HTML dump
    - MEDIUM: stats: convert stats_dump_li_stats() to use stats_dump_fields_csv()
    - MEDIUM: stats: make stats_dump_li_stats() use stats fields for HTML dump
    - MEDIUM: stats: convert stats_dump_be_stats() to use stats_dump_fields_csv()
    - MEDIUM: stats: make stats_dump_be_stats() use stats fields for HTML dump
    - MEDIUM: stats: convert stats_dump_sv_stats() to use stats_dump_fields_csv()
    - MEDIUM: stats: make stats_dump_sv_stats() use the stats field for HTML
    - MEDIUM: stats: move the server state coloring logic to the server dump function
    - MINOR: stats: do not use srv->admin & STATS_ADMF_MAINT in HTML dumps
    - MINOR: stats: do not check srv->state for SRV_ST_STOPPED in HTML dumps
    - MINOR: stats: make CSV report server check status only when enabled
    - MINOR: stats: only report backend's down time if it has servers
    - MINOR: stats: prepend '*' in front of the check status when in progress
    - MINOR: stats: make HTML stats dump rely on the table for the check status
    - MINOR: stats: add agent_status, agent_code, agent_duration to output
    - MINOR: stats: add check_desc and agent_desc to the output fields
    - MINOR: stats: add check and agent's health values in the output
    - MEDIUM: stats: make the HTML server state dump use the CSV states
    - MEDIUM: stats: only report observe errors when observe is set
    - MEDIUM: stats: expose the same flags for CLI and HTTP accesses
    - MEDIUM: stats: report server's address in the CSV output
    - MEDIUM: stats: report the cookie value in the server & backend CSV dumps
    - MEDIUM: stats: compute the color code only in the HTML form
    - MEDIUM: stats: report the listeners' address in the CSV output
    - MEDIUM: stats: make it possible to report the WAITING state for listeners
    - REORG: stats: dump the frontend's HTML stats via a generic function
    - REORG: stats: dump the socket stats via the generic function
    - REORG: stats: dump the server stats via the generic function
    - REORG: stats: dump the backend stats via the generic function
    - MEDIUM: stats: add a new "mode" column to report the proxy mode
    - MINOR: stats: report the load balancing algorithm in CSV output
    - MINOR: stats: add 3 fields to report the frontend-specific connection stats
    - MINOR: stats: report number of intercepted requests for frontend and backends
    - MINOR: stats: introduce stats_dump_one_line() to dump one stats line
    - CLEANUP: stats: make stats_dump_fields_html() not rely on proxy anymore
    - MINOR: stats: add ST_SHOWADMIN to pass the admin info in the regular flags
    - MINOR: stats: make stats_dump_fields_html() not use &trash by default
    - MINOR: stats: add functions to emit typed fields into a chunk
    - MEDIUM: stats: support "show info typed" on the CLI
    - MEDIUM: stats: implement a typed output format for stats
    - DOC: document the "show info typed" and "show stat typed" output formats
    - MINOR: cfgparse: warn when uid parameter is not a number
    - MINOR: cfgparse: warn when gid parameter is not a number
    - BUG/MINOR: standard: Avoid free of non-allocated pointer
    - BUG/MINOR: pattern: Avoid memory leak on out-of-memory condition
    - CLEANUP: http: fix a build warning introduced by a recent fix
    - BUG/MINOR: log: GMT offset not updated when entering/leaving DST

9 years agoBUG/MINOR: log: GMT offset not updated when entering/leaving DST
Benoit GARNIER [Sun, 27 Mar 2016 09:08:03 +0000 (11:08 +0200)] 
BUG/MINOR: log: GMT offset not updated when entering/leaving DST

GMT offset used in local time formats was computed at startup, but was not updated when DST status changed while running.

For example these two RFC5424 syslog traces where emitted 5 seconds apart, just before and after DST changed:
  <14>1 2016-03-27T01:59:58+01:00 bunch-VirtualBox haproxy 2098 - - Connect ...
  <14>1 2016-03-27T03:00:03+01:00 bunch-VirtualBox haproxy 2098 - - Connect ...

It looked like they were emitted more than 1 hour apart, unlike with the fix:
  <14>1 2016-03-27T01:59:58+01:00 bunch-VirtualBox haproxy 3381 - - Connect ...
  <14>1 2016-03-27T03:00:03+02:00 bunch-VirtualBox haproxy 3381 - - Connect ...

This patch should be backported to 1.6 and partially to 1.5 (no fix needed in log.c).

9 years agoCLEANUP: http: fix a build warning introduced by a recent fix
Willy Tarreau [Sun, 13 Mar 2016 07:17:02 +0000 (08:17 +0100)] 
CLEANUP: http: fix a build warning introduced by a recent fix

Cyril reported that recent commit 320ec2a ("BUG/MEDIUM: chunks: always
reject negative-length chunks") introduced a build warning because gcc
cannot guess that we can't fall into the case where the auth_method
chunk is not initialized.

This patch addresses it, though for the long term it would be best
if chunk_initlen() would always initialize the result.

This fix must be backported to 1.6 and 1.5 where the aforementionned
fix was already backported.

9 years agoBUG/MINOR: pattern: Avoid memory leak on out-of-memory condition
Andreas Seltenreich [Thu, 3 Mar 2016 19:20:23 +0000 (20:20 +0100)] 
BUG/MINOR: pattern: Avoid memory leak on out-of-memory condition

pattern_new_expr() failed to free the allocated list element when an
out-of-memory error occurs during initialization of the element.  As
this only happens when loading the configuration file or evaluating
commands via the CLI, it is unlikely for this leak to be relevant
unless the user makes automated, heavy use of the CLI.

Found in HAProxy 1.5.14.

9 years agoBUG/MINOR: standard: Avoid free of non-allocated pointer
Andreas Seltenreich [Thu, 3 Mar 2016 19:40:37 +0000 (20:40 +0100)] 
BUG/MINOR: standard: Avoid free of non-allocated pointer

The original author forgot to dereference the argument to free in
parse_binary.  This may result in a crash on reading bad input from
the configuration file instead of a proper error message.

Found in HAProxy 1.5.14.

9 years agoMINOR: cfgparse: warn when gid parameter is not a number
Baptiste Assmann [Fri, 11 Mar 2016 16:21:15 +0000 (17:21 +0100)] 
MINOR: cfgparse: warn when gid parameter is not a number

Currently, no warning are emitted when the gid is not a number.
Purpose of this warning is to let admins know they their configuration
won't be applied as expected.

9 years agoMINOR: cfgparse: warn when uid parameter is not a number
Baptiste Assmann [Fri, 11 Mar 2016 16:10:04 +0000 (17:10 +0100)] 
MINOR: cfgparse: warn when uid parameter is not a number

Currently, no warning are emitted when the uid is not a number.
Purpose of this warning is to let admins know they their configuration
won't be applied as expected.

9 years agoDOC: document the "show info typed" and "show stat typed" output formats
Willy Tarreau [Fri, 11 Mar 2016 10:09:34 +0000 (11:09 +0100)] 
DOC: document the "show info typed" and "show stat typed" output formats

These formats are more complex and are only usable if properly
documented. Let's hope it will be enough.

9 years agoMEDIUM: stats: implement a typed output format for stats
Willy Tarreau [Mon, 11 Jan 2016 17:57:53 +0000 (18:57 +0100)] 
MEDIUM: stats: implement a typed output format for stats

The output for each field is :
  field:<origin><nature><scope>:type:value

where field reminds the type of the object being dumped as well as its
position (pid, iid, sid), field number and field name. This way a
monitoring utility may very well report all available information without
knowing new fields in advance.

This format is also supported in the HTTP version of the stats by adding
";typed" after the URI, instead of ";csv" for the CSV format.

The doc was not updated yet.

9 years agoMEDIUM: stats: support "show info typed" on the CLI
Willy Tarreau [Mon, 11 Jan 2016 19:08:42 +0000 (20:08 +0100)] 
MEDIUM: stats: support "show info typed" on the CLI

This emits the field positions, names and types. It is more convenient
than the default output for a parser that doesn't know all the fields. It
simply relies on stats_emit_typed_data_field() and stats_emit_field_tags()
added by previous patch for the output. A new stats format flag was added,
STAT_FMT_TYPED, which is set when the "typed" keyword is specified on the
CLI.

9 years agoMINOR: stats: add functions to emit typed fields into a chunk
Willy Tarreau [Wed, 24 Feb 2016 22:28:31 +0000 (23:28 +0100)] 
MINOR: stats: add functions to emit typed fields into a chunk

New function stats_emit_typed_data_field() does exactly like
stats_emit_raw_data_field() except that it also prints the data
type after a colon. This will be used to print using the typed
format.

And function stats_emit_field_tags() appends a 3-letter code
describing the origin, nature, and scope, followed by an optional
delimiter. This will be particularly convenient to dump typed
data.

9 years agoMINOR: stats: make stats_dump_fields_html() not use &trash by default
Willy Tarreau [Mon, 11 Jan 2016 14:32:30 +0000 (15:32 +0100)] 
MINOR: stats: make stats_dump_fields_html() not use &trash by default

This function must dump into the buffer it gets in argument, and should
not assume it's always trash. This was the last part of the rework, now
the CSV and HTML functions are compatible and the output format may easily
be extended.

9 years agoMINOR: stats: add ST_SHOWADMIN to pass the admin info in the regular flags
Willy Tarreau [Mon, 11 Jan 2016 14:28:40 +0000 (15:28 +0100)] 
MINOR: stats: add ST_SHOWADMIN to pass the admin info in the regular flags

It's easier to have a new flag in <flags> to indicate whether or not we
want to display the admin column in HTML dumps. We already have similar
flags to show the version or the legends.

9 years agoCLEANUP: stats: make stats_dump_fields_html() not rely on proxy anymore
Willy Tarreau [Mon, 11 Jan 2016 14:22:55 +0000 (15:22 +0100)] 
CLEANUP: stats: make stats_dump_fields_html() not rely on proxy anymore

Now this function doesn't need to use the proxy anymore, remove it from
its arguments.

9 years agoMINOR: stats: introduce stats_dump_one_line() to dump one stats line
Willy Tarreau [Fri, 8 Jan 2016 16:37:22 +0000 (17:37 +0100)] 
MINOR: stats: introduce stats_dump_one_line() to dump one stats line

This new function dumps the current stats line according to the
specified format (CSV or HTML for now), and returns these functions'
output code, which will serve later to indicate a failure (eg: buffer
full).

This further simplifies the code since all dumpers now just call this
function.

9 years agoMINOR: stats: report number of intercepted requests for frontend and backends
Willy Tarreau [Mon, 11 Jan 2016 13:40:47 +0000 (14:40 +0100)] 
MINOR: stats: report number of intercepted requests for frontend and backends

This was reported in HTML dumps already but not CSV. It reports the
number of monitor and stats requests. Ideally use-service and redirs
should be accounted for as well.

9 years agoMINOR: stats: add 3 fields to report the frontend-specific connection stats
Willy Tarreau [Mon, 11 Jan 2016 12:52:04 +0000 (13:52 +0100)] 
MINOR: stats: add 3 fields to report the frontend-specific connection stats

Frontends have extra information compared to other entities, they can
report some statistics at the connection level while the other ones
are limited to the session level. This patch adds 3 more fields for
this :
 - conn_rate
 - conn_rate_max
 - conn_tot

It's worth noting that listeners theorically have such statistics, except
that the distinction between connections and sessions is not clearly made
in the code, so that will have to be improved later.

9 years agoMINOR: stats: report the load balancing algorithm in CSV output
Willy Tarreau [Mon, 11 Jan 2016 13:48:36 +0000 (14:48 +0100)] 
MINOR: stats: report the load balancing algorithm in CSV output

It was already present in the HTML output, let's add it to CSV now,
but only when SHLGNDS is set.

9 years agoMEDIUM: stats: add a new "mode" column to report the proxy mode
Willy Tarreau [Mon, 11 Jan 2016 13:09:38 +0000 (14:09 +0100)] 
MEDIUM: stats: add a new "mode" column to report the proxy mode

Now even CSV stats will see the proxy mode, and we can save the
HTML stats dumps from accessing px->mode directly.

9 years agoREORG: stats: dump the backend stats via the generic function
Willy Tarreau [Fri, 8 Jan 2016 16:25:50 +0000 (17:25 +0100)] 
REORG: stats: dump the backend stats via the generic function

The code was simply moved as-is to the new function. There's no
functional change.

9 years agoREORG: stats: dump the server stats via the generic function
Willy Tarreau [Fri, 8 Jan 2016 16:23:28 +0000 (17:23 +0100)] 
REORG: stats: dump the server stats via the generic function

The code was simply moved as-is to the new function. There's no
functional change.

9 years agoREORG: stats: dump the socket stats via the generic function
Willy Tarreau [Fri, 8 Jan 2016 16:20:51 +0000 (17:20 +0100)] 
REORG: stats: dump the socket stats via the generic function

The code was simply moved as-is to the new function. There's no
functional change.

9 years agoREORG: stats: dump the frontend's HTML stats via a generic function
Willy Tarreau [Fri, 8 Jan 2016 16:15:39 +0000 (17:15 +0100)] 
REORG: stats: dump the frontend's HTML stats via a generic function

This new function stats_dump_fields_html() checks the type of the object
being dumped from the stats table, and emits it in HTML format. It uses
an argument indicating if the HTML page is also used as an admin page,
and for now still takes the proxy in argument as a few entries still
need it.

The code was simply moved as-is to the new function. There's no
functional change.

9 years agoMEDIUM: stats: make it possible to report the WAITING state for listeners
Willy Tarreau [Fri, 8 Jan 2016 16:05:19 +0000 (17:05 +0100)] 
MEDIUM: stats: make it possible to report the WAITING state for listeners

HTML output used to have it but not the CSV output. It indicates that the
listener is not full but was forced to wait because the max connection
rate was reached.

9 years agoMEDIUM: stats: report the listeners' address in the CSV output
Willy Tarreau [Fri, 8 Jan 2016 15:59:56 +0000 (16:59 +0100)] 
MEDIUM: stats: report the listeners' address in the CSV output

It's the same principle as for the server dump, and we use this field
for the HTML dump of course.

9 years agoMEDIUM: stats: compute the color code only in the HTML form
Willy Tarreau [Fri, 8 Jan 2016 15:51:35 +0000 (16:51 +0100)] 
MEDIUM: stats: compute the color code only in the HTML form

The color code requires a complex logic, and we use it only in the
HTML part. So let's compute it there based on the server state, its
health and its weight. The thing is tricky but OK. There's a 1-to-1
mapping of down servers, but not of up servers, hence the need for
the weight and health.

9 years agoMEDIUM: stats: report the cookie value in the server & backend CSV dumps
Willy Tarreau [Fri, 8 Jan 2016 14:43:54 +0000 (15:43 +0100)] 
MEDIUM: stats: report the cookie value in the server & backend CSV dumps

The server's cookie value is now reported in the "cookie" column and
used as-is from the HTML dump. It was the last reference to the sv
pointer from this place.

The same was done for the backend's dump.

9 years agoMEDIUM: stats: report server's address in the CSV output
Willy Tarreau [Fri, 8 Jan 2016 14:35:43 +0000 (15:35 +0100)] 
MEDIUM: stats: report server's address in the CSV output

This new field "addr" presents the server's address:port if the client
is either enabled via "stats show legends" in case of HTTP dumps, or
has at least level operator on the CLI. The address formats might be :
 - ipv4:port
 - [ipv6]:port
 - unix
 - (error message)

9 years agoMEDIUM: stats: expose the same flags for CLI and HTTP accesses
Willy Tarreau [Fri, 8 Jan 2016 14:33:18 +0000 (15:33 +0100)] 
MEDIUM: stats: expose the same flags for CLI and HTTP accesses

The HTML dump over HTTP request may have several flags including
ST_SHLGNDS (to show legends), ST_SHNODE (to show node name),
ST_SHDESC (to show some descriptions).

There's no such thing over the CLI so we need to have an equivalent.
Let's compute the flags earlier so that we can make use of these flags
regardless of the call point.

9 years agoMEDIUM: stats: only report observe errors when observe is set
Willy Tarreau [Fri, 8 Jan 2016 14:12:28 +0000 (15:12 +0100)] 
MEDIUM: stats: only report observe errors when observe is set

This doesn't produce this field when not relevant anymore.

9 years agoMEDIUM: stats: make the HTML server state dump use the CSV states
Willy Tarreau [Fri, 8 Jan 2016 13:57:09 +0000 (14:57 +0100)] 
MEDIUM: stats: make the HTML server state dump use the CSV states

Now instead of recomputing the state based on the health, rise etc,
we reuse the same state as in the CSV file, and optionally complete
it with a down or an up arrow if a change is occurring. We could
have parsed the strings to detect a '/' indicating a state change,
but it was easier to check the health against rise and fall.

9 years agoMINOR: stats: add check and agent's health values in the output
Willy Tarreau [Fri, 8 Jan 2016 13:25:28 +0000 (14:25 +0100)] 
MINOR: stats: add check and agent's health values in the output

This adds the following fields :
- check_rise [...S]: server's "rise" parameter used by checks
- check_fall [...S]: server's "fall" parameter used by checks
- check_health [...S]: server's health check value between 0 and rise+fall-1
- agent_rise [...S]: agent's "rise" parameter, normally 1
- agent_fall [...S]: agent's "fall" parameter, normally 1
- agent_health [...S]: agent's health parameter, between 0 and rise+fall-1

9 years agoMINOR: stats: add check_desc and agent_desc to the output fields
Willy Tarreau [Fri, 8 Jan 2016 12:47:26 +0000 (13:47 +0100)] 
MINOR: stats: add check_desc and agent_desc to the output fields

Added these two new fields to the CSV output :
- check_desc : short human-readable description of check_status
- agent_desc : short human-readable description of agent_status

Also factor two tests for enabled checks.

9 years agoMINOR: stats: add agent_status, agent_code, agent_duration to output
Willy Tarreau [Fri, 8 Jan 2016 10:40:03 +0000 (11:40 +0100)] 
MINOR: stats: add agent_status, agent_code, agent_duration to output

The agent check status is now reported :
- agent_status : status of last agent check
- agent_code : numeric code reported by agent if any (unused for now)
- agent_duration : time in ms taken to finish last check

9 years agoMINOR: stats: make HTML stats dump rely on the table for the check status
Willy Tarreau [Fri, 8 Jan 2016 08:48:26 +0000 (09:48 +0100)] 
MINOR: stats: make HTML stats dump rely on the table for the check status

We can now check that the check status field is present to know that a
check is enabled.

9 years agoMINOR: stats: prepend '*' in front of the check status when in progress
Willy Tarreau [Fri, 8 Jan 2016 08:43:54 +0000 (09:43 +0100)] 
MINOR: stats: prepend '*' in front of the check status when in progress

The HTML version already does this, but the CSV doesn't provide this
status, so make both of them report the same status.

9 years agoMINOR: stats: only report backend's down time if it has servers
Willy Tarreau [Mon, 11 Jan 2016 11:04:02 +0000 (12:04 +0100)] 
MINOR: stats: only report backend's down time if it has servers

There's no point in reporting a backend's up/down time if it has no
servers. The CSV output used to report "0" for a serverless backend
while the HTML version already removed the field. For servers, this
field is already omitted if checks are disabled. Let's uniformize
all of this and remove the field in CSV as well when irrelevant.

9 years agoMINOR: stats: make CSV report server check status only when enabled
Willy Tarreau [Fri, 8 Jan 2016 08:41:59 +0000 (09:41 +0100)] 
MINOR: stats: make CSV report server check status only when enabled

The HTML version doesn't report a check status when the server is in
maintenance since it can be quite old and irrelevant. The CSV forgot
to care about that, so let's do it here as well.

9 years agoMINOR: stats: do not check srv->state for SRV_ST_STOPPED in HTML dumps
Willy Tarreau [Thu, 7 Jan 2016 12:59:10 +0000 (13:59 +0100)] 
MINOR: stats: do not check srv->state for SRV_ST_STOPPED in HTML dumps

We don't want the HTML dump to rely on the server state. We
already have this piece of information in the status field by
checking that it starts with "DOWN".

9 years agoMINOR: stats: do not use srv->admin & STATS_ADMF_MAINT in HTML dumps
Willy Tarreau [Thu, 7 Jan 2016 11:59:57 +0000 (12:59 +0100)] 
MINOR: stats: do not use srv->admin & STATS_ADMF_MAINT in HTML dumps

We don't want the HTML dump to rely on the server admin bits. We
already have this piece of information in the status field.

9 years agoMEDIUM: stats: move the server state coloring logic to the server dump function
Willy Tarreau [Thu, 7 Jan 2016 08:54:40 +0000 (09:54 +0100)] 
MEDIUM: stats: move the server state coloring logic to the server dump function

It currently is really not convenient to have a state and a color detection
outside of the function and to use these ones inside. It makes it harder to
adjust the stats output based on the server state exactly. Let's move the
logic into the dump function itself.

9 years agoMEDIUM: stats: make stats_dump_sv_stats() use the stats field for HTML
Willy Tarreau [Wed, 6 Jan 2016 18:48:21 +0000 (19:48 +0100)] 
MEDIUM: stats: make stats_dump_sv_stats() use the stats field for HTML

Here we still have a huge amount of stuff to extract from the HTML code
and even from the caller. Indeed, the calling function computes the
server state and prepares a color code that will be used to determine
what style to use. The operations needed to decide what field to present
or not depend a lot on the server's state, admin state, health value,
rise and fall etc... all of which are not easily present in the table.

We also have to check the reference's values for all of the above.

There are also a number of differences between the CSV and HTML outputs :
  - CSV always reports check duration, HTML only if not zero
  - regarding last_change, CSV always report the server's while the HTML
    considers either the server's or the reference based on the admin state.
  - agent and health are separate in the CSV but mixed in the HTML.
  - too few info on agent anyway.

After careful code inspection it happens that both sv->last_change and
ref->last_change are identical and can both derive from [LASTCHG].

Also, the following info are missing from the array to complete the HTML
code :
  - cookie, address, status description, check-in-progress, srv->admin

At least for now it still works but a lot of info now need to be added.

9 years agoMEDIUM: stats: convert stats_dump_sv_stats() to use stats_dump_fields_csv()
Willy Tarreau [Wed, 6 Jan 2016 18:25:38 +0000 (19:25 +0100)] 
MEDIUM: stats: convert stats_dump_sv_stats() to use stats_dump_fields_csv()

This function now only fills the relevant fields with raw values and
calls stats_dump_fields_csv() for the CSV part. The output remains
exactly the same for now.

Some limits are only emitted if set, so the HTML part will have to
check for these being set.

A number of fields had to be built using printf-format strings, so
instead of allocating strings that risk not being freed, we use
chunk_newstr() and chunk_appendf().

Text strings are now copied verbatim in the stats fields so that only
the CSV dump encodes them as CSV. A single "out" chunk is used and cut
into multiple substrings using chunk_newstr() so that we don't need
distinct chunks for each stats field holding a string. The total amount
of data being emitted at once will never overflow the "out" chunk since
only a small part of it goes into the trash buffer which is the same size
and will thus overflow first.

One point of care is that failed_checks and down_trans were logged as
64-bit quantities on servers but they're 32-bit on proxies. This may
have to be changed later to unify them.

9 years agoMEDIUM: stats: make stats_dump_be_stats() use stats fields for HTML dump
Willy Tarreau [Wed, 6 Jan 2016 16:14:42 +0000 (17:14 +0100)] 
MEDIUM: stats: make stats_dump_be_stats() use stats fields for HTML dump

Some fields are still needed to complete the conversion :
  - px->srv : used to take decisions when backend has no server (eg: print down or not)
  - algo string (useful for CSV as well) // only if SHLGNDS
  - cookie_name (useful for CSV as well) // only if SHLGNDS
  - px->mode == HTTP (or px->mode as a string) // same for frontend
  - px->be_counters.intercepted_req (stats and redirects ?)

The following field already has a place but was not presented in the
CSV output, so it should simply be added afterwards :
  - px->be_counters.http.cum_req (was in HTML and missing from CSV)

9 years agoMEDIUM: stats: convert stats_dump_be_stats() to use stats_dump_fields_csv()
Willy Tarreau [Wed, 6 Jan 2016 15:14:50 +0000 (16:14 +0100)] 
MEDIUM: stats: convert stats_dump_be_stats() to use stats_dump_fields_csv()

This function now only fills the relevant fields with raw values and
calls stats_dump_fields_csv() for the CSV part. The output remains
exactly the same for now. It's worth noting that there are some
ambiguities between connections and sessions, for example cum_conn
is dumped into cum_sess. Additionally, there is a naming ambiguity
in that the internal "d_time" (time where the beginning of data
appeared) is called "rtime" in the output (response time) and they
actually are indeed the same.

9 years agoMEDIUM: stats: make stats_dump_li_stats() use stats fields for HTML dump
Willy Tarreau [Wed, 6 Jan 2016 14:49:26 +0000 (15:49 +0100)] 
MEDIUM: stats: make stats_dump_li_stats() use stats fields for HTML dump

The conversion still requires some elements which are not present in the
current fields :
  - the HTML status may emit "WAITING"/"OPEN"/"FULL" while the CSV format
    doesn't propose "WAITING", so this last one will have to be added.

  - the HTML output emits the listening adresses when the ST_SHLGNDS flag
    is set but this address field doesn't exist in the CSV format

  - it's interesting to note that when the ST_SHLGNDS flag is not set, the
    HTML output doesn't provide the listener's ID while it's present in the
    CSV output accessible from the same interface.

9 years agoMEDIUM: stats: convert stats_dump_li_stats() to use stats_dump_fields_csv()
Willy Tarreau [Wed, 6 Jan 2016 14:41:29 +0000 (15:41 +0100)] 
MEDIUM: stats: convert stats_dump_li_stats() to use stats_dump_fields_csv()

This function now only fills the relevant fields with raw values and
calls stats_dump_fields_csv() for the CSV part. The output remains
exactly the same for now.

It is worth mentionning that l->cum_conn is being dumped into a cum_sess
field and that once we introduce an official cum_conn field we may have
to dump the same value at both places to maintain compatibility with the
existing stats.

9 years agoMEDIUM: stats: make stats_dump_fe_stats() use stats fields for HTML dump
Willy Tarreau [Wed, 6 Jan 2016 14:26:40 +0000 (15:26 +0100)] 
MEDIUM: stats: make stats_dump_fe_stats() use stats fields for HTML dump

Now we avoid directly accessing the proxy and instead we pick the values
from the stats fields. This unveils that only a few fields are missing to
complete the job :
  - know whether or not the checkbox column needs to be displayed. This
    is not directly relevant to the stats but rather to the fact that the
    HTML dump is also a control interface. This doesn't need a field, just
    a function argument.
  - px->mode == HTTP (or px->mode as a string)
  - px->fe_counters.intercepted_req (stats and redirects ?)
  - px->fe_counters.cum_conn
  - px->fe_counters.cps_max
  - px->fe_conn_per_sec

All the last ones make sense in the CSV, so they'll have to be added as well.

9 years agoMEDIUM: stats: convert stats_dump_fe_stats() to use stats_dump_fields_csv()
Willy Tarreau [Mon, 4 Jan 2016 18:36:41 +0000 (19:36 +0100)] 
MEDIUM: stats: convert stats_dump_fe_stats() to use stats_dump_fields_csv()

This function now only fills the relevant fields with raw values and
calls stats_dump_fields_csv() for the CSV part. The output remains
exactly the same for now.

9 years agoMINOR: stats: create stats fields storage and CSV dump function
Willy Tarreau [Mon, 4 Jan 2016 18:04:18 +0000 (19:04 +0100)] 
MINOR: stats: create stats fields storage and CSV dump function

The new function stats_dump_fields_csv() currenty walks over all CSV
fields and prints all non-empty ones as one line. Strings are csv-encoded
on the fly.

9 years agoMINOR: stats: don't hard-code the CSV fields list anymore
Willy Tarreau [Mon, 4 Jan 2016 16:24:29 +0000 (17:24 +0100)] 
MINOR: stats: don't hard-code the CSV fields list anymore

Now the list of CSV fields is directly taken from the table.

9 years agoMINOR: stats: add a declaration of all stats fields
Willy Tarreau [Mon, 4 Jan 2016 16:23:25 +0000 (17:23 +0100)] 
MINOR: stats: add a declaration of all stats fields

This is in preparation for a unifying of the stats output between the
multiple formats. The long-term goal will be that HTML stats are built
from the array used to produce the CSV output in order to ensure that
no information is missing in any format.

9 years agoMEDIUM: stats: make use of stats_dump_info_fields() for "show info"
Willy Tarreau [Mon, 11 Jan 2016 17:29:04 +0000 (18:29 +0100)] 
MEDIUM: stats: make use of stats_dump_info_fields() for "show info"

Now we can get rid of the huge chunk_printf() and use this new function
instead.

9 years agoMINOR: stats: add stats_dump_info_fields() to dump one field per line
Willy Tarreau [Mon, 11 Jan 2016 17:27:29 +0000 (18:27 +0100)] 
MINOR: stats: add stats_dump_info_fields() to dump one field per line

This function dumps non-empty fields, one per line with their name and
values, in the same format as is currently used by "show info". It relies
on previously added stats_emit_raw_data_field().

9 years agoMINOR: stats: add a function to emit fields into a chunk
Willy Tarreau [Wed, 24 Feb 2016 22:11:01 +0000 (23:11 +0100)] 
MINOR: stats: add a function to emit fields into a chunk

New function stats_emit_raw_data_field() may be used to write a field
into a chunk. It takes care of the field format to know how to print
it.

9 years agoMEDIUM: stats: fill all the show info elements prior to displaying them
Willy Tarreau [Mon, 11 Jan 2016 17:17:07 +0000 (18:17 +0100)] 
MEDIUM: stats: fill all the show info elements prior to displaying them

The table is completely filled with all relevant information. Only the
fields that should appear are presented. The description field is now
properly omitted if not set, instead of being reported as empty.

9 years agoMINOR: stats: add all the "show info" fields in a table
Willy Tarreau [Mon, 11 Jan 2016 17:12:26 +0000 (18:12 +0100)] 
MINOR: stats: add all the "show info" fields in a table

This will be used to dump them in the most appropriate format.

9 years agoMINOR: stats: create fields types suitable for all CSV output data
Willy Tarreau [Mon, 4 Jan 2016 16:23:25 +0000 (17:23 +0100)] 
MINOR: stats: create fields types suitable for all CSV output data

We're preparing for various data types for each stats field as they
appear in the CSV output. For now we only cover the regular types handled
by printf, so we have 32 and 64 bit ints and counters, strings, and of
course "empty" to indicate that there's nothing in the field and which
guarantees that any accessed entry will return 0.

More types will surely come later so that some fields are properly
represented. For example, we could see limits where only the value 0
doesn't show up, or human time, etc.

9 years agoBUG/MINOR: ssl: fix usage of the various sample fetch functions
Willy Tarreau [Thu, 10 Mar 2016 16:05:28 +0000 (17:05 +0100)] 
BUG/MINOR: ssl: fix usage of the various sample fetch functions

Technically speaking, many SSL sample fetch functions act on the
connection and depend on USE_L5CLI on the client side, which means
they're usable as soon as a handshake is completed on a connection.
This means that the test consisting in refusing to call them when
the stream is NULL will prevent them from working when we implement
the tcp-request session ruleset. Better fix this now. The fix consists
in using smp->sess->origin when they're called for the front connection,
and smp->strm->si[1].end when called for the back connection.

There is currently no known side effect for this issue, though it would
better be backported into 1.6 so that the code base remains consistend.

9 years agoCLEANUP: payload: remove useless and confusing nullity checks for channel buffer
Willy Tarreau [Thu, 10 Mar 2016 15:53:03 +0000 (16:53 +0100)] 
CLEANUP: payload: remove useless and confusing nullity checks for channel buffer

The buffer could not be null by definition since we moved the stream out
of the session. It's the stream which gained the ability to be NULL (hence
the recent fix for this case). The checks in place are useless and make one
think this situation can happen.

9 years agoBUG/MAJOR: vars: always retrieve the stream and session from the sample
Willy Tarreau [Thu, 10 Mar 2016 15:33:04 +0000 (16:33 +0100)] 
BUG/MAJOR: vars: always retrieve the stream and session from the sample

This is the continuation of previous patch called "BUG/MAJOR: samples:
check smp->strm before using it".

It happens that variables may have a session-wide scope, and that their
session is retrieved by dereferencing the stream. But nothing prevents them
from being used from a streamless context such as tcp-request connection,
thus crashing the process. Example :

    tcp-request connection accept if { src,set-var(sess.foo) -m found }

In order to fix this, we have to always ensure that variable manipulation
only happens via the sample, which contains the correct owner and context,
and that we never use one from a different source. This results in quite a
large change since a lot of functions are inderctly involved in the call
chain, but the change is easy to follow.

This fix must be backported to 1.6, and requires the last two patches.

9 years agoMINOR: sample: always set a new sample's owner before evaluating it
Willy Tarreau [Thu, 10 Mar 2016 15:28:58 +0000 (16:28 +0100)] 
MINOR: sample: always set a new sample's owner before evaluating it

Some functions like sample_conv_var2smp(), var_get_byname(), and
var_set_byname() directly or indirectly need to access the current
stream and/or session and must find it in the sample itself and not
as a distinct argument. Thus we first need to call smp_set_owner()
prior to each such calls.

9 years agoMINOR: sample: add a new helper to initialize the owner of a sample
Willy Tarreau [Thu, 10 Mar 2016 15:15:46 +0000 (16:15 +0100)] 
MINOR: sample: add a new helper to initialize the owner of a sample

Since commit 6879ad3 ("MEDIUM: sample: fill the struct sample with the
session, proxy and stream pointers") merged in 1.6-dev2, the sample
contains the pointer to the stream and sample fetch functions as well
as converters use it heavily. This requires from a lot of call places
to initialize 4 fields, and it was even forgotten at a few places.

This patch provides a convenient helper to initialize all these fields
at once, making it easy to prepare a new sample from a previous one for
example.

A few call places were cleaned up to make use of it. It will be needed
by further fixes.

At one place in the Lua code, it was moved earlier because we used to
call sample casts with a non completely initialized sample, which is
not clean eventhough at the moment there are no consequences.

9 years agoBUG/MAJOR: samples: check smp->strm before using it
Willy Tarreau [Thu, 10 Mar 2016 10:47:01 +0000 (11:47 +0100)] 
BUG/MAJOR: samples: check smp->strm before using it

Since commit 6879ad3 ("MEDIUM: sample: fill the struct sample with the
session, proxy and stream pointers") merged in 1.6-dev2, the sample
contains the pointer to the stream and sample fetch functions as well
as converters use it heavily.

The problem is that earlier commit 87b0966 ("REORG/MAJOR: session:
rename the "session" entity to "stream"") had split the session and
stream resulting in the possibility for smp->strm to be NULL before
the stream was initialized. This is what happens in tcp-request
connection rulesets, as discovered by Baptiste.

The sample fetch functions must now check that smp->strm is valid
before using it. An alternative could consist in using a dummy stream
with nothing in it to avoid some checks but it would only result in
deferring them to the next step anyway, and making it harder to detect
that a stream is valid or the dummy one.

There is still an issue with variables which requires a complete
independant fix. They use strm->sess to find the session with strm
possibly NULL and passed as an argument. All call places indirectly
use smp->strm to build strm. So the problem is there but the API needs
to be changed to remove this duplicate argument that makes it much
harder to know what pointer to use.

This fix must be backported to 1.6, as well as the next one fixing
variables.

9 years agoBUG/MINOR: tcpcheck: fix incorrect list usage resulting in failure to load certain...
Willy Tarreau [Tue, 8 Mar 2016 14:20:25 +0000 (15:20 +0100)] 
BUG/MINOR: tcpcheck: fix incorrect list usage resulting in failure to load certain configs

Commit baf9794 ("BUG/MINOR: tcpcheck: conf parsing error when no port
configured on server and first rule(s) is (are) COMMENT") was wrong, it
incorrectly implemented a list access by dereferencing a pointer of an
incorrect type resulting in checking the next element in the list. The
consequence is that it stops before the last comment instead of at the
last one and skips the first rule. In the end, rules starting with
comments are not affected, but if a sequence of checks directly starts
with connect, it is then skipped and this is visible when no port is
configured on the server line as the config refuses to load.

There was another occurence of the same bug a few lines below, both
of them were fixed. Tests were made on different configs and confirm
the new fix is OK.

This fix must be backported to 1.6.

9 years agoCLEANUP: map: Avoid memory leak in out-of-memory condition.
Andreas Seltenreich [Thu, 3 Mar 2016 19:32:23 +0000 (20:32 +0100)] 
CLEANUP: map: Avoid memory leak in out-of-memory condition.

This memory leak of about 100 bytes occurs only if there is an error
condidtion during evaluation of a "map" directive in the configuration
file.  This evaluation only happens once on startup because haproxy
does not have a mechanism for re-loading the configuration file during
run-time.  The startup will be aborted anyway due to error conditions
raised.

Nevertheless fix it to silence warnings of static code analysis tools
and be safe against future revisions of the code.

Found in haproxy 1.5.14.

9 years agoCLEANUP: pattern: Ignore unknown samples in pat_match_ip().
Andreas Seltenreich [Thu, 3 Mar 2016 19:08:35 +0000 (20:08 +0100)] 
CLEANUP: pattern: Ignore unknown samples in pat_match_ip().

Ignore samples that are neither SMP_T_IPV4 nor SMP_T_IPV6 instead of
matching with an uninitialized value in this case.

This situation should not occur in the current codebase but triggers
warnings in static code analysis tools.

Found in haproxy 1.5.

9 years agoCLEANUP: stats: Avoid computation with uninitialized bits.
Andreas Seltenreich [Thu, 3 Mar 2016 18:32:25 +0000 (19:32 +0100)] 
CLEANUP: stats: Avoid computation with uninitialized bits.

stats_map_lookup() sets bit SMP_F_CONST in the uninitialized member
flags of a stack-allocated sample, leaving the other bits
uninitialized.  All code paths that can access the struct only ever
check for this specific flag, so there is no risk of unintended
behavior.

Nevertheless fix it as it triggers warnings in static code analysis
tools and might become a problem on future revisions of the code.

Problem found in version 1.5.

9 years agoBUG/MEDIUM: cfgparse: wrong argument offset after parsing server "sni" keyword
Cyril Bonté [Mon, 7 Mar 2016 21:13:22 +0000 (22:13 +0100)] 
BUG/MEDIUM: cfgparse: wrong argument offset after parsing server "sni" keyword

Owen Marshall reported an issue depending on the server keywords order in the
configuration.

Working line :
  server dev1 <ip>:<port> check inter 5000 ssl verify none sni req.hdr(Host)

Non working line :
  server dev1 <ip>:<port> check inter 5000 ssl sni req.hdr(Host) verify none

Indeed, both parse_server() and srv_parse_sni() modified the current argument
offset at the same time. To fix the issue, srv_parse_sni() can work on a local
copy ot the offset, leaving parse_server() responsible of the actual value.

This fix must be backported to 1.6.