]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
12 years agoMEDIUM: counters: add support for tracking a third counter
Willy Tarreau [Tue, 28 May 2013 16:32:20 +0000 (18:32 +0200)] 
MEDIUM: counters: add support for tracking a third counter

We're often missin a third counter to track base, src and base+src at
the same time. Here we introduce track_sc3 to have this third counter.
It would be wise not to add much more counters because that slightly
increases the session size and processing time though the real issue
is more the declaration of the keywords in the code and in the doc.

12 years agoMINOR: counters: make it easier to extend the amount of tracked counters
Willy Tarreau [Tue, 28 May 2013 15:40:25 +0000 (17:40 +0200)] 
MINOR: counters: make it easier to extend the amount of tracked counters

By properly affecting the flags and values, it becomes easier to add
more tracked counters, for example for experimentation. It also slightly
reduces the code and the number of tests. No counters were added with
this patch.

12 years agoDOC: readme: add suggestion to link against static openssl
Lukas Tribus [Sun, 19 May 2013 14:28:17 +0000 (16:28 +0200)] 
DOC: readme: add suggestion to link against static openssl

Adds a suggestion in README howto link against a static build of openssl.

This is useful if the OS includes an old openssl releas and recent features
or ciphers are required.

12 years agoDOC: fix wrong copy-paste in the rspdel example
Willy Tarreau [Sat, 25 May 2013 06:31:25 +0000 (08:31 +0200)] 
DOC: fix wrong copy-paste in the rspdel example

As reported by Cristian Ditoiu, the rspdel example is based on the reqrep
action, which is quite confusing!

12 years agoCLEANUP: fix minor typo in error message.
Prach Pongpanich [Tue, 14 May 2013 18:56:28 +0000 (20:56 +0200)] 
CLEANUP: fix minor typo in error message.

"accomodate" => "accommodate".

12 years agoMINOR: ssl: add pattern fetch 'ssl_c_sha1'
James Voth [Tue, 14 May 2013 18:37:59 +0000 (20:37 +0200)] 
MINOR: ssl: add pattern fetch 'ssl_c_sha1'

This new pattern fetch returns the client certificate's SHA-1 fingerprint
(i.e. SHA-1 hash of DER-encoded certificate) in a binary chunk.

This can be useful to pass it to a server in a header or to stick a client
to a server across multiple SSL connections.

12 years agoDOC: examples: provide an example of transparent proxy configuration for FreeBSD 8
Pieter Baauw [Sat, 11 May 2013 06:00:53 +0000 (08:00 +0200)] 
DOC: examples: provide an example of transparent proxy configuration for FreeBSD 8

There is very little documentation on how to make haproxy work in
transparent mode under FreeBSD, so let's start with this example.

12 years agoMINOR: tproxy: add support for OpenBSD
Pieter Baauw [Wed, 8 May 2013 21:30:23 +0000 (23:30 +0200)] 
MINOR: tproxy: add support for OpenBSD

OpenBSD uses (SOL_SOCKET, SO_BINDANY) to enable transparent
proxy on a socket.

This patch adds support for the relevant setsockopt() calls.

12 years agoMINOR: tproxy: add support for FreeBSD
Pieter Baauw [Wed, 8 May 2013 21:22:39 +0000 (23:22 +0200)] 
MINOR: tproxy: add support for FreeBSD

FreeBSD uses (IPPROTO_IP, IP_BINDANY) and (IPPROTO_IPV6, IPV6_BINDANY)
to enable transparent proxy on a socket.

This patch adds support for the relevant setsockopt() calls.

12 years agoREORG: tproxy: prepare the transparent proxy defines for accepting other OSes
Pieter Baauw [Wed, 8 May 2013 20:49:23 +0000 (22:49 +0200)] 
REORG: tproxy: prepare the transparent proxy defines for accepting other OSes

This patch does not change the logic of the code, it only changes the
way OS-specific defines are tested.

At the moment the transparent proxy code heavily depends on Linux-specific
defines. This first patch introduces a new define "CONFIG_HAP_TRANSPARENT"
which is set every time the defines used by transparent proxy are present.
This also means that with an up-to-date libc, it should not be necessary
anymore to force CONFIG_HAP_LINUX_TPROXY during the build, as the flags
will automatically be detected.

The CTTPROXY flags still remain separate because this older API doesn't
work the same way.

A new line has been added in the version output for haproxy -vv to indicate
what transparent proxy support is available.

12 years agoBUG/MINOR: acl: fix a double free during exit when using PCRE_JIT
Willy Tarreau [Wed, 8 May 2013 16:09:54 +0000 (18:09 +0200)] 
BUG/MINOR: acl: fix a double free during exit when using PCRE_JIT

When freeing ACL regex, we don't want to perform the free() in regex_free()
as it's already performed in free_pattern(). The double free only happens
when using PCRE_JIT when freeing everything during exit so it's harmless
but exhibits libc errors during a reload/restart.

Bug reported by Seri.

12 years agoMEDIUM: ssl: improve crt-list format to support negation
Emmanuel Hocdet [Tue, 7 May 2013 18:20:06 +0000 (20:20 +0200)] 
MEDIUM: ssl: improve crt-list format to support negation

Improve the crt-list file format to allow a rule to negate a certain SNI :

        <crtfile> [[!]<snifilter> ...]

This can be useful when a domain supports a wildcard but you don't want to
deliver the wildcard cert for certain specific domains.

12 years agoMINOR: ebtree: add new eb_next_dup/eb_prev_dup() functions to visit duplicates
Willy Tarreau [Tue, 7 May 2013 13:58:28 +0000 (15:58 +0200)] 
MINOR: ebtree: add new eb_next_dup/eb_prev_dup() functions to visit duplicates

Sometimes it's very useful to visit duplicates of a same node, but doing
so from the application is not convenient because keys have to be compared,
while all the information is available during the next/prev steps.

Let's introduce a couple of new eb_next_dup/eb_prev_dup functions to visit
only duplicates of the current node and return NULL once it's done. Now we
have all 3 combinations :
  - next        : returns next node in the tree
  - next_dup    : returns next dup in the sub-tree
  - next_unique : returns next value after skipping dups

(cherry picked from commit 3327b8ae6866f3878322a1a29e70b450226d216d)

12 years agoDOC: readme: add a small reminder about restrictions to respect in the code
Willy Tarreau [Wed, 1 May 2013 08:07:21 +0000 (10:07 +0200)] 
DOC: readme: add a small reminder about restrictions to respect in the code

For code portability, we need to respect a few restrictions (mainly no C99 etc).

12 years agoBUILD: stdbool is not portable (again)
Willy Tarreau [Wed, 1 May 2013 07:55:17 +0000 (09:55 +0200)] 
BUILD: stdbool is not portable (again)

Another build issue on Solaris without c99. Please don't use stdbool.

12 years agoBUG/MEDIUM: compression: the deflate algorithm must use global settings as well
Willy Tarreau [Sun, 28 Apr 2013 06:52:52 +0000 (08:52 +0200)] 
BUG/MEDIUM: compression: the deflate algorithm must use global settings as well

Global compression settings (windowsize and memlevel) were only considered
for the gzip algorithm but not the deflate algorithm. Since a single allocator
is used for both algos, if gzip was first initialized the memory with parameters
smaller than default, then initializing deflate after with default settings
would result in overusing the small allocated areas.

To fix this, we make use of deflateInit2() for deflate_init() as well.

Thanks to Godbach for reporting this bug, introduced by in 1.5-dev13 by commit
8b52bb38. No backport is needed.

12 years agoBUG/MEDIUM: shctx: makes the code independent on SSL runtime version.
Emeric Brun [Fri, 26 Apr 2013 16:56:49 +0000 (18:56 +0200)] 
BUG/MEDIUM: shctx: makes the code independent on SSL runtime version.

struct SSL(ssl_st) defintion changed between openssl versions and must not be dereferenced.

12 years agoMINOR: init: indicate the SSL runtime version on -vv.
Willy Tarreau [Fri, 26 Apr 2013 16:16:13 +0000 (18:16 +0200)] 
MINOR: init: indicate the SSL runtime version on -vv.

It happens that openssl's API can differ between versions, causing some
serious trouble if the version used at runtime is not the same as used
for building.

Now we report the two versions separately along with a warning if the
version differs (except the patch version).

12 years agoBUG/MEDIUM: ssl: EDH ciphers are not usable if no DH parameters present in pem file.
Emeric Brun [Fri, 26 Apr 2013 09:05:44 +0000 (11:05 +0200)] 
BUG/MEDIUM: ssl: EDH ciphers are not usable if no DH parameters present in pem file.

Uses default defined DH parameters when none present in pem file.

