]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
11 years agoMEDIUM: listener: support rebinding during resume()
Willy Tarreau [Mon, 7 Jul 2014 19:06:24 +0000 (21:06 +0200)] 
MEDIUM: listener: support rebinding during resume()

When a listener resumes operations, supporting a full rebind makes it
possible to perform a full stop as a pause(). This will be used for
pausing abstract namespace unix sockets.

11 years agoMEDIUM: listener: implement a per-protocol pause() function
Willy Tarreau [Mon, 7 Jul 2014 18:22:12 +0000 (20:22 +0200)] 
MEDIUM: listener: implement a per-protocol pause() function

In order to fix the abstact socket pause mechanism during soft restarts,
we'll need to proceed differently depending on the socket protocol. The
pause_listener() function already supports some protocol-specific handling
for the TCP case.

This commit makes this cleaner by adding a new ->pause() function to the
protocol struct, which, if defined, may be used to pause a listener of a
given protocol.

For now, only TCP has been adapted, with the specific code moved from
pause_listener() to tcp_pause_listener().

11 years agoBUG/MEDIUM: unix: failed abstract socket binding is retryable
Willy Tarreau [Mon, 7 Jul 2014 16:36:45 +0000 (18:36 +0200)] 
BUG/MEDIUM: unix: failed abstract socket binding is retryable

Jan Seda noticed that abstract sockets are incompatible with soft reload,
because the new process cannot bind and immediately fails. This patch marks
the binding as retryable and not fatal so that the new process can try to
bind again after sending a signal to the old process.

Note that this fix is not enough to completely solve the problem, but it
is necessary. This patch should be backported to 1.5.

11 years agoBUG/MINOR: listener: set the listener's fd to -1 after deletion
Willy Tarreau [Mon, 7 Jul 2014 16:24:48 +0000 (18:24 +0200)] 
BUG/MINOR: listener: set the listener's fd to -1 after deletion

This is currently harmless, but when stopping a listener, its fd is
closed but not set to -1, so it is not possible to re-open it again.
Currently this has no impact but can have after the abstract sockets
are modified to perform a complete close on soft-reload.

The fix can be backported to 1.5 and may even apply to 1.4 (protocols.c).

11 years agoBUILD: http: fix isdigit & isspace warnings on Solaris
Willy Tarreau [Mon, 7 Jul 2014 22:59:48 +0000 (00:59 +0200)] 
BUILD: http: fix isdigit & isspace warnings on Solaris

As usual, when touching any is* function, Solaris complains about the
type of the element being checked. Better backport this to 1.5 since
nobody knows what the emitted code looks like since macros are used
instead of functions.

11 years agoBUILD: checks: kill a minor warning on Solaris in external checks
Willy Tarreau [Mon, 7 Jul 2014 22:56:27 +0000 (00:56 +0200)] 
BUILD: checks: kill a minor warning on Solaris in external checks

Gcc on Solaris complains that elem->pid is pid_t and that we display
it as int. A simple cast fixes this. No backport needed, this is 1.6
only.

11 years agoBUILD: checks: external checker needs signal.h
Willy Tarreau [Mon, 7 Jul 2014 22:54:10 +0000 (00:54 +0200)] 
BUILD: checks: external checker needs signal.h

check.c doesn't build on solaris since 98637e5 ("MEDIUM: Add external check")
because sigset_t is unknown. Simply include signal.h to fix the issue.

No need to backport, this is 1.6-only.

11 years agoDOC: provide an example of how to use ssl_c_sha1
Willy Tarreau [Wed, 2 Jul 2014 17:01:22 +0000 (19:01 +0200)] 
DOC: provide an example of how to use ssl_c_sha1

As suggested by Aydan Yumerefendi, a little bit of examples never hurts.

11 years agoBUG/MEDIUM: unix: do not unlink() abstract namespace sockets upon failure.
Jan Seda [Thu, 26 Jun 2014 18:44:05 +0000 (20:44 +0200)] 
BUG/MEDIUM: unix: do not unlink() abstract namespace sockets upon failure.

When bind() fails (function uxst_bind_listener()), the fail path doesn't
consider the abstract namespace and tries to unlink paths held in
uninitiliazed memory (tempname and backname). See the strace excerpt;
the strings still hold the path from test1.

===============================================================================================
23722 bind(5, {sa_family=AF_FILE, path=@"test2"}, 110) = -1 EADDRINUSE (Address already in use)
23722 unlink("/tmp/test1.sock.23722.tmp") = -1 ENOENT (No such file or directory)
23722 close(5)                          = 0
23722 unlink("/tmp/test1.sock.23722.bak") = -1 ENOENT (No such file or directory)
===============================================================================================

This patch should be backported to 1.5.

11 years agoMINOR: stats: fix minor typo in HTML page
Marco Corte [Wed, 2 Jul 2014 15:49:34 +0000 (17:49 +0200)] 
MINOR: stats: fix minor typo in HTML page

There is a very small typo in the statistics interface: a "set" in
lowercase where allothers are uppercase "Set".

11 years agoMEDIUM: log: support a user-configurable max log line length
Willy Tarreau [Fri, 27 Jun 2014 16:10:07 +0000 (18:10 +0200)] 
MEDIUM: log: support a user-configurable max log line length

With all the goodies supported by logformat, people find that the limit
of 1024 chars for log lines is too short. Some servers do not support
larger lines and can simply drop them, so changing the default value is
not always the best choice.

This patch takes a different approach. Log line length is specified per
log server on the "log" line, with a value between 80 and 65535. That
way it's possibly to satisfy all needs, even with some fat local servers
and small remote ones.

11 years agoMINOR: log: make MAX_SYSLOG_LEN overridable at build time
Willy Tarreau [Fri, 27 Jun 2014 16:08:49 +0000 (18:08 +0200)] 
MINOR: log: make MAX_SYSLOG_LEN overridable at build time

This value was set in log.h without any #ifndef around, so when one
wanted to change it, a patch was needed. Let's move it to defaults.h
with the usual #ifndef so that it's easier to change it.

11 years agoBUILD: remove TODO from the spec file and add README
Willy Tarreau [Thu, 26 Jun 2014 06:20:38 +0000 (08:20 +0200)] 
BUILD: remove TODO from the spec file and add README

This used to cause a build failure since 1.5.0, as reported by
Timothy Shelton. The proxy protocol doc was also added.

11 years agoBUG/MEDIUM: counters: fix track-sc* to wait on unstable contents
Willy Tarreau [Wed, 25 Jun 2014 15:01:56 +0000 (17:01 +0200)] 
BUG/MEDIUM: counters: fix track-sc* to wait on unstable contents

I've been facing multiple configurations which involved track-sc* rules
in tcp-request content without the "if ..." to force it to wait for the
contents, resulting in random behaviour with contents sometimes retrieved
and sometimes not.

Reading the doc doesn't make it clear either that the tracking will be
performed only if data are already there and that waiting on an ACL is
the only way to avoid this.

Since this behaviour is not natural and we now have the ability to fix
it, this patch ensures that if input data are still moving, instead of
silently dropping them, we naturally wait for them to stabilize up to
the inspect-delay. This way it's not needed anymore to implement an
ACL-based condition to force to wait for data, eventhough the behaviour
is not changed for when an ACL is present.

The most obvious usage will be when track-sc is followed by any HTTP
sample expression, there's no need anymore for adding "if HTTP".

It's probably worth backporting this to 1.5 to avoid further configuration
issues. Note that it requires previous patch.

11 years agoMINOR: stick-table: make stktable_fetch_key() indicate why it failed
Willy Tarreau [Wed, 25 Jun 2014 14:20:53 +0000 (16:20 +0200)] 
MINOR: stick-table: make stktable_fetch_key() indicate why it failed

stktable_fetch_key() does not indicate whether it returns NULL because
the input sample was not found or because it's unstable. It causes trouble
with track-sc* rules. Just like with sample_fetch_string(), we want it to
be able to give more information to the caller about what it found. Thus,
now we use the pointer to a sample passed by the caller, and fill it with
the information we have about the sample. That way, even if we return NULL,
the caller has the ability to check whether a sample was found and if it is
still changing or not.

