]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
9 years agoMINOR: filters/http: Use a wrapper function instead of stream_int_retnclose
Christopher Faulet [Wed, 9 Dec 2015 14:55:06 +0000 (15:55 +0100)] 
MINOR: filters/http: Use a wrapper function instead of stream_int_retnclose

The function http_reply_and_close has been added in proto_http.c to wrap calls
to stream_int_retnclose. This functions will be modified when the filters will
be added.

9 years agoBUG/MINOR: http: Be sure to process all the data received from a server
Christopher Faulet [Fri, 19 Jun 2015 07:00:58 +0000 (09:00 +0200)] 
BUG/MINOR: http: Be sure to process all the data received from a server

When the response body is forwarded, if the server closes the input before the
end, an error is thrown. But if the data processing is too slow, all data could
already be received and pending in the input buffer. So this is a bug to stop
processing in this context. The server doesn't really closed the input before
the end.

As an example, this could happen when HAProxy is configured to do compression
offloading. If the server closes the connection explicitly after the response
(keep-alive disabled by the server) and if HAProxy receives the data faster than
they are compressed, then the response could be truncated.

This patch fixes the bug by checking if some pending data remain in the input
buffer before returning an error. If yes, the processing continues.

9 years agoBUG/MINOR: http: fix several off-by-one errors in the url_param parser
Willy Tarreau [Sun, 27 Dec 2015 13:51:01 +0000 (14:51 +0100)] 
BUG/MINOR: http: fix several off-by-one errors in the url_param parser

Several cases of "<=" instead of "<" were found in the url_param parser,
mostly affecting the case where the parameter is wrapping. They shouldn't
affect header operations, just body parsing in a wrapped pipelined request.

The code is a bit complicated with certain operations done multiple times
in multiple functions, so it's not sure others are not left. This code
must be re-audited.

It should only be backported to 1.6 once carefully tested, because it is
possible that other bugs relied on these ones.

9 years agoMINOR: lua: add set/get priv for applets
Thierry FOURNIER [Fri, 25 Dec 2015 00:33:18 +0000 (01:33 +0100)] 
MINOR: lua: add set/get priv for applets

The applet can't have access to the session private data. This patch
fix this problem. Now an applet can use private data stored by actions
and fecthes.

9 years agoDOC: lua: fix somme errors and add implicit types
Thierry FOURNIER [Fri, 25 Dec 2015 00:31:35 +0000 (01:31 +0100)] 
DOC: lua: fix somme errors and add implicit types

This patch fix some errors and adds implicit types for AppletHTTP
and AppletTCP.

Should be backported in 1.6

9 years agoBUG/MINOR: stream: bad return code
Thierry FOURNIER [Thu, 26 Nov 2015 18:48:04 +0000 (19:48 +0100)] 
BUG/MINOR: stream: bad return code

In error case, we expect the enum ACT_RET_PRS_ERR, but the
function "stream_parse_use_service()" returns "-1"

This patch must be backported in 1.6

9 years agoBUILD/MINOR: regex: missing header
Thierry FOURNIER [Thu, 26 Nov 2015 18:33:54 +0000 (19:33 +0100)] 
BUILD/MINOR: regex: missing header

When HAProxy is compiled with pcre, strlen() is used, but <string.h>
is not included.

This patch must be backported in 1.6

9 years agoDOC: compression: missing mention of libslz for compression algorithm
Baptiste Assmann [Mon, 21 Dec 2015 16:57:32 +0000 (17:57 +0100)] 
DOC: compression: missing mention of libslz for compression algorithm

Compression algorithm documentation only mention zlib, while HAProxy
also support libslz, which is much lighter and faster.

9 years agoDOC: mailers: typo in 'hostname' description
Baptiste Assmann [Mon, 21 Dec 2015 14:27:53 +0000 (15:27 +0100)] 
DOC: mailers: typo in 'hostname' description

fixed a typo caused by a copy/paste where <hostname> parameter
description was replaced by <emailaddr>...

9 years agoDOC: lua: fix lua API
Thierry FOURNIER [Mon, 21 Dec 2015 10:13:52 +0000 (11:13 +0100)] 
DOC: lua: fix lua API

This patch fix the Lua API documentation, and adds some internal link
between values returned and associated class.

This patch can be backported in 1.6.

9 years ago[RELEASE] Released version 1.7-dev1 v1.7-dev1
Willy Tarreau [Sun, 20 Dec 2015 22:33:18 +0000 (23:33 +0100)] 
[RELEASE] Released version 1.7-dev1

Released version 1.7-dev1 with the following main changes :
    - DOC: specify that stats socket doc (section 9.2) is in management
    - BUILD: install only relevant and existing documentation
    - CLEANUP: don't ignore debian/ directory if present
    - BUG/MINOR: dns: parsing error of some DNS response
    - BUG/MEDIUM: namespaces: don't fail if no namespace is used
    - BUG/MAJOR: ssl: free the generated SSL_CTX if the LRU cache is disabled
    - MEDIUM: dns: Don't use the ANY query type
    - BUILD: ssl: fix build error introduced in commit 7969a3 with OpenSSL < 1.0.0
    - DOC: fix a typo for a "deviceatlas" keyword
    - FIX: small typo in an example using the "Referer" header
    - MINOR: cli: ability to set per-server maxconn
    - DEBUG/MINOR: memory: add a build option to disable memory pools sharing
    - DEBUG/MEDIUM: memory: optionally protect free data in pools
    - DEBUG/MEDIUM: memory: add optional control pool memory operations
    - MEDIUM: memory: add accounting for failed allocations
    - BUG/MEDIUM: config: count memory limits on 64 bits, not 32
    - BUG/MAJOR: dns: first DNS response packet not matching queried hostname may lead to a loop
    - BUG/MINOR: dns: unable to parse CNAMEs response
    - BUG/MINOR: examples/haproxy.init: missing brace in quiet_check()
    - DOC: deviceatlas: more example use cases.
    - MINOR: config: allow IPv6 bracketed literals
    - BUG/BUILD: replace haproxy-systemd-wrapper with $(EXTRA) in install-bin.
    - BUILD: add Haiku as supported target.
    - BUG/MAJOR: http: don't requeue an idle connection that is already queued
    - DOC: typo on capture.res.hdr and capture.req.hdr
    - BUG/MINOR: dns: check for duplicate nameserver id in a resolvers section was missing
    - CLEANUP: use direction names in place of numeric values
    - BUG/MEDIUM: lua: sample fetches based on response doesn't work
    - MINOR: check: add agent-send server parameter
    - BUG/MINOR: http rule: http capture 'id' rule points to a non existing id
    - BUG/MINOR: server: check return value of fgets() in apply_server_state()
    - BUG/MINOR: acl: don't use record layer in req_ssl_ver
    - BUILD: freebsd: double declaration
    - BUG/MEDIUM: lua: clean output buffer
    - BUILD: check for libressl to be able to build against it
    - DOC: lua-api/index.rst small example fixes, spelling correction.
    - DOC: lua: architecture and first steps
    - DOC: relation between timeout http-request and option http-buffer-request
    - BUILD: Make deviceatlas require PCRE
    - BUG: http: do not abort keep-alive connections on server timeout
    - BUG/MEDIUM: http: switch the request channel to no-delay once done.
    - BUG/MINOR: lua: don't force-sslv3 LUA's SSL socket
    - BUILD/MINOR: http: proto_http.h needs sample.h
    - BUG/MEDIUM: http: don't enable auto-close on the response side
    - BUG/MEDIUM: stream: fix half-closed timeout handling
    - CLEANUP: compression: don't allocate DEFAULT_MAXZLIBMEM without USE_ZLIB
    - BUG/MEDIUM: cli: changing compression rate-limiting must require admin level
    - BUG/MEDIUM: sample: urlp can't match an empty value
    - BUILD: dumpstats: silencing warning for printf format specifier / time_t
    - CLEANUP: proxy: calloc call inverted arguments
    - MINOR: da: silent logging by default and displaying DeviceAtlas support if built.
    - BUG/MEDIUM: da: stop DeviceAtlas processing in the convertor if there is no input.
    - DOC: Edited 51Degrees section of README/
    - BUG/MEDIUM: checks: email-alert not working when declared in defaults
    - BUG/MINOR: checks: email-alert causes a segfault when an unknown mailers section is configured
    - BUG/MINOR: checks: typo in an email-alert error message
    - BUG/MINOR: tcpcheck: conf parsing error when no port configured on server and last rule is a CONNECT with no port
    - BUG/MINOR: tcpcheck: conf parsing error when no port configured on server and first rule(s) is (are) COMMENT
    - BUG/MEDIUM: http: fix http-reuse when frontend and backend differ
    - DOC: prefer using http-request/response over reqXXX/rspXXX directives
    - CLEANUP: haproxy: using _GNU_SOURCE instead of __USE_GNU macro.
    - MINOR: ssl: Added cert_key_and_chain struct
    - MEDIUM: ssl: Added support for creating SSL_CTX with multiple certs
    - MINOR: ssl: Added multi cert support for crt-list config keyword
    - MEDIUM: ssl: Added multi cert support for loading crt directories
    - MEDIUM: ssl: Added support for Multi-Cert OCSP Stapling
    - BUILD: ssl: set SSL_SOCK_NUM_KEYTYPES with openssl < 1.0.2
    - MINOR: config: make tune.recv_enough configurable
    - BUG/MEDIUM: config: properly adjust maxconn with nbproc when memmax is forced
    - DOC: ssl: Adding docs for Multi-Cert bundling
    - BUG/MEDIUM: peers: table entries learned from a remote are pushed to others after a random delay.
    - BUG/MEDIUM: peers: old stick table updates could be repushed.
    - MINOR: lua: service/applet can have access to the HTTP headers when a POST is received
    - REORG/MINOR: lua: convert boolean "int" to bitfield
    - BUG/MEDIUM: lua: Lua applets must not fetch samples using http_txn
    - BUG/MINOR: lua: Lua applets must not use http_txn
    - BUG/MEDIUM: lua: Forbid HTTP applets from being called from tcp rulesets
    - BUG/MAJOR: lua: Do not force the HTTP analysers in use-services
    - CLEANUP: lua: bad error messages
    - CONTRIB: initiate a debugging suite to make debugging easier

