]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
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.

12 years agoDOC: mention the new HTTP 307 and 308 redirect statues
Willy Tarreau [Fri, 29 Mar 2013 18:28:11 +0000 (19:28 +0100)] 
DOC: mention the new HTTP 307 and 308 redirect statues

12 years agoMINOR: http: status 301 should not be marked non-cacheable
Yves Lafon [Mon, 11 Mar 2013 15:06:05 +0000 (11:06 -0400)] 
MINOR: http: status 301 should not be marked non-cacheable

Also, browsers behaviour is inconsistent regarding the Cache-Control
header field on a 301.

12 years agoMEDIUM: http: implement redirect 307 and 308
Yves Lafon [Mon, 11 Mar 2013 15:06:05 +0000 (11:06 -0400)] 
MEDIUM: http: implement redirect 307 and 308

I needed to emit a 307 and noticed it was not available so I did it,
as well as 308.

12 years agoMINOR: http: status code 303 is HTTP/1.1 only
Yves Lafon [Mon, 11 Mar 2013 15:06:05 +0000 (11:06 -0400)] 
MINOR: http: status code 303 is HTTP/1.1 only

Don't return a 303 redirect with "HTTP/1.0" as it's HTTP/1.1 only.

12 years agoBUG/MEDIUM: http: fix another issue caused by http-send-name-header
Willy Tarreau [Tue, 26 Mar 2013 00:08:21 +0000 (01:08 +0100)] 
BUG/MEDIUM: http: fix another issue caused by http-send-name-header

An issue reported by David Coulson is that when using http-send-name-header,
the response processing would randomly be performed. The issue was first
diagnosed by Cyril Bonté as being related to a time race when processing
the closing of the response.

In practice, the issue is a bit trickier. It happens that
http_send_name_header() did not update msg->sol after a rewrite. This
counter is supposed to point to the beginning of the message's body
once headers are scheduled for being forwarded. And not updating it
means that the first forwarding of the request headers in
http_request_forward_body() does not send the correct count, leaving
some bytes in chn->to_forward.

Then if the server sends its response in a single packet with the
close, the stream interface switches to state SI_ST_DIS which in
turn moves to SI_ST_CLO in process_session(), and to close the
outgoing connection. This is detected by http_request_forward_body(),
which then switches the request message to the error state, and syncs
all FSMs and removes any response analyser.

The response analyser being removed, no processing is performed on
the response buffer, which is tunnelled as-is to the client.

Of course, the correct fix consists in having http_send_name_header()
update msg->sol. Normally this ought not to have been needed, but it
is an abuse to modify data already scheduled for being forwarded, so
it is expected that such specific handling has to be done there. Better
not have generic functions deal with such cases, so that it does not
become the standard.

Note: 1.4 does not have this issue even if it does not update the
pointer either, because it forwards from msg->som which is not
updated at the moment the connect() succeeds. So no backport is
required.

12 years agoBUG/MEDIUM: config: ACL compatibility check on "redirect" was wrong
Willy Tarreau [Mon, 25 Mar 2013 18:16:31 +0000 (19:16 +0100)] 
BUG/MEDIUM: config: ACL compatibility check on "redirect" was wrong

The check was made on "cond" instead of "rule->cond", so it never
emitted any warning since either the rule was NULL or it was set to
the last condition met.

This is 1.5-specific and the bug was introduced by commit 4baae248
in 1.5-dev17, so no backport is needed.

12 years agoBUG/MEDIUM: http: add-header should not emit "-" for empty fields
Willy Tarreau [Sun, 24 Mar 2013 06:33:22 +0000 (07:33 +0100)] 
BUG/MEDIUM: http: add-header should not emit "-" for empty fields

Patch 6cbbdbf3 fixed the missing "-" delimitors in logs but it caused
them to be emitted with "http-request add-header", eventhough it was
correctly fixed for the unique-id format. Fix this by simply removing
LOG_OPT_MANDATORY in this case.