11 years agoBUG/MAJOR: sample: correctly reinitialize sample fetch context before calling sample_...
Willy Tarreau [Wed, 25 Jun 2014 14:56:41 +0000 (16:56 +0200)] 
BUG/MAJOR: sample: correctly reinitialize sample fetch context before calling sample_process()

We used to only clear flags when reusing the static sample before calling
sample_process(), but that's not enough because there's a context in samples
that can be used by some fetch functions such as auth, headers and cookies,
and not reinitializing it risks that a pointer of a different type is used
in the wrong context.

An example configuration which triggers the case consists in mixing hdr()
and http_auth_group() which both make use of contexts :

     http-request add-header foo2 %[hdr(host)],%[http_auth_group(foo)]

The solution is simple, initialize all the sample and not just the flags.
This fix must be backported into 1.5 since it was introduced in 1.5-dev19.

11 years agoBUG/MINOR: counters: do not untrack counters before logging
Willy Tarreau [Wed, 25 Jun 2014 13:36:04 +0000 (15:36 +0200)] 
BUG/MINOR: counters: do not untrack counters before logging

Baptiste Assmann reported a corner case in the releasing of stick-counters:
we release content-aware counters before logging. In the past it was not a
problem, but since now we can log them it, it prevents one from logging
their value. Simply switching the log production and the release of the
counter fixes the issue.

This should be backported into 1.5.

11 years agoBUG/MINOR: ssl: Fix external function in order not to return a pointer on an internal...
Emeric Brun [Tue, 24 Jun 2014 16:26:41 +0000 (18:26 +0200)] 
BUG/MINOR: ssl: Fix external function in order not to return a pointer on an internal trash buffer.

'ssl_sock_get_common_name' applied to a connection was also renamed
'ssl_sock_get_remote_common_name'. Currently, this function is only used
with protocol PROXYv2 to retrieve the client certificate's common name.
A further usage could be to retrieve the server certificate's common name
on an outgoing connection.

11 years agoBUG/MEDIUM: http: fetch "base" is not compatible with set-header
Willy Tarreau [Tue, 24 Jun 2014 15:27:02 +0000 (17:27 +0200)] 
BUG/MEDIUM: http: fetch "base" is not compatible with set-header

The sample fetch function "base" makes use of the trash which is also
used by set-header/add-header etc... everything which builds a formated
line. So we end up with some junk in the header if base is in use. Let's
fix this as all other fetches by using a trash chunk instead.

This bug was reported by Baptiste Assmann, and also affects 1.5.

11 years agoBUG/MINOR: config: http-request replace-header arg typo
Baptiste Assmann [Tue, 24 Jun 2014 09:10:00 +0000 (11:10 +0200)] 
BUG/MINOR: config: http-request replace-header arg typo

http-request replace-header was introduced with a typo which prevents it
to be conditionned by an ACL.
This patch fixes this issue.

11 years agoBUG/MINOR: logs: properly initialize and count log sockets
Willy Tarreau [Mon, 23 Jun 2014 16:07:15 +0000 (18:07 +0200)] 
BUG/MINOR: logs: properly initialize and count log sockets

Commit 81ae195 ("[MEDIUM] add support for logging via a UNIX socket")
merged in 1.3.14 introduced a few minor issues with log sockets. All
of them happen only when a failure is encountered when trying to set
up the logging socket (eg: socket family is not available or is
temporarily short in resources).