9 years agoCONTRIB: initiate a debugging suite to make debugging easier
Willy Tarreau [Sun, 20 Dec 2015 22:21:57 +0000 (23:21 +0100)] 
CONTRIB: initiate a debugging suite to make debugging easier

The goal is to have a collection of quick-n-dirty utilities that make
debugging easier and that can easily be modified when needed. The first
utility in this series is called "flags". For a given numeric argument,
it reports the various known combinations of flags for channels, streams
and so on. This way it's easy to copy-paste values from the CLI or from
gdb and immediately know what state a stream-interface or connection is
in.

9 years agoCLEANUP: lua: bad error messages
Thierry FOURNIER [Sun, 20 Dec 2015 18:51:06 +0000 (19:51 +0100)] 
CLEANUP: lua: bad error messages

An error message reference "register_service" in place of
"register_action".

This one should be backported to 1.6.

9 years agoBUG/MAJOR: lua: Do not force the HTTP analysers in use-services
Thierry FOURNIER [Sun, 20 Dec 2015 18:14:35 +0000 (19:14 +0100)] 
BUG/MAJOR: lua: Do not force the HTTP analysers in use-services

INNER and XFERBODY analyzer were set in order to support HTTP applets
from TCP rulesets, but this does not work (cf previous patch).

Other cases already provides theses analyzers, so their addition is
not needed. Furthermore if INNER was set it could cause some headers
to be rewritten (ex: connection) after headers were already forwarded,
resulting in a crash in buffer_insert_line2().

Special thanks to Bernd Helm for providing very detailed information,
captures and stack traces making it possible to spot the root cause
here.

This fix must be backported to 1.6.

9 years agoBUG/MEDIUM: lua: Forbid HTTP applets from being called from tcp rulesets
Thierry FOURNIER [Sun, 20 Dec 2015 19:13:14 +0000 (20:13 +0100)] 
BUG/MEDIUM: lua: Forbid HTTP applets from being called from tcp rulesets

HTTP applets request requires everything initilized by
"http_process_request" (analyzer flag AN_REQ_HTTP_INNER).
The applet will be immediately initilized, but its before
the call of this analyzer.

Due to this problem HTTP applets could be called with uncompletely
initialized http_txn.

This fix must be backported to 1.6.

9 years agoBUG/MINOR: lua: Lua applets must not use http_txn
Thierry FOURNIER [Sun, 20 Dec 2015 18:14:52 +0000 (19:14 +0100)] 
BUG/MINOR: lua: Lua applets must not use http_txn

In certain circumstances (eg: Lua HTTP applet called from a
TCP ruleset before http_process_request()), the HTTP TXN is not
yet fully initialized so some information it contains cannot be
relied on. Such information include the HTTP version, the state
of the expect: 100-continue header, the connection header and
the transfer-encoding header.

Here the bug only turns something which already doesn't work
into something wrong, but better avoid any references to the
http_txn from the Lua code to avoid future mistakes.

This patch should be backported into 1.6 for code consistency.

9 years agoBUG/MEDIUM: lua: Lua applets must not fetch samples using http_txn
Thierry FOURNIER [Sun, 20 Dec 2015 17:43:03 +0000 (18:43 +0100)] 
BUG/MEDIUM: lua: Lua applets must not fetch samples using http_txn

If a sample fetch needing http_txn is called from an HTTP Lua applet,
the result will be invalid and may even cause a crash because some HTTP
data can be forwarded and the HTTP txn is no longer valid.

Here the solution is to ensure that a fetch called from Lua never
needs http_txn. This is done thanks to a new flag HLUA_F_MAY_USE_HTTP
which indicates whether or not it is safe to call a fetch which needs
HTTP.

This fix needs to be backported to 1.6.

9 years agoREORG/MINOR: lua: convert boolean "int" to bitfield
Thierry FOURNIER [Sun, 20 Dec 2015 17:42:25 +0000 (18:42 +0100)] 
REORG/MINOR: lua: convert boolean "int" to bitfield

This patch converts a boolean "int" to a bitfiled. The main
reason is to save space in the struct if another flag may will
be require.

Note that this patch is required for next fix and will need to be
backported to 1.6.

9 years agoMINOR: lua: service/applet can have access to the HTTP headers when a POST is received
Thierry FOURNIER [Fri, 11 Dec 2015 16:10:09 +0000 (17:10 +0100)] 
MINOR: lua: service/applet can have access to the HTTP headers when a POST is received

When a POST is processed by a Lua service, the HTTP header are
potentially gone. So, we cannot retrieve their content using
the standard "hdr" sample fetchs (which will soon become invalid
anyway) from an applet.

This patch add an entry "headers" to the object applet_http. This
entry is an array containing all the headers. It permits to use the
HTTP headers during the processing of the service.

Many thanks to Jan Bruder for reporting this issue with enough
details to reproduce it.

This patch will have to be backported to 1.6 since it will be the
only way to access headers from Lua applets.

9 years agoBUG/MEDIUM: peers: old stick table updates could be repushed.
Emeric Brun [Wed, 16 Dec 2015 14:28:12 +0000 (15:28 +0100)] 
BUG/MEDIUM: peers: old stick table updates could be repushed.

Because the stick table updates tree was not properly initialized to EB_ROOT_UNIQUE.

9 years agoBUG/MEDIUM: peers: table entries learned from a remote are pushed to others after...
Emeric Brun [Wed, 16 Dec 2015 14:16:46 +0000 (15:16 +0100)] 
BUG/MEDIUM: peers: table entries learned from a remote are pushed to others after a random delay.

New sticktable entries learned from a remote peer can be pushed to others after
a random delay because they are not inserted at the right position in the updates
tree.

9 years agoDOC: ssl: Adding docs for Multi-Cert bundling
yanbzhu [Mon, 14 Dec 2015 20:10:25 +0000 (15:10 -0500)] 
DOC: ssl: Adding docs for Multi-Cert bundling

Added entries in crt and crt-list to document multi-cert bundling.

9 years agoBUG/MEDIUM: config: properly adjust maxconn with nbproc when memmax is forced
Willy Tarreau [Mon, 14 Dec 2015 11:46:07 +0000 (12:46 +0100)] 
BUG/MEDIUM: config: properly adjust maxconn with nbproc when memmax is forced

When memmax is forced using "-m", the per-process memory limit is enforced
using setrlimit(), but this value is not used to compute the automatic
maxconn limit. In addition, the per-process memory limit didn't consider
the fact that the shared SSL cache only needs to be accounted once.

The doc was also fixed to clearly state that "-m" is global and not per
process. It makes sense because people who use -m want to protect the
system's resources regardless of whatever appears in the configuration.

9 years agoMINOR: config: make tune.recv_enough configurable
Willy Tarreau [Mon, 14 Dec 2015 11:04:35 +0000 (12:04 +0100)] 
MINOR: config: make tune.recv_enough configurable

This setting used to be assigned to a variable tunable from a constant
and for an unknown reason never made its way into the config parser.