12 years agoBUILD: last fix broke non-linux platforms
Willy Tarreau [Thu, 25 Apr 2013 15:35:22 +0000 (17:35 +0200)] 
BUILD: last fix broke non-linux platforms

src.tproxy_addr only exists on linux.

12 years agoBUG/MINOR: config: "source" does not work in defaults section
Godbach [Tue, 23 Apr 2013 07:27:57 +0000 (15:27 +0800)] 
BUG/MINOR: config: "source" does not work in defaults section

Source function will not work with the following line in default section:
     source 0.0.0.0 usesrc clientip
even that related settings by iptables and ip rule have been set correctly.
But it can work well in backend setcion.

The reason is that the operation in line 1815 in cfgparse.c as below:
     curproxy->conn_src.opts = defproxy.conn_src.opts & ~CO_SRC_TPROXY_MASK;

clears three low bits of conn_src.opts which stores the configuration of
'usesrc'. Without correct bits set, the source address function can not
work well. They should be copied to the backend proxy without being modified.

Since conn_src.tproxy_addr had not copied from defproxy to backend proxy
while initializing backend proxy, source function will not work well
with explicit source address set in default section either.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
Note: the bug was introduced in 1.5-dev16 with commit ef9a3605

12 years agoBUG/MINOR: fix unterminated ACL array in compression
Willy Tarreau [Tue, 23 Apr 2013 17:39:43 +0000 (19:39 +0200)] 
BUG/MINOR: fix unterminated ACL array in compression

Recent commit 727db8b4 was lacking a NULL ACL descriptor to terminate
the array, causing a random behaviour upon startup. No backport is needed.

12 years agoBUG/MEDIUM: Fix crt-list file parsing error: filtered name was ignored.
Emeric Brun [Mon, 22 Apr 2013 11:05:23 +0000 (13:05 +0200)] 
BUG/MEDIUM: Fix crt-list file parsing error: filtered name was ignored.

Also add support for multiple filtered names on same certificate (per line).

12 years agoBUG/MEDIUM: stats: fix a regression when dealing with POST requests
Willy Tarreau [Sun, 21 Apr 2013 06:04:22 +0000 (08:04 +0200)] 
BUG/MEDIUM: stats: fix a regression when dealing with POST requests

In 1.5-dev17 (commit 1facd6d6), we reorganized the way HTTP stats
requests are handled. When moving the code, we dropped a "return 0"
which happens upon incomplete POST request, so we now end up with
the next return 1 which causes processing to go on with next
analyser. This causes incomplete POST requests to try to forward
the request to servers, resulting in either a 404 or a 503 depending
on the configuration.

This patch fixes this regression to restore the previous behaviour.
It's not enough though, as it happens that the stats code is handled
after all http header processing but in the same function. The net
effect is that incomplete requests cause the headers manipulation to
be performed multiple times, possibly resulting in multiple headers
in the request buffer. Since the stats requests are not meant to be
forwarded, it's not an issue yet but this is something to take care
of later.

A remaining issue that's not handled yet is that if the client does
not send the complete POST headers, then the request is finally
forwarded. This is not a regression, it has always been there and
seems to be caused by the lack of timeout processing when waiting
for the POST body. The solution to this issue would be to move the
handling of stats requests into a dedicated analyser placed after
http_process_request_body().

Bug reported by Guillaume de Lafond.

12 years agoMINOR: compression: acl "res.comp" and fetch "res.comp_algo"
William Lallemand [Sat, 20 Apr 2013 15:33:20 +0000 (17:33 +0200)] 
MINOR: compression: acl "res.comp" and fetch "res.comp_algo"

Implements the "res.comp" ACL which is a boolean returning 1 when a
response has been compressed by HAProxy or 0 otherwise.

Implements the "res.comp_algo" fetch which contains the name of the
algorithm HAProxy used to compress the response.

12 years agoBUG/MEDIUM: stats: allocate the stats frontend also on "stats bind-process"
Willy Tarreau [Sat, 20 Apr 2013 07:48:50 +0000 (09:48 +0200)] 
BUG/MEDIUM: stats: allocate the stats frontend also on "stats bind-process"

Bryan Talbot reported that a config with only "stats bind-process 1" in
the global section would crash during parsing. This bug was introduced
with this new statement in 1.5-dev13. The stats frontend must be allocated
if it was not yet.

No backport is needed. The workaround consists in having previously declared
any other stats keyword (generally stats socket).

12 years agoMINOR: stats: show soft-stopped servers in different color
Geoff Bucar [Thu, 18 Apr 2013 20:53:16 +0000 (13:53 -0700)] 
MINOR: stats: show soft-stopped servers in different color

A "soft-stopped" server (weight 0) can be missed easily in the
webinterface. Fix this by using a specific class (and color).

Signed-off-by: Lukas Tribus <luky-37@hotmail.com>
12 years agoBUG/MINOR: stats: the status bar does not appear anymore after a change
Willy Tarreau [Fri, 19 Apr 2013 12:41:29 +0000 (14:41 +0200)] 
BUG/MINOR: stats: the status bar does not appear anymore after a change

When a server state change happens, a status bar appears with a link. Since
commit 1.5-dev16 (commit e7dbfc66), it was not visible anymore because of
the CSS properties set on the whole "div" tag used by the tooltips. Fix this
by using a specific class for the tooltips.

12 years agoBUG/MINOR: stats: fix confirmation links on the stats interface
Willy Tarreau [Fri, 19 Apr 2013 10:16:55 +0000 (12:16 +0200)] 
BUG/MINOR: stats: fix confirmation links on the stats interface

The confirmation link on the web interface forgets to set the displaying
options, so that when one clicks on "[X] Action processed successfully",
the auto-refresh, up/down and scope search settings are lost. We need to
pass all these info in the new link.

12 years agoMINOR: stats: remove the autofocus on the scope input field
Cyril Bonté [Thu, 18 Apr 2013 20:38:35 +0000 (22:38 +0200)] 
MINOR: stats: remove the autofocus on the scope input field

commit 88c278fadf provided a new input field on the statistics page which was
focused by default. The autofocus prevent to scroll down the page with the
keyboard immediately afterloading it, without the need to leave that field.
It also interfered with "stats refresh" by scrolling up to this field on each
refresh.

This small patch removes the autofocus keyword and adds a tabindex="1" as
suggested by Vincent Bernat. It also cleans up the generated html code.

12 years agoMEDIUM: stats: add proxy name filtering on the statistic page
de Lafond Guillaume [Mon, 15 Apr 2013 17:27:10 +0000 (19:27 +0200)] 
MEDIUM: stats: add proxy name filtering on the statistic page

This patch adds a "scope" box in the statistics page in order to
display only proxies with a name that contains the requested value.
The scope filter is preserved across all clicks on the page.

12 years agoBUG/MINOR: jit: don't rely on USE flag to detect support
Lukas Tribus [Sun, 14 Apr 2013 22:41:40 +0000 (00:41 +0200)] 
BUG/MINOR: jit: don't rely on USE flag to detect support

Since ea68d36 we show whether JIT is enabled, based on the USE-flag
(USE_PCRE_JIT). This is too naive; libpcre may be built without JIT
support (which is the default).

Fix this by calling pcre_config(), which has the accurate information
we are looking for.

Example of a libpcre without JIT support after this patch:
> ./haproxy -vv | grep PCRE
>   OPTIONS = USE_STATIC_PCRE=1 USE_PCRE_JIT=1
> Built with PCRE version : 8.32 2012-11-30
> PCRE library supports JIT : no (libpcre build without JIT?)

12 years agoBUG/MAJOR: http: compression still has defects on chunked responses
Willy Tarreau [Tue, 9 Apr 2013 06:13:58 +0000 (08:13 +0200)] 
BUG/MAJOR: http: compression still has defects on chunked responses

The compression state machine happens to start work it cannot undo if
there's no more data in the input buffer, and has trouble accounting
for it. Fixing it requires more than a few lines, as the confusion is
in part caused by the way the pointers to the various places in the
message are handled internally. So as a temporary fix, let's disable
compression on chunk-encoded responses. This will give us more time
to perform the required changes.

12 years agoBUG/MINOR: cli: "clear table xx data.xx" does not work anymore
Willy Tarreau [Sat, 13 Apr 2013 07:41:37 +0000 (09:41 +0200)] 
BUG/MINOR: cli: "clear table xx data.xx" does not work anymore

Commit 654694e1 introduced in 1.5-dev12 broke the ability to clear
some entries in a table by the value of their data fields.

12 years agoBUG/MINOR: cli: "clear table" did not work anymore without a key
Willy Tarreau [Sat, 13 Apr 2013 07:22:25 +0000 (09:22 +0200)] 
BUG/MINOR: cli: "clear table" did not work anymore without a key