12 years agoMAJOR: tools: support environment variables in addresses
Willy Tarreau [Mon, 11 Mar 2013 00:20:04 +0000 (01:20 +0100)] 
MAJOR: tools: support environment variables in addresses

Now that all addresses are parsed using str2sa_range(), it becomes easy
to add support for environment variables and use them everywhere an address
is needed. Environment variables are used as $VAR or ${VAR} as in shell.
Any number of variables may compose an address, allowing various fantasies
such as "fd@${FD_HTTP}" or "${LAN_DC1}.1:80".

These ones are usable in logs, bind, servers, peers, stats socket, source,
dispatch, and check address.

12 years agoMAJOR: listener: support inheriting a listening fd from the parent
Willy Tarreau [Sun, 10 Mar 2013 22:51:38 +0000 (23:51 +0100)] 
MAJOR: listener: support inheriting a listening fd from the parent

Using the address syntax "fd@<num>", a listener may inherit a file
descriptor that the caller process has already bound and passed as
this number. The fd's socket family is detected using getsockname(),
and the usual initialization is performed through the existing code
for that family, but the socket creation is skipped.

Whether the parent has performed the listen() call or not is not
important as this is detected.

For UNIX sockets, we immediately clear the path after preparing a
socket so that we never remove it in case an abort would happen due
to a late error during startup.

12 years agoMEDIUM: tools: support specifying explicit address families in str2sa_range()
Willy Tarreau [Sun, 10 Mar 2013 20:32:12 +0000 (21:32 +0100)] 
MEDIUM: tools: support specifying explicit address families in str2sa_range()

This change allows one to force the address family in any address parsed
by str2sa_range() by specifying it as a prefix followed by '@' then the
address. Currently supported address prefixes are 'ipv4@', 'ipv6@', 'unix@'.
This also helps forcing resolving for host names (when getaddrinfo is used),
and force the family of the empty address (eg: 'ipv4@' = 0.0.0.0 while
'ipv6@' = ::).

The main benefits is that unix sockets can now get a local name without
being forced to begin with a slash. This is useful during development as
it is no longer necessary to have stats socket sent to /tmp.

12 years agoCLEANUP: config: do not use multiple errmsg at once
Willy Tarreau [Sun, 10 Mar 2013 18:44:48 +0000 (19:44 +0100)] 
CLEANUP: config: do not use multiple errmsg at once

Several of the parsing functions made use of multiple errmsg/err_msg
variables which had to be freed, while there is already one in each
function that is freed upon exit. Adapt the code to use the existing
variable exclusively.

12 years agoCLEANUP: minor cleanup in str2sa_range() and str2ip()
Willy Tarreau [Sun, 10 Mar 2013 18:27:44 +0000 (19:27 +0100)] 
CLEANUP: minor cleanup in str2sa_range() and str2ip()

Don't use a statically allocated address both for str2ip and str2sa_range,
use the same. The inet and unix code paths have been splitted a little
better to improve readability.

12 years agoMEDIUM: config: add complete support for str2sa_range() in 'source' and 'usesrc'
Willy Tarreau [Sun, 10 Mar 2013 17:51:54 +0000 (18:51 +0100)] 
MEDIUM: config: add complete support for str2sa_range() in 'source' and 'usesrc'

The 'source' and 'usesrc' statements now completely rely on str2sa_range() to
parse an address. A test is made to ensure that the address family supports
connect().

12 years agoMEDIUM: config: add complete support for str2sa_range() in 'peer'
Willy Tarreau [Sun, 10 Mar 2013 17:37:42 +0000 (18:37 +0100)] 
MEDIUM: config: add complete support for str2sa_range() in 'peer'

The peer addresses are now completely parsed using str2sa_range()
and the resulting protocol is checked for support for connect().