tune.recv_enough <number>
  Haproxy uses some hints to detect that a short read indicates the end of the
  socket buffers. One of them is that a read returns more than <recv_enough>
  bytes, which defaults to 10136 (7 segments of 1448 each). This default value
  may be changed by this setting to better deal with workloads involving lots
  of short messages such as telnet or SSH sessions.

9 years agoBUILD: ssl: set SSL_SOCK_NUM_KEYTYPES with openssl < 1.0.2
Willy Tarreau [Mon, 14 Dec 2015 10:28:33 +0000 (11:28 +0100)] 
BUILD: ssl: set SSL_SOCK_NUM_KEYTYPES with openssl < 1.0.2

Last patch unfortunately broke build with openssl older than 1.0.2.
Let's just define a single key type in this case.

9 years agoMEDIUM: ssl: Added support for Multi-Cert OCSP Stapling
yanbzhu [Thu, 10 Dec 2015 20:07:30 +0000 (15:07 -0500)] 
MEDIUM: ssl: Added support for Multi-Cert OCSP Stapling

Enabled loading of OCSP staple responses (.ocsp files) when processing a
bundled certificate with multiple keytypes.

9 years agoMEDIUM: ssl: Added multi cert support for loading crt directories
yanbzhu [Wed, 9 Dec 2015 18:35:14 +0000 (13:35 -0500)] 
MEDIUM: ssl: Added multi cert support for loading crt directories

Loading of multiple certs into shared contexts is now supported if a user
specifies a directory instead of a cert file.

9 years agoMINOR: ssl: Added multi cert support for crt-list config keyword
yanbzhu [Wed, 2 Dec 2015 18:54:14 +0000 (13:54 -0500)] 
MINOR: ssl: Added multi cert support for crt-list config keyword

Added support for loading mutiple certs into shared contexts when they
are specified in a crt-list

Note that it's not practical to support SNI filters with multicerts, so
any SNI filters that's provided to the crt-list is ignored if a
multi-cert opertion is used.

9 years agoMEDIUM: ssl: Added support for creating SSL_CTX with multiple certs
yanbzhu [Wed, 2 Dec 2015 18:01:29 +0000 (13:01 -0500)] 
MEDIUM: ssl: Added support for creating SSL_CTX with multiple certs

Added ability for users to specify multiple certificates that all relate
a single server. Users do this by specifying certificate "cert_name.pem"
but having "cert_name.pem.rsa", "cert_name.pem.dsa" and/or
"cert_name.pem.ecdsa" in the directory.

HAProxy will now intelligently search for those 3 files and try combine
them into as few SSL_CTX's as possible based on CN/SAN. This will allow
HAProxy to support multiple ciphersuite key algorithms off a single
SSL_CTX.

This change integrates into the existing architecture of SNI lookup and
multiple SNI's can point to the same SSL_CTX, which can support multiple
key_types.

9 years agoMINOR: ssl: Added cert_key_and_chain struct
yanbzhu [Tue, 1 Dec 2015 20:16:07 +0000 (15:16 -0500)] 
MINOR: ssl: Added cert_key_and_chain struct

Added cert_key_and_chain struct to ssl. This struct will store the
contents of a crt path (from the config file) into memory. This will
allow us to use the data stored in memory instead of reading the file
multiple times.

This will be used to support a later commit to load multiple pkeys/certs
into a single SSL_CTX

9 years agoCLEANUP: haproxy: using _GNU_SOURCE instead of __USE_GNU macro.
David Carlier [Tue, 8 Dec 2015 21:43:09 +0000 (21:43 +0000)] 
CLEANUP: haproxy: using _GNU_SOURCE instead of __USE_GNU macro.

In order to properly enable sched_setaffinity, in some versions of Linux,
it is rather _GNU_SOURCE than __USE_GNU (spotted on Alpine Linux for instance),
also for the sake of consistency as __USE_GNU seems not used across the code and
for last, it seems on Linux it is the best way to enable non portable code.
On Linux glibc's based versions, it seems _GNU_SOURCE defines __USE_GNU
it should be safe enough.

9 years agoDOC: prefer using http-request/response over reqXXX/rspXXX directives
Ruoshan Huang [Tue, 8 Dec 2015 13:00:23 +0000 (21:00 +0800)] 
DOC: prefer using http-request/response over reqXXX/rspXXX directives

add referrence for "http-request" or "http-response" in reqXXX/rspXXX
directives.

add a paragraph in "http-request" and "http-response" stating that
reqXXX/rspXXX directives are discouraged

9 years agoBUG/MEDIUM: http: fix http-reuse when frontend and backend differ
Willy Tarreau [Mon, 7 Dec 2015 16:04:59 +0000 (17:04 +0100)] 
BUG/MEDIUM: http: fix http-reuse when frontend and backend differ

Krishna Kumar reported that the following configuration doesn't permit
HTTP reuse between two clients :

    frontend private-frontend
        mode http
        bind :8001
        default_backend private-backend

    backend private-backend
        mode http
        http-reuse always
        server bck 127.0.0.1:8888

The reason for this is that in http_end_txn_clean_session() we check the
stream's backend backend's http-reuse option before deciding whether the
backend connection should be moved back to the server's pool or not. But
since we're doing this after the call to http_reset_txn(), the backend is
reset to match the frontend, which doesn't have the option. However it
will work fine in a setup involving a "listen" section.

We just need to keep a pointer to the current backend before calling
http_reset_txn(). The code does that and replaces the few remaining
references to s->be inside the same function so that if any part of
code were to be moved later, this trap doesn't happen again.

This fix must be backported to 1.6.

9 years agoBUG/MINOR: tcpcheck: conf parsing error when no port configured on server and first...
Baptiste Assmann [Fri, 4 Dec 2015 05:49:31 +0000 (06:49 +0100)] 
BUG/MINOR: tcpcheck: conf parsing error when no port configured on server and first rule(s) is (are) COMMENT

A small configuration parsing error exists when no port is setup on the
server IP:port statement and the server's parameter 'port' is not set
and if the first tcp-check rule is a comment, like in the example below:

  backend b
   option tcp-check
   tcp-check comment blah
   tcp-check connect 8444
   server s 127.0.0.1 check

In such case, an ALERT is improperly returned, despite this
configuration is valid and works.

The new code move the pointer to the first tcp-check rule which isn't a
comment before checking the presence of the port.

backport status: 1.6 and above

9 years agoBUG/MINOR: tcpcheck: conf parsing error when no port configured on server and last...
Baptiste Assmann [Fri, 4 Dec 2015 05:57:25 +0000 (06:57 +0100)] 
BUG/MINOR: tcpcheck: conf parsing error when no port configured on server and last rule is a CONNECT with no port

Current configuration parsing is permissive in such situation:
A server in a backend with no port conigured on the IP address
statement, no 'port' parameter configured and last rule of a tcp-check
is a CONNECT with no port.

The current code currently parses all the rules to validate a port is
well available, but it misses the last one, which means such
configuration is valid:

  backend b
   option tcp-check
   tcp-check connect port 8444
   tcp-check connect
   server s 127.0.0.1 check

the second connect tentative is sent to port '0'...

Current patch fixes this by parsing the list the right way, including
the last rule.

backport status: 1.6 and above

9 years agoBUG/MINOR: checks: typo in an email-alert error message
Cyril Bonté [Fri, 4 Dec 2015 02:07:08 +0000 (03:07 +0100)] 
BUG/MINOR: checks: typo in an email-alert error message

When the email alert message couldn't be formatted, the logged error message
said the contrary.

This fix must be backported to 1.6.

9 years agoBUG/MINOR: checks: email-alert causes a segfault when an unknown mailers section...
Cyril Bonté [Fri, 4 Dec 2015 02:07:07 +0000 (03:07 +0100)] 
BUG/MINOR: checks: email-alert causes a segfault when an unknown mailers section is configured

A segfault can occur during at the initialization phase, when an unknown
"mailers" name is configured. This happens when "email-alert myhostname" is not
set, where a direct pointer to an array is used instead of copying the string,
causing the segfault when haproxy tries to free the memory.

This is a minor issue because the configuration is invalid and a fatal error
will remain, but it should be fixed to prevent reload issues.

Example of minimal configuration to reproduce the bug :
    backend example
        email-alert mailers NOT_FOUND
        email-alert from foo@localhost
        email-alert to bar@localhost

This fix must be backported to 1.6.

9 years agoBUG/MEDIUM: checks: email-alert not working when declared in defaults
Cyril Bonté [Fri, 4 Dec 2015 02:07:06 +0000 (03:07 +0100)] 
BUG/MEDIUM: checks: email-alert not working when declared in defaults