Will Glass-Husain reported this breakage which was caused by commit
dec9814e merged in 1.5-dev12, and which was incomplete, resulting in
both "clear table" and "show table" to do the same thing.

No backport is needed.

12 years agoMEDIUM: log: report file name, line number, and directive name with log-format errors
Willy Tarreau [Fri, 12 Apr 2013 16:30:32 +0000 (18:30 +0200)] 
MEDIUM: log: report file name, line number, and directive name with log-format errors

Improve error log reporting in the format parser by always giving the
file name, line number, and directive name instead of the hard-coded
"log-format".

Previously we got this when dealing with log-format errors:
  [WARNING] 101/183012 (8561) : Warning: log-format variable name 'r' is not suited to HTTP mode
  [WARNING] 101/183012 (8561) : log-format: sample fetch <hdr(a,1)> may not be reliably used with 'log-format' because it needs 'HTTP request headers,HTTP response headers' which is not available here.
  [WARNING] 101/183012 (8561) : Warning: no such variable name 'k' in log-format

Now we have this :
  [WARNING] 101/183016 (8593) : parsing [fmt.cfg:8] : 'log-format' variable name 'r' is reserved for HTTP mode
  [WARNING] 101/183016 (8593) : parsing [fmt.cfg:8] : 'log-format' : sample fetch <hdr(a,1)> may not be reliably used here because it needs 'HTTP request headers,HTTP response headers' which is not available here.
  [WARNING] 101/183016 (8593) : parsing [fmt.cfg:15] : no such variable name 'k' in 'unique-id-format'

12 years agoBUG/MEDIUM: log: fix regression on log-format handling
Willy Tarreau [Fri, 12 Apr 2013 16:13:46 +0000 (18:13 +0200)] 
BUG/MEDIUM: log: fix regression on log-format handling

Commit a4312fa2 merged into dev18 improved log-format management by
processing "log-format" and "unique-id-format" where they were declared,
so that the faulty args could be reported with their correct line numbers.

Unfortunately, the log-format parser considers the proxy mode (TCP/HTTP)
and now if the directive is set before the "mode" statement, it can be
rejected and report warnings.

So we really need to parse these directives at the end of a section at
least. Right now we do not have an "end of section" event, so we need
to store the file name and line number for each of these directives,
and take care of them at the end.

One of the benefits is that now the line numbers can be inherited from
the line passing "option httplog" even if it's in a defaults section.

Future improvements should be performed to report line numbers in every
log-format processed by the parser.

12 years agoBUG/MAJOR: backend: consistent hash can loop forever in certain circumstances
Willy Tarreau [Fri, 12 Apr 2013 12:46:51 +0000 (14:46 +0200)] 
BUG/MAJOR: backend: consistent hash can loop forever in certain circumstances

When the parameter passed to a consistent hash is not found, we fall back to
round-robin using chash_get_next_server(). This one stores the last visited
server in lbprm.chash.last, which can be NULL upon the first invocation or if
the only server was recently brought up.

The loop used to scan for a server is able to skip the previously attempted
server in case of a redispatch, by passing this previous server in srvtoavoid.
For this reason, the loop stops when the currently considered server is
different from srvtoavoid and different from the original chash.last.

A problem happens in a special sequence : if a connection to a server fails,
then all servers are removed from the farm, then the original server is added
again before the redispatch happens, we have chash.last = NULL and srvtoavoid
set to the only server in the farm. Then this server is always equal to
srvtoavoid and never to NULL, and the loop never stops.

The fix consists in assigning the stop point to the first encountered node if
it was not yet set.

This issue cannot happen with the map-based algorithm since it's based on an
index and not a stop point.

This issue was reported by Henry Qian who kindly provided lots of critically
useful information to figure out the conditions to reproduce the issue.

The fix needs to be backported to 1.4 which is also affected.

12 years agoMINOR: tcp: report the erroneous word in tcp-request track*
Willy Tarreau [Fri, 12 Apr 2013 06:26:32 +0000 (08:26 +0200)] 
MINOR: tcp: report the erroneous word in tcp-request track*

We used to report the word after the fetch.

12 years agoMINOR: session: only call http_send_name_header() when changing the server
Willy Tarreau [Sun, 7 Apr 2013 16:19:16 +0000 (18:19 +0200)] 
MINOR: session: only call http_send_name_header() when changing the server

Till now we used to call the function until the connection established, which
means that the header rewriting was performed for nothing upon each even (eg:
uploaded contents) until the server responded or timed out.

Now we only call the function when we assign the server.

12 years agoBUG/MAJOR: peers: fix an overflow when syncing strings larger than 16 bytes
Willy Tarreau [Thu, 11 Apr 2013 14:56:44 +0000 (16:56 +0200)] 
BUG/MAJOR: peers: fix an overflow when syncing strings larger than 16 bytes

When syncing data between two haproxy instances, the received keys were
allocated in the stack but no room was planned for type string. So in
practice all strings of 16 or less bytes were properly handled (due to
the union with in6_addr which reserves some room), but above this some
local variables were overwritten. Up to 8 additional bytes could be
written without impact, but random behaviours are expected above, including
crashes and memory corruption.

If large enough strings are allowed in the configuration, it is possible that
code execution could be triggered when the function's return pointer is
overwritten.

A quick workaround consists in ensuring that no stick-table uses a string
larger than 16 bytes (default is 32). Another workaround is to disable peer
sync when strings are in use.

Thanks to Will Glass-Husain for bringing up this issue with a backtrace to
understand the issue.

The bug only affects 1.5-dev3 and above. No backport is needed.

12 years agoMINOR: stick-table: allow to allocate an entry without filling it
Willy Tarreau [Thu, 11 Apr 2013 14:55:37 +0000 (16:55 +0200)] 
MINOR: stick-table: allow to allocate an entry without filling it

By passing a NULL key to stksess_new(), we allocate it but do not yet
fill it. That way the caller can do that.

12 years agoCLEANUP: peers: remove a bit of spaghetti to prepare for the next bugfix
Willy Tarreau [Thu, 11 Apr 2013 14:14:13 +0000 (16:14 +0200)] 
CLEANUP: peers: remove a bit of spaghetti to prepare for the next bugfix

We'll need to centralize some pool_alloc()/pool_free() calls in the
upcoming fix so before that we need to reduce the number of points
by which we leave the critical code.

12 years agoBUG/MINOR: tcp: fix error reporting for TCP rules
Willy Tarreau [Wed, 10 Apr 2013 14:31:11 +0000 (16:31 +0200)] 
BUG/MINOR: tcp: fix error reporting for TCP rules

tcp-request swapped two output words in the error message, making it meaningless.

12 years agoBUG: regex: fix pcre compile error when using JIT
Hiroaki Nakamura [Thu, 11 Apr 2013 06:17:37 +0000 (08:17 +0200)] 
BUG: regex: fix pcre compile error when using JIT

According to "man pcreapi", pcre_compile() does not accept being passed
a NULL pointer in errptr or erroffset. It immediately returns NULL, causing
any expression to fail. So let's pass real variables and make use of them
to improve error reporting.

12 years agoBUG/MAJOR: acl: add implicit arguments to the resolve list
Willy Tarreau [Sun, 7 Apr 2013 19:20:44 +0000 (21:20 +0200)] 
BUG/MAJOR: acl: add implicit arguments to the resolve list

When an ACL keyword needs a mandatory argument and this argument is of
type proxy or table, it is allowed not to specify it so that current
proxy is used by default.

In order to achieve this, the ACL expression parser builds a dummy
argument from scratch and marks it unresolved.

However, since recent changes on the ACL and samples, an unresolved
argument needs to be added to the unresolved list. This specific code
did not do it, resulting in random data being used as a proxy pointer
if no argument was passed for a proxy name, possibly even causing a
crash.

A quick workaround consists explicitly naming proxies in ACLs.

12 years agoBUG/MEDIUM: splicing is broken since 1.5-dev12
Willy Tarreau [Sat, 6 Apr 2013 09:29:39 +0000 (11:29 +0200)] 
BUG/MEDIUM: splicing is broken since 1.5-dev12

Commit 96199b10 reintroduced the splice() mechanism in the new connection
system. However, it failed to account for the number of transferred bytes,
allowing more bytes than scheduled to be transferred to the client. This
can cause an issue with small-chunked responses, where each packet from
the server may contain several chunks, because a single splice() call may
succeed, then try to splice() a second time as the pipe is not full, thus
consuming the next chunk size.

This patch also reverts commit baf2a5 ("OPTIM: splice: detect shutdowns...")
because it introduced a related regression. The issue is that splice() may
return less data than available also if the pipe is full, so having EPOLLRDHUP
after splice() returns less than expected is not a sufficient indication that
the input is empty.