12 years agoMEDIUM: config: add complete support for str2sa_range() in 'server'
Willy Tarreau [Wed, 6 Mar 2013 19:04:27 +0000 (20:04 +0100)] 
MEDIUM: config: add complete support for str2sa_range() in 'server'

The server addresses are now completely parsed using str2sa_range()
and the resulting protocol is checked for support for connect().

12 years agoMEDIUM: config: add complete support for str2sa_range() in server addr
Willy Tarreau [Wed, 6 Mar 2013 17:05:34 +0000 (18:05 +0100)] 
MEDIUM: config: add complete support for str2sa_range() in server addr

The server addr statement now completely relies on str2sa_range() to
parse an address.

12 years agoMEDIUM: config: add complete support for str2sa_range() in dispatch
Willy Tarreau [Wed, 6 Mar 2013 15:52:04 +0000 (16:52 +0100)] 
MEDIUM: config: add complete support for str2sa_range() in dispatch

The dispatch statement now completely relies on str2sa_range() to parse
an address.

12 years agoCLEANUP: tools: remove str2sun() which is not used anymore.
Willy Tarreau [Wed, 6 Mar 2013 14:08:16 +0000 (15:08 +0100)] 
CLEANUP: tools: remove str2sun() which is not used anymore.

12 years agoMEDIUM: config: use str2sa_range() to parse log addresses
Willy Tarreau [Wed, 6 Mar 2013 14:02:49 +0000 (15:02 +0100)] 
MEDIUM: config: use str2sa_range() to parse log addresses

str2sa_range() is now used to parse log addresses, both INET and
UNIX. str2sun() is not used anymore.

12 years agoMEDIUM: config: use a single str2sa_range() call to parse bind addresses
Willy Tarreau [Wed, 6 Mar 2013 14:45:03 +0000 (15:45 +0100)] 
MEDIUM: config: use a single str2sa_range() call to parse bind addresses

str2listener() now doesn't check the address syntax, it only relies on
str2sa_range() to retrieve the address and family.

12 years agoMEDIUM: config: make str2listener() use str2sa_range() to parse unix addresses
Willy Tarreau [Mon, 4 Mar 2013 18:56:20 +0000 (19:56 +0100)] 
MEDIUM: config: make str2listener() use str2sa_range() to parse unix addresses

Now that str2sa_range() knows how to parse UNIX addresses, make str2listener()
use it. It simplifies the function. Next step consists in unifying the error
handling to further simplify the call.

Tests have been done and show that unix sockets are correctly handled, with
and without prefixes, both for global stats and normal "bind" statements.

12 years agoMEDIUM: tools: make str2sa_range() parse unix addresses too
Willy Tarreau [Mon, 4 Mar 2013 18:48:14 +0000 (19:48 +0100)] 
MEDIUM: tools: make str2sa_range() parse unix addresses too

str2sa_range() now considers that any address beginning with '/' is a UNIX
address. It is compatible with all callers at the moment since all of them
perform this test and use a different parser for such addresses. However,
some parsers (eg: servers) still don't check for unix addresses.

12 years agoMINOR: tools: prepare str2sa_range() to accept a prefix
Willy Tarreau [Mon, 4 Mar 2013 17:22:00 +0000 (18:22 +0100)] 
MINOR: tools: prepare str2sa_range() to accept a prefix

We'll need str2sa_range() to support a prefix for unix sockets. Since
we don't always want to use it (eg: stats socket), let's not take it
unconditionally from global but let the caller pass it.

12 years agoBUG/MEDIUM: checks: don't call connect() on unsupported address families
Willy Tarreau [Mon, 4 Mar 2013 19:07:44 +0000 (20:07 +0100)] 
BUG/MEDIUM: checks: don't call connect() on unsupported address families

At the moment, all address families supported on a "server" statement support
a connect() method, but this will soon change with the generalization of
str2sa_range(). Checks currently call ->connect() unconditionally so let's
add a check for this.