]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
9 years agoBUG/MEDIUM: log: fix risk of segfault when logging HTTP fields in TCP mode
Willy Tarreau [Mon, 25 Apr 2016 15:09:40 +0000 (17:09 +0200)] 
BUG/MEDIUM: log: fix risk of segfault when logging HTTP fields in TCP mode

David Torgerson faced an issue when using HTTP fields in log-format in TCP
sections. The txn is dereferenced while it's null, resulting in a crash of
the process. Such configurations are invalid and a warning is emitted, but
nevertheless the process must not crash. As found by Lukas Tribus, this is
a side effect of the split between the stream and the HTTP transaction that
happened in 1.6, making it possible to have txn==NULL there.

The fix consists in checking that txn is valid before using it. Fortunately
it's easy since almost all places already used to check for the existence
of a field (eg: txn->uri).

This patch should be backported to 1.6.

9 years agoBUG/MEDIUM: channel: fix miscalculation of available buffer space (3rd try)
Willy Tarreau [Wed, 20 Apr 2016 16:05:17 +0000 (18:05 +0200)] 
BUG/MEDIUM: channel: fix miscalculation of available buffer space (3rd try)

Latest fix 8a32106 ("BUG/MEDIUM: channel: fix miscalculation of available
buffer space (2nd try)") did happen to fix some observable issues but not
all of them in fact, some corner cases still remained and at least one user
reported a busy loop that appeared possible, though not easily reproducible
under experimental conditions.

The remaining issue is that we still consider min(i, to_fwd) as the number
of bytes in transit, but in fact <i> is not relevant here. Indeed, what
matters is that we can read everything we want at once provided that at
the end, <i> cannot be larger than <size-maxrw> (if it was not already).

This is visible in two cases :
  - let's have i=o=max/2 and to_fwd=0. Then i+o >= max indicates that the
    buffer is already full, while it is not since once <o> is forwarded,
    some space remains.

  - when to_fwd is much larger than i, it's obvious that we can fill the
    buffer.

The only relevant part in fact is o + to_fwd. to_fwd will ensure that at
least this many bytes will be moved from <i> to <o> hence will leave the
buffer, whatever the number of rounds it takes.

Interestingly, the fix applied here ensures that channel_recv_max() will
now equal (size - maxrw - i + to_fwd), which is indeed what remains
available below maxrw after to_fwd bytes are forwarded from i to o and
leave the buffer.

Additionally, the latest fix made it possible to meet an integer overflow
that was not caught by the range test when forwarding in TCP or tunnel
mode due to to_forward being added to an existing value, causing the
buffer size to be limited when it should not have been, resulting in 2
to 3 recv() calls when a single one was enough. The first one was limited
to the unreserved buffer size, the second one to the size of the reserve
minus 1, and the last one to the last byte. Eg with a 2kB buffer :

recvfrom(22, "HTTP/1.1 200\r\nConnection: close\r"..., 1024, 0, NULL, NULL) = 1024
recvfrom(22, "23456789.123456789.123456789.123"..., 1023, 0, NULL, NULL) = 1023
recvfrom(22, "5", 1, 0, NULL, NULL)     = 1

This bug is still present in 1.6 and 1.5 so the fix should be backported
there.

9 years agoBUG/MEDIUM: channel: incorrect polling condition may delay event delivery
Willy Tarreau [Thu, 21 Apr 2016 10:12:45 +0000 (12:12 +0200)] 
BUG/MEDIUM: channel: incorrect polling condition may delay event delivery

The condition to poll for receive as implemented in channel_may_recv()
is still incorrect. If buf->o is null and buf->i is slightly larger than
chn->to_forward and at least as large as buf->size - maxrewrite, then
reading will be disabled. It may slightly delay some data delivery by
having first to forward pending bytes, but may also cause some random
issues with analysers that wait for some data before starting to forward
what they correctly parsed. For instance, a body analyser may be prevented
from seeing the data that only fits in the reserve.

This bug may also prevent an applet's chk_rcv() function from being called
when part of a buffer is released. It is possible (though not verified)
that this participated to some peers frozen session issues some people
have been facing.

This fix should be backported to 1.6 and 1.5 to ensure better coherency
with channel_recv_limit().

9 years agoBUG/MEDIUM: channel: don't allow to overwrite the reserve until connected
Willy Tarreau [Wed, 20 Apr 2016 18:09:22 +0000 (20:09 +0200)] 
BUG/MEDIUM: channel: don't allow to overwrite the reserve until connected

Commit 9c06ee4 ("BUG/MEDIUM: channel: don't schedule data in transit for
leaving until connected") took care of an issue involving POST in conjunction
with http-send-name-header, where we absolutely never want to touch the
reserve until we're sure not to touch the buffer contents anymore, which
is indicated by the output stream-interface being connected.

But channel_may_recv() was not equipped with such a test, so in some
situations it might decide that it is possible to poll for reads, and
later channel_recv_limit() will decide it's not possible to read,
causing a loop. So we must add a similar test there.

Since the fix above was backported to 1.6 and 1.5, this fix must as well.

9 years agoDOC: filters: Add filters documentation
Christopher Faulet [Thu, 7 Apr 2016 13:30:10 +0000 (15:30 +0200)] 
DOC: filters: Add filters documentation

The configuration documention has been updated. Doc about the filter line has
been added and a new chapter (§. 9) has been created to list and document
supported filters (for now, flt_trace and flt_http_comp).

The developer documentation about filters has also been added. The is a "pre"
version. Incoming changes in the filter API will require an update.
This documentation requires a deeper review and some TODO need to be complete.

9 years agoMINOR: filters: Filters must define the callbacks struct during config parsing
Christopher Faulet [Tue, 19 Apr 2016 15:00:44 +0000 (17:00 +0200)] 
MINOR: filters: Filters must define the callbacks struct during config parsing

9 years agoMINOR: filters: Typo in an error message
Christopher Faulet [Mon, 4 Apr 2016 08:51:17 +0000 (10:51 +0200)] 
MINOR: filters: Typo in an error message

9 years agoMINOR: filters: Print the list of existing filters during HA startup
Christopher Faulet [Mon, 7 Mar 2016 11:46:38 +0000 (12:46 +0100)] 
MINOR: filters: Print the list of existing filters during HA startup

This is done  in verbose/debug mode and when build options are reported.

9 years agoMEDIUM: unblock signals on startup.
Willy Tarreau [Wed, 20 Apr 2016 08:33:15 +0000 (10:33 +0200)] 
MEDIUM: unblock signals on startup.

A problem was reported recently by some users of programs compiled
with Go 1.5 which by default blocks all signals before executing
processes, resulting in haproxy not receiving SIGUSR1 or even SIGTERM,
causing lots of zombie processes.

This problem was apparently observed by users of consul and kubernetes
(at least).

This patch is a workaround for this issue. It consists in unblocking
all signals on startup. Since they're normally not blocked in a regular
shell, it ensures haproxy always starts under the same conditions.

Quite useful information reported by both Matti Savolainen and REN
Xiaolei actually helped find the root cause of this problem and this
workaround. Thanks to them for this.

This patch must be backported to 1.6 and 1.5 where the problem is
observed.

9 years agoTESTS: add blocksig.c to run tests with all signals blocked
Willy Tarreau [Wed, 20 Apr 2016 08:20:22 +0000 (10:20 +0200)] 
TESTS: add blocksig.c to run tests with all signals blocked

A problem was reported recently by some users of programs compiled
with Go 1.5 which by default blocks all signals before executing
processes, resulting in haproxy not receiving SIGUSR1 or even SIGTERM.

This program mimmicks this behaviour to make it easier to run tests.
It also displays the current signal mask. A simple test consists in
running it through itself.

9 years agoBUG/MINOR: fix maxaccept computation according to the frontend process range
Cyril Bonté [Fri, 15 Apr 2016 05:58:43 +0000 (07:58 +0200)] 
BUG/MINOR: fix maxaccept computation according to the frontend process range

commit 7c0ffd23 is only considering the explicit use of the "process" keyword
on the listeners. But at this step, if it's not defined in the configuration,
the listener bind_proc mask is set to 0. As a result, the code will compute
the maxaccept value based on only 1 process, which is not always true.

For example :
  global
    nbproc 4

  frontend test
    bind-process 1-2
    bind :80

Here, the maxaccept value for the "test" frontend was set to the global
tune.maxaccept value (default to 64), whereas it should consider 2 processes
will accept connections. As of the documentation, the value should be divided
by twice the number of processes the listener is bound to.

To fix this, we can consider that if no mask is set to the listener, we take
the frontend mask.

This is not critical but it can introduce unfairness distribution of the
incoming connections across the processes.

It should be backported to the same branches as commit 7c0ffd23 (1.6 and 1.5
were in the scope).

9 years agoBUG/MINOR: listener: stop unbound listeners on startup
Willy Tarreau [Thu, 14 Apr 2016 10:05:02 +0000 (12:05 +0200)] 
BUG/MINOR: listener: stop unbound listeners on startup

When a listener is not bound to a process its frontend belongs to, it
is only paused and not stopped. This creates confusion from the outside
as "netstat -ltnp" for example will report only the parent process as
the listener instead of the effective one. "ss -lnp" will report that
all processes are listening to all sockets.

This is confusing enough to suggest a fix. Now we simply stop the unused
listeners. Example with this simple config :

  global
      nbproc 4

  frontend haproxy_test
      bind-process 1-40
      bind :12345 process 1
      bind :12345 process 2
      bind :12345 process 3
      bind :12345 process 4

Before the patch :
  $ netstat -ltnp
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30457/./haproxy
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30457/./haproxy
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30457/./haproxy
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30457/./haproxy

After the patch :
  $ netstat -ltnp
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30504/./haproxy
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30503/./haproxy
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30502/./haproxy
  tcp        0      0 0.0.0.0:12345           0.0.0.0:*               LISTEN      30501/./haproxy

This patch may be backported to 1.6 and 1.5, but it relies on commit
7a798e5 ("CLEANUP: fix inconsistency between fd->iocb, proto->accept
and accept()") since it will expose an API inconsistency by including
listener.h in the .c.

9 years agoBUG/MEDIUM: fix maxaccept computation on per-process listeners
Willy Tarreau [Thu, 14 Apr 2016 09:47:38 +0000 (11:47 +0200)] 
BUG/MEDIUM: fix maxaccept computation on per-process listeners

Christian Ruppert reported a performance degradation when binding a
single frontend to many processes while only one bind line was being
used, bound to a single process.

The reason comes from the fact that whenever a listener is bound to
multiple processes, the it is assigned a maxaccept value which equals
half the global maxaccept value divided by the number of processes the
frontend is bound to. The purpose is to ensure that no single process
will drain all the incoming requests at once and ensure a fair share
between all listeners. Usually this works pretty well, when a listener
is bound to all the processes of its frontend. But here we're in a
situation where the maxaccept of a listener which is bound to a single
process is still divided by a large value.

The fix consists in taking into account the number of processes the
listener is bound do and not only those of the frontend. This way it
is perfectly possible to benefit from nbproc and SO_REUSEPORT without
performance degradation.

1.6 and 1.5 normally suffer from the same issue.

9 years agoCLEANUP: fix inconsistency between fd->iocb, proto->accept and accept()
Willy Tarreau [Thu, 14 Apr 2016 09:13:20 +0000 (11:13 +0200)] 
CLEANUP: fix inconsistency between fd->iocb, proto->accept and accept()

There's quite some inconsistency in the internal API. listener_accept()
which is the main accept() function returns void but is declared as int
in the include file. It's assigned to proto->accept() for all stream
protocols where an int is expected but the result is never checked (nor
is it documented by the way). This proto->accept() is in turn assigned
to fd->iocb() which is supposed to return an int composed of FD_WAIT_*
flags, but which is never checked either.

So let's fix all this mess :
  - nobody checks accept()'s return
  - nobody checks iocb()'s return
  - nobody sets a return value

=> let's mark all these functions void and keep the current ones intact.

Additionally we now include listener.h from listener.c to ensure we won't
silently hide this incoherency in the future.

Note that this patch could/should be backported to 1.6 and even 1.5 to
simplify debugging sessions.

9 years agoDOC: Clarify IPv4 address / mask notation rules
Daniel Schneller [Tue, 12 Apr 2016 22:26:52 +0000 (00:26 +0200)] 
DOC: Clarify IPv4 address / mask notation rules

Adds some examples regarding shorthand IPv4 address notation which might
be confused with RFC 4632 CIDR notation, leading to different than
expected results.

9 years agoCLEANUP: .gitignore cleanup
Vincent Bernat [Tue, 12 Apr 2016 08:56:55 +0000 (10:56 +0200)] 
CLEANUP: .gitignore cleanup

.gitignore is an odd beast. All the stuff at the beginning is useless
since in the bottom part starts with /.* and /*. Therefore, the top part
is useless. Moreover, the bottom part makes unignore *.o and
friends. Add it back at the bottom.

9 years agoMINOR: acl: Add predefined METH_DELETE, METH_PUT
Daniel Schneller [Mon, 11 Apr 2016 15:45:29 +0000 (17:45 +0200)] 
MINOR: acl: Add predefined METH_DELETE, METH_PUT

Adds the missing HTTP verbs DELETE and PUT as predefined ACLs, similar
to GET, POST etc.

9 years agoDOC: fix discrepancy in the example for http-request redirect
Coen Rosdorff [Mon, 11 Apr 2016 09:33:49 +0000 (11:33 +0200)] 
DOC: fix discrepancy in the example for http-request redirect

Commit c8f0e78 ("DOC: typo: req.uri is now replaced by capture.req.uri")
fixed a discrepancy in the doc but the scheme is still missing, resulting
in a redirect loop. Let's fix this as well. This should be backported to
1.5.

9 years agoBUG/MEDIUM: sample: initialize the pointer before parse_binary call.
David Carlier [Fri, 8 Apr 2016 09:37:02 +0000 (10:37 +0100)] 
BUG/MEDIUM: sample: initialize the pointer before parse_binary call.

parse_binary line 2025 checks the nullity of binstr parameter.
Other calls of parse_binary properly zeroify this parameter.
[wt: this could result in random failures of the const parser]

9 years agoBUG/MINOR: cfgparse: couple of small memory leaks.
David Carlier [Fri, 8 Apr 2016 09:35:26 +0000 (10:35 +0100)] 
BUG/MINOR: cfgparse: couple of small memory leaks.

During the config parse in some code paths, there is some
forgotten pointers freeing, and as often, during errors handlings.

9 years agoBUG/MINOR: server: risk of over reading the pref_net array.
David Carlier [Fri, 8 Apr 2016 09:26:44 +0000 (10:26 +0100)] 
BUG/MINOR: server: risk of over reading the pref_net array.

dns_option struct pref_net field is an array of 5. The issue
here shows that pref_net_nb can go up to 5 as well which might lead
to read outside of this array.

9 years agoBUG/MEDIUM: channel: fix miscalculation of available buffer space (2nd try)
Willy Tarreau [Mon, 11 Apr 2016 15:04:02 +0000 (17:04 +0200)] 
BUG/MEDIUM: channel: fix miscalculation of available buffer space (2nd try)

Commit 999f643 ("BUG/MEDIUM: channel: fix miscalculation of available buffer
space.") introduced a bug which made output data to be ignored when computing
the remaining room in a buffer. The problem is that channel_may_recv()
properly considers them and may declare that the FD may be polled for read
events, but once the even strikes, channel_recv_limit() called before recv()
says the opposite. In 1.6 and later this case is automatically caught by
polling loop detection at the connection level and is harmless. But the
backport in 1.5 ends up with a busy polling loop as soon as it becomes
possible to have a buffer with this conflict. In order to reproduce it, it
is necessary to have less than [maxrewrite] bytes available in a buffer, no
forwarding enabled (end of transfer) and [buf->o >= maxrewrite - free space].

Since this heavily depends on socket buffers, it will randomly strike users.
On 1.5 with 8kB buffers it was possible to reproduce it with httpterm using
the following command line :

   $ (printf "GET /?s=675000 HTTP/1.0\r\n\r\n"; sleep 60) | \
       nc6 --rcvbuf-size 1 --send-only 127.0.0.1 8002

This bug is only medium in 1.6 and later but is major in the 1.5 backport,
so it must be backported there.

Thanks to Nenad Merdanovic and Janusz Dziemidowicz for reporting this issue
with enough elements to help understand it.

9 years agoBUG/MEDIUM: trace.c: rdtsc() is defined in two files
William Lallemand [Sat, 9 Apr 2016 19:27:21 +0000 (21:27 +0200)] 
BUG/MEDIUM: trace.c: rdtsc() is defined in two files

The rdtsc() function provided in standard.h forbid trace.c to compile
because it's already defined there.

9 years agoDOC: http: rename the unique-id sample and add the documentation
Thierry Fournier [Thu, 7 Apr 2016 13:47:40 +0000 (15:47 +0200)] 
DOC: http: rename the unique-id sample and add the documentation

This patch renames the ssample fetch from "uniqueid" to "unique-id".
It also adds the documentation associated with this sample fetch.

9 years agoOPTIM/MINOR: session: abort if possible before connecting to the backend
Frederik Deweerdt [Thu, 7 Apr 2016 16:01:04 +0000 (09:01 -0700)] 
OPTIM/MINOR: session: abort if possible before connecting to the backend

Depending on the path that led to sess_update_stream_int(), it's
possible that we had a read error on the frontend, but that we haven't
checked if we may abort the connection.

This was seen in particular the following setup: tcp mode, with
abortonclose set, frontend using ssl. If the ssl connection had a first
successful read, but the second read failed, we would stil try to open a
connection to the backend, although we had enough information to close
the connection early.

sess_update_stream_int() had some logic to handle that case in the
SI_ST_QUE and SI_ST_TAR, but that was missing in the SI_ST_ASS case.

This patches addresses the issue by verifying the state of the req
channel (and the abortonclose option) right before opening the
connection to the backend, so we have the opportunity to close the
connection there, and factorizes the shared SI_ST_{QUE,TAR,ASS} code.

9 years agoBUG/MEDIUM: ssl: rewind the BIO when reading certificates
Willy Tarreau [Wed, 6 Apr 2016 17:02:38 +0000 (19:02 +0200)] 
BUG/MEDIUM: ssl: rewind the BIO when reading certificates

Emeric found that some certificate files that were valid with the old method
(the one with the explicit name involving SSL_CTX_use_PrivateKey_file()) do
not work anymore with the new one (the one trying to load multiple cert types
using PEM_read_bio_PrivateKey()). With the last one, the private key couldn't
be loaded.

The difference was related to the ordering in the PEM file was different. The
old method would always work. The new method only works if the private key is
at the top, or if it appears as an "EC" private key. The cause in fact is that
we never rewind the BIO between the various calls. So this patch moves the
loading of the private key as the first step, then it rewinds the BIO, and
then it loads the cert and the chain. With this everything works.

No backport is needed, this issue came with the recent addition of the
multi-cert support.

9 years agoBUG/MINOR : allow to log cookie for tarpit and denied request
Bertrand Paquet [Wed, 6 Apr 2016 09:58:31 +0000 (11:58 +0200)] 
BUG/MINOR : allow to log cookie for tarpit and denied request

The following patch allow to log cookie for tarpit and denied request.
This minor bug affect at least 1.5, 1.6 and 1.7 branch.

The solution is not perfect : may be the cookie processing
(manage_client_side_cookies) can be moved into http_process_req_common.

9 years agoBUG/MINOR: DNS: resolution structure change
Baptiste Assmann [Tue, 5 Apr 2016 19:19:51 +0000 (21:19 +0200)] 
BUG/MINOR: DNS: resolution structure change

060e57301db98853eef91b344b6ace187b657190 introduced a bug, related to a
dns option structure change and an improper rebase.

Thanks Lukas Tribus for reporting it.

backport: 1.7 and above

9 years agoCLEANUP: proto_http: few corrections for gcc warnings.
David Carlier [Mon, 4 Apr 2016 10:54:42 +0000 (11:54 +0100)] 
CLEANUP: proto_http: few corrections for gcc warnings.

first, we modify the signatures of http_msg_forward_body and
http_msg_forward_chunked_body as they are declared as inline
below. Secondly, just verify the returns of the chunk initialization
which holds the Authorization Method (althought it is unlikely to fail  ...).
Both from gcc warnings.

9 years agoBUG/MINOR: dns: trigger a DNS query type change on resolution timeout
Baptiste Assmann [Wed, 6 Jan 2016 01:01:59 +0000 (02:01 +0100)] 
BUG/MINOR: dns: trigger a DNS query type change on resolution timeout

After Cedric Jeanneret reported an issue with HAProxy and DNS resolution
when multiple servers are in use, I saw that the implementation of DNS
query type update on resolution timeout was not implemented, even if it
is documented.

backport: 1.6 and above

9 years agoBUG/MINOR: dns: inapropriate way out after a resolution timeout
Baptiste Assmann [Wed, 6 Jan 2016 00:53:46 +0000 (01:53 +0100)] 
BUG/MINOR: dns: inapropriate way out after a resolution timeout

A bug leading HAProxy to stop DNS resolution when multiple servers are
configured and one is in timeout, the request is not resent.
Current code fix this issue.

backport status: 1.6 and above

9 years agoBUG/MINOR: dumpstats: fix write to global chunk
Conrad Hoffmann [Fri, 1 Apr 2016 18:40:58 +0000 (20:40 +0200)] 
BUG/MINOR: dumpstats: fix write to global chunk

This just happens to work as it is the correct chunk, but should be whatever
gets passed in as argument.

Signed-off-by: Conrad Hoffmann <conrad@soundcloud.com>
9 years agoDOC: fix "needed" typo
Thiago Farina [Fri, 1 Apr 2016 19:43:50 +0000 (16:43 -0300)] 
DOC: fix "needed" typo

While at it use "You" instead of "They" as in the context
it seems to make more sense to refer to "you", as it is
you that are going to be running the command, there is no
"they".

Signed-off-by: Thiago Farina <tfarina@chromium.org>
9 years agoCLEANUP: uniformize last argument of malloc/calloc
Vincent Bernat [Sun, 3 Apr 2016 11:48:43 +0000 (13:48 +0200)] 
CLEANUP: uniformize last argument of malloc/calloc

Instead of repeating the type of the LHS argument (sizeof(struct ...))
in calls to malloc/calloc, we directly use the pointer
name (sizeof(*...)). The following Coccinelle patch was used:

@@
type T;
T *x;
@@

  x = malloc(
- sizeof(T)
+ sizeof(*x)
  )

@@
type T;
T *x;
@@

  x = calloc(1,
- sizeof(T)
+ sizeof(*x)
  )

When the LHS is not just a variable name, no change is made. Moreover,
the following patch was used to ensure that "1" is consistently used as
a first argument of calloc, not the last one:

@@
@@

  calloc(
+ 1,
  ...
- ,1
  )

9 years agoCLEANUP: remove unneeded casts
Vincent Bernat [Sun, 3 Apr 2016 11:48:42 +0000 (13:48 +0200)] 
CLEANUP: remove unneeded casts

In C89, "void *" is automatically promoted to any pointer type. Casting
the result of malloc/calloc to the type of the LHS variable is therefore
unneeded.

Most of this patch was built using this Coccinelle patch:

@@
type T;
@@

- (T *)
  (\(lua_touserdata\|malloc\|calloc\|SSL_get_app_data\|hlua_checkudata\|lua_newuserdata\)(...))

@@
type T;
T *x;
void *data;
@@

  x =
- (T *)
  data

@@
type T;
T *x;
T *data;
@@

  x =
- (T *)
  data

Unfortunately, either Coccinelle or I is too limited to detect situation
where a complex RHS expression is of type "void *" and therefore casting
is not needed. Those cases were manually examined and corrected.

9 years agoMEDIUM: proxy: use dynamic allocation for error dumps
Willy Tarreau [Thu, 31 Mar 2016 11:45:10 +0000 (13:45 +0200)] 
MEDIUM: proxy: use dynamic allocation for error dumps

There are two issues with error captures. The first one is that the
capture size is still hard-coded to BUFSIZE regardless of any possible
tune.bufsize setting and of the fact that frontends only capture request
errors and that backends only capture response errors. The second is that
captures are allocated in both directions for all proxies, which start to
count a lot in configs using thousands of proxies.

This patch changes this so that error captures are allocated only when
needed, and of the proper size. It also refrains from dumping a buffer
that was not allocated, which still allows to emit all relevant info
such as flags and HTTP states. This way it is possible to save up to
32 kB of RAM per proxy in the default configuration.

9 years agoBUG/MEDIUM: stick-tables: some sample-fetch doesn't work in the connection state.
Thierry Fournier [Tue, 29 Mar 2016 19:27:36 +0000 (21:27 +0200)] 
BUG/MEDIUM: stick-tables: some sample-fetch doesn't work in the connection state.

The sc_* sample fetch can work without the struct strm, because the
tracked counters are also stored in the session. So, this patchs
removes the check for the strm existance.

This bug is recent and was introduced in 1.7-dev2 by commit 6204cd9
("BUG/MAJOR: vars: always retrieve the stream and session from the sample")

This bugfix must be backported in 1.6.

9 years agoMINOR: lua: add class listener
Thierry Fournier [Thu, 25 Feb 2016 07:36:46 +0000 (08:36 +0100)] 
MINOR: lua: add class listener

This class provides the access to the listener struct, it allows
some manipulations and retrieve informations.

9 years agoMINOR: lua: add class server
Thierry Fournier [Mon, 22 Feb 2016 07:21:39 +0000 (08:21 +0100)] 
MINOR: lua: add class server

This class provides the access to the server struct, it allows
some manipulations and retrieve informations.

9 years agoMINOR: lua: add class proxy
Thierry Fournier [Fri, 19 Feb 2016 19:56:00 +0000 (20:56 +0100)] 
MINOR: lua: add class proxy

This class provides the access to the proxy struct, it allows
some manipulations and retrieve informations.

9 years agoMINOR: lua: dump general info
Thierry Fournier [Fri, 18 Mar 2016 07:47:13 +0000 (08:47 +0100)] 
MINOR: lua: dump general info

This patch adds function able to dump general haproxy information.

9 years agoMINOR: dumpstats: split stats_dump_be_stats() in two parts
Thierry Fournier [Fri, 25 Mar 2016 07:21:51 +0000 (08:21 +0100)] 
MINOR: dumpstats: split stats_dump_be_stats() in two parts

This patch splits the function stats_dump_be_stats() in two parts. The
part is called stats_fill_be_stats(), and just fill the stats buffer.
This split allows the usage of preformated stats in other parts of HAProxy
like the Lua.

9 years agoMINOR: dumpstats: split stats_dump_sv_stats() in two parts
Thierry Fournier [Fri, 25 Mar 2016 07:21:21 +0000 (08:21 +0100)] 
MINOR: dumpstats: split stats_dump_sv_stats() in two parts

This patch splits the function stats_dump_sv_stats() in two parts. The
extracted part is called stats_fill_sv_stats(), and just fill the stats buffer.
This split allows the usage of preformated stats in other parts of HAProxy
like the Lua.

9 years agoMINOR: dumpstats: split stats_dump_li_stats() in two parts
Thierry Fournier [Fri, 25 Mar 2016 07:20:49 +0000 (08:20 +0100)] 
MINOR: dumpstats: split stats_dump_li_stats() in two parts

This patch splits the function stats_dump_li_stats() in two parts. The
extracted part is called stats_fill_li_stats(), and just fill the stats buffer.
This split allows the usage of preformated stats in other parts of HAProxy
like the Lua.

9 years agoMINOR: dumpstats: split stats_dump_fe_stats() in two parts
Thierry Fournier [Fri, 25 Mar 2016 07:20:11 +0000 (08:20 +0100)] 
MINOR: dumpstats: split stats_dump_fe_stats() in two parts

This patch splits the function stats_dump_fe_stats() in two parts. The
extracted part is called stats_fill_fe_stats(), and just fill the stats buffer.
This split allows the usage of preformated stats in other parts of HAProxy
like the Lua.

9 years agoMINOR: dumpstats: split stats_dump_info_to_buffer() in two parts
Thierry Fournier [Fri, 25 Mar 2016 07:19:23 +0000 (08:19 +0100)] 
MINOR: dumpstats: split stats_dump_info_to_buffer() in two parts

This patch splits the function stats_dump_info_to_buffer() in two parts. The
extracted part is called stats_fill_info(), and just fill the stats buffer.
This split allows the usage of preformated stats in other parts of HAProxy
like the Lua.

9 years agoMINOR: dumpstats: extract stats fields enum and names
Thierry Fournier [Wed, 23 Mar 2016 15:25:49 +0000 (16:25 +0100)] 
MINOR: dumpstats: extract stats fields enum and names

These field names can be used outside of the dumpstats file.
This will be useful for exporting stats in Lua.

9 years agoMINOR: http: sample fetch which returns unique-id
Thierry Fournier [Tue, 29 Mar 2016 15:23:51 +0000 (17:23 +0200)] 
MINOR: http: sample fetch which returns unique-id

This patch adds a sample fetch which returns the unique-id if it is
configured. If the unique-id is not yet generated, it build it. If
the unique-id is not configured, it returns none.

9 years agoDOC: name set-gpt0 mismatch with the expected keyword
Thierry Fournier [Tue, 29 Mar 2016 17:34:37 +0000 (19:34 +0200)] 
DOC: name set-gpt0 mismatch with the expected keyword

replace set-gpt0 by sc-set-gpt0

must be backported in 1.6

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.