In both cases, the issue may be detected by the presence of "SD" termination
flags in the logs, and worked around by disabling splicing (using "-dS").

This problem was reported by Sander Klein, and no backport is needed.

12 years agoBUILD: mention in the Makefile that USE_PCRE_JIT is for libpcre >= 8.32
Willy Tarreau [Thu, 4 Apr 2013 21:05:32 +0000 (23:05 +0200)] 
BUILD: mention in the Makefile that USE_PCRE_JIT is for libpcre >= 8.32

JIT was introduced in 8.20 but it's said everywhere that it was
significantly improved in 8.32. Let's not tempt users of older
versions then. BTW the patch was developped on 8.32.

12 years agoMINOR: show PCRE version and JIT status in -vv
Lukas Tribus [Thu, 4 Apr 2013 10:24:16 +0000 (12:24 +0200)] 
MINOR: show PCRE version and JIT status in -vv

haproxy -vv shows build informations about USE flags and lib versions.
This patch introduces informations about PCRE and the new JIT feature.
It also makes USE_PCRE_JIT=1 appear in the haproxy -vv "OPTIONS".

This is useful since with the introduction of JIT we will see libpcre
related issues.

12 years agoBUG/MINOR: http: add-header/set-header did not accept the ACL condition
Willy Tarreau [Wed, 3 Apr 2013 12:13:58 +0000 (14:13 +0200)] 
BUG/MINOR: http: add-header/set-header did not accept the ACL condition

Sander Klein reported this bug. The test for the extra argument on these
rules prevent any condition from being added. The bug was introduced with
the feature itself in 1.5-dev16.

12 years ago[RELEASE] Released version 1.5-dev18 v1.5-dev18
Willy Tarreau [Wed, 3 Apr 2013 00:26:31 +0000 (02:26 +0200)] 
[RELEASE] Released version 1.5-dev18

Released version 1.5-dev18 with the following main changes :
    - DOCS: Add explanation of intermediate certs to crt paramater
    - DOC: typo and minor fixes in compression paragraph
    - MINOR: config: http-request configuration error message misses new keywords
    - DOC: minor typo fix in documentation
    - BUG/MEDIUM: ssl: ECDHE ciphers not usable without named curve configured.
    - MEDIUM: ssl: add bind-option "strict-sni"
    - MEDIUM: ssl: add mapping from SNI to cert file using "crt-list"
    - MEDIUM: regex: Use PCRE JIT in acl
    - DOC: simplify bind option "interface" explanation
    - DOC: tfo: bump required kernel to linux-3.7
    - BUILD: add explicit support for TFO with USE_TFO
    - MEDIUM: New cli option -Ds for systemd compatibility
    - MEDIUM: add haproxy-systemd-wrapper
    - MEDIUM: add systemd service
    - BUG/MEDIUM: systemd-wrapper: don't leak zombie processes
    - BUG/MEDIUM: remove supplementary groups when changing gid
    - BUG/MEDIUM: config: fix parser crash with bad bind or server address
    - BUG/MINOR: Correct logic in cut_crlf()
    - CLEANUP: checks: Make desc argument to set_server_check_status const
    - CLEANUP: dumpstats: Make cli_release_handler() static
    - MEDIUM: server: Break out set weight processing code
    - MEDIUM: server: Allow relative weights greater than 100%
    - MEDIUM: server: Tighten up parsing of weight string
    - MEDIUM: checks: Add agent health check
    - BUG/MEDIUM: ssl: openssl 0.9.8 doesn't open /dev/random before chroot
    - BUG/MINOR: time: frequency counters are not totally accurate
    - BUG/MINOR: http: don't process abortonclose when request was sent
    - BUG/MEDIUM: stream_interface: don't close outgoing connections on shutw()
    - BUG/MEDIUM: checks: ignore late resets after valid responses
    - DOC: fix bogus recommendation on usage of gpc0 counter
    - BUG/MINOR: http-compression: lookup Cache-Control in the response, not the request
    - MINOR: signal: don't block SIGPROF by default
    - OPTIM: epoll: make use of EPOLLRDHUP
    - OPTIM: splice: detect shutdowns and avoid splice() == 0
    - OPTIM: splice: assume by default that splice is working correctly
    - BUG/MINOR: log: temporary fix for lost SSL info in some situations
    - BUG/MEDIUM: peers: only the last peers section was used by tables
    - BUG/MEDIUM: config: verbosely reject peers sections with multiple local peers
    - BUG/MINOR: epoll: use a fix maxevents argument in epoll_wait()
    - BUG/MINOR: config: fix improper check for failed memory alloc in ACL parser
    - BUG/MINOR: config: free peer's address when exiting upon parsing error
    - BUG/MINOR: config: check the proper variable when parsing log minlvl
    - BUG/MEDIUM: checks: ensure the health_status is always within bounds
    - BUG/MINOR: cli: show sess should always validate s->listener
    - BUG/MINOR: log: improper NULL return check on utoa_pad()
    - CLEANUP: http: remove a useless null check
    - CLEANUP: tcp/unix: remove useless NULL check in {tcp,unix}_bind_listener()
    - BUG/MEDIUM: signal: signal handler does not properly check for signal bounds
    - BUG/MEDIUM: tools: off-by-one in quote_arg()
    - BUG/MEDIUM: uri_auth: missing NULL check and memory leak on memory shortage
    - BUG/MINOR: unix: remove the 'level' field from the ux struct
    - CLEANUP: http: don't try to deinitialize http compression if it fails before init
    - CLEANUP: config: slowstart is never negative
    - CLEANUP: config: maxcompcpuusage is never negative
    - BUG/MEDIUM: log: emit '-' for empty fields again
    - BUG/MEDIUM: checks: fix a race condition between checks and observe layer7
    - BUILD: fix a warning emitted by isblank() on non-c99 compilers
    - BUILD: improve the makefile's support for libpcre
    - MEDIUM: halog: add support for counting per source address (-ic)
    - MEDIUM: tools: make str2sa_range support all address syntaxes
    - MEDIUM: config: make use of str2sa_range() instead of str2sa()
    - MEDIUM: config: use str2sa_range() to parse server addresses
    - MEDIUM: config: use str2sa_range() to parse peers addresses
    - MINOR: tests: add a config file to ease address parsing tests.
    - MINOR: ssl: add a global tunable for the max SSL/TLS record size
    - BUG/MINOR: syscall: fix NR_accept4 system call on sparc/linux
    - BUILD/MINOR: syscall: add definition of NR_accept4 for ARM
    - MINOR: config: report missing peers section name
    - BUG/MEDIUM: tools: fix bad character handling in str2sa_range()
    - BUG/MEDIUM: stats: never apply "unix-bind prefix" to the global stats socket
    - MINOR: tools: prepare str2sa_range() to return an error message
    - BUG/MEDIUM: checks: don't call connect() on unsupported address families
    - MINOR: tools: prepare str2sa_range() to accept a prefix
    - MEDIUM: tools: make str2sa_range() parse unix addresses too
    - MEDIUM: config: make str2listener() use str2sa_range() to parse unix addresses
    - MEDIUM: config: use a single str2sa_range() call to parse bind addresses
    - MEDIUM: config: use str2sa_range() to parse log addresses
    - CLEANUP: tools: remove str2sun() which is not used anymore.
    - MEDIUM: config: add complete support for str2sa_range() in dispatch
    - MEDIUM: config: add complete support for str2sa_range() in server addr
    - MEDIUM: config: add complete support for str2sa_range() in 'server'
    - MEDIUM: config: add complete support for str2sa_range() in 'peer'
    - MEDIUM: config: add complete support for str2sa_range() in 'source' and 'usesrc'
    - CLEANUP: minor cleanup in str2sa_range() and str2ip()
    - CLEANUP: config: do not use multiple errmsg at once
    - MEDIUM: tools: support specifying explicit address families in str2sa_range()
    - MAJOR: listener: support inheriting a listening fd from the parent
    - MAJOR: tools: support environment variables in addresses
    - BUG/MEDIUM: http: add-header should not emit "-" for empty fields
    - BUG/MEDIUM: config: ACL compatibility check on "redirect" was wrong
    - BUG/MEDIUM: http: fix another issue caused by http-send-name-header
    - DOC: mention the new HTTP 307 and 308 redirect statues
    - MEDIUM: poll: do not use FD_* macros anymore
    - BUG/MAJOR: ev_select: disable the select() poller if maxsock > FD_SETSIZE
    - BUG/MINOR: acl: ssl_fc_{alg,use}_keysize must parse integers, not strings
    - BUG/MINOR: acl: ssl_c_used, ssl_fc{,_has_crt,_has_sni} take no pattern
    - BUILD: fix usual isdigit() warning on solaris
    - BUG/MEDIUM: tools: vsnprintf() is not always reliable on Solaris
    - OPTIM: buffer: remove one jump in buffer_count()
    - OPTIM: http: improve branching in chunk size parser
    - OPTIM: http: optimize the response forward state machine
    - BUILD: enable poll() by default in the makefile
    - BUILD: add explicit support for Mac OS/X
    - BUG/MAJOR: http: use a static storage for sample fetch context
    - BUG/MEDIUM: ssl: improve error processing and reporting in ssl_sock_load_cert_list_file()
    - BUG/MAJOR: http: fix regression introduced by commit a890d072
    - BUG/MAJOR: http: fix regression introduced by commit d655ffe
    - BUG/CRITICAL: using HTTP information in tcp-request content may crash the process
    - MEDIUM: acl: remove flag ACL_MAY_LOOKUP which is improperly used
    - MEDIUM: samples: use new flags to describe compatibility between fetches and their usages
    - MINOR: log: indicate it when some unreliable sample fetches are logged
    - MEDIUM: samples: move payload-based fetches and ACLs to their own file
    - MINOR: backend: rename sample fetch functions and declare the sample keywords
    - MINOR: frontend: rename sample fetch functions and declare the sample keywords
    - MINOR: listener: rename sample fetch functions and declare the sample keywords
    - MEDIUM: http: unify acl and sample fetch functions
    - MINOR: session: rename sample fetch functions and declare the sample keywords
    - MAJOR: acl: make all ACLs reference the fetch function via a sample.
    - MAJOR: acl: remove the arg_mask from the ACL definition and use the sample fetch's
    - MAJOR: acl: remove fetch argument validation from the ACL struct
    - MINOR: http: add new direction-explicit sample fetches for headers and cookies
    - MINOR: payload: add new direction-explicit sample fetches
    - CLEANUP: acl: remove ACL hooks which were never used
    - MEDIUM: proxy: remove acl_requires and just keep a flag "http_needed"
    - MINOR: sample: provide a function to report the name of a sample check point
    - MAJOR: acl: convert all ACL requires to SMP use+val instead of ->requires
    - CLEANUP: acl: remove unused references to ACL_USE_*
    - MINOR: http: replace acl_parse_ver with acl_parse_str
    - MEDIUM: acl: move the ->parse, ->match and ->smp fields to acl_expr
    - MAJOR: acl: add option -m to change the pattern matching method
    - MINOR: acl: remove the use_count in acl keywords
    - MEDIUM: acl: have a pointer to the keyword name in acl_expr
    - MEDIUM: acl: support using sample fetches directly in ACLs
    - MEDIUM: http: remove val_usr() to validate user_lists
    - MAJOR: sample: maintain a per-proxy list of the fetch args to resolve
    - MINOR: ssl: add support for the "alpn" bind keyword
    - MINOR: http: status code 303 is HTTP/1.1 only
    - MEDIUM: http: implement redirect 307 and 308
    - MINOR: http: status 301 should not be marked non-cacheable