The first socket which experiences an error causes the socket setup
loop to abort, possibly preventing any log from being sent if it was
the first logger. The second issue is that if this socket finally
succeeds after a second attempt, errors are reported for the wrong
logger (eg: logger #1 failed instead of #2).  The last point is that
we now have multiple loggers, and it's a waste of time to walk over
their list for every log while they're almost always properly set up.

So in order to fix all this, let's merge the two lists. If a logger
experiences an error, it simply sends an alert and skips to the next
one. That way they don't prevent messages from being sent and are
all properly accounted for.

11 years agoBUG/MAJOR: session: revert all the crappy client-side timeout changes
Willy Tarreau [Mon, 23 Jun 2014 13:22:31 +0000 (15:22 +0200)] 
BUG/MAJOR: session: revert all the crappy client-side timeout changes

This is the 3rd regression caused by the changes below. The latest to
date was reported by Finn Arne Gangstad. If a server responds with no
content-length and the client's FIN is never received, either we leak
the client-side FD or we spin at 100% CPU if timeout client-fin is set.

Enough is enough. The amount of tricks needed to cover these side-effects
starts to look like used toilet paper stacked over a chocolate cake. I
don't want to eat that cake anymore!

All this to avoid reporting a server-side timeout when a client stops
uploading data and haproxy expires faster than the server... A lot of
"ifs" resulting in a technically valid log that doesn't always please
users, and whose alternative causes that many issues for all others
users.

So let's revert this crap merged since 1.5-dev25 :
  Revert "CLEANUP: http: don't clear CF_READ_NOEXP twice"
    This reverts commit 1592d1e72a4a2d25a554c299ae95a3e6cad80bf1.
  Revert "BUG/MEDIUM: http: clear CF_READ_NOEXP when preparing a new transaction"
    This reverts commit 77d29029af1c44216b190dd7442964b9d8f45257.
  Revert "BUG/MEDIUM: session: don't clear CF_READ_NOEXP if analysers are not called"
    This reverts commit 0943757a2144761c60e416b5ed07baa76934f5a4.
  Revert "BUG/MEDIUM: http: disable server-side expiration until client has sent the body"
    This reverts commit 3bed5e9337fd6eeab0f0006ebefcbe98ee5c4f9f.
  Revert "BUG/MEDIUM: http: correctly report request body timeouts"
    This reverts commit b9edf8fbecc9d1b5c82794735adcc367a80a4ae2.
  Revert "BUG/MEDIUM: http/session: disable client-side expiration only after body"
    This reverts commit b1982e27aaff2a92a389a9f1bc847e3bb8fdb4f2.

If a cleaner AND SAFER way to do something equivalent in 1.6-dev, we *might*
consider backporting it to 1.5, but given the vicious bugs that have surfaced
since, I doubt it will happen any time soon.

Fortunately, that crap never made it into 1.4 so no backport is needed.

11 years agoBUG/MINOR: ssl: Fix OCSP resp update fails with the same certificate configured twice.
Emeric Brun [Fri, 20 Jun 2014 13:37:32 +0000 (15:37 +0200)] 
BUG/MINOR: ssl: Fix OCSP resp update fails with the same certificate configured twice.

11 years agoBUG/MEDIUM: ssl: Fix to not serve expired OCSP responses.
Emeric Brun [Fri, 20 Jun 2014 13:46:13 +0000 (15:46 +0200)] 
BUG/MEDIUM: ssl: Fix to not serve expired OCSP responses.

For some browsers (firefox), an expired OCSP Response causes unwanted behavior.

Haproxy stops serving OCSP response if nextupdate date minus
the supported time skew (#define OCSP_MAX_RESPONSE_TIME_SKEW) is
in the past.

11 years agoBUG/MINOR: ssl: rejects OCSP response without nextupdate.
Emeric Brun [Fri, 20 Jun 2014 13:44:34 +0000 (15:44 +0200)] 
BUG/MINOR: ssl: rejects OCSP response without nextupdate.

To cache an OCSP Response without expiration time is not safe.

11 years agoMEDIUM: Add external check
Simon Horman [Fri, 20 Jun 2014 03:30:16 +0000 (12:30 +0900)] 
MEDIUM: Add external check

Add an external check which makes use of an external process to
check the status of a server.

11 years agoBUG/MEDIUM: Consistently use 'check' in process_chk
Simon Horman [Fri, 20 Jun 2014 03:29:47 +0000 (12:29 +0900)] 
BUG/MEDIUM: Consistently use 'check' in process_chk

I am not entirely sure that this is a bug, but it seems
to me that it may cause a problem if there agent-check is
configured and there is some kind of error making a connection for it.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years ago[DEV] open new 1.6 development branch v1.6-dev0
Willy Tarreau [Thu, 19 Jun 2014 19:10:58 +0000 (21:10 +0200)] 
[DEV] open new 1.6 development branch

This new branch is based on 1.5.0, which 1.6-dev0 is 100% equivalent to.
The README has been updated to mention that it is a development branch.

Released version 1.6-dev0 with the following main changes :
    - exact copy of 1.5.0

11 years ago[RELEASE] Released version 1.5.0 v1.5.0
Willy Tarreau [Thu, 19 Jun 2014 19:01:06 +0000 (21:01 +0200)] 
[RELEASE] Released version 1.5.0

Released version 1.5.0 with the following main changes :
    - MEDIUM: ssl: ignored file names ending as '.issuer' or '.ocsp'.
    - MEDIUM: ssl: basic OCSP stapling support.
    - MINOR: ssl/cli: Fix unapropriate comment in code on 'set ssl ocsp-response'
    - MEDIUM: ssl: add 300s supported time skew on OCSP response update.
    - MINOR: checks: mysql-check: Add support for v4.1+ authentication
    - MEDIUM: ssl: Add the option to use standardized DH parameters >= 1024 bits
    - MEDIUM: ssl: fix detection of ephemeral diffie-hellman key exchange by using the cipher description.
    - MEDIUM: http: add actions "replace-header" and "replace-values" in http-req/resp
    - MEDIUM: Break out check establishment into connect_chk()
    - MEDIUM: Add port_to_str helper
    - BUG/MEDIUM: fix ignored values for half-closed timeouts (client-fin and server-fin) in defaults section.
    - BUG/MEDIUM: Fix unhandled connections problem with systemd daemon mode and SO_REUSEPORT.
    - MINOR: regex: fix a little configuration memory leak.
    - MINOR: regex: Create JIT compatible function that return match strings
    - MEDIUM: regex: replace all standard regex function by own functions
    - MEDIUM: regex: Remove null terminated strings.
    - MINOR: regex: Use native PCRE API.
    - MINOR: missing regex.h include
    - DOC: Add Exim as Proxy Protocol implementer.
    - BUILD: don't use type "uint" which is not portable
    - BUILD: stats: workaround stupid and bogus -Werror=format-security behaviour
    - BUG/MEDIUM: http: clear CF_READ_NOEXP when preparing a new transaction
    - CLEANUP: http: don't clear CF_READ_NOEXP twice
    - DOC: fix proxy protocol v2 decoder example
    - DOC: fix remaining occurrences of "pattern extraction"
    - MINOR: log: allow the HTTP status code to be logged even in TCP frontends
    - MINOR: logs: don't limit HTTP header captures to HTTP frontends
    - MINOR: sample: improve sample_fetch_string() to report partial contents
    - MINOR: capture: extend the captures to support non-header keys
    - MINOR: tcp: prepare support for the "capture" action
    - MEDIUM: tcp: add a new tcp-request capture directive
    - MEDIUM: session: allow shorter retry delay if timeout connect is small
    - MEDIUM: session: don't apply the retry delay when redispatching
    - MEDIUM: session: redispatch earlier when possible
    - MINOR: config: warn when tcp-check rules are used without option tcp-check
    - BUG/MINOR: connection: make proxy protocol v1 support the UNKNOWN protocol
    - DOC: proxy protocol example parser was still wrong
    - DOC: minor updates to the proxy protocol doc
    - CLEANUP: connection: merge proxy proto v2 header and address block
    - MEDIUM: connection: add support for proxy protocol v2 in accept-proxy
    - MINOR: tools: add new functions to quote-encode strings
    - DOC: clarify the CSV format
    - MEDIUM: stats: report the last check and last agent's output on the CSV status
    - MINOR: freq_ctr: introduce a new averaging method
    - MEDIUM: session: maintain per-backend and per-server time statistics
    - MEDIUM: stats: report per-backend and per-server time stats in HTML and CSV outputs
    - BUG/MINOR: http: fix typos in previous patch
    - DOC: remove the ultra-obsolete TODO file
    - DOC: update roadmap
    - DOC: minor updates to the README
    - DOC: mention the maxconn limitations with the select poller
    - DOC: commit a few old design thoughts files

11 years agoDOC: commit a few old design thoughts files
Willy Tarreau [Thu, 19 Jun 2014 14:03:41 +0000 (16:03 +0200)] 
DOC: commit a few old design thoughts files

These ones were design notes and ideas collected during the 1.5
development phase lying on my development machine. There might still
be some value in keeping them for future reference since they mention
certain corner cases.

11 years agoDOC: mention the maxconn limitations with the select poller
Willy Tarreau [Thu, 19 Jun 2014 13:31:25 +0000 (15:31 +0200)] 
DOC: mention the maxconn limitations with the select poller

Select()'s safe area is limited to 1024 FDs, and anything higher
than this will report "select: FAILED" on startup in debug mode,
so better document it.

11 years agoDOC: minor updates to the README
Willy Tarreau [Thu, 19 Jun 2014 13:26:32 +0000 (15:26 +0200)] 
DOC: minor updates to the README

- mention that this is a stable version
- stop mentionning the outdated contrib.html page.

11 years agoDOC: update roadmap
Willy Tarreau [Thu, 19 Jun 2014 12:49:40 +0000 (14:49 +0200)] 
DOC: update roadmap

1.5-dev is closed, it will not get any more updates.

11 years agoDOC: remove the ultra-obsolete TODO file
Willy Tarreau [Thu, 19 Jun 2014 13:54:30 +0000 (15:54 +0200)] 
DOC: remove the ultra-obsolete TODO file

This one was still written in french and outdated since 1.4 or so.

11 years agoMEDIUM: ssl: add 300s supported time skew on OCSP response update.
Emeric Brun [Thu, 19 Jun 2014 12:16:17 +0000 (14:16 +0200)] 
MEDIUM: ssl: add 300s supported time skew on OCSP response update.

OCSP_MAX_RESPONSE_TIME_SKEW can be set to a different value at
compilation (default is 300 seconds).

11 years agoMINOR: ssl/cli: Fix unapropriate comment in code on 'set ssl ocsp-response'
Emeric Brun [Thu, 19 Jun 2014 12:10:45 +0000 (14:10 +0200)] 
MINOR: ssl/cli: Fix unapropriate comment in code on 'set ssl ocsp-response'

11 years agoMINOR: missing regex.h include
Thierry FOURNIER [Thu, 19 Jun 2014 11:37:01 +0000 (13:37 +0200)] 
MINOR: missing regex.h include

11 years agoMEDIUM: ssl: basic OCSP stapling support.
Emeric Brun [Mon, 16 Jun 2014 16:36:30 +0000 (18:36 +0200)] 
MEDIUM: ssl: basic OCSP stapling support.

The support is all based on static responses. This doesn't add any
request / response logic to HAProxy, but allows a way to update
information through the socket interface.

Currently certificates specified using "crt" or "crt-list" on "bind" lines
are loaded as PEM files.
For each PEM file, haproxy checks for the presence of file at the same path
suffixed by ".ocsp". If such file is found, support for the TLS Certificate
Status Request extension (also known as "OCSP stapling") is automatically
enabled. The content of this file is optional. If not empty, it must contain
a valid OCSP Response in DER format. In order to be valid an OCSP Response
must comply with the following rules: it has to indicate a good status,
it has to be a single response for the certificate of the PEM file, and it
has to be valid at the moment of addition. If these rules are not respected
the OCSP Response is ignored and a warning is emitted. In order to  identify
which certificate an OCSP Response applies to, the issuer's certificate is
necessary. If the issuer's certificate is not found in the PEM file, it will
be loaded from a file at the same path as the PEM file suffixed by ".issuer"
if it exists otherwise it will fail with an error.

It is possible to update an OCSP Response from the unix socket using:

  set ssl ocsp-response <response>

This command is used to update an OCSP Response for a certificate (see "crt"
on "bind" lines). Same controls are performed as during the initial loading of
the response. The <response> must be passed as a base64 encoded string of the
DER encoded response from the OCSP server.

Example:
  openssl ocsp -issuer issuer.pem -cert server.pem \
               -host ocsp.issuer.com:80 -respout resp.der
  echo "set ssl ocsp-response $(base64 -w 10000 resp.der)" | \
               socat stdio /var/run/haproxy.stat

This feature is automatically enabled on openssl 0.9.8h and above.

This work was performed jointly by Dirkjan Bussink of GitHub and
Emeric Brun of HAProxy Technologies.

11 years agoMEDIUM: ssl: ignored file names ending as '.issuer' or '.ocsp'.
Emeric Brun [Wed, 18 Jun 2014 16:15:09 +0000 (18:15 +0200)] 
MEDIUM: ssl: ignored file names ending as '.issuer' or '.ocsp'.

We don't want to load these files found in directories specified in "crt" or
"crt-list".

These suffixes are reserved for OCSP stapling.

11 years agoMINOR: regex: Use native PCRE API.
Thierry FOURNIER [Wed, 18 Jun 2014 09:50:51 +0000 (11:50 +0200)] 
MINOR: regex: Use native PCRE API.

The pcreposix layer (in the pcre projetc) execute strlen to find
thlength of the string. When we are using the function "regex_exex*2",
the length is used to add a final \0, when pcreposix is executed a
strlen is executed to compute the length.

If we are using a native PCRE api, the length is provided as an
argument, and these operations disappear.

This is useful because PCRE regex are more used than POSIC regex.

11 years agoMEDIUM: regex: Remove null terminated strings.
Thierry FOURNIER [Wed, 18 Jun 2014 09:53:08 +0000 (11:53 +0200)] 
MEDIUM: regex: Remove null terminated strings.

The new regex function can use string and length. The HAproxy buffer are
not null-terminated, and the use of the regex_exec* functions implies
the add of this null character. This patch replace these function by the
functions which takes a string and length as input.

Just the file "proto_http.c" is change because this one is more executed
than other. The file "checks.c" have a very low usage, and it is not
interesting to change it. Furthermore, the buffer used by "checks.c" are
null-terminated.

11 years agoMEDIUM: regex: replace all standard regex function by own functions
Thierry FOURNIER [Wed, 18 Jun 2014 09:35:54 +0000 (11:35 +0200)] 
MEDIUM: regex: replace all standard regex function by own functions

This patch remove all references of standard regex in haproxy. The last
remaining references are only in the regex.[ch] files.

In the file src/checks.c, the original function uses a "pmatch" array.
In fact this array is unused. This patch remove it.

11 years agoMINOR: regex: Create JIT compatible function that return match strings
Thierry FOURNIER [Wed, 11 Jun 2014 11:59:05 +0000 (13:59 +0200)] 
MINOR: regex: Create JIT compatible function that return match strings

This patchs rename the "regex_exec" to "regex_exec2". It add a new
"regex_exec", "regex_exec_match" and "regex_exec_match2" function. This
function can match regex and return array containing matching parts.
Otherwise, this function use the compiled method (JIT or PCRE or POSIX).

JIT require a subject with length. PCREPOSIX and native POSIX regex
require a null terminted subject. The regex_exec* function are splited
in two version. The first version take a null terminated string, but it
execute strlen() on the subject if it is compiled with JIT. The second
version (terminated by "2") take the subject and the length. This
version adds a null character in the subject if it is compiled with
PCREPOSIX or native POSIX functions.

The documentation of posix regex and pcreposix says that the function
returns 0 if the string matche otherwise it returns REG_NOMATCH. The
REG_NOMATCH macro take the value 1 with posix regex and the value 17
with the pcreposix. The documentaion of the native pcre API (used with
JIT) returns a negative number if no match, otherwise, it returns 0 or a
positive number.

This patch fix also the return codes of the regex_exec* functions. Now,
these function returns true if the string match, otherwise it returns
false.

11 years agoBUG/MINOR: http: fix typos in previous patch
Willy Tarreau [Tue, 17 Jun 2014 16:58:26 +0000 (18:58 +0200)] 
BUG/MINOR: http: fix typos in previous patch

When I renamed the modify-header action to replace-value, one of them
was mistakenly set to "replace-val" instead. Additionally, differentiation
of the two actions must be done on args[0][8] and not *args[8]. Thanks
Thierry for spotting...

11 years agoMEDIUM: http: add actions "replace-header" and "replace-values" in http-req/resp
Sasha Pachev [Mon, 16 Jun 2014 18:05:59 +0000 (12:05 -0600)] 
MEDIUM: http: add actions "replace-header" and "replace-values" in http-req/resp

This patch adds two new actions to http-request and http-response rulesets :
  - replace-header : replace a whole header line, suited for headers
                     which might contain commas
  - replace-value  : replace a single header value, suited for headers
                     defined as lists.

The match consists in a regex, and the replacement string takes a log-format
and supports back-references.

11 years agoMEDIUM: stats: report per-backend and per-server time stats in HTML and CSV outputs
Willy Tarreau [Tue, 17 Jun 2014 10:20:59 +0000 (12:20 +0200)] 
MEDIUM: stats: report per-backend and per-server time stats in HTML and CSV outputs

The time statistics computed by previous patches are now reported in the
HTML stats in the tips related to the total sessions for backend and servers,
and as separate columns for the CSV stats.

11 years agoMEDIUM: session: maintain per-backend and per-server time statistics
Willy Tarreau [Tue, 17 Jun 2014 10:19:18 +0000 (12:19 +0200)] 
MEDIUM: session: maintain per-backend and per-server time statistics

Using the last rate counters, we now compute the queue, connect, response
and total times per server and per backend with a 95% accuracy over the last
1024 samples. The operation is cheap so we don't need to condition it.

11 years agoMINOR: freq_ctr: introduce a new averaging method
Willy Tarreau [Mon, 16 Jun 2014 18:24:22 +0000 (20:24 +0200)] 
MINOR: freq_ctr: introduce a new averaging method

While the current functions report average event counts per period, we are
also interested in average values per event. For this we use a different
method. The principle is to rely on a long tail which sums the new value
with a fraction of the previous value, resulting in a sliding window of
infinite length depending on the precision we're interested in.

The idea is that we always keep (N-1)/N of the sum and add the new sampled
value. The sum over N values can be computed with a simple program for a
constant value 1 at each iteration :

    N
  ,---
   \       N - 1              e - 1
    >  ( --------- )^x ~= N * -----
   /         N                  e
  '---
  x = 1

Note: I'm not sure how to demonstrate this but at least this is easily
verified with a simple program, the sum equals N * 0.632120 for any N
moderately large (tens to hundreds).

Inserting a constant sample value V here simply results in :

   sum = V * N * (e - 1) / e

But we don't want to integrate over a small period, but infinitely. Let's
cut the infinity in P periods of N values. Each period M is exactly the same
as period M-1 with a factor of ((N-1)/N)^N applied. A test shows that given a
large N :

     N - 1           1
  ( ------- )^N ~=  ---
       N             e

Our sum is now a sum of each factor times  :

   N*P                                     P
  ,---                                   ,---
   \         N - 1               e - 1    \     1
    >  v ( --------- )^x ~= VN * -----  *  >   ---
   /           N                   e      /    e^x
  '---                                   '---
  x = 1                                  x = 0

For P "large enough", in tests we get this :

    P
  ,---
   \     1        e
    >   --- ~=  -----
   /    e^x     e - 1
  '---
  x = 0

This simplifies the sum above :

   N*P
  ,---
   \         N - 1
    >  v ( --------- )^x = VN
   /           N
  '---
  x = 1

So basically by summing values and applying the last result an (N-1)/N factor
we just get N times the values over the long term, so we can recover the
constant value V by dividing by N.

A value added at the entry of the sliding window of N values will thus be
reduced to 1/e or 36.7% after N terms have been added. After a second batch,
it will only be 1/e^2, or 13.5%, and so on. So practically speaking, each
old period of N values represents only a quickly fading ratio of the global
sum :

  period    ratio
    1       36.7%
    2       13.5%
    3       4.98%
    4       1.83%
    5       0.67%
    6       0.25%
    7       0.09%
    8       0.033%
    9       0.012%
   10       0.0045%

So after 10N samples, the initial value has already faded out by a factor of
22026, which is quite fast. If the sliding window is 1024 samples wide, it
means that a sample will only count for 1/22k of its initial value after 10k
samples went after it, which results in half of the value it would represent
using an arithmetic mean. The benefit of this method is that it's very cheap
in terms of computations when N is a power of two. This is very well suited
to record response times as large values will fade out faster than with an
arithmetic mean and will depend on sample count and not time.

Demonstrating all the above assumptions with maths instead of a program is
left as an exercise for the reader.

11 years agoMEDIUM: stats: report the last check and last agent's output on the CSV status
Willy Tarreau [Mon, 16 Jun 2014 14:40:14 +0000 (16:40 +0200)] 
MEDIUM: stats: report the last check and last agent's output on the CSV status

Now that we can quote unsafe string, it becomes possible to dump the health
check responses on the CSV page as well. The two new fields are "last_chk"
and "last_agt".

11 years agoDOC: clarify the CSV format
Willy Tarreau [Mon, 16 Jun 2014 13:43:21 +0000 (15:43 +0200)] 
DOC: clarify the CSV format

Indicate that the text cells in the CSV format may contain quotes to
escape ambiguous texts. We don't have this case right now since we limit
the output, but it may happen in the future.

11 years agoMINOR: tools: add new functions to quote-encode strings
Willy Tarreau [Mon, 16 Jun 2014 13:16:40 +0000 (15:16 +0200)] 
MINOR: tools: add new functions to quote-encode strings

qstr() and cstr() will be used to quote-encode strings. The first one
does it unconditionally. The second one is aimed at CSV files where the
quote-encoding is only needed when the field contains a quote or a comma.

11 years agoMINOR: regex: fix a little configuration memory leak.
Thierry FOURNIER [Wed, 11 Jun 2014 12:45:31 +0000 (14:45 +0200)] 
MINOR: regex: fix a little configuration memory leak.

The function regfree free the memory allocated to the pattern buffer by
the compiling process. It is not freeing the buffer itself.

11 years agoMEDIUM: Add port_to_str helper
Simon Horman [Mon, 16 Jun 2014 00:39:41 +0000 (09:39 +0900)] 
MEDIUM: Add port_to_str helper

This helper is similar to addr_to_str but
tries to convert the port rather than the address
of a struct sockaddr_storage.

This is in preparation for supporting
an external agent check.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoMEDIUM: connection: add support for proxy protocol v2 in accept-proxy
Willy Tarreau [Sat, 14 Jun 2014 09:06:17 +0000 (11:06 +0200)] 
MEDIUM: connection: add support for proxy protocol v2 in accept-proxy

The "accept-proxy" statement of bind lines was still limited to version
1 of the protocol, while send-proxy-v2 is now available on the server
lines. This patch adds support for parsing v2 of the protocol on incoming
connections. The v2 header is automatically recognized so there is no
need for a new option.

11 years agoCLEANUP: connection: merge proxy proto v2 header and address block
Willy Tarreau [Sat, 14 Jun 2014 06:28:06 +0000 (08:28 +0200)] 
CLEANUP: connection: merge proxy proto v2 header and address block

This is in order to simplify the PPv2 header parsing code to look more
like the one provided as an example in the spec. No code change was
performed beyond just merging the proxy_addr union into the proxy_hdr_v2
struct.

11 years agoDOC: minor updates to the proxy protocol doc
Willy Tarreau [Sat, 14 Jun 2014 09:45:09 +0000 (11:45 +0200)] 
DOC: minor updates to the proxy protocol doc

Update the release data, revision history and the link to the Forwarded
HTTP extension.

11 years agoDOC: proxy protocol example parser was still wrong
Willy Tarreau [Sat, 14 Jun 2014 06:36:29 +0000 (08:36 +0200)] 
DOC: proxy protocol example parser was still wrong

Now that version and cmd are in the same byte, it is not possible
anymore to compare the version as a 13th byte.

11 years agoBUG/MINOR: connection: make proxy protocol v1 support the UNKNOWN protocol
Willy Tarreau [Sat, 14 Jun 2014 09:41:36 +0000 (11:41 +0200)] 
BUG/MINOR: connection: make proxy protocol v1 support the UNKNOWN protocol

If haproxy receives a connection over a unix socket and forwards it to
another haproxy instance using proxy protocol v1, it sends an UNKNOWN
protocol, which is rejected by the other side. Make the receiver accept
the UNKNOWN protocol as per the spec, and only use the local connection's
address for this.

11 years agoMEDIUM: Break out check establishment into connect_chk()
Simon Horman [Fri, 13 Jun 2014 07:18:16 +0000 (16:18 +0900)] 
MEDIUM: Break out check establishment into connect_chk()

This is in preparation for adding a new type of check that
uses a process rather than a socket.

Signed-off-by: Simon Horman <horms@verge.net.au>
11 years agoMINOR: config: warn when tcp-check rules are used without option tcp-check
Willy Tarreau [Fri, 13 Jun 2014 16:30:23 +0000 (18:30 +0200)] 
MINOR: config: warn when tcp-check rules are used without option tcp-check

Since this case means that the rules will be ignored, better emit a warning.

11 years agoMEDIUM: session: redispatch earlier when possible
Willy Tarreau [Fri, 13 Jun 2014 15:49:40 +0000 (17:49 +0200)] 
MEDIUM: session: redispatch earlier when possible

As discussed with Dmitry Sivachenko, is a server farm has more than one
active server, uses a guaranteed non-determinist algorithm (round robin),
and a connection was initiated from a non-persistent connection, there's
no point insisting to reconnect to the same server after a connect failure,
better redispatch upon the very first retry instead of insisting on the same
server multiple times.

11 years agoMEDIUM: session: don't apply the retry delay when redispatching
Willy Tarreau [Fri, 13 Jun 2014 15:40:15 +0000 (17:40 +0200)] 
MEDIUM: session: don't apply the retry delay when redispatching

The retry delay is only useful when sticking to a same server. During
a redispatch, it's useless and counter-productive if we're sure to
switch to another server, which is almost guaranteed when there's
more than one server and the balancing algorithm is round robin, so
better not pass via the turn-around state in this case. It could be
done as well for leastconn, but there's a risk of always killing the
delay after the recovery of a server in a farm where it's almost
guaranteed to take most incoming traffic. So better only kill the
delay when using round robin.

11 years agoMEDIUM: session: allow shorter retry delay if timeout connect is small
Willy Tarreau [Fri, 13 Jun 2014 15:04:44 +0000 (17:04 +0200)] 
MEDIUM: session: allow shorter retry delay if timeout connect is small

As discussed with Dmitry Sivachenko, the default 1-second connect retry
delay can be large for situations where the connect timeout is much smaller,
because it means that an active connection reject will take more time to be
retried than a silent drop, and that does not make sense.

This patch changes this so that the retry delay is the minimum of 1 second
and the connect timeout. That way people running with sub-second connect
timeout will benefit from the shorter reconnect.

11 years agoMEDIUM: tcp: add a new tcp-request capture directive
Willy Tarreau [Fri, 13 Jun 2014 14:18:52 +0000 (16:18 +0200)] 
MEDIUM: tcp: add a new tcp-request capture directive

This new directive captures the specified fetch expression, converts
it to text and puts it into the next capture slot. The capture slots
are shared with header captures so that it is possible to dump all
captures at once or selectively in logs and header processing.

The purpose is to permit logs to contain whatever payload is found in
a request, for example bytes at a fixed location or the SNI of forwarded
SSL traffic.

11 years agoMINOR: tcp: prepare support for the "capture" action
Willy Tarreau [Fri, 13 Jun 2014 14:17:14 +0000 (16:17 +0200)] 
MINOR: tcp: prepare support for the "capture" action

A few minor entries will be needed to capture sample fetches in requests
or responses. This patch just prepares the code for this.

11 years agoMINOR: capture: extend the captures to support non-header keys
Willy Tarreau [Fri, 13 Jun 2014 14:11:48 +0000 (16:11 +0200)] 
MINOR: capture: extend the captures to support non-header keys

This patch adds support for captures with no header name. The purpose
is to allow extra captures to be defined and logged along with the
header captures.

11 years agoMINOR: sample: improve sample_fetch_string() to report partial contents
Willy Tarreau [Fri, 13 Jun 2014 14:04:35 +0000 (16:04 +0200)] 
MINOR: sample: improve sample_fetch_string() to report partial contents

Currently, all callers to sample_fetch_string() call it with SMP_OPT_FINAL.
Now we improve it to support the case where this option is not set, and to
make it return the original sample as-is. The purpose is to let the caller
check the SMP_F_MAY_CHANGE flag in the result and know that it should wait
to get complete contents. Currently this has no effect on existing code.

11 years agoMINOR: logs: don't limit HTTP header captures to HTTP frontends
Willy Tarreau [Fri, 13 Jun 2014 10:23:06 +0000 (12:23 +0200)] 
MINOR: logs: don't limit HTTP header captures to HTTP frontends

Similar to previous patches, HTTP header captures are performed when
a TCP frontend switches to an HTTP backend, but are not possible to
report. So let's relax the check to explicitly allow them to be present
in TCP frontends.

11 years agoMINOR: log: allow the HTTP status code to be logged even in TCP frontends
Willy Tarreau [Fri, 13 Jun 2014 10:21:40 +0000 (12:21 +0200)] 
MINOR: log: allow the HTTP status code to be logged even in TCP frontends

Log format is defined in the frontend, and some frontends may be chained to
an HTTP backend. Sometimes it's very convenient to be able to log the HTTP
status code of these HTTP backends. This status is definitely present in
the internal structures, it's just that we used to limit it to be used in
HTTP frontends. So let's simply relax the check to allow it to be used in
TCP frontends as well.

11 years agoDOC: fix remaining occurrences of "pattern extraction"
Willy Tarreau [Fri, 13 Jun 2014 14:31:59 +0000 (16:31 +0200)] 
DOC: fix remaining occurrences of "pattern extraction"

11 years agoMEDIUM: ssl: fix detection of ephemeral diffie-hellman key exchange by using the...
Remi Gacogne [Thu, 12 Jun 2014 16:20:11 +0000 (18:20 +0200)] 
MEDIUM: ssl: fix detection of ephemeral diffie-hellman key exchange by using the cipher description.

In OpenSSL, the name of a cipher using ephemeral diffie-hellman for key
 exchange can start with EDH, but also DHE, EXP-EDH or EXP1024-DHE.
We work around this issue by using the cipher's description instead of
the cipher's name.
Hopefully the description is less likely to change in the future.

11 years agoMEDIUM: ssl: Add the option to use standardized DH parameters >= 1024 bits
Remi Gacogne [Thu, 12 Jun 2014 12:58:40 +0000 (14:58 +0200)] 
MEDIUM: ssl: Add the option to use standardized DH parameters >= 1024 bits

When no static DH parameters are specified, this patch makes haproxy
use standardized (rfc 2409 / rfc 3526) DH parameters with prime lenghts
of 1024, 2048, 4096 or 8192 bits for DHE key exchange. The size of the
temporary/ephemeral DH key is computed as the minimum of the RSA/DSA server
key size and the value of a new option named tune.ssl.default-dh-param.

11 years agoBUG/MEDIUM: Fix unhandled connections problem with systemd daemon mode and SO_REUSEPORT.
Simone Gotti [Tue, 10 Jun 2014 22:15:51 +0000 (00:15 +0200)] 
BUG/MEDIUM: Fix unhandled connections problem with systemd daemon mode and SO_REUSEPORT.

Using the systemd daemon mode the parent doesn't exits but waits for
his childs without closing its listening sockets.

As linux 3.9 introduced a SO_REUSEPORT option (always enabled in
haproxy if available) this will give unhandled connections problems
after an haproxy reload with open connections.

The problem is that when on reload a new parent is started (-Ds
$oldchildspids), in haproxy.c main there's a call to start_proxies
that, without SO_REUSEPORT, should fail (as the old processes are
already listening) and so a SIGTOU is sent to old processes. On this
signal the old childs will call (in pause_listener) a shutdown() on
the listening fd. From my tests (if I understand it correctly) this
affects the in kernel file (so the listen is really disabled for all
the processes, also the parent).

Instead, with SO_REUSEPORT, the call to start_proxies doesn't fail and
so SIGTOU is never sent. Only SIGUSR1 is sent and the listen isn't
disabled for the parent but only the childs will stop listening (with
a call to close())

So, with SO_REUSEPORT, the old childs will close their listening
sockets but will wait for the current connections to finish or
timeout, and, as their parent has its listening socket open, the
kernel will schedule some connections on it. These connections will
never be accepted by the parent as it's in the waitpid loop.

This fix will close all the listeners on the parent before entering the
waitpid loop.

Signed-off-by: Simone Gotti <simone.gotti@gmail.com>
11 years agoDOC: fix proxy protocol v2 decoder example
Willy Tarreau [Wed, 11 Jun 2014 19:21:26 +0000 (21:21 +0200)] 
DOC: fix proxy protocol v2 decoder example

Richard Russo reported that the example code in the PP spec is wrong
now that we slightly changed the format to merge <ver> and <cmd>. Also
rename the field <ver_cmd> to avoid any ambiguity on the usage.

11 years agoBUG/MEDIUM: fix ignored values for half-closed timeouts (client-fin and server-fin...
Simone Gotti [Wed, 11 Jun 2014 10:25:28 +0000 (12:25 +0200)] 
BUG/MEDIUM: fix ignored values for half-closed timeouts (client-fin and server-fin) in defaults section.

Signed-off-by: Simone Gotti <simone.gotti@gmail.com>
WT: bug introduced with the new feature in 1.5-dev25, no backport is needed.

11 years agoMINOR: checks: mysql-check: Add support for v4.1+ authentication
Nenad Merdanovic [Fri, 30 May 2014 12:26:32 +0000 (14:26 +0200)] 
MINOR: checks: mysql-check: Add support for v4.1+ authentication

MySQL will in stop supporting pre-4.1 authentication packets in the future
and is already giving us a hard time regarding non-silencable warnings
which are logged on each health check. Warnings look like the following:

"[Warning] Client failed to provide its character set. 'latin1' will be used
as client character set."

This patch adds basic support for post-4.1 authentication by sending the proper
authentication packet with the character set, along with the QUIT command.

11 years agoCLEANUP: http: don't clear CF_READ_NOEXP twice
Willy Tarreau [Wed, 11 Jun 2014 14:49:14 +0000 (16:49 +0200)] 
CLEANUP: http: don't clear CF_READ_NOEXP twice

Last patch cleared the flag twice in the response, which is useless.
Thanks Lukas for spotting it :-)

11 years agoBUG/MEDIUM: http: clear CF_READ_NOEXP when preparing a new transaction
Willy Tarreau [Wed, 11 Jun 2014 12:11:44 +0000 (14:11 +0200)] 
BUG/MEDIUM: http: clear CF_READ_NOEXP when preparing a new transaction

Commit b1982e2 ("BUG/MEDIUM: http/session: disable client-side expiration
only after body") was tricky and caused an issue which was fixed by commit
0943757 ("BUG/MEDIUM: session: don't clear CF_READ_NOEXP if analysers are
not called"). But that's not enough, another issue was introduced and further
emphasized by last fix.

The issue is that the CF_READ_NOEXP flag needs to be cleared when waiting
for a new request over that connection, otherwise we cannot expire anymore
an idle connection waiting for a new request.

This explains the neverending keepalives reported by at least 3 different
persons since dev24. No backport is needed.

11 years agoDOC: Add Exim as Proxy Protocol implementer.
Todd Lyons [Tue, 3 Jun 2014 20:29:33 +0000 (13:29 -0700)] 
DOC: Add Exim as Proxy Protocol implementer.

11 years agoBUILD: stats: workaround stupid and bogus -Werror=format-security behaviour
Willy Tarreau [Wed, 28 May 2014 23:04:35 +0000 (01:04 +0200)] 
BUILD: stats: workaround stupid and bogus -Werror=format-security behaviour

As reported by Vincent Bernat and Ryan O'Hara, building haproxy with the
option above causes this :

src/dumpstats.c: In function 'stats_dump_sv_stats':
src/dumpstats.c:3059:4: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [src/dumpstats.o] Error 1

With that option, gcc wants an argument after a string format even when
that string format is a const but not a litteral. It can be anything
invalid, for example an integer when a string is expected, it just
wants something. So feed it with something :-(

11 years agoBUILD: don't use type "uint" which is not portable
Willy Tarreau [Wed, 28 May 2014 21:05:07 +0000 (23:05 +0200)] 
BUILD: don't use type "uint" which is not portable

Dmitry Sivachenko reported that "uint" doesn't build on FreeBSD 10.
On Linux it's defined in sys/types.h and indicated as "old". Just
get rid of the very few occurrences.

11 years ago[RELEASE] Released version 1.5-dev26 v1.5-dev26
Willy Tarreau [Wed, 28 May 2014 15:50:53 +0000 (17:50 +0200)] 
[RELEASE] Released version 1.5-dev26

Released version 1.5-dev26 with the following main changes :
    - BUG/MEDIUM: polling: fix possible CPU hogging of worker processes after receiving SIGUSR1.
    - BUG/MINOR: stats: fix a typo on a closing tag for a server tracking another one
    - OPTIM: stats: avoid the calculation of a useless link on tracking servers in maintenance
    - MINOR: fix a few memory usage errors
    - CONTRIB: halog: Filter input lines by date and time through timestamp
    - MINOR: ssl: SSL_CTX_set_options() and SSL_CTX_set_mode() take a long, not an int
    - BUG/MEDIUM: regex: fix risk of buffer overrun in exp_replace()
    - MINOR: acl: set "str" as default match for strings
    - DOC: Add some precisions about acl default matching method
    - MEDIUM: acl: strenghten the option parser to report invalid options
    - BUG/MEDIUM: config: a stats-less config crashes in 1.5-dev25
    - BUG/MINOR: checks: tcp-check must not stop on '\0' for binary checks
    - MINOR: stats: improve alignment of color codes to save one line of header
    - MINOR: checks: simplify and improve reporting of state changes when using log-health-checks
    - MINOR: server: remove the SRV_DRAIN flag which can always be deduced
    - MINOR: server: use functions to detect state changes and to update them
    - MINOR: server: create srv_was_usable() from srv_is_usable() and use a pointer
    - BUG/MINOR: stats: do not report "100%" in the thottle column when server is draining
    - BUG/MAJOR: config: don't free valid regex memory
    - BUG/MEDIUM: session: don't clear CF_READ_NOEXP if analysers are not called
    - BUG/MINOR: stats: tracking servers may incorrectly report an inherited DRAIN status
    - MEDIUM: proxy: make timeout parser a bit stricter
    - REORG/MEDIUM: server: split server state and flags in two different variables
    - REORG/MEDIUM: server: move the maintenance bits out of the server state
    - MAJOR: server: use states instead of flags to store the server state
    - REORG: checks: put the functions in the appropriate files !
    - MEDIUM: server: properly support and propagate the maintenance status
    - MEDIUM: server: allow multi-level server tracking
    - CLEANUP: checks: rename the server_status_printf function
    - MEDIUM: checks: simplify server up/down/nolb transitions
    - MAJOR: checks: move health checks changes to set_server_check_status()
    - MINOR: server: make the status reporting function support a reason
    - MINOR: checks: simplify health check reporting functions
    - MINOR: server: implement srv_set_stopped()
    - MINOR: server: implement srv_set_running()
    - MINOR: server: implement srv_set_stopping()
    - MEDIUM: checks: simplify failure notification using srv_set_stopped()
    - MEDIUM: checks: simplify success notification using srv_set_running()
    - MEDIUM: checks: simplify stopping mode notification using srv_set_stopping()
    - MEDIUM: stats: report a server's own state instead of the tracked one's
    - MINOR: server: make use of srv_is_usable() instead of checking eweight
    - MAJOR: checks: add support for a new "drain" administrative mode
    - MINOR: stats: use the admin flags for soft enable/disable/stop/start on the web page
    - MEDIUM: stats: introduce new actions to simplify admin status management
    - MINOR: cli: introduce a new "set server" command
    - MINOR: stats: report a distinct output for DOWN caused by agent
    - MINOR: checks: support specific check reporting for the agent
    - MINOR: checks: support a neutral check result
    - BUG/MINOR: cli: "agent" was missing from the "enable"/"disable" help message
    - MEDIUM: cli: add support for enabling/disabling health checks.
    - MEDIUM: stats: report down caused by agent prior to reporting up
    - MAJOR: agent: rework the response processing and support additional actions
    - MINOR: stats: improve the stats web page to support more actions
    - CONTRIB: halog: avoid calling time/localtime/mktime for each line
    - DOC: document the workarouds for Google Chrome's bogus pre-connect
    - MINOR: stats: report SSL key computations per second
    - MINOR: stats: add counters for SSL cache lookups and misses

11 years agoMINOR: stats: add counters for SSL cache lookups and misses
Willy Tarreau [Wed, 28 May 2014 14:47:01 +0000 (16:47 +0200)] 
MINOR: stats: add counters for SSL cache lookups and misses

One important aspect of SSL performance tuning is the cache size,
but there's no metric to know whether it's large enough or not. This
commit introduces two counters, one for the cache lookups and another
one for cache misses. These counters are reported on "show info" on
the stats socket. This way, it suffices to see the cache misses
counter constantly grow to know that a larger cache could possibly
help.

11 years agoMINOR: stats: report SSL key computations per second
Willy Tarreau [Wed, 28 May 2014 10:28:58 +0000 (12:28 +0200)] 
MINOR: stats: report SSL key computations per second

It's commonly needed to know how many SSL asymmetric keys are computed
per second on either side (frontend or backend), and to know the SSL
session reuse ratio. Now we compute these values and report them in
"show info".

11 years agoBUG/MEDIUM: regex: fix risk of buffer overrun in exp_replace()
Sasha Pachev [Mon, 26 May 2014 18:33:48 +0000 (12:33 -0600)] 
BUG/MEDIUM: regex: fix risk of buffer overrun in exp_replace()

Currently exp_replace() (which is used in reqrep/reqirep) is
vulnerable to a buffer overrun. I have been able to reproduce it using
the attached configuration file and issuing the following command:

  wget -O - -S -q http://localhost:8000/`perl -e 'print "a"x4000'`/cookie.php

Str was being checked only in in while (str) and it was possible to
read past that when more than one character was being accessed in the
loop.

WT:
   Note that this bug is only marked MEDIUM because configurations
   capable of triggering this bug are very unlikely to exist at all due
   to the fact that most rewrites consist in static string additions
   that largely fit into the reserved area (8kB by default).

   This fix should also be backported to 1.4 and possibly even 1.3 since
   it seems to have been present since 1.1 or so.

Config:
-------

  global
        maxconn         500
        stats socket /tmp/haproxy.sock mode 600

  defaults
        timeout client      1000
        timeout connect      5000
        timeout server      5000
        retries         1
        option redispatch

  listen stats
        bind :8080
        mode http
        stats enable
        stats uri /stats
        stats show-legends

  listen  tcp_1
        bind :8000
        mode            http
        maxconn 400
        balance roundrobin
        reqrep ^([^\ :]*)\ /(.*)/(.*)\.php(.*) \1\ /\3.php?arg=\2\2\2\2\2\2\2\2\2\2\2\2\2\4
        server  srv1 127.0.0.1:9000 check port 9000 inter 1000 fall 1
        server  srv2 127.0.0.1:9001 check port 9001 inter 1000 fall 1

11 years agoDOC: document the workarouds for Google Chrome's bogus pre-connect
Willy Tarreau [Fri, 23 May 2014 15:38:34 +0000 (17:38 +0200)] 
DOC: document the workarouds for Google Chrome's bogus pre-connect

More and more people are complaining about the bugs experienced by
Chrome users due to the pre-connect feature and the fact that Chrome
does not monitor its connections and happily displays the error page
instead of re-opening a new connection. Since we can work around this
bug, let's document how to do it.

11 years agoCONTRIB: halog: avoid calling time/localtime/mktime for each line
Willy Tarreau [Fri, 23 May 2014 14:36:56 +0000 (16:36 +0200)] 
CONTRIB: halog: avoid calling time/localtime/mktime for each line

The last commit provides time-based filtering. Unfortunately, it wastes
90% of the time calling the expensive time()/localtime()/mktime()
functions.

This patch does 3 things :
  - call time()/localtime() only once to initialize the correct
    struct timeinfo ;

  - call mktime() only when the time has changed regardless of
    the current second.

  - manually add the current second to the cached result.

Doing just this is enough to multiply the parsing speed by 8.

11 years agoCONTRIB: halog: Filter input lines by date and time through timestamp
Olivier Burgard [Thu, 22 May 2014 14:44:59 +0000 (16:44 +0200)] 
CONTRIB: halog: Filter input lines by date and time through timestamp

I wanted to make a graph with average answer time in nagios that takes only
the last 5 mn of the log. Filtering the log before using halog was too
slow, so I added that filter to halog.

The patch attached to this mail is a proposal to add a new option : -time
[min][:max]

The values are min timestamp and/or max timestamp of the lines to be used
for stats. The date and time of the log lines between '[' and ']' are
converted to timestamp and compared to these values.

Here is an exemple of usage :
cat /var/log/haproxy.log | ./halog -srv -H -q -time $(date --date '-5 min' +%s)

11 years agoMINOR: stats: improve the stats web page to support more actions
Willy Tarreau [Fri, 23 May 2014 12:59:48 +0000 (14:59 +0200)] 
MINOR: stats: improve the stats web page to support more actions

It is now possible to enable/disable agent and health checks, as well
as to force their status.

11 years agoMAJOR: agent: rework the response processing and support additional actions
Willy Tarreau [Mon, 9 Dec 2013 19:51:51 +0000 (20:51 +0100)] 
MAJOR: agent: rework the response processing and support additional actions

We now retrieve a lot of information from a single line of response, which
can be made up of various words delimited by spaces/tabs/commas. We try to
arrange all this and report whatever unusual we detect. The agent now supports :
  - "up", "down", "stopped", "fail" for the operational states
  - "ready", "drain", "maint" for the administrative states
  - any "%" number for the weight
  - an optional reason after a "#" that can be reported on the stats page

The line parser and processor should move to its own function so that
we can reuse the exact same one for http-based agent checks later.

11 years agoMEDIUM: stats: report down caused by agent prior to reporting up
Willy Tarreau [Fri, 23 May 2014 10:15:15 +0000 (12:15 +0200)] 
MEDIUM: stats: report down caused by agent prior to reporting up

When an agent is enabled and forces a down state, it's important to have
this exact information and to report the agent's status, so let's check
the agent before checking the health check.

11 years agoMEDIUM: cli: add support for enabling/disabling health checks.
Willy Tarreau [Fri, 23 May 2014 09:53:10 +0000 (11:53 +0200)] 
MEDIUM: cli: add support for enabling/disabling health checks.

"enable health" and "disable health" are introduced to manipulate the
health check subsystem.

11 years agoBUG/MINOR: cli: "agent" was missing from the "enable"/"disable" help message
Willy Tarreau [Fri, 23 May 2014 09:41:45 +0000 (11:41 +0200)] 
BUG/MINOR: cli: "agent" was missing from the "enable"/"disable" help message

Commit 671b6f0 ("MEDIUM: Add enable and disable agent unix socket commands")
forgot to update the relevant help messages. This was done in 1.5-dev20, no
backport is needed.

11 years agoMINOR: checks: support a neutral check result
Willy Tarreau [Tue, 20 May 2014 18:56:30 +0000 (20:56 +0200)] 
MINOR: checks: support a neutral check result

Agent will have the ability to return a weight without indicating an
up/down status. Currently this is not possible, so let's add a 5th
result CHK_RES_NEUTRAL for this purpose. It has been mapped to the
unused HCHK_STATUS_CHECKED which already serves as a neutral delimitor
between initiated checks and those returning a result.

11 years agoMINOR: checks: support specific check reporting for the agent
Willy Tarreau [Fri, 23 May 2014 09:32:36 +0000 (11:32 +0200)] 
MINOR: checks: support specific check reporting for the agent

Indicate "Agent" instead of "Health" in health check reports sent when
"option log-health-checks" is set. Also, ensure that any agent check
status change is correctly reported. Till now we used not to emit logs
when the agent could not be reached.

11 years agoMINOR: stats: report a distinct output for DOWN caused by agent
Willy Tarreau [Fri, 23 May 2014 09:19:57 +0000 (11:19 +0200)] 
MINOR: stats: report a distinct output for DOWN caused by agent

Till now we only had "DOWN" on the stats page, whether it's the agent
or regular checks which caused this status. Let's differentiate the
two with "DOWN (agent)" so that admins know that the agent is causing
this status.

11 years agoMINOR: cli: introduce a new "set server" command
Willy Tarreau [Thu, 22 May 2014 16:42:35 +0000 (18:42 +0200)] 
MINOR: cli: introduce a new "set server" command

This command supports "agent", "health", "state" and "weight" to adjust
various server attributes as well as changing server health check statuses
on the fly or setting the drain mode.

11 years agoMEDIUM: stats: introduce new actions to simplify admin status management
Willy Tarreau [Thu, 22 May 2014 16:04:49 +0000 (18:04 +0200)] 
MEDIUM: stats: introduce new actions to simplify admin status management

Instead of enabling/disabling maintenance mode and drain mode separately
using 4 actions, we now offer 3 simplified actions :
  - set state to READY
  - set state to DRAIN
  - set state to MAINT

They have the benefit of reporting the same state as displayed on the page,
and of doing the double-switch atomically eg when switching from drain to
maint.

Note that the old actions are still supported for users running scripts.

11 years agoMINOR: stats: use the admin flags for soft enable/disable/stop/start on the web page
Willy Tarreau [Thu, 22 May 2014 15:22:34 +0000 (17:22 +0200)] 
MINOR: stats: use the admin flags for soft enable/disable/stop/start on the web page

Instead of changing the weight to zero or enforcing maintenance mode, we
now make use of the new MAINT/DRAIN flags which are correctly propagated.

11 years agoMAJOR: checks: add support for a new "drain" administrative mode
Willy Tarreau [Thu, 22 May 2014 14:14:34 +0000 (16:14 +0200)] 
MAJOR: checks: add support for a new "drain" administrative mode

This patch adds support for a new "drain" mode. So now we have 3 admin
modes for a server :
  - READY
  - DRAIN
  - MAINT

The drain mode disables load balancing but leaves the server up. It can
coexist with maint, except that maint has precedence. It is also inherited
from tracked servers, so just like maint, it's represented with 2 bits.

New functions were designed to set/clear each flag and to propagate the
changes to tracking servers when relevant, and to log the changes. Existing
functions srv_set_adm_maint() and srv_set_adm_ready() were replaced to make
use of the new functions.

Currently the drain mode is not yet used, however the whole logic was tested
with all combinations of set/clear of both flags in various orders to catch
all corner cases.