Tommy Atkinson and Sylvain Faivre reported that email alerts didn't work when
they were declared in the defaults section. This is due to the use of an
internal attribute which is set once an email-alert is at least partially
configured. But this attribute was not propagated to the current proxy during
the configuration parsing.

Not that the issue doesn't occur if "email-alert myhostname" is configured in
the defaults section.

This fix must be backported to 1.6.

9 years agoDOC: Edited 51Degrees section of README/
Ben Shillito [Thu, 3 Dec 2015 10:36:20 +0000 (10:36 +0000)] 
DOC: Edited 51Degrees section of README/

9 years agoBUG/MEDIUM: da: stop DeviceAtlas processing in the convertor if there is no input.
David Carlier [Wed, 2 Dec 2015 12:05:42 +0000 (12:05 +0000)] 
BUG/MEDIUM: da: stop DeviceAtlas processing in the convertor if there is no input.

In case a HTTP header modifier, like req*del, is used, the User-Agent would be removed
and cause a segfault, hence the work is stopped in due time.

9 years agoMINOR: da: silent logging by default and displaying DeviceAtlas support if built.
David Carlier [Wed, 2 Dec 2015 11:22:53 +0000 (11:22 +0000)] 
MINOR: da: silent logging by default and displaying DeviceAtlas support if built.

9 years agoCLEANUP: proxy: calloc call inverted arguments
David CARLIER [Wed, 25 Nov 2015 15:27:36 +0000 (15:27 +0000)] 
CLEANUP: proxy: calloc call inverted arguments

Nothing major but a human typo mistake.

9 years agoBUILD: dumpstats: silencing warning for printf format specifier / time_t
David Carlier [Wed, 18 Nov 2015 06:10:22 +0000 (06:10 +0000)] 
BUILD: dumpstats: silencing warning for printf format specifier / time_t

time_t is not necesseraly a long int (spotted in OpenBSD), so just an explicit cast to
avoid the compiler warning. should be safe enough.

9 years agoBUG/MEDIUM: sample: urlp can't match an empty value
Cyril Bonté [Thu, 26 Nov 2015 20:39:56 +0000 (21:39 +0100)] 
BUG/MEDIUM: sample: urlp can't match an empty value

Currently urlp fetching samples were able to find parameters with an empty
value, but the return code depended on the value length. The final result was
that acls using urlp couldn't match empty values.

Example of acl which always returned "false":
  acl MATCH_EMPTY urlp(foo) -m len 0

The fix consists in unconditionally return 1 when the parameter is found.

This fix must be backported to 1.6 and 1.5.

9 years agoBUG/MEDIUM: cli: changing compression rate-limiting must require admin level
Willy Tarreau [Thu, 26 Nov 2015 17:32:39 +0000 (18:32 +0100)] 
BUG/MEDIUM: cli: changing compression rate-limiting must require admin level

Right now it's possible to change the global compression rate limiting
without the CLI being at the admin level.

This fix must be backported to 1.6 and 1.5.

9 years agoCLEANUP: compression: don't allocate DEFAULT_MAXZLIBMEM without USE_ZLIB
Willy Tarreau [Thu, 26 Nov 2015 15:34:56 +0000 (16:34 +0100)] 
CLEANUP: compression: don't allocate DEFAULT_MAXZLIBMEM without USE_ZLIB

It's pointless to reserve this amount of memory when zlib is not used.
Adding the condition will make build scripts easier to manage. This may
be backported to 1.6.

9 years agoBUG/MEDIUM: stream: fix half-closed timeout handling
Willy Tarreau [Wed, 25 Nov 2015 19:17:27 +0000 (20:17 +0100)] 
BUG/MEDIUM: stream: fix half-closed timeout handling

client-fin and server-fin are bogus. They are applied on the write
side after a SHUTR was seen. The immediate effect is that sometimes
if a SHUTR was seen after a SHUTW on the same side, the timeout is
enabled again regardless of the fact that the output is already
closed. This results in the timeout event not to be processed and
a busy poll loop to happen until another timeout on the stream gets
rid of it. Note that haproxy continues its job during this, it's just
that it eats all the CPU trying to handle an event that it ignores.

An reproducible case consists in having a client stop reading data from
a server to ensure data remain in the response buffer, then the client
sends a shutdown(write). If abortonclose is enabled on haproxy, the
shutdown is passed to the server side and the server responds with a
SHUTR that cannot immediately be forwarded to the client since the
buffer is full. During this time the event is ignored and the task is
woken again in loops.

It is worth noting that the timeout handling since 1.5 is a bit fragile
and that it might be possible that other similar conditions still exist,
so the timeout handling should be audited regarding this issue.

Many thanks to BaiYang for providing detailed information showing the
problem in action.

This bug also affects 1.5 thus the fix must be backported.

9 years agoBUG/MEDIUM: http: don't enable auto-close on the response side
Willy Tarreau [Wed, 25 Nov 2015 19:11:11 +0000 (20:11 +0100)] 
BUG/MEDIUM: http: don't enable auto-close on the response side

There is a bug where "option http-keep-alive" doesn't force a response
to stay in keep-alive if the server sends the FIN along with the response
on the second or subsequent response. The reason is that the auto-close
was forced enabled when recycling the HTTP transaction and it's never
disabled along the response processing chain before the SHUTR gets a
chance to be forwarded to the client side. The MSG_DONE state of the
HTTP response properly disables it but too late.

There's no more reason for enabling auto-close here, because either it
doesn't matter in non-keep-alive modes because the connection is closed,
or it is automatically enabled by process_stream() when it sees there's
no analyser on the stream.

This bug also affects 1.5 so a backport is desired.

9 years agoBUILD/MINOR: http: proto_http.h needs sample.h
Willy Tarreau [Wed, 25 Nov 2015 10:29:47 +0000 (11:29 +0100)] 
BUILD/MINOR: http: proto_http.h needs sample.h

Since commit fd7edd3 ("MINOR: Move http method enum from proto_http to sample")
proto_http.h needs to include sample.h. This can be backported to 1.6 though
it doesn't affect existing code.

9 years agoBUG/MINOR: lua: don't force-sslv3 LUA's SSL socket
Lukas Tribus [Thu, 26 Nov 2015 00:48:08 +0000 (01:48 +0100)] 
BUG/MINOR: lua: don't force-sslv3 LUA's SSL socket

Sander Klein reported an error messages about SSLv3 not
being supported on Debian 8, although he didn't force-sslv3.

Vincent Bernat tracked this down to the LUA initialization, which
actually does force-sslv3.

This patch removes force-sslv3 from the LUA initialization, so
the LUA SSL socket can actually use TLS and doesn't trigger
warnings when SSLv3 is not supported by libssl (such as in
Debian 8).

This should be backported to 1.6.

9 years agoBUG/MEDIUM: http: switch the request channel to no-delay once done.
Willy Tarreau [Wed, 18 Nov 2015 10:59:55 +0000 (11:59 +0100)] 
BUG/MEDIUM: http: switch the request channel to no-delay once done.

There's an issue when sending POST data that came in a second packet,
the CF_NEVER_WAIT flag is not always set on the request channel, while
the server is waiting for the request. We must always set this flag in
this case since we're not going to shut down after sending, contrary
to the response side.

Note that option http-no-delay works around this issue.

Reproducer :

listen  px
        mode http
        timeout client 10s
        timeout server 5s
        timeout connect 3s
        option http-server-close
        #option http-no-delay
        bind :8001
        server s1 127.0.0.1:8003

$ (printf "POST / HTTP/1.1\r\nTransfer-encoding: chunked\r\n\r\n"; sleep 0.01; printf "10\r\nAZERTYUIOPQSDFGH\r\n0\r\n\r\n") | nc6 0 8001

Before this fix :