12 years agoMINOR: ssl: add support for the "alpn" bind keyword
Willy Tarreau [Tue, 2 Apr 2013 00:30:41 +0000 (02:30 +0200)] 
MINOR: ssl: add support for the "alpn" bind keyword

The ALPN extension is meant to replace the now deprecated NPN extension.
This patch implements support for it. It requires a version of openssl
with support for this extension. Patches are available here right now :

   http://html5labs.interopbridges.com/media/167447/alpn_patches.zip

12 years agoMAJOR: sample: maintain a per-proxy list of the fetch args to resolve
Willy Tarreau [Tue, 2 Apr 2013 14:34:32 +0000 (16:34 +0200)] 
MAJOR: sample: maintain a per-proxy list of the fetch args to resolve

While ACL args were resolved after all the config was parsed, it was not the
case with sample fetch args because they're almost everywhere now.

The issue is that ACLs now solely rely on sample fetches, so their args
resolving doesn't work anymore. And many fetches involving a server, a
proxy or a userlist don't work at all.

The real issue is that at the bottom layers we have no information about
proxies, line numbers, even ACLs in order to report understandable errors,
and that at the top layers we have no visibility over the locations where
fetches are referenced (think log node).

After failing multiple unsatisfying solutions attempts, we now have a new
concept of args list. The principle is that every proxy has a list head
which contains a number of indications such as the config keyword, the
context where it's used, the file and line number, etc... and a list of
arguments. This list head is of the same type as the elements, so it
serves as a template for adding new elements. This way, it is filled from
top to bottom by the callers with the information they have (eg: line
numbers, ACL name, ...) and the lower layers just have to duplicate it and
add an element when they face an argument they cannot resolve yet.

Then at the end of the configuration parsing, a loop passes over each
proxy's list and resolves all the args in sequence. And this way there is
all necessary information to report verbose errors.