12:03:31.946763 epoll_wait(3, {{EPOLLIN, {u32=5, u64=5}}}, 200, 1000) = 1
12:03:32.634175 accept4(5, {sa_family=AF_INET, sin_port=htons(53849), sin_addr=inet_addr("127.0.0.1")}, [16], SOCK_NONBLOCK) = 6
12:03:32.634318 setsockopt(6, SOL_TCP, TCP_NODELAY, [1], 4) = 0
12:03:32.634434 accept4(5, 0x7ffccfbb2cf0, [128], SOCK_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
12:03:32.634574 recvfrom(6, "POST / HTTP/1.1\r\nTransfer-encodi"..., 8192, 0, NULL, NULL) = 47
12:03:32.634809 setsockopt(6, SOL_TCP, TCP_QUICKACK, [1], 4) = 0
12:03:32.634952 socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 7
12:03:32.635031 fcntl(7, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
12:03:32.635089 setsockopt(7, SOL_TCP, TCP_NODELAY, [1], 4) = 0
12:03:32.635153 connect(7, {sa_family=AF_INET, sin_port=htons(8003), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
12:03:32.635315 epoll_wait(3, {}, 200, 0) = 0
12:03:32.635394 sendto(7, "POST / HTTP/1.1\r\nTransfer-encodi"..., 66, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 66
12:03:32.635527 recvfrom(6, 0x7f0224e66024, 8192, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
12:03:32.635651 epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN|0x2000, {u32=6, u64=6}}) = 0
12:03:32.635782 epoll_wait(3, {}, 200, 0) = 0
12:03:32.635842 recvfrom(7, 0x7f0224e66024, 8192, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
12:03:32.635924 epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLIN|0x2000, {u32=7, u64=7}}) = 0
12:03:32.636027 epoll_wait(3, {{EPOLLIN, {u32=6, u64=6}}}, 200, 1000) = 1
12:03:32.644892 recvfrom(6, "10\r\nAZERTYUIOPQSDFGH\r\n0\r\n\r\n", 8192, 0, NULL, NULL) = 27
12:03:32.645016 epoll_wait(3, {}, 200, 0) = 0
12:03:32.645105 sendto(7, "10\r\nAZERTYUIOPQSDFGH\r\n0\r\n\r\n", 27, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_MORE, NULL, 0) = 27

After the fix :

11:59:12.538617 connect(7, {sa_family=AF_INET, sin_port=htons(8003), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
11:59:12.538787 epoll_wait(3, {}, 200, 0) = 0
11:59:12.538867 sendto(7, "POST / HTTP/1.1\r\nTransfer-encodi"..., 66, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 66
11:59:12.539031 recvfrom(6, 0x7f832ce45024, 8192, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
11:59:12.539161 epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN|0x2000, {u32=6, u64=6}}) = 0
11:59:12.539259 epoll_wait(3, {}, 200, 0) = 0
11:59:12.539337 recvfrom(7, 0x7f832ce45024, 8192, 0, 0, 0) = -1 EAGAIN (Resource temporarily unavailable)
11:59:12.539421 epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLIN|0x2000, {u32=7, u64=7}}) = 0
11:59:12.539499 epoll_wait(3, {{EPOLLIN, {u32=6, u64=6}}}, 200, 1000) = 1
11:59:12.548519 recvfrom(6, "10\r\nAZERTYUIOPQSDFGH\r\n0\r\n\r\n", 8192, 0, NULL, NULL) = 27
11:59:12.548844 epoll_wait(3, {}, 200, 0) = 0
11:59:12.549012 sendto(7, "10\r\nAZERTYUIOPQSDFGH\r\n0\r\n\r\n", 27, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 27
11:59:12.549454 epoll_wait(3, {}, 200, 1000) = 0

This fix must be backported to 1.6, 1.5 and 1.4.

9 years agoBUG: http: do not abort keep-alive connections on server timeout
lsenta [Fri, 13 Nov 2015 09:44:22 +0000 (10:44 +0100)] 
BUG: http: do not abort keep-alive connections on server timeout

When a server timeout is detected on the second or nth request of a keep-alive
connection, HAProxy closes the connection without writing a response.
Some clients would fail with a remote disconnected exception and some
others would retry potentially unsafe requests.

This patch removes the special case and makes sure a 504 timeout is
written back whenever a server timeout is handled.

Signed-off-by: lsenta <laurent.senta@gmail.com>
9 years agoBUILD: Make deviceatlas require PCRE
David CARLIER [Fri, 6 Nov 2015 15:13:06 +0000 (15:13 +0000)] 
BUILD: Make deviceatlas require PCRE

Makefile deviceatlas throwing an error if the necessary pcre flag
is not passed avoiding surprising bunch of 'undefined reference'
for the user. Plus a tiny typo in OPENSSL area.

[wt: backport to 1.6]

9 years agoDOC: relation between timeout http-request and option http-buffer-request
Baptiste Assmann [Wed, 28 Oct 2015 12:49:01 +0000 (13:49 +0100)] 
DOC: relation between timeout http-request and option http-buffer-request

The documentation missed the explanation and relation between the
timeout http-request and option http-buffer-request.
Combined together, it helps protecting against slow POST types of
attacks.

[wt: backport to 1.6]

9 years agoDOC: lua: architecture and first steps
Thierry FOURNIER [Sun, 8 Nov 2015 21:02:21 +0000 (22:02 +0100)] 
DOC: lua: architecture and first steps

Add some lua documentation

[wt: should be backported to 1.6]

9 years agoDOC: lua-api/index.rst small example fixes, spelling correction.
Pieter Baauw [Sun, 8 Nov 2015 15:38:08 +0000 (16:38 +0100)] 
DOC: lua-api/index.rst small example fixes, spelling correction.

[wt: backport to 1.6]

9 years agoBUILD: check for libressl to be able to build against it
Daniel Jakots [Fri, 6 Nov 2015 19:02:41 +0000 (20:02 +0100)] 
BUILD: check for libressl to be able to build against it

[wt: might be worth backporting it to 1.6]

9 years agoBUG/MEDIUM: lua: clean output buffer
Thierry FOURNIER [Wed, 4 Nov 2015 09:52:59 +0000 (10:52 +0100)] 
BUG/MEDIUM: lua: clean output buffer

When the txn.done() fiunction is called, the ouput buffer is cleaned,
but the associated relative pointer on the HTTP requests elements
is not reseted.

This patch remove this cleanup, because the output buffer may contain
data to forward.

9 years agoBUILD: freebsd: double declaration
Thierry FOURNIER [Tue, 3 Nov 2015 18:17:37 +0000 (19:17 +0100)] 
BUILD: freebsd: double declaration

On freebsd, the macro LIST_PREV already exists in the header file
<sys/queue.h>, and this makes a build error.

This patch removes the macros before declaring it. This ensure
that the error doesn't occurs.

9 years agoBUG/MINOR: acl: don't use record layer in req_ssl_ver
Lukas Tribus [Thu, 5 Nov 2015 12:59:30 +0000 (13:59 +0100)] 
BUG/MINOR: acl: don't use record layer in req_ssl_ver

The initial record layer version in a SSL handshake may be set to TLSv1.0
or similar for compatibility reasons, this is allowed as per RFC5246
Appendix E.1 [1]. Some implementations are Openssl [2] and NSS [3].

A related issue has been fixed some time ago in commit 57d229747
("BUG/MINOR: acl: req_ssl_sni fails with SSLv3 record version").

Fix this by using the real client hello version instead of the record
layer version.

This was reported by Julien Vehent and analyzed by Cyril Bonté.
The initial patch is from Julien Vehent as well.

This should be backported to stable series, the req_ssl_ver keyword was
first introduced in 1.3.16.

[1] https://tools.ietf.org/html/rfc5246#appendix-E.1
[2] https://github.com/openssl/openssl/commit/4a1cf50187659e60c5867ecbbc36e37b2605d2c3
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=774547

9 years agoBUG/MINOR: server: check return value of fgets() in apply_server_state()
Dragan Dosen [Wed, 4 Nov 2015 22:03:26 +0000 (23:03 +0100)] 
BUG/MINOR: server: check return value of fgets() in apply_server_state()

fgets() can return NULL on error or when EOF occurs. This patch adds a
check of fgets() return value and displays a warning if the first line of
the server state file can not be read. Additionally, we make sure to close
the previously opened file descriptor.

9 years agoBUG/MINOR: http rule: http capture 'id' rule points to a non existing id
Baptiste Assmann [Tue, 3 Nov 2015 22:31:35 +0000 (23:31 +0100)] 
BUG/MINOR: http rule: http capture 'id' rule points to a non existing id

It is possible to create a http capture rule which points to a capture slot
id which does not exist.

Current patch prevent this when parsing configuration and prevent running
configuration which contains such rules.

This configuration is now invalid:

  frontend f
   bind :8080
   http-request capture req.hdr(User-Agent) id 0
   default_backend b

this one as well:

  frontend f
   bind :8080
   declare capture request len 32 # implicit id is 0 here
   http-request capture req.hdr(User-Agent) id 1
   default_backend b

It applies of course to both http-request and http-response rules.

9 years agoMINOR: check: add agent-send server parameter
James Brown [Thu, 22 Oct 2015 01:19:05 +0000 (18:19 -0700)] 
MINOR: check: add agent-send server parameter

Causes HAProxy to emit a static string to the agent on every check,
so that you can independently control multiple services running
behind a single agent port.

9 years agoBUG/MEDIUM: lua: sample fetches based on response doesn't work
Thierry FOURNIER [Mon, 2 Nov 2015 09:01:59 +0000 (10:01 +0100)] 
BUG/MEDIUM: lua: sample fetches based on response doesn't work

The direction (request or response) is not propagated in the
sample fecthes called throught Lua. This patch adds the direction
status in some structs (hlua_txn and hlua_smp) to make sure that
the sample fetches will be called with all the information.

The converters can not access to a TXN object, so there are not
impacted the direction. However, the samples used as input of the
Lua converter wrapper are initiliazed with the direction. Thereby,
the struct smp stay consistent.
[wt: needs to be backported to 1.6]

9 years agoCLEANUP: use direction names in place of numeric values
Thierry FOURNIER [Mon, 2 Nov 2015 08:52:54 +0000 (09:52 +0100)] 
CLEANUP: use direction names in place of numeric values

This patch cleanups the direction names. It replaces numeric values,
by the associated defines. It ensure the compliance with values found
somwhere else in HAProxy.

It is required by the bugfix patch which is following.
[wt: needs to be backported to 1.6]

9 years agoBUG/MINOR: dns: check for duplicate nameserver id in a resolvers section was missing
Baptiste Assmann [Mon, 2 Nov 2015 21:55:49 +0000 (22:55 +0100)] 
BUG/MINOR: dns: check for duplicate nameserver id in a resolvers section was missing

Current resolvers section parsing function is permissive on nameserver
id and two nameservers may have the same id.
It's a shame, since we don't know for example, whose statistics belong
to which nameserver...

From now, configuration with duplicated nameserver id in a resolvers
section are considered as broken and returns a fatal error when parsing.

9 years agoDOC: typo on capture.res.hdr and capture.req.hdr
Baptiste Assmann [Wed, 21 Oct 2015 21:13:46 +0000 (23:13 +0200)] 
DOC: typo on capture.res.hdr and capture.req.hdr

capture.res.hdr and capture.req.hdr were mis-spelled (hdr.req.capture)
in the doc, leading to misunderstandings.

9 years agoBUG/MAJOR: http: don't requeue an idle connection that is already queued
Willy Tarreau [Mon, 2 Nov 2015 19:20:11 +0000 (20:20 +0100)] 
BUG/MAJOR: http: don't requeue an idle connection that is already queued

Cyril Bonté reported a reproduceable sequence which can lead to a crash
when using backend connection reuse. The problem comes from the fact that
we systematically add the server connection to an idle pool at the end of
the HTTP transaction regardless of the fact that it might already be there.

This is possible for example when processing a request which doesn't use
a server connection (typically a redirect) after a request which used a
connection. Then after the first request, the connection was already in
the idle queue and we're putting it a second time at the end of the second
request, causing a corruption of the idle pool.

Interestingly, the memory debugger in 1.7 immediately detected a suspicious
double free on the connection, leading to a very early detection of the
cause instead of its consequences.

Thanks to Cyril for quickly providing a working reproducer.

This fix must be backported to 1.6 since connection reuse was introduced
there.

9 years agoBUILD: add Haiku as supported target.
Jerome Duval [Mon, 19 Oct 2015 23:01:16 +0000 (23:01 +0000)] 
BUILD: add Haiku as supported target.

9 years agoBUG/BUILD: replace haproxy-systemd-wrapper with $(EXTRA) in install-bin.
Jerome Duval [Mon, 2 Nov 2015 17:47:43 +0000 (17:47 +0000)] 
BUG/BUILD: replace haproxy-systemd-wrapper with $(EXTRA) in install-bin.

[wt: this should be backported to 1.6 and 1.5 as well since some platforms
 don't build the systemd-wrapper]

9 years agoMINOR: config: allow IPv6 bracketed literals
mildis [Mon, 26 Oct 2015 17:50:08 +0000 (18:50 +0100)] 
MINOR: config: allow IPv6 bracketed literals

9 years agoDOC: deviceatlas: more example use cases.
David Carlier [Wed, 28 Oct 2015 11:08:15 +0000 (11:08 +0000)] 
DOC: deviceatlas: more example use cases.

In addition of adding additional headers examples, some examples of
defining an ACL.

9 years agoBUG/MINOR: examples/haproxy.init: missing brace in quiet_check()
jesse.defer@asu.edu [Sun, 1 Nov 2015 03:29:56 +0000 (20:29 -0700)] 
BUG/MINOR: examples/haproxy.init: missing brace in quiet_check()

There is a missing curly brace in the quiet_check function of the example
init script.

[note: This needs to be backported to 1.6]

9 years agoBUG/MINOR: dns: unable to parse CNAMEs response
Baptiste Assmann [Wed, 28 Oct 2015 01:10:02 +0000 (02:10 +0100)] 
BUG/MINOR: dns: unable to parse CNAMEs response

A bug lied in the parsing of DNS CNAME response, leading HAProxy to
think the CNAME was improperly resolved in the response.

This should be backported into 1.6 branch

9 years agoBUG/MAJOR: dns: first DNS response packet not matching queried hostname may lead...
Baptiste Assmann [Wed, 28 Oct 2015 01:03:32 +0000 (02:03 +0100)] 
BUG/MAJOR: dns: first DNS response packet not matching queried hostname may lead to a loop

The status DNS_UPD_NAME_ERROR returned by dns_get_ip_from_response and
which means the queried name can't be found in the response was
improperly processed (fell into the default case).
This lead to a loop where HAProxy simply resend a new query as soon as
it got a response for this status and in the only case where such type
of response is the very first one received by the process.

This should be backported into 1.6 branch

9 years agoBUG/MEDIUM: config: count memory limits on 64 bits, not 32
Willy Tarreau [Thu, 29 Oct 2015 09:42:55 +0000 (10:42 +0100)] 
BUG/MEDIUM: config: count memory limits on 64 bits, not 32

It was accidently discovered that limiting haproxy to 5000 MB leads to
an effective limit of 904 MB. This is because the computation for the
size limit is performed by multiplying rlimit_memmax by 1048576, and
doing so causes the operation to be performed on an int instead of a
long or long long. Just switch to 1048576ULL as is done at other places
to fix this.

This bug affects all supported versions, the backport is desired, though
it rarely affects users since few people apply memory limits.

9 years agoMEDIUM: memory: add accounting for failed allocations
Willy Tarreau [Wed, 28 Oct 2015 15:24:21 +0000 (16:24 +0100)] 
MEDIUM: memory: add accounting for failed allocations

We now keep a per-pool counter of failed memory allocations and
we report that, as well as the amount of memory allocated and used
on the CLI.

9 years agoDEBUG/MEDIUM: memory: add optional control pool memory operations
Willy Tarreau [Wed, 28 Oct 2015 14:23:51 +0000 (15:23 +0100)] 
DEBUG/MEDIUM: memory: add optional control pool memory operations

When DEBUG_MEMORY_POOLS is used, we now use the link pointer at the end
of the pool to store a pointer to the pool, and to control it during
pool_free2() in order to serve four purposes :
  - at any instant we can know what pool an object was allocated from
    when examining memory, hence how we should possibly decode it ;

  - it serves to detect double free when they happen, as the pointer
    cannot be valid after the element is linked into the pool ;

  - it serves to detect if an element is released in the wrong pool ;

  - it serves as a canary, to detect if some buffers experienced an
    overflow before being release.

All these elements will definitely help better troubleshoot strange
situations, or at least confirm that certain conditions did not happen.

9 years agoDEBUG/MEDIUM: memory: optionally protect free data in pools
Willy Tarreau [Wed, 28 Oct 2015 14:09:29 +0000 (15:09 +0100)] 
DEBUG/MEDIUM: memory: optionally protect free data in pools

When debugging a core file, it's sometimes convenient to be able to
visit the released entries in the pools (typically last released
session). Unfortunately the first bytes of these entries are destroyed
by the link elements of the pool. And of course, most structures have
their most accessed elements at the beginning of the structure (typically
flags). Let's add a build-time option DEBUG_MEMORY_POOLS which allocates
an extra pointer in each pool to put the link at the end of each pool
item instead of the beginning.

9 years agoDEBUG/MINOR: memory: add a build option to disable memory pools sharing
Willy Tarreau [Wed, 28 Oct 2015 11:04:02 +0000 (12:04 +0100)] 
DEBUG/MINOR: memory: add a build option to disable memory pools sharing

Sometimes analysing a core file isn't easy due to shared memory pools.
Let's add a build option to disable this. It's not enabled by default,
it could be backported to older versions.

9 years agoMINOR: cli: ability to set per-server maxconn
Andrew Hayworth [Tue, 27 Oct 2015 21:46:25 +0000 (21:46 +0000)] 
MINOR: cli: ability to set per-server maxconn

This commit adds support for setting a per-server maxconn from the stats
socket. The only really notable part of this commit is that we need to
check if maxconn == minconn before changing things, as this indicates
that we are NOT using dynamic maxconn. When we are not using dynamic
maxconn, we should update maxconn/minconn in lockstep.

9 years agoFIX: small typo in an example using the "Referer" header
Cyril Bonté [Mon, 26 Oct 2015 21:37:39 +0000 (22:37 +0100)] 
FIX: small typo in an example using the "Referer" header

It was reported that an example was manipulating a "Referrer" header instead
of the known "Referer" one. Even if it's an example wich doesn't break things,
the typo can be fixed.

The fix should be backported in 1.4/1.5/1.6 branches.

9 years agoDOC: fix a typo for a "deviceatlas" keyword
Cyril Bonté [Mon, 26 Oct 2015 21:37:38 +0000 (22:37 +0100)] 
DOC: fix a typo for a "deviceatlas" keyword

The global keyword 'deviceatlas-properties-cookie' was miswritten.

This typo should also be backported to the 1.6 branch.

9 years agoBUILD: ssl: fix build error introduced in commit 7969a3 with OpenSSL < 1.0.0
Christopher Faulet [Mon, 19 Oct 2015 11:59:24 +0000 (13:59 +0200)] 
BUILD: ssl: fix build error introduced in commit 7969a3 with OpenSSL < 1.0.0

The function 'EVP_PKEY_get_default_digest_nid()' was introduced in OpenSSL
1.0.0. So for older version of OpenSSL, compiled with the SNI support, the
HAProxy compilation fails with the following error:

src/ssl_sock.c: In function 'ssl_sock_do_create_cert':
src/ssl_sock.c:1096:7: warning: implicit declaration of function 'EVP_PKEY_get_default_digest_nid'
   if (EVP_PKEY_get_default_digest_nid(capkey, &nid) <= 0)
[...]
src/ssl_sock.c:1096: undefined reference to `EVP_PKEY_get_default_digest_nid'
collect2: error: ld returned 1 exit status
Makefile:760: recipe for target 'haproxy' failed
make: *** [haproxy] Error 1

So we must add a #ifdef to check the OpenSSL version (>= 1.0.0) to use this
function. It is used to get default signature digest associated to the private
key used to sign generated X509 certificates. It is called when the private key
differs than EVP_PKEY_RSA, EVP_PKEY_DSA and EVP_PKEY_EC. It should be enough for
most of cases.

9 years agoMEDIUM: dns: Don't use the ANY query type
Andrew Hayworth [Mon, 19 Oct 2015 22:29:51 +0000 (22:29 +0000)] 
MEDIUM: dns: Don't use the ANY query type

Basically, it's ill-defined and shouldn't really be used going forward.
We can't guarantee that resolvers will do the 'legwork' for us and
actually resolve CNAMES when we request the ANY query-type. Case in point
(obfuscated, clearly):

  PRODUCTION! ahayworth@secret-hostname.com:~$
  dig @10.11.12.53 ANY api.somestartup.io

  ; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> @10.11.12.53 ANY api.somestartup.io
  ; (1 server found)
  ;; global options: +cmd
  ;; Got answer:
  ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62454
  ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0

  ;; QUESTION SECTION:
  ;api.somestartup.io.                        IN      ANY

  ;; ANSWER SECTION:
  api.somestartup.io.         20      IN      CNAME api-somestartup-production.ap-southeast-2.elb.amazonaws.com.

  ;; AUTHORITY SECTION:
  somestartup.io.               166687  IN      NS      ns-1254.awsdns-28.org.
  somestartup.io.               166687  IN      NS      ns-1884.awsdns-43.co.uk.
  somestartup.io.               166687  IN      NS      ns-440.awsdns-55.com.
  somestartup.io.               166687  IN      NS      ns-577.awsdns-08.net.

  ;; Query time: 1 msec
  ;; SERVER: 10.11.12.53#53(10.11.12.53)
  ;; WHEN: Mon Oct 19 22:02:29 2015
  ;; MSG SIZE  rcvd: 242

HAProxy can't handle that response correctly.

Rather than try to build in support for resolving CNAMEs presented
without an A record in an answer section (which may be a valid
improvement further on), this change just skips ANY record types
altogether. A and AAAA are much more well-defined and predictable.

Notably, this commit preserves the implicit "Prefer IPV6 behavior."

Furthermore, ANY query type by default is a bad idea: (from Robin on
HAProxy's ML):
  Using ANY queries for this kind of stuff is considered by most people
  to be a bad practice since besides all the things you named it can
  lead to incomplete responses. Basically a resolver is allowed to just
  return whatever it has in cache when it receives an ANY query instead
  of actually doing an ANY query at the authoritative nameserver. Thus
  if it only received queries for an A record before you do an ANY query
  you will not get an AAAA record even if it is actually available since
  the resolver doesn't have it in its cache. Even worse if before it
  only got MX queries, you won't get either A or AAAA

9 years agoBUG/MAJOR: ssl: free the generated SSL_CTX if the LRU cache is disabled
Willy Tarreau [Tue, 20 Oct 2015 13:16:01 +0000 (15:16 +0200)] 
BUG/MAJOR: ssl: free the generated SSL_CTX if the LRU cache is disabled

Kim Seri reported that haproxy 1.6.0 crashes after a few requests
when a bind line has SSL enabled with more than one certificate. This
was caused by an insufficient condition to free generated certs during
ssl_sock_close() which can also catch other certs.

Christopher Faulet analysed the situation like this :

-------
First the LRU tree is only initialized when the SSL certs generation is
configured on a bind line. So, in the most of cases, it is NULL (it is
not the same thing than empty).
When the SSL certs generation is used, if the cache is not NULL, a such
certificate is pushed in the cache and there is no need to release it
when the connection is closed.
But it can be disabled in the configuration. So in that case, we must
free the generated certificate when the connection is closed.

Then here, we have really a bug. Here is the buggy part:

3125)      if (conn->xprt_ctx) {
3126) #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
3127)              if (!ssl_ctx_lru_tree && objt_listener(conn->target)) {
3128)                      SSL_CTX *ctx = SSL_get_SSL_CTX(conn->xprt_ctx);
3129)                      if (ctx != 3130)
 SSL_CTX_free(ctx);
3131)              }
3133)              SSL_free(conn->xprt_ctx);
3134)              conn->xprt_ctx = NULL;
3135)              sslconns--;
3136)      }

The check on the line 3127 is not enough to determine if this is a
generated certificate or not. Because ssl_ctx_lru_tree is NULL,
generated certificates, if any, must be freed. But here ctx should also
be compared to all SNI certificates and not only to default_ctx. Because
of this bug, when a SNI certificate is used for a connection, it is
erroneously freed when this connection is closed.
-------

Christopher provided this reliable reproducer :

----------
global
    tune.ssl.default-dh-param   2048
    daemon

listen ssl_server
    mode tcp
    bind 127.0.0.1:4443 ssl crt srv1.test.com.pem crt srv2.test.com.pem

    timeout connect 5000
    timeout client  30000
    timeout server  30000

    server srv A.B.C.D:80

You just need to generate 2 SSL certificates with 2 CN (here
srv1.test.com and srv2.test.com).

Then, by doing SSL requests with the first CN, there is no problem. But
with the second CN, it should segfault on the 2nd request.

openssl s_client -connect 127.0.0.1:4443 -servername srv1.test.com // OK
openssl s_client -connect 127.0.0.1:4443 -servername srv1.test.com // OK

But,

openssl s_client -connect 127.0.0.1:4443 -servername srv2.test.com // OK
openssl s_client -connect 127.0.0.1:4443 -servername srv2.test.com // KO
-----------

A long discussion led to the following proposal which this patch implements :

- the cert is generated. It gets a refcount = 1.
- we assign it to the SSL. Its refcount becomes two.
- we try to insert it into the tree. The tree will handle its freeing
  using SSL_CTX_free() during eviction.
- if we can't insert into the tree because the tree is disabled, then
  we have to call SSL_CTX_free() ourselves, then we'd rather do it
  immediately. It will more closely mimmick the case where the cert
  is added to the tree and immediately evicted by concurrent activity
  on the cache.
- we never have to call SSL_CTX_free() during ssl_sock_close() because
  the SSL session only relies on openssl doing the right thing based on
  the refcount only.
- thus we never need to know how the cert was created since the
  SSL_CTX_free() is either guaranteed or already done for generated
  certs, and this protects other ones against any accidental call to
  SSL_CTX_free() without having to track where the cert comes from.

This patch also reduces the inter-dependence between the LRU tree and
the SSL stack, so it should cause less sweating to migrate to threads
later.

This bug is specific to 1.6.0, as it was introduced after dev7 by
this fix :

   d2cab92 ("BUG/MINOR: ssl: fix management of the cache where forged certificates are stored")

Thus a backport to 1.6 is required, but not to 1.5.

9 years agoBUG/MEDIUM: namespaces: don't fail if no namespace is used
Willy Tarreau [Tue, 20 Oct 2015 13:14:07 +0000 (15:14 +0200)] 
BUG/MEDIUM: namespaces: don't fail if no namespace is used

Susheel Jalali reported a confusing bug in namespaces implementation.
If namespaces are enabled at build time (USE_NS=1) and *no* namespace
is used at all in the whole config file, my_socketat() returns -1 and
all socket bindings fail. This is because of a wrong condition in this
function. A possible workaround consists in creating some namespaces.

9 years agoBUG/MINOR: dns: parsing error of some DNS response
Baptiste Assmann [Thu, 15 Oct 2015 13:23:28 +0000 (15:23 +0200)] 
BUG/MINOR: dns: parsing error of some DNS response

The function which parses a DNS response buffer did not move properly a
pointer when reading a packet where records does not use DNS "message
compression" techniques.

Thanks to 0yvind Johnsen for the help provided during the troubleshooting
session.

9 years agoCLEANUP: don't ignore debian/ directory if present
Vincent Bernat [Wed, 14 Oct 2015 19:43:58 +0000 (21:43 +0200)] 
CLEANUP: don't ignore debian/ directory if present

This makes packaging with git tools easier as it is not possible to
cancel anything in debian/.gitignore since the whole directory is
ignored.

9 years agoBUILD: install only relevant and existing documentation
Vincent Bernat [Tue, 13 Oct 2015 20:20:55 +0000 (22:20 +0200)] 
BUILD: install only relevant and existing documentation

doc/haproxy-{en,fr}.txt have been removed recently but they were still
referenced in the Makefile. Many other documents have also been
added. Instead of hard-coding a list of documents to install, install
all those in doc/ with some exceptions:

 - coding-style.txt is more for developers
 - gpl.txt and lgpl.txt are usually present at other places (and I would
   have to remove them in the Debian packaging, less work for me)

The documentation in the subdirectories is not installed as it is more
targeted to developers.

9 years agoDOC: specify that stats socket doc (section 9.2) is in management
Kevin Decherf [Tue, 13 Oct 2015 21:26:44 +0000 (23:26 +0200)] 
DOC: specify that stats socket doc (section 9.2) is in management

Commit 44aed90ce102c4136a5eda66d541f6fa79e141e8 moved the stats socket
documentation from config to management but the remaining references to
section 9.2 were not updated; improve it to be less confusing.

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
9 years ago[RELEASE] Released version 1.7-dev0 v1.7-dev0
Willy Tarreau [Tue, 13 Oct 2015 19:48:10 +0000 (21:48 +0200)] 
[RELEASE] Released version 1.7-dev0

Released version 1.7-dev0 with the following main changes :
    - exact copy of 1.6.0

9 years ago[RELEASE] Released version 1.6.0 v1.6.0
Willy Tarreau [Tue, 13 Oct 2015 16:52:22 +0000 (18:52 +0200)] 
[RELEASE] Released version 1.6.0

Released version 1.6.0 with the following main changes :
    - BUG/MINOR: Handle interactive mode in cli handler
    - DOC: global section missing parameters
    - DOC: backend section missing parameters
    - DOC: stats paramaters available in frontend
    - MINOR: lru: do not allocate useless memory in lru64_lookup
    - BUG/MINOR: http: Add OPTIONS in supported http methods (found by find_http_meth)
    - BUG/MINOR: ssl: fix management of the cache where forged certificates are stored
    - MINOR: ssl: Release Servers SSL context when HAProxy is shut down
    - MINOR: ssl: Read the file used to generate certificates in any order
    - MINOR: ssl: Add support for EC for the CA used to sign generated certificates
    - MINOR: ssl: Add callbacks to set DH/ECDH params for generated certificates
    - BUG/MEDIUM: logs: fix time zone offset format in RFC5424
    - BUILD: Fix the build on OSX (htonll/ntohll)
    - BUILD: enable build on Linux/s390x
    - BUG/MEDIUM: lua: direction test failed
    - MINOR: lua: fix a spelling error in some error messages
    - CLEANUP: cli: ensure we can never double-free error messages
    - BUG/MEDIUM: lua: force server-close mode on Lua services
    - MEDIUM: init: support more command line arguments after pid list
    - MEDIUM: init: support a list of files on the command line
    - MINOR: debug: enable memory poisonning to use byte 0
    - BUILD: ssl: fix build error introduced by recent commit
    - BUG/MINOR: config: make the stats socket pass the correct proxy to the parsers
    - MEDIUM: server: implement TCP_USER_TIMEOUT on the server
    - DOC: mention the "namespace" options for bind and server lines
    - DOC: add the "management" documentation
    - DOC: move the stats socket documentation from config to management
    - MINOR: examples: update haproxy.spec to mention new docs
    - DOC: mention management.txt in README
    - DOC: remove haproxy-{en,fr}.txt
    - BUILD: properly report when USE_ZLIB and USE_SLZ are used together
    - MINOR: init: report use of libslz instead of "no compression"
    - CLEANUP: examples: remove some obsolete and confusing files
    - CLEANUP: examples: remove obsolete configuration file samples
    - CLEANUP: examples: fix the example file content-sw-sample.cfg
    - CLEANUP: examples: update sample file option-http_proxy.cfg
    - CLEANUP: examples: update sample file ssl.cfg
    - CLEANUP: tests: move a test file from examples/ to tests/
    - CLEANUP: examples: shut up warnings in transparent proxy example
    - CLEANUP: tests: removed completely obsolete test files
    - DOC: update ROADMAP to remove what was done in 1.6
    - BUG/MEDIUM: pattern: fixup use_after_free in the pat_ref_delete_by_id

9 years agoDOC: update ROADMAP to remove what was done in 1.6
Willy Tarreau [Tue, 13 Oct 2015 16:38:15 +0000 (18:38 +0200)] 
DOC: update ROADMAP to remove what was done in 1.6

9 years agoBUG/MEDIUM: pattern: fixup use_after_free in the pat_ref_delete_by_id
peter cai [Wed, 7 Oct 2015 07:07:43 +0000 (00:07 -0700)] 
BUG/MEDIUM: pattern: fixup use_after_free in the pat_ref_delete_by_id

I found there is use_after_free bug in the pat_ref_delete_by_id.

[wt: it seems this fix must be backported to 1.5 as well]

9 years agoCLEANUP: tests: removed completely obsolete test files
Willy Tarreau [Tue, 13 Oct 2015 15:07:34 +0000 (17:07 +0200)] 
CLEANUP: tests: removed completely obsolete test files

A number of config files were present in the tests/ directory and which
would either test features that are easier to test using more recent files
or test obsolete features. All of them emit tons of useless warnings, and
instead of fixing them, better remove them since they have never been used
in the last 10 years or so.

The remaining files may still emit warnings and require some fixing but
they provide some value for some tests.

9 years agoCLEANUP: examples: shut up warnings in transparent proxy example
Willy Tarreau [Tue, 13 Oct 2015 13:46:50 +0000 (15:46 +0200)] 
CLEANUP: examples: shut up warnings in transparent proxy example

Just add some missing timeouts.

9 years agoCLEANUP: tests: move a test file from examples/ to tests/
Willy Tarreau [Tue, 13 Oct 2015 13:45:17 +0000 (15:45 +0200)] 
CLEANUP: tests: move a test file from examples/ to tests/

examples are for users, tests are for developers.

9 years agoCLEANUP: examples: update sample file ssl.cfg
Willy Tarreau [Tue, 13 Oct 2015 13:44:31 +0000 (15:44 +0200)] 
CLEANUP: examples: update sample file ssl.cfg

This one emitted an error due to the lack of "verify none" on the server line.

9 years agoCLEANUP: examples: update sample file option-http_proxy.cfg
Willy Tarreau [Tue, 13 Oct 2015 13:43:39 +0000 (15:43 +0200)] 
CLEANUP: examples: update sample file option-http_proxy.cfg

This one was still valid but emitted lots of warnings.