The first immediate benefit is that for the first time we got very precise
location of issues (arg number in a keyword in its context, ...). Second,
in order to do this we had to parse log-format and unique-id-format a bit
earlier, so that was a great opportunity for doing so when the directives
are encountered (unless it's a default section). This way, the recorded
line numbers for these args are the ones of the place where the log format
is declared, not the end of the file.

Userlists report slightly more information now. They're the only remaining
ones in the ACL resolving function.

12 years agoMEDIUM: http: remove val_usr() to validate user_lists
Willy Tarreau [Tue, 2 Apr 2013 20:44:58 +0000 (22:44 +0200)] 
MEDIUM: http: remove val_usr() to validate user_lists

This one was incorrect since it tried to validate the user-lists
before end of parsing.

12 years agoMEDIUM: acl: support using sample fetches directly in ACLs
Willy Tarreau [Sun, 31 Mar 2013 21:14:46 +0000 (23:14 +0200)] 
MEDIUM: acl: support using sample fetches directly in ACLs

Now it becomes possible to directly use sample fetches as the ACL fetch
methods. In this case, the matching method is mandatory. This allows to
form more ACL combinations from existing fetches and will limit the need
for new ACLs when everything is available to form them from sample fetches
and matches.

12 years agoMEDIUM: acl: have a pointer to the keyword name in acl_expr
Willy Tarreau [Sun, 31 Mar 2013 20:59:32 +0000 (22:59 +0200)] 
MEDIUM: acl: have a pointer to the keyword name in acl_expr

The acl_expr struct used to hold a pointer to the ACL keyword. But since
we now have all the relevant pointers, we don't need that anymore, we just
need the pointer to the keyword as a string in order to return warnings
and error messages.

So let's change this in order to remove the dependency on the acl_keyword
struct from acl_expr.

During this change, acl_cond_kw_conflicts() used to return a pointer to an
ACL keyword but had to be changed to return a const char* for the same reason.

12 years agoMINOR: acl: remove the use_count in acl keywords
Willy Tarreau [Sun, 31 Mar 2013 20:51:33 +0000 (22:51 +0200)] 
MINOR: acl: remove the use_count in acl keywords

use_cnt is not used at all anymore, let's get rid of it.

12 years agoMAJOR: acl: add option -m to change the pattern matching method
Willy Tarreau [Sun, 31 Mar 2013 20:13:34 +0000 (22:13 +0200)] 
MAJOR: acl: add option -m to change the pattern matching method

ACL expressions now support "-m" in addition to "-i" and "-f". This new
option is followed by the name of the pattern matching method to be used
on the extracted pattern. This makes it possible to reuse existing sample
fetch methods with other matching methods (eg: regex). A "found" matching
method ignores any pattern and only verifies that the required sample was
found (useful for cookies).

12 years agoMEDIUM: acl: move the ->parse, ->match and ->smp fields to acl_expr
Willy Tarreau [Sun, 31 Mar 2013 16:34:33 +0000 (18:34 +0200)] 
MEDIUM: acl: move the ->parse, ->match and ->smp fields to acl_expr

We'll need each ACL expression to be able to support its own parse and
match methods, so we're moving these fields to the ACL expression.

12 years agoMINOR: http: replace acl_parse_ver with acl_parse_str
Willy Tarreau [Sun, 31 Mar 2013 16:49:18 +0000 (18:49 +0200)] 
MINOR: http: replace acl_parse_ver with acl_parse_str

The HTTP version parser used in ACLs has long been a string and
still had its own parser. This makes no sense, switch it to use
the standard string parser.

12 years agoCLEANUP: acl: remove unused references to ACL_USE_*
Willy Tarreau [Mon, 25 Mar 2013 07:21:05 +0000 (08:21 +0100)] 
CLEANUP: acl: remove unused references to ACL_USE_*

Now that acl->requires is not used anymore, we can remove all references
to it as well as all ACL_USE_* flags.

12 years agoMAJOR: acl: convert all ACL requires to SMP use+val instead of ->requires
Willy Tarreau [Mon, 25 Mar 2013 07:12:18 +0000 (08:12 +0100)] 
MAJOR: acl: convert all ACL requires to SMP use+val instead of ->requires

The ACLs now use the fetch's ->use and ->val to decide upon compatibility
between the place where they are used and where the information are fetched.
The code is capable of reporting warnings about very fine incompatibilities
between certain fetches and an exact usage location, so it is expected that
some new warnings will be emitted on some existing configurations.

Two degrees of detection are provided :
  - detecting ACLs that never match
  - detecting keywords that are ignored

All tests show that this seems to work well, though bugs are still possible.

12 years agoMINOR: sample: provide a function to report the name of a sample check point
Willy Tarreau [Mon, 25 Mar 2013 13:52:41 +0000 (14:52 +0100)] 
MINOR: sample: provide a function to report the name of a sample check point

We need to put names on places where samples are used in order to emit warnings
and errors. Let's do that now.

12 years agoMEDIUM: proxy: remove acl_requires and just keep a flag "http_needed"
Willy Tarreau [Sun, 24 Mar 2013 06:22:08 +0000 (07:22 +0100)] 
MEDIUM: proxy: remove acl_requires and just keep a flag "http_needed"

Proxy's acl_requires was a copy of all bits taken from ACLs, but we'll
get rid of ACL flags and only rely on sample fetches soon. The proxy's
acl_requires was only used to allocate an HTTP context when needed, and
was even forced in HTTP mode. So better have a flag which exactly says
what it's supposed to be used for.

12 years agoCLEANUP: acl: remove ACL hooks which were never used
Willy Tarreau [Sun, 24 Mar 2013 00:34:58 +0000 (01:34 +0100)] 
CLEANUP: acl: remove ACL hooks which were never used

These hooks, which established the relation between ACL_USE_* and the location
where the ACL were used, were never used because they were superseded with the
sample capabilities. Remove them now.

12 years agoMINOR: payload: add new direction-explicit sample fetches
Willy Tarreau [Mon, 14 Jan 2013 15:07:52 +0000 (16:07 +0100)] 
MINOR: payload: add new direction-explicit sample fetches

Similarly to previous commit fixing "hdr" and "cookie" in HTTP, we have to deal
with "payload" and "payload_lv" which are request-only for ACLs and req/resp for
sample fetches depending on the context, and to a less extent with other req_*
and rep_*/rep_* fetches. So let's add explicit "req." and "res." variants and
make the ACLs rely on that instead.

12 years agoMINOR: http: add new direction-explicit sample fetches for headers and cookies
Willy Tarreau [Mon, 14 Jan 2013 14:56:36 +0000 (15:56 +0100)] 
MINOR: http: add new direction-explicit sample fetches for headers and cookies

Since "hdr" and "cookie" were ambiguously referring to the request or response
depending on the context, we need a way to explicitly specify the direction.
By prefixing the fetches names with "req." and "res.", we can now restrict such
fetches to the appropriate direction. At the moment the fetches are explicitly
declared by later we might think about having an automatic match when "req." or
"res." appears. These explicit fetches are now used by the relevant ACLs.

12 years agoMAJOR: acl: remove fetch argument validation from the ACL struct
Willy Tarreau [Fri, 11 Jan 2013 16:06:15 +0000 (17:06 +0100)] 
MAJOR: acl: remove fetch argument validation from the ACL struct

ACL fetch being inherited from the sample fetch keyword, we don't need
anymore to specify what function to use to validate the fetch arguments.

Note that the job is still done in the ACL parsing code based on elements
from the sample fetch structs.

12 years agoMAJOR: acl: remove the arg_mask from the ACL definition and use the sample fetch's
Willy Tarreau [Fri, 11 Jan 2013 15:56:48 +0000 (16:56 +0100)] 
MAJOR: acl: remove the arg_mask from the ACL definition and use the sample fetch's

Now that ACLs solely rely on sample fetch functions, make them use the
same arg mask. All inconsistencies have been fixed separately prior to
this patch, so this patch almost only adds a new pointer indirection
and removes all references to ARG*() in the definitions.

The parsing is still performed by the ACL code though.

12 years agoMAJOR: acl: make all ACLs reference the fetch function via a sample.
Willy Tarreau [Fri, 11 Jan 2013 14:49:37 +0000 (15:49 +0100)] 
MAJOR: acl: make all ACLs reference the fetch function via a sample.

ACL fetch functions used to directly reference a fetch function. Now
that all ACL fetches have their sample fetches equivalent, we can make
ACLs reference a sample fetch keyword instead.

In order to simplify the code, a sample keyword name may be NULL if it
is the same as the ACL's, which is the most common case.

A minor change appeared, http_auth always expects one argument though
the ACL allowed it to be missing and reported as such afterwards, so
fix the ACL to match this. This is not really a bug.

12 years agoMINOR: session: rename sample fetch functions and declare the sample keywords
Willy Tarreau [Tue, 8 Jan 2013 00:23:27 +0000 (01:23 +0100)] 
MINOR: session: rename sample fetch functions and declare the sample keywords

The following sample fetch functions were only usable by ACLs but are now
usable by sample fetches too :

  sc1_bytes_in_rate, sc1_bytes_out_rate, sc1_clr_gpc0, sc1_conn_cnt,
  sc1_conn_cur, sc1_conn_rate, sc1_get_gpc0, sc1_http_err_cnt,
  sc1_http_err_rate, sc1_http_req_cnt, sc1_http_req_rate, sc1_inc_gpc0,
  sc1_kbytes_in, sc1_kbytes_out, sc1_sess_cnt, sc1_sess_rate, sc1_trackers,
  sc2_bytes_in_rate, sc2_bytes_out_rate, sc2_clr_gpc0, sc2_conn_cnt,
  sc2_conn_cur, sc2_conn_rate, sc2_get_gpc0, sc2_http_err_cnt,
  sc2_http_err_rate, sc2_http_req_cnt, sc2_http_req_rate, sc2_inc_gpc0,
  sc2_kbytes_in, sc2_kbytes_out, sc2_sess_cnt, sc2_sess_rate, sc2_trackers,
  src_bytes_in_rate, src_bytes_out_rate, src_clr_gpc0, src_conn_cnt,
  src_conn_cur, src_conn_rate, src_get_gpc0, src_http_err_cnt,
  src_http_err_rate, src_http_req_cnt, src_http_req_rate, src_inc_gpc0,
  src_kbytes_in, src_kbytes_out, src_sess_cnt, src_sess_rate,
  src_updt_conn_cnt, table_avl, table_cnt,

The fetch functions have been renamed "smp_fetch_*".

12 years agoMEDIUM: http: unify acl and sample fetch functions
Willy Tarreau [Mon, 7 Jan 2013 23:31:00 +0000 (00:31 +0100)] 
MEDIUM: http: unify acl and sample fetch functions

The following sample fetch functions were only usable by ACLs but are now
usable by sample fetches too :

    cook, cook_cnt, cook_val, hdr_cnt, hdr_ip, hdr_val, http_auth,
    http_auth_group, http_first_req, method, req_proto_http, req_ver,
    resp_ver, scook, scook_cnt, scook_val, shdr, shdr_cnt, shdr_ip,
    shdr_val, status, urlp, urlp_val,

Most of them won't bring much benefit at the moment, or are even aliases of
existing ones, however they'll be needed for ACL->SMP convergence.

A new val_usr() function was added to resolve userlist names into pointers.

The http_auth_group ACL forgot to make its first argument mandatory, so
there was a check in cfgparse to report a vague error. Now that args are
correctly parsed, let's report something more precise.

All urlp* ACLs now support an optional 3rd argument like their sample
counter-part which is the optional delimiter.

The fetch functions have been renamed "smp_fetch_*".

Some args controls on the sample keywords have been relaxed so that we
can soon use them for ACLs :

  - cookie now accepts to have an optional name ; it will return the
    first matching cookie if the name is not set ;
  - same for set-cookie and hdr

12 years agoMINOR: listener: rename sample fetch functions and declare the sample keywords
Willy Tarreau [Mon, 7 Jan 2013 21:54:17 +0000 (22:54 +0100)] 
MINOR: listener: rename sample fetch functions and declare the sample keywords

The following sample fetch functions were only usable by ACLs but are now
usable by sample fetches too :

          dst_conn, so_id,

The fetch functions have been renamed "smp_fetch_*".

12 years agoMINOR: frontend: rename sample fetch functions and declare the sample keywords
Willy Tarreau [Mon, 7 Jan 2013 21:48:29 +0000 (22:48 +0100)] 
MINOR: frontend: rename sample fetch functions and declare the sample keywords

The following sample fetch functions were only usable by ACLs but are now
usable by sample fetches too :

      fe_conn, fe_id, fe_sess_rate

The fetch functions have been renamed "smp_fetch_*".

12 years agoMINOR: backend: rename sample fetch functions and declare the sample keywords
Willy Tarreau [Mon, 7 Jan 2013 21:38:03 +0000 (22:38 +0100)] 
MINOR: backend: rename sample fetch functions and declare the sample keywords

The following sample fetch functions were only usable by ACLs but are now
usable by sample fetches too :

  avg_queue, be_conn, be_id, be_sess_rate, connslots, nbsrv,
  queue, srv_conn, srv_id, srv_is_up, srv_sess_rate

The fetch functions have been renamed "smp_fetch_*".

12 years agoMEDIUM: samples: move payload-based fetches and ACLs to their own file
Willy Tarreau [Mon, 7 Jan 2013 20:59:07 +0000 (21:59 +0100)] 
MEDIUM: samples: move payload-based fetches and ACLs to their own file

The file acl.c is a real mess, it both contains functions to parse and
process ACLs, and some sample extraction functions which act on buffers.
Some other payload analysers were arbitrarily dispatched to proto_tcp.c.

So now we're moving all payload-based fetches and ACLs to payload.c
which is capable of extracting data from buffers and rely on everything
that is protocol-independant. That way we can safely inflate this file
and only use the other ones when some fetches are really specific (eg:
HTTP, SSL, ...).

As a result of this cleanup, the following new sample fetches became
available even if they're not really useful :

  always_false, always_true, rep_ssl_hello_type, rdp_cookie_cnt,
  req_len, req_ssl_hello_type, req_ssl_sni, req_ssl_ver, wait_end

The function 'acl_fetch_nothing' was wrong and never used anywhere so it
was removed.

The "rdp_cookie" sample fetch used to have a mandatory argument while it
was optional in ACLs, which are supposed to iterate over RDP cookies. So
we're making it optional as a fetch too, and it will return the first one.

12 years agoMINOR: log: indicate it when some unreliable sample fetches are logged
Willy Tarreau [Tue, 8 Jan 2013 00:10:24 +0000 (01:10 +0100)] 
MINOR: log: indicate it when some unreliable sample fetches are logged

If a log-format involves some sample fetches that may not be present at
the logging instant, we can now report a warning.

Note that this is done both for log-format and for add-header and carefully
respects the original fetch keyword's capabilities.

12 years agoMEDIUM: samples: use new flags to describe compatibility between fetches and their...
Willy Tarreau [Mon, 7 Jan 2013 14:42:20 +0000 (15:42 +0100)] 
MEDIUM: samples: use new flags to describe compatibility between fetches and their usages

Samples fetches were relying on two flags SMP_CAP_REQ/SMP_CAP_RES to describe
whether they were compatible with requests rules or with response rules. This
was never reliable because we need a finer granularity (eg: an HTTP request
method needs to parse an HTTP request, and is available past this point).

Some fetches are also dependant on the context (eg: "hdr" uses request or
response depending where it's involved, causing some abiguity).

In order to solve this, we need to precisely indicate in fetches what they
use, and their users will have to compare with what they have.

So now we have a bunch of bits indicating where the sample is fetched in the
processing chain, with a few variants indicating for some of them if it is
permanent or volatile (eg: an HTTP status is stored into the transaction so
it is permanent, despite being caught in the response contents).

The fetches also have a second mask indicating their validity domain. This one
is computed from a conversion table at registration time, so there is no need
for doing it by hand. This validity domain consists in a bitmask with one bit
set for each usage point in the processing chain. Some provisions were made
for upcoming controls such as connection-based TCP rules which apply on top of
the connection layer but before instantiating the session.

Then everywhere a fetch is used, the bit for the control point is checked in
the fetch's validity domain, and it becomes possible to finely ensure that a
fetch will work or not.

Note that we need these two separate bitfields because some fetches are usable
both in request and response (eg: "hdr", "payload"). So the keyword will have
a "use" field made of a combination of several SMP_USE_* values, which will be
converted into a wider list of SMP_VAL_* flags.

The knowledge of permanent vs dynamic information has disappeared for now, as
it was never used. Later we'll probably reintroduce it differently when
dealing with variables. Its only use at the moment could have been to avoid
caching a dynamic rate measurement, but nothing is cached as of now.

12 years agoMEDIUM: acl: remove flag ACL_MAY_LOOKUP which is improperly used
Willy Tarreau [Fri, 4 Jan 2013 15:31:47 +0000 (16:31 +0100)] 
MEDIUM: acl: remove flag ACL_MAY_LOOKUP which is improperly used

This flag is used on ACL matches that support being looking up patterns
in trees. At the moment, only strings and IPs support tree-based lookups,
but the flag is randomly set also on integers and binary data, and is not
even always set on strings nor IPs.

Better get rid of this mess by only relying on the matching function to
decide whether or not it supports tree-based lookups, this is safer and
easier to maintain.

12 years agoBUG/CRITICAL: using HTTP information in tcp-request content may crash the process
Willy Tarreau [Fri, 29 Mar 2013 11:31:49 +0000 (12:31 +0100)] 
BUG/CRITICAL: using HTTP information in tcp-request content may crash the process

During normal HTTP request processing, request buffers are realigned if
there are less than global.maxrewrite bytes available after them, in
order to leave enough room for rewriting headers after the request. This
is done in http_wait_for_request().

However, if some HTTP inspection happens during a "tcp-request content"
rule, this realignment is not performed. In theory this is not a problem
because empty buffers are always aligned and TCP inspection happens at
the beginning of a connection. But with HTTP keep-alive, it also happens
at the beginning of each subsequent request. So if a second request was
pipelined by the client before the first one had a chance to be forwarded,
the second request will not be realigned. Then, http_wait_for_request()
will not perform such a realignment either because the request was
already parsed and marked as such. The consequence of this, is that the
rewrite of a sufficient number of such pipelined, unaligned requests may
leave less room past the request been processed than the configured
reserve, which can lead to a buffer overflow if request processing appends
some data past the end of the buffer.

A number of conditions are required for the bug to be triggered :
  - HTTP keep-alive must be enabled ;
  - HTTP inspection in TCP rules must be used ;
  - some request appending rules are needed (reqadd, x-forwarded-for)
  - since empty buffers are always realigned, the client must pipeline
    enough requests so that the buffer always contains something till
    the point where there is no more room for rewriting.

While such a configuration is quite unlikely to be met (which is
confirmed by the bug's lifetime), a few people do use these features
together for very specific usages. And more importantly, writing such
a configuration and the request to attack it is trivial.

A quick workaround consists in forcing keep-alive off by adding
"option httpclose" or "option forceclose" in the frontend. Alternatively,
disabling HTTP-based TCP inspection rules enough if the application
supports it.

At first glance, this bug does not look like it could lead to remote code
execution, as the overflowing part is controlled by the configuration and
not by the user. But some deeper analysis should be performed to confirm
this. And anyway, corrupting the process' memory and crashing it is quite
trivial.

Special thanks go to Yves Lafon from the W3C who reported this bug and
deployed significant efforts to collect the relevant data needed to
understand it in less than one week.

CVE-2013-1912 was assigned to this issue.

Note that 1.4 is also affected so the fix must be backported.

12 years agoBUG/MAJOR: http: fix regression introduced by commit d655ffe
Willy Tarreau [Tue, 2 Apr 2013 22:22:25 +0000 (00:22 +0200)] 
BUG/MAJOR: http: fix regression introduced by commit d655ffe

Sander Klein reported that since last snapshot, some downloads would
hang from nginx but succeed from apache. The culprit was not too hard
to find given the low number of recent changes affecting the data path.

Commit d655ffe slightly reorganized the HTTP state machine and
introduced this regression. The reason is that we must never jump
into the MSG_DONE case without first flushing remaining data because
this is not done anymore afterwards. This part is scheduled for
being reorganized since it's totally ugly especially since we added
compression, and this regression is an illustration of its readability.

The issue is entirely dependant on the server close sequence, which
explains why it was reproducible only with nginx here.

12 years agoBUG/MAJOR: http: fix regression introduced by commit a890d072
Willy Tarreau [Tue, 2 Apr 2013 21:16:53 +0000 (23:16 +0200)] 
BUG/MAJOR: http: fix regression introduced by commit a890d072

This commit fixed a bug and introduced a new one at the same time.
It's a stupid typo, the index to store the context is [0], not [2].

The effect is that parsing the header can loop forever if multiple
headers are found. This issue was reported by Lukas Tribus.

12 years agoBUILD: add explicit support for TFO with USE_TFO
Lukas Tribus [Tue, 2 Apr 2013 14:43:24 +0000 (16:43 +0200)] 
BUILD: add explicit support for TFO with USE_TFO

TCP Fast Open is supported in server mode since Linux 3.7, but current
libc's don't define TCP_FASTOPEN=23. Introduce the new USE flag USE_TFO
to define it manually in compat.h. Also note this in the TFO related
documentation.

12 years agoBUG/MEDIUM: ssl: improve error processing and reporting in ssl_sock_load_cert_list_file()
Willy Tarreau [Tue, 2 Apr 2013 15:35:58 +0000 (17:35 +0200)] 
BUG/MEDIUM: ssl: improve error processing and reporting in ssl_sock_load_cert_list_file()

fe61656b added the ability to load a list of certificates from a file,
but error control was incomplete and misleading, as some errors such
as missing files were not reported, and errors reported with Alert()
instead of memprintf() were inappropriate and mixed with upper errors.
Also, the code really supports a single SNI filter right now, so let's
correct it and the doc for that, leaving room for later change if needed.

12 years agoMEDIUM: ssl: add mapping from SNI to cert file using "crt-list"
Emmanuel Hocdet [Tue, 22 Jan 2013 14:31:15 +0000 (15:31 +0100)] 
MEDIUM: ssl: add mapping from SNI to cert file using "crt-list"

It designates a list of PEM file with an optional list of SNI filter
per certificate, with the following format for each line :

    <crtfile>[ <snifilter>]*

Wildcards are supported in the SNI filter. The certificates will be
presented to clients who provide a valid TLS Server Name Indication
field matching one of SNI filter. If no SNI filter is specified the
CN and alt subjects are used.

12 years agoBUG/MEDIUM: systemd-wrapper: don't leak zombie processes
Marc-Antoine Perennou [Tue, 2 Apr 2013 11:53:21 +0000 (13:53 +0200)] 
BUG/MEDIUM: systemd-wrapper: don't leak zombie processes

Formerly, if A was replaced by B, and then B by C before
A finished exiting, we didn't wait for B to finish so it
ended up as a zombie process.
Fix this by waiting randomly every child we spawn.

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
12 years agoBUG/MAJOR: http: use a static storage for sample fetch context
Willy Tarreau [Tue, 2 Apr 2013 10:01:06 +0000 (12:01 +0200)] 
BUG/MAJOR: http: use a static storage for sample fetch context

Baptiste Assmann reported that the cook*() ACLs do not work anymore.

The reason is the way we store the hdr_ctx between subsequent calls
to smp_fetch_cookie() since commit 3740635b (1.5-dev10).

The smp->ctx.a[] storage holds up to 8 pointers. It is not meant for
generic storage. We used to store hdr_ctx in the ctx, but while it used
to just fit for smp_fetch_hdr(), it does not for smp_fetch_cookie()
since we stored it at offset 2.

The correct solution is to use this storage to store a pointer to the
current hdr_ctx struct which is statically allocated.

12 years agoBUILD: add explicit support for Mac OS/X
Willy Tarreau [Tue, 2 Apr 2013 06:17:43 +0000 (08:17 +0200)] 
BUILD: add explicit support for Mac OS/X

The "osx" target may now be passed in the TARGET variable. It supports
the same features as FreeBSD and allows its users to use the GNU makefile
instead of the platform-specific makefile which lacks some features.

12 years agoBUILD: enable poll() by default in the makefile
Willy Tarreau [Tue, 2 Apr 2013 06:14:29 +0000 (08:14 +0200)] 
BUILD: enable poll() by default in the makefile

This allows to build haproxy for unknown targets and still have poll().
If for any reason a target does not support it, just passing USE_POLL=""
disables it.

12 years agoOPTIM: http: optimize the response forward state machine
Willy Tarreau [Mon, 1 Apr 2013 23:48:58 +0000 (01:48 +0200)] 
OPTIM: http: optimize the response forward state machine

By replacing the if/else series with a switch/case, we could save
another 20% on the worst case (chunks of 1 byte).

12 years agoOPTIM: http: improve branching in chunk size parser
Willy Tarreau [Mon, 1 Apr 2013 23:26:55 +0000 (01:26 +0200)] 
OPTIM: http: improve branching in chunk size parser

By tweaking a bit some conditions in http_parse_chunk_size(), we could
improve the overall performance in the worst case by 15%.

12 years agoOPTIM: buffer: remove one jump in buffer_count()
Willy Tarreau [Mon, 1 Apr 2013 23:25:57 +0000 (01:25 +0200)] 
OPTIM: buffer: remove one jump in buffer_count()

We can help gcc build an expression not involving a jump. This function
is used a lot when parsing chunks.

12 years agoMEDIUM: regex: Use PCRE JIT in acl
Hiroaki Nakamura [Sun, 13 Jan 2013 06:00:42 +0000 (15:00 +0900)] 
MEDIUM: regex: Use PCRE JIT in acl

This is a patch for using PCRE JIT in acl.

I notice regex are used in other places, but they are more complicated
to modify to use PCRE APIs. So I focused to acl in the first try.

BTW, I made a simple benchmark program for PCRE JIT beforehand.
https://github.com/hnakamur/pcre-jit-benchmark

I read the manual for PCRE JIT
http://www.manpagez.com/man/3/pcrejit/

and wrote my benchmark program.
https://github.com/hnakamur/pcre-jit-benchmark/blob/master/test-pcre.c

12 years agoDOCS: Add explanation of intermediate certs to crt paramater
Alex Davies [Sat, 2 Mar 2013 16:04:50 +0000 (16:04 +0000)] 
DOCS: Add explanation of intermediate certs to crt paramater

This change makes the "crt" block of the documentation easier to use
for those not clear on what needs to go in what file, specifically for
those using CAs that require intermediate certificates.

12 years agoBUG/MEDIUM: tools: vsnprintf() is not always reliable on Solaris
Willy Tarreau [Mon, 1 Apr 2013 20:48:54 +0000 (22:48 +0200)] 
BUG/MEDIUM: tools: vsnprintf() is not always reliable on Solaris

Seen on Solaris 8, calling vsnprintf() with a null-size results
in the output size not being computed. This causes some random
behaviour including crashes when trying to display error messages
when loading an invalid configuration.

12 years agoBUILD: fix usual isdigit() warning on solaris
Willy Tarreau [Mon, 1 Apr 2013 18:37:42 +0000 (20:37 +0200)] 
BUILD: fix usual isdigit() warning on solaris

src/standard.c: In function `str2sa_range':
src/standard.c:734: warning: subscript has type `char'

This one was recently introduced by commit c120c8d3.

12 years agoBUG/MINOR: acl: ssl_c_used, ssl_fc{,_has_crt,_has_sni} take no pattern
Willy Tarreau [Sun, 31 Mar 2013 17:44:57 +0000 (19:44 +0200)] 
BUG/MINOR: acl: ssl_c_used, ssl_fc{,_has_crt,_has_sni} take no pattern

The ones are booleans, not integers. This bug has no impact however.

12 years agoBUG/MINOR: acl: ssl_fc_{alg,use}_keysize must parse integers, not strings
Willy Tarreau [Sun, 31 Mar 2013 17:38:19 +0000 (19:38 +0200)] 
BUG/MINOR: acl: ssl_fc_{alg,use}_keysize must parse integers, not strings

This is a copy-paste typo making the ACLs unusable.

12 years agoBUG/MAJOR: ev_select: disable the select() poller if maxsock > FD_SETSIZE
Willy Tarreau [Sun, 31 Mar 2013 12:41:15 +0000 (14:41 +0200)] 
BUG/MAJOR: ev_select: disable the select() poller if maxsock > FD_SETSIZE

Some recent glibc updates have added controls on FD_SET/FD_CLR/FD_ISSET
that crash the program if it tries to use a file descriptor larger than
FD_SETSIZE.

For this reason, we now control the compatibility between global.maxsock
and FD_SETSIZE, and refuse to use select() if there too many FDs are
expected to be used. Note that on Solaris, FD_SETSIZE is already forced
to 65536, and that FreeBSD and OpenBSD allow it to be redefined, though
this is not needed thanks to kqueue which is much more efficient.

In practice, since poll() is enabled on all targets, it should not cause
any problem, unless it is explicitly disabled.

This change must be backported to 1.4 because the crashes caused by glibc
have already been reported on this version.

12 years agoMEDIUM: poll: do not use FD_* macros anymore
Willy Tarreau [Sun, 31 Mar 2013 12:06:57 +0000 (14:06 +0200)] 
MEDIUM: poll: do not use FD_* macros anymore

Some recent glibc updates have added controls on FD_SET/FD_CLR/FD_ISSET
that crash the program if it tries to use a file descriptor larger than
FD_SETSIZE.

Do not rely on FD_* macros anymore and replace them with bit fields.