]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
8 years agoBUG/MAJOR: Use -fwrapv.
Olivier Houchard [Wed, 19 Apr 2017 09:34:10 +0000 (11:34 +0200)] 
BUG/MAJOR: Use -fwrapv.

Haproxy relies on signed integer wraparound on overflow, however this is
really an undefined behavior, so the C compiler is allowed to do whatever
it wants, and clang does exactly that, and that causes problems when the
timer goes from <= INT_MAX to > INT_MAX, and explains the various hangs
reported on FreeBSD every 49.7 days. To make sure we get the intended
behavior, use -fwrapv for now. A proper fix is to switch everything to
unsigned, and it will happen later, but this is simpler, and more likely to
be backported to the stable branches.
Many thanks to David King, Mark S, Dave Cottlehuber, Slawa Olhovchenkov,
Piotr Pawel Stefaniak, and any other I may have forgotten for reporting that
and investigating.

8 years agoMEDIUM: config: don't check config validity when there are fatal errors
Willy Tarreau [Wed, 19 Apr 2017 09:24:07 +0000 (11:24 +0200)] 
MEDIUM: config: don't check config validity when there are fatal errors

Overall we do have an issue with the severity of a number of errors. Most
fatal errors are reported with ERR_FATAL (which prevents startup) and not
ERR_ABORT (which stops parsing ASAP), but check_config_validity() is still
called on ERR_FATAL, and will most of the time report bogus errors. This
is what caused smp_resolve_args() to be called on a number of unparsable
ACLs, and it also is what reports incorrect ordering or unresolvable
section names when certain entries could not be properly parsed.

This patch stops this domino effect by simply aborting before trying to
further check and resolve the configuration when it's already know that
there are fatal errors.

A concrete example comes from this config :

  userlist users :
      user foo insecure-password bar

  listen foo
      bind :1234
      mode htttp
      timeout client 10S
      timeout server 10s
      timeout connect 10s
      stats uri /stats
      stats http-request auth unless { http_auth(users) }
      http-request redirect location /index.html if { path / }

It contains a colon after the userlist name, a typo in the client timeout value,
another one in "mode http" which cause some other configuration elements not to
be properly handled.

Previously it would confusingly report :

  [ALERT] 108/114851 (20224) : parsing [err-report.cfg:1] : 'userlist' cannot handle unexpected argument ':'.
  [ALERT] 108/114851 (20224) : parsing [err-report.cfg:6] : unknown proxy mode 'htttp'.
  [ALERT] 108/114851 (20224) : parsing [err-report.cfg:7] : unexpected character 'S' in 'timeout client'
  [ALERT] 108/114851 (20224) : Error(s) found in configuration file : err-report.cfg
  [ALERT] 108/114851 (20224) : parsing [err-report.cfg:11] : unable to find userlist 'users' referenced in arg 1 of ACL keyword 'http_auth' in proxy 'foo'.
  [WARNING] 108/114851 (20224) : config : missing timeouts for proxy 'foo'.
     | While not properly invalid, you will certainly encounter various problems
     | with such a configuration. To fix this, please ensure that all following
     | timeouts are set to a non-zero value: 'client', 'connect', 'server'.
  [WARNING] 108/114851 (20224) : config : 'stats' statement ignored for proxy 'foo' as it requires HTTP mode.
  [WARNING] 108/114851 (20224) : config : 'http-request' rules ignored for proxy 'foo' as they require HTTP mode.
  [ALERT] 108/114851 (20224) : Fatal errors found in configuration.

The "requires HTTP mode" errors are just pollution resulting from the
improper spelling of this mode earlier. The unresolved reference to the
userlist is caused by the extra colon on the declaration, and the warning
regarding the missing timeouts is caused by the wrong character.

Now it more accurately reports :

  [ALERT] 108/114900 (20225) : parsing [err-report.cfg:1] : 'userlist' cannot handle unexpected argument ':'.
  [ALERT] 108/114900 (20225) : parsing [err-report.cfg:6] : unknown proxy mode 'htttp'.
  [ALERT] 108/114900 (20225) : parsing [err-report.cfg:7] : unexpected character 'S' in 'timeout client'
  [ALERT] 108/114900 (20225) : Error(s) found in configuration file : err-report.cfg
  [ALERT] 108/114900 (20225) : Fatal errors found in configuration.

Despite not really a fix, this patch should be backported at least to 1.7,
possibly even 1.6, and 1.5 since it hardens the config parser against
certain bad situations like the recently reported use-after-free and the
last null dereference.

8 years agoBUG/MEDIUM: acl: proprely release unused args in prune_acl_expr()
Willy Tarreau [Wed, 19 Apr 2017 09:13:48 +0000 (11:13 +0200)] 
BUG/MEDIUM: acl: proprely release unused args in prune_acl_expr()

Stephan Zeisberg reported another dirty abort case which can be triggered
with this simple config (where file "d" doesn't exist) :

    backend b1
        stats  auth a:b
        acl auth_ok http_auth(c) -f d

This issue was brought in 1.5-dev9 by commit 34db108 ("MAJOR: acl: make use
of the new argument parsing framework") when prune_acl_expr() started to
release arguments. The arg pointer is set to NULL but not its length.
Because of this, later in smp_resolve_args(), the argument is still seen
as valid (since only a test on the length is made as in all other places),
and the NULL pointer is dereferenced.

This patch properly clears the lengths to avoid such tests.

This fix needs to be backported to 1.7, 1.6, and 1.5.

8 years agoCLEANUP: logs: typo: simgle => single
Jim Freeman [Sat, 15 Apr 2017 14:01:59 +0000 (08:01 -0600)] 
CLEANUP: logs: typo: simgle => single

Typo in error message. Backport to 1.7.

8 years agoBUG/MAJOR: Broken parsing for valid keywords provided after 'source' setting.
Frédéric Lécaille [Sun, 16 Apr 2017 15:14:14 +0000 (17:14 +0200)] 
BUG/MAJOR: Broken parsing for valid keywords provided after 'source' setting.

Any valid keyword could not be parsed anymore if provided after 'source' keyword.
This was due to the fact that 'source' number of arguments is variable.
So, as its parser srv_parse_source() is the only one who may know how many arguments
was provided after 'source' keyword, it updates 'cur_arg' variable (the index
in the line of the current arg to be parsed), this is a good thing.
This variable is also incremented by one (to skip the 'source' keyword).
This patch disable this behavior.

Should have come with dba9707 commit.

8 years agoBUG/MINOR: server: Fix a wrong error message during 'usesrc' keyword parsing.
Frédéric Lécaille [Fri, 14 Apr 2017 13:19:56 +0000 (15:19 +0200)] 
BUG/MINOR: server: Fix a wrong error message during 'usesrc' keyword parsing.

'usesrc' setting is not permitted on 'server' lines if not provided after
'source' setting. This is now also the case on 'default-server' lines.
Without this patch parse_server() parser displayed that 'usersrc' is
an unknown keyword.

Should have come with dba9707 commit.

8 years agoMINOR: systemd wrapper: add support for passing the -x option.
Olivier Houchard [Sun, 9 Apr 2017 14:28:10 +0000 (16:28 +0200)] 
MINOR: systemd wrapper: add support for passing the -x option.

Make the systemd wrapper chech if HAPROXY_STATS_SOCKET if set.
If set, it will use it as an argument to the "-x" option, which makes
haproxy asks for any listening socket, on the stats socket, in order
to achieve reloads with no new connection lost.

8 years agoMINOR: socket transfer: Set a timeout on the socket.
Olivier Houchard [Thu, 6 Apr 2017 12:45:14 +0000 (14:45 +0200)] 
MINOR: socket transfer: Set a timeout on the socket.

Make sure we're not stuck forever by setting a timeout on the socket.

8 years agoMINOR: proxy: Don't close FDs if not our proxy.
Olivier Houchard [Wed, 5 Apr 2017 23:05:05 +0000 (01:05 +0200)] 
MINOR: proxy: Don't close FDs if not our proxy.

When running with multiple process, if some proxies are just assigned
to some processes, the other processes will just close the file descriptors
for the listening sockets. However, we may still have to provide those
sockets when reloading, so instead we just try hard to pretend those proxies
are dead, while keeping the sockets opened.
A new global option, no-reused-socket", has been added, to restore the old
behavior of closing the sockets not bound to this process.

8 years agoMINOR: doc: document the -x flag
Olivier Houchard [Wed, 5 Apr 2017 20:50:59 +0000 (22:50 +0200)] 
MINOR: doc: document the -x flag

8 years agoMINOR: tcp: When binding socket, attempt to reuse one from the old proc.
Olivier Houchard [Wed, 5 Apr 2017 20:39:56 +0000 (22:39 +0200)] 
MINOR: tcp: When binding socket, attempt to reuse one from the old proc.

Try to reuse any socket from the old process, provided by the "-x" flag,
before binding a new one, assuming it is compatible.
"Compatible" here means same address and port, same namspace if any,
same interface if any, and that the following flags are the same :
LI_O_FOREIGN, LI_O_V6ONLY and LI_O_V4V6.
Also change tcp_bind_listener() to always enable/disable socket options,
instead of just doing so if it is in the configuration file, as the option
may have been removed, ie TCP_FASTOPEN may have been set in the old process,
and removed from the new configuration, so we have to disable it.

8 years agoMINOR: global: Add an option to get the old listening sockets.
Olivier Houchard [Wed, 5 Apr 2017 20:33:04 +0000 (22:33 +0200)] 
MINOR: global: Add an option to get the old listening sockets.

Add the "-x" flag, that takes a path to a unix socket as an argument. If
used, haproxy will connect to the socket, and asks to get all the
listening sockets from the old process. Any failure is fatal.
This is needed to get seamless reloads on linux.

8 years agoMINOR: cli: Add a command to send listening sockets.
Olivier Houchard [Wed, 5 Apr 2017 20:24:59 +0000 (22:24 +0200)] 
MINOR: cli: Add a command to send listening sockets.

Add a new command that will send all the listening sockets, via the
stats socket, and their properties.
This is a first step to workaround the linux problem when reloading
haproxy.

8 years agoMINOR: lua: ensure the memory allocator is used all the time
Willy Tarreau [Wed, 12 Apr 2017 19:40:29 +0000 (21:40 +0200)] 
MINOR: lua: ensure the memory allocator is used all the time

luaL_setstate() uses malloc() to initialize the first objects, and only
after this we replace the allocator. This creates trouble when replacing
the standard memory allocators during debugging sessions since the new
allocator is used to realloc() an area previously allocated using the
default malloc().

Lua provides lua_newstate() in addition to luaL_newstate(), which takes
an allocator for the initial malloc. This is exactly what we need, and
this patch does this and fixes the problem. The now useless call to
lua_setallocf() could be removed.

This has no impact outside of debugging sessions and there's no need to
backport this.

8 years agoBUG/MEDIUM: servers: unbreak server weight propagation
Willy Tarreau [Thu, 13 Apr 2017 13:09:26 +0000 (15:09 +0200)] 
BUG/MEDIUM: servers: unbreak server weight propagation

This reverts commit 266b1a8 ("MEDIUM: server: Inherit CLI weight changes and
agent-check weight responses") from Michal Idzikowski, which is still broken.
It stops propagating weights at the first error encountered, leaving servers
in a random state depending on what LB algorithms are used on other servers
tracking the one experiencing the weight change. It's unsure what the best
way to address this is, but we cannot leave the servers in an inconsistent
state between farms. For example :

  backend site1
      mode http
      balance uri
      hash-type consistent
      server s1 127.0.0.1:8001 weight 10 track servers/s1

  backend site2
      mode http
      balance uri
      server s1 127.0.0.1:8001 weight 10 track servers/s1

  backend site3
      mode http
      balance uri
      hash-type consistent
      server s1 127.0.0.1:8001 weight 10 track servers/s1

  backend servers
      server s1 127.0.0.1:8001 weight 10 check inter 1s

The weight change is applied on "servers/s1". It tries to propagate
to the servers tracking it, which are site1/s1, site2/s1 and site3/s1.
Let's say that "weight 50%" is requested. The servers are linked in
reverse-order, so the change is applied to "servers/s1", then to
"site3/s1", then to "site2/s1" and this one fails and rejects the
change. The change is aborted and never propagated to "site1/s1",
which keeps the server in a different state from "site3/s1". At the
very least, in case of error, the changes should probably be unrolled.

Also the error reported on the CLI (when changing from the CLI) simply says :

  Backend is using a static LB algorithm and only accepts weights '0%' and '100%'.

Without more indications what the faulty backend is.

Let's revert this change for now, as initially feared it will definitely
cause more harm than good and at least needs to be revisited. It was never
backported to any stable branch so no backport is needed.

8 years agoBUG/MEDIUM: acl: don't free unresolved args in prune_acl_expr()
Willy Tarreau [Wed, 12 Apr 2017 21:03:31 +0000 (23:03 +0200)] 
BUG/MEDIUM: acl: don't free unresolved args in prune_acl_expr()

In case of error it's very difficult to properly unroll the list of
unresolved args because the error can appear on any argument, and all
of them share the same memory area, pointed to by one or multiple links
from the global args list. The problem is that till now the arguments
themselves were released and were not unlinked from the list, causing
all forms of corruption in deinit() when quitting on the error path if
an argument couldn't properly parse.

A few attempts at trying to selectively spot the appropriate list entries
to kill before releasing the shared area have only resulted in complicating
the code and pushing the issue further.

Here instead we use a simple conservative approach : prune_acl_expr()
only tries to free the argument array if none of the arguments were
unresolved, which means that none of them was added to the arg list.

It's unclear what a better approach would be. We could imagine that
args would point to their own location in the shared list but given
that this extra cost and complexity would be added exclusively in
order to cleanly release everything when we're exiting due to a config
parse error, this seems quite overkill.

This bug was noticed on 1.7 and likely affects 1.6 and 1.5, so the fix
should be backported. It's not easy to reproduce it, as the reproducers
randomly work depending on how memory is allocated. One way to do it is
to use parsable and non-parsable patterns on an ACL making use of args.

Big thanks to Stephan Zeisberg for reporting this problem with a working
reproducer.

8 years agoBUG/MEDIUM: arg: ensure that we properly unlink unresolved arguments on error
Willy Tarreau [Wed, 12 Apr 2017 20:32:04 +0000 (22:32 +0200)] 
BUG/MEDIUM: arg: ensure that we properly unlink unresolved arguments on error

If make_arg_list() fails to process an argument after having queued an
unresolvable one, it frees the allocated argument list but doesn't remove
the referenced args from the arg list. This causes a use after free or a
double free if the same location was reused, during the deinit phase upon
exit after reporting the error.

Since it's not easy to properly unlinked all elements, we only release the
args block if none of them was queued in the list.

8 years agoMEDIUM: server: Inherit CLI weight changes and agent-check weight responses
Michal Idzikowski [Mon, 27 Mar 2017 12:45:49 +0000 (14:45 +0200)] 
MEDIUM: server: Inherit CLI weight changes and agent-check weight responses

When agent-check or CLI command executes relative weight change this patch
propagates it to tracking server allowing grouping many backends running on
same server underneath. Additionaly in case with many src IPs many backends
can have shared state checker, so there won't be unnecessary health checks.

[wt: Note: this will induce some behaviour change on some setups]

8 years agoBUG/MINOR: arg: don't try to add an argument on failed memory allocation
Willy Tarreau [Wed, 12 Apr 2017 20:28:52 +0000 (22:28 +0200)] 
BUG/MINOR: arg: don't try to add an argument on failed memory allocation

Take care of arg_list_clone() returning NULL in arg_list_add() since
the former does it too. It's only used during parsing so the impact
is very low.

Can be backported to 1.7, 1.6 and 1.5.

8 years agoBUG/MINOR: config: missing goto out after parsing an incorrect ACL character
Willy Tarreau [Wed, 12 Apr 2017 16:54:00 +0000 (18:54 +0200)] 
BUG/MINOR: config: missing goto out after parsing an incorrect ACL character

The error doesn't prevent checking for other errors after an invalid
character was detected in an ACL name. Better quit ASAP to avoid risking
to emit garbled and confusing error messages if something else fails on
the same line.

This should be backported to 1.7, 1.6 and 1.5.

8 years agoBUG/MINOR: dns: Wrong address family used when creating IPv6 sockets.
Frédéric Lécaille [Tue, 11 Apr 2017 06:46:37 +0000 (08:46 +0200)] 
BUG/MINOR: dns: Wrong address family used when creating IPv6 sockets.

AF_INET address family was always used to create sockets to connect
to name servers. This prevented any connection over IPv6 from working.

This fix must be backported to 1.7 and 1.6.

8 years agoBUILD/MINOR: tools: fix build warning in debug_hexdump()
Willy Tarreau [Tue, 11 Apr 2017 05:58:08 +0000 (07:58 +0200)] 
BUILD/MINOR: tools: fix build warning in debug_hexdump()

Commit 0ebb511 ("MINOR: tools: add a generic hexdump function for debugging")
introduced debug_hexdump() which is used to dump a memory area during
debugging sessions. This function can start at an unaligned offset and
uses a signed comparison to know where to start dumping from. But the
operation mixes signed and unsigned, making the test incorrect and causing
the following warnings to be emitted under Clang :

  src/standard.c:3775:14: warning: comparison of unsigned expression >= 0 is
        always true [-Wtautological-compare]
                          if (b + j >= 0 && b + j < len)
                              ~~~~~ ^  ~

Make "j" signed instead. At the moment this function is not used at all
so there's no impact. Thanks to Dmitry Sivachenko for reporting it. No
backport is needed.

8 years agoBUILD/MINOR: stats: remove unexpected argument to stats_dump_json_header()
Willy Tarreau [Tue, 11 Apr 2017 05:53:04 +0000 (07:53 +0200)] 
BUILD/MINOR: stats: remove unexpected argument to stats_dump_json_header()

Commit 05ee213 ("MEDIUM: stats: Add JSON output option to show (info|stat)")
used to pass argument "uri" to the aforementionned function which doesn't
take any. It's probably a leftover from multiple iterations of the same
patchset. Spotted by Dmitry Sivachenko. No backport is needed.

8 years agoBUG/MINOR: server : no transparent proxy for DragonflyBSD
David Carlier [Fri, 7 Apr 2017 19:48:00 +0000 (20:48 +0100)] 
BUG/MINOR: server : no transparent proxy for DragonflyBSD

IP*_BINDANY is not defined under this system thus it is
necessary to make those fields access since CONFIG_HAP_TRANSPARENT
is not defined.
[wt: problem introduced late in 1.8-dev. The same fix was also reported
  by Steven Davidovitz]

8 years agoDOC: stick-table is available in frontend sections
Adam Spiers [Thu, 6 Apr 2017 15:31:39 +0000 (16:31 +0100)] 
DOC: stick-table is available in frontend sections

Fix the proxy keywords matrix to reflect that it's permitted to use
stick-table in frontend sections.

Signed-off-by: Adam Spiers <aspiers@suse.com>
8 years agoMINOR server: Restrict dynamic cookie check to the same proxy.
Olivier Houchard [Tue, 4 Apr 2017 20:10:36 +0000 (22:10 +0200)] 
MINOR server: Restrict dynamic cookie check to the same proxy.

Each time we generate a dynamic cookie, we try to make sure the same
cookie hasn't been generated for another server, it's very unlikely, but
it may happen.
We only have to check that for the servers in the same proxy, no, need to
check in others, plus the code was buggy and would always check in the
first proxy of the proxy list.

8 years agoDOC: mention lighttpd 1.4.46 implements PROXY
Glenn Strauss [Wed, 5 Apr 2017 05:51:37 +0000 (01:51 -0400)] 
DOC: mention lighttpd 1.4.46 implements PROXY

lighttpd 1.4.46 implements PROXY v1 and v2 for incoming connections.

8 years agoDOC: update sample code for PROXY protocol
Glenn Strauss [Wed, 5 Apr 2017 05:37:20 +0000 (01:37 -0400)] 
DOC: update sample code for PROXY protocol

lengths are in network byte order so use ntohs(hdr.v2.len)
when calculating size of v2 header to recv() from head of stream.

8 years agoDOC: add few comments to examples.
Jarno Huuskonen [Mon, 3 Apr 2017 11:36:21 +0000 (14:36 +0300)] 
DOC: add few comments to examples.

- http-check expect rstring is missing html comment closing tag.
- option redis-check: See also "option tcp-check", "tcp-check expect".
- ignore-persist static url example ((from 7.2 Using ACLs to form
  conditions)
- tcp-request content: hdr(x-forwarded-for) example: added
  hdr_ip(x-forwarded-for) version.
- tcp-request content: added comments to sc0_inc_gpc0 stick table example.
- timeout tarpit: mention http-request tarpit.

8 years agoDOC: changed "block"(deprecated) examples to http-request deny
Jarno Huuskonen [Mon, 3 Apr 2017 11:20:34 +0000 (14:20 +0300)] 
DOC: changed "block"(deprecated) examples to http-request deny

8 years agoCLEANUP: server: moving netinet/tcp.h inclusion
David Carlier [Mon, 3 Apr 2017 20:58:04 +0000 (21:58 +0100)] 
CLEANUP: server: moving netinet/tcp.h inclusion

netinet/tcp.h needs sys/types.h for u_int* types usage,
issue found while building on OpenBSD.

8 years ago[RELEASE] Released version 1.8-dev1 v1.8-dev1
Willy Tarreau [Mon, 3 Apr 2017 07:27:49 +0000 (09:27 +0200)] 
[RELEASE] Released version 1.8-dev1

Released version 1.8-dev1 with the following main changes :
    - BUG/MEDIUM: proxy: return "none" and "unknown" for unknown LB algos
    - BUG/MINOR: stats: make field_str() return an empty string on NULL
    - DOC: Spelling fixes
    - BUG/MEDIUM: http: Fix tunnel mode when the CONNECT method is used
    - BUG/MINOR: http: Keep the same behavior between 1.6 and 1.7 for tunneled txn
    - BUG/MINOR: filters: Protect args in macros HAS_DATA_FILTERS and IS_DATA_FILTER
    - BUG/MINOR: filters: Invert evaluation order of HTTP_XFER_BODY and XFER_DATA analyzers
    - BUG/MINOR: http: Call XFER_DATA analyzer when HTTP txn is switched in tunnel mode
    - BUG/MAJOR: stream: fix session abort on resource shortage
    - OPTIM: stream-int: don't disable polling anymore on DONT_READ
    - BUG/MINOR: cli: allow the backslash to be escaped on the CLI
    - BUG/MEDIUM: cli: fix "show stat resolvers" and "show tls-keys"
    - DOC: Fix map table's format
    - DOC: Added 51Degrees conv and fetch functions to documentation.
    - BUG/MINOR: http: don't send an extra CRLF after a Set-Cookie in a redirect
    - DOC: mention that req_tot is for both frontends and backends
    - BUG/MEDIUM: variables: some variable name can hide another ones
    - MINOR: lua: Allow argument for actions
    - BUILD: rearrange target files by build time
    - CLEANUP: hlua: just indent functions
    - MINOR: lua: give HAProxy variable access to the applets
    - BUG/MINOR: stats: fix be/sessions/max output in html stats
    - MINOR: proxy: Add fe_name/be_name fetchers next to existing fe_id/be_id
    - DOC: lua: Documentation about some entry missing
    - DOC: lua: Add documentation about variable manipulation from applet
    - MINOR: Do not forward the header "Expect: 100-continue" when the option http-buffer-request is set
    - DOC: Add undocumented argument of the trace filter
    - DOC: Fix some typo in SPOE documentation
    - MINOR: cli: Remove useless call to bi_putchk
    - BUG/MINOR: cli: be sure to always warn the cli applet when input buffer is full
    - MINOR: applet: Count number of (active) applets
    - MINOR: task: Rename run_queue and run_queue_cur counters
    - BUG/MEDIUM: stream: Save unprocessed events for a stream
    - BUG/MAJOR: Fix how the list of entities waiting for a buffer is handled
    - BUILD/MEDIUM: Fixing the build using LibreSSL
    - BUG/MEDIUM: lua: In some case, the return of sample-fetches is ignored (2)
    - SCRIPTS: git-show-backports: fix a harmless typo
    - SCRIPTS: git-show-backports: add -H to use the hash of the commit message
    - BUG/MINOR: stream-int: automatically release SI_FL_WAIT_DATA on SHUTW_NOW
    - CLEANUP: applet/lua: create a dedicated ->fcn entry in hlua_cli context
    - CLEANUP: applet/table: add an "action" entry in ->table context
    - CLEANUP: applet: remove the now unused appctx->private field
    - DOC: lua: documentation about time parser functions
    - DOC: lua: improve links
    - DOC: lua: section declared twice
    - MEDIUM: cli: 'show cli sockets' list the CLI sockets
    - BUG/MINOR: cli: "show cli sockets" wouldn't list all processes
    - BUG/MINOR: cli: "show cli sockets" would always report process 64
    - CLEANUP: lua: rename one of the lua appctx union
    - BUG/MINOR: lua/cli: bad error message
    - MEDIUM: lua: use memory pool for hlua struct in applets
    - MINOR: lua/signals: Remove Lua part from signals.
    - DOC: cli: show cli sockets
    - MINOR: cli: automatically enable a CLI I/O handler when there's no parser
    - CLEANUP: memory: remove the now unused cli_parse_show_pools() function
    - CLEANUP: applet: group all CLI contexts together
    - CLEANUP: stats: move a misplaced stats context initialization
    - MINOR: cli: add two general purpose pointers and integers in the CLI struct
    - MINOR: appctx/cli: remove the cli_socket entry from the appctx union
    - MINOR: appctx/cli: remove the env entry from the appctx union
    - MINOR: appctx/cli: remove the "be" entry from the appctx union
    - MINOR: appctx/cli: remove the "dns" entry from the appctx union
    - MINOR: appctx/cli: remove the "server_state" entry from the appctx union
    - MINOR: appctx/cli: remove the "tlskeys" entry from the appctx union
    - CONTRIB: tcploop: add limits.h to fix build issue with some compilers
    - MINOR/DOC: lua: just precise one thing
    - DOC: fix small typo in fe_id (backend instead of frontend)
    - BUG/MINOR: Fix the sending function in Lua's cosocket
    - BUG/MINOR: lua: memory leak executing tasks
    - BUG/MINOR: lua: bad return code
    - BUG/MINOR: lua: memleak when Lua/cli fails
    - MEDIUM: lua: remove Lua struct from session, and allocate it with memory pools
    - CLEANUP: haproxy: statify unexported functions
    - MINOR: haproxy: add a registration for build options
    - CLEANUP: wurfl: use the build options list to report it
    - CLEANUP: 51d: use the build options list to report it
    - CLEANUP: da: use the build options list to report it
    - CLEANUP: namespaces: use the build options list to report it
    - CLEANUP: tcp: use the build options list to report transparent modes
    - CLEANUP: lua: use the build options list to report it
    - CLEANUP: regex: use the build options list to report the regex type
    - CLEANUP: ssl: use the build options list to report the SSL details
    - CLEANUP: compression: use the build options list to report the algos
    - CLEANUP: auth: use the build options list to report its support
    - MINOR: haproxy: add a registration for post-check functions
    - CLEANUP: checks: make use of the post-init registration to start checks
    - CLEANUP: filters: use the function registration to initialize all proxies
    - CLEANUP: wurfl: make use of the late init registration
    - CLEANUP: 51d: make use of the late init registration
    - CLEANUP: da: make use of the late init registration code
    - MINOR: haproxy: add a registration for post-deinit functions
    - CLEANUP: wurfl: register the deinit function via the dedicated list
    - CLEANUP: 51d: register the deinitialization function
    - CLEANUP: da: register the deinitialization function
    - CLEANUP: wurfl: move global settings out of the global section
    - CLEANUP: 51d: move global settings out of the global section
    - CLEANUP: da: move global settings out of the global section
    - MINOR: cfgparse: add two new functions to check arguments count
    - MINOR: cfgparse: move parsing of "ca-base" and "crt-base" to ssl_sock
    - MEDIUM: cfgparse: move all tune.ssl.* keywords to ssl_sock
    - MEDIUM: cfgparse: move maxsslconn parsing to ssl_sock
    - MINOR: cfgparse: move parsing of ssl-default-{bind,server}-ciphers to ssl_sock
    - MEDIUM: cfgparse: move ssl-dh-param-file parsing to ssl_sock
    - MEDIUM: compression: move the zlib-specific stuff from global.h to compression.c
    - BUG/MEDIUM: ssl: properly reset the reused_sess during a forced handshake
    - BUG/MEDIUM: ssl: avoid double free when releasing bind_confs
    - BUG/MINOR: stats: fix be/sessions/current out in typed stats
    - MINOR: tcp-rules: check that the listener exists before updating its counters
    - MEDIUM: spoe: don't create a dummy listener for outgoing connections
    - MINOR: listener: move the transport layer pointer to the bind_conf
    - MEDIUM: move listener->frontend to bind_conf->frontend
    - MEDIUM: ssl: remote the proxy argument from most functions
    - MINOR: connection: add a new prepare_bind_conf() entry to xprt_ops
    - MEDIUM: ssl_sock: implement ssl_sock_prepare_bind_conf()
    - MINOR: connection: add a new destroy_bind_conf() entry to xprt_ops
    - MINOR: ssl_sock: implement ssl_sock_destroy_bind_conf()
    - MINOR: server: move the use_ssl field out of the ifdef USE_OPENSSL
    - MINOR: connection: add a minimal transport layer registration system
    - CLEANUP: connection: remove all direct references to raw_sock and ssl_sock
    - CLEANUP: connection: unexport raw_sock and ssl_sock
    - MINOR: connection: add new prepare_srv()/destroy_srv() entries to xprt_ops
    - MINOR: ssl_sock: implement and use prepare_srv()/destroy_srv()
    - CLEANUP: ssl: move tlskeys_finalize_config() to a post_check callback
    - CLEANUP: ssl: move most ssl-specific global settings to ssl_sock.c
    - BUG/MINOR: backend: nbsrv() should return 0 if backend is disabled
    - BUG/MEDIUM: ssl: for a handshake when server-side SNI changes
    - BUG/MINOR: systemd: potential zombie processes
    - DOC: Add timings events schemas
    - BUILD: lua: build failed on FreeBSD.
    - MINOR: samples: add xx-hash functions
    - MEDIUM: regex: pcre2 support
    - BUG/MINOR: option prefer-last-server must be ignored in some case
    - MINOR: stats: Support "select all" for backend actions
    - BUG/MINOR: sample-fetches/stick-tables: bad type for the sample fetches sc*_get_gpt0
    - BUG/MAJOR: channel: Fix the definition order of channel analyzers
    - BUG/MINOR: http: report real parser state in error captures
    - BUILD: scripts: automatically update the branch in version.h when releasing
    - MINOR: tools: add a generic hexdump function for debugging
    - BUG/MAJOR: http: fix risk of getting invalid reports of bad requests
    - MINOR: http: custom status reason.
    - MINOR: connection: add sample fetch "fc_rcvd_proxy"
    - BUG/MINOR: config: emit a warning if http-reuse is enabled with incompatible options
    - BUG/MINOR: tools: fix off-by-one in port size check
    - BUG/MEDIUM: server: consider AF_UNSPEC as a valid address family
    - MEDIUM: server: split the address and the port into two different fields
    - MINOR: tools: make str2sa_range() return the port in a separate argument
    - MINOR: server: take the destination port from the port field, not the addr
    - MEDIUM: server: disable protocol validations when the server doesn't resolve
    - BUG/MEDIUM: tools: do not force an unresolved address to AF_INET:0.0.0.0
    - BUG/MINOR: ssl: EVP_PKEY must be freed after X509_get_pubkey usage
    - BUG/MINOR: ssl: assert on SSL_set_shutdown with BoringSSL
    - MINOR: Use "500 Internal Server Error" for 500 error/status code message.
    - MINOR: proto_http.c 502 error txt typo.
    - DOC: add deprecation notice to "block"
    - MINOR: compression: fix -vv output without zlib/slz
    - BUG/MINOR: Reset errno variable before calling strtol(3)
    - MINOR: ssl: don't show prefer-server-ciphers output
    - OPTIM/MINOR: config: Optimize fullconn automatic computation loading configuration
    - BUG/MINOR: stream: Fix how backend-specific analyzers are set on a stream
    - MAJOR: ssl: bind configuration per certificat
    - MINOR: ssl: add curve suite for ECDHE negotiation
    - MINOR: checks: Add agent-addr config directive
    - MINOR: cli: Add possiblity to change agent config via CLI/socket
    - MINOR: doc: Add docs for agent-addr configuration variable
    - MINOR: doc: Add docs for agent-addr and agent-send CLI commands
    - BUILD: ssl: fix to build (again) with boringssl
    - BUILD: ssl: fix build on OpenSSL 1.0.0
    - BUILD: ssl: silence a warning reported for ERR_remove_state()
    - BUILD: ssl: eliminate warning with OpenSSL 1.1.0 regarding RAND_pseudo_bytes()
    - BUILD: ssl: kill a build warning introduced by BoringSSL compatibility
    - BUG/MEDIUM: tcp: don't poll for write when connect() succeeds
    - BUG/MINOR: unix: fix connect's polling in case no data are scheduled
    - MINOR: server: extend the flags to 32 bits
    - BUG/MINOR: lua: Map.end are not reliable because "end" is a reserved keyword
    - MINOR: dns: give ability to dns_init_resolvers() to close a socket when requested
    - BUG/MAJOR: dns: restart sockets after fork()
    - MINOR: chunks: implement a simple dynamic allocator for trash buffers
    - BUG/MEDIUM: http: prevent redirect from overwriting a buffer
    - BUG/MEDIUM: filters: Do not truncate HTTP response when body length is undefined
    - BUG/MEDIUM: http: Prevent replace-header from overwriting a buffer
    - BUG/MINOR: http: Return an error when a replace-header rule failed on the response
    - BUG/MINOR: sendmail: The return of vsnprintf is not cleanly tested
    - BUG/MAJOR: ssl: fix a regression in ssl_sock_shutw()
    - BUG/MAJOR: lua segmentation fault when the request is like 'GET ?arg=val HTTP/1.1'
    - BUG/MEDIUM: config: reject anything but "if" or "unless" after a use-backend rule
    - MINOR: http: don't close when redirect location doesn't start with "/"
    - MEDIUM: boringssl: support native multi-cert selection without bundling
    - BUG/MEDIUM: ssl: fix verify/ca-file per certificate
    - BUG/MEDIUM: ssl: switchctx should not return SSL_TLSEXT_ERR_ALERT_WARNING
    - MINOR: ssl: removes SSL_CTX_set_ssl_version call and cleanup CTX creation.
    - BUILD: ssl: fix build with -DOPENSSL_NO_DH
    - MEDIUM: ssl: add new sample-fetch which captures the cipherlist
    - MEDIUM: ssl: remove ssl-options from crt-list
    - BUG/MEDIUM: ssl: in bind line, ssl-options after 'crt' are ignored.
    - BUG/MINOR: ssl: fix cipherlist captures with sustainable SSL calls
    - MINOR: ssl: improved cipherlist captures
    - BUG/MINOR: spoe: Fix soft stop handler using a specific id for spoe filters
    - BUG/MINOR: spoe: Fix parsing of arguments in spoe-message section
    - MAJOR: spoe: Add support of pipelined and asynchronous exchanges with agents
    - MINOR: spoe: Add support for pipelining/async capabilities in the SPOA example
    - MINOR: spoe: Remove SPOE details from the appctx structure
    - MINOR: spoe: Add status code in error variable instead of hardcoded value
    - MINOR: spoe: Send a log message when an error occurred during event processing
    - MINOR: spoe: Check the scope of sample fetches used in SPOE messages
    - MEDIUM: spoe: Be sure to wakeup the good entity waiting for a buffer
    - MINOR: spoe: Use the min of all known max_frame_size to encode messages
    - MAJOR: spoe: Add support of payload fragmentation in NOTIFY frames
    - MINOR: spoe: Add support for fragmentation capability in the SPOA example
    - MAJOR: spoe: refactor the filter to clean up the code
    - MINOR: spoe: Handle NOTIFY frames cancellation using ABORT bit in ACK frames
    - REORG: spoe: Move struct and enum definitions in dedicated header file
    - REORG: spoe: Move low-level encoding/decoding functions in dedicated header file
    - MINOR: spoe: Improve implementation of the payload fragmentation
    - MINOR: spoe: Add support of negation for options in SPOE configuration file
    - MINOR: spoe: Add "pipelining" and "async" options in spoe-agent section
    - MINOR: spoe: Rely on alertif_too_many_arg during configuration parsing
    - MINOR: spoe: Add "send-frag-payload" option in spoe-agent section
    - MINOR: spoe: Add "max-frame-size" statement in spoe-agent section
    - DOC: spoe: Update SPOE documentation to reflect recent changes
    - MINOR: config: warn when some HTTP rules are used in a TCP proxy
    - BUG/MEDIUM: ssl: Clear OpenSSL error stack after trying to parse OCSP file
    - BUG/MEDIUM: cli: Prevent double free in CLI ACL lookup
    - BUG/MINOR: Fix "get map <map> <value>" CLI command
    - MINOR: Add nbsrv sample converter
    - CLEANUP: Replace repeated code to count usable servers with be_usable_srv()
    - MINOR: Add hostname sample fetch
    - CLEANUP: Remove comment that's no longer valid
    - MEDIUM: http_error_message: txn->status / http_get_status_idx.
    - MINOR: http-request tarpit deny_status.
    - CLEANUP: http: make http_server_error() not set the status anymore
    - MEDIUM: stats: Add JSON output option to show (info|stat)
    - MEDIUM: stats: Add show json schema
    - BUG/MAJOR: connection: update CO_FL_CONNECTED before calling the data layer
    - MINOR: server: Add dynamic session cookies.
    - MINOR: cli: Let configure the dynamic cookies from the cli.
    - BUG/MINOR: checks: attempt clean shutw for SSL check
    - CONTRIB: tcploop: make it build on FreeBSD
    - CONTRIB: tcploop: fix time format to silence build warnings
    - CONTRIB: tcploop: report action 'K' (kill) in usage message
    - CONTRIB: tcploop: fix connect's address length
    - CONTRIB: tcploop: use the trash instead of NULL for recv()
    - BUG/MEDIUM: listener: do not try to rebind another process' socket
    - BUG/MEDIUM server: Fix crash when dynamic is defined, but not key is provided.
    - CLEANUP: config: Typo in comment.
    - BUG/MEDIUM: filters: Fix channels synchronization in flt_end_analyze
    - TESTS: add a test configuration to stress handshake combinations
    - BUG/MAJOR: stream-int: do not depend on connection flags to detect connection
    - BUG/MEDIUM: connection: ensure to always report the end of handshakes
    - MEDIUM: connection: don't test for CO_FL_WAKE_DATA
    - CLEANUP: connection: completely remove CO_FL_WAKE_DATA
    - BUG: payload: fix payload not retrieving arbitrary lengths
    - BUILD: ssl: simplify SSL_CTX_set_ecdh_auto compatibility
    - BUILD: ssl: fix OPENSSL_NO_SSL_TRACE for boringssl and libressl
    - BUG/MAJOR: http: fix typo in http_apply_redirect_rule
    - MINOR: doc: 2.4. Examples should be 2.5. Examples
    - BUG/MEDIUM: stream: fix client-fin/server-fin handling
    - MINOR: fd: add a new flag HAP_POLL_F_RDHUP to struct poller
    - BUG/MINOR: raw_sock: always perfom the last recv if RDHUP is not available
    - OPTIM: poll: enable support for POLLRDHUP
    - MINOR: kqueue: exclusively rely on the kqueue returned status
    - MEDIUM: kqueue: take care of EV_EOF to improve polling status accuracy
    - MEDIUM: kqueue: only set FD_POLL_IN when there are pending data
    - DOC/MINOR: Fix typos in proxy protocol doc
    - DOC: Protocol doc: add checksum, TLV type ranges
    - DOC: Protocol doc: add SSL TLVs, rename CHECKSUM
    - DOC: Protocol doc: add noop TLV
    - MEDIUM: global: add a 'hard-stop-after' option to cap the soft-stop time
    - MINOR: dns: improve DNS response parsing to use as many available records as possible
    - BUG/MINOR: cfgparse: loop in tracked servers lists not detected by check_config_validity().
    - MINOR: server: irrelevant error message with 'default-server' config file keyword.
    - MINOR: server: Make 'default-server' support 'backup' keyword.
    - MINOR: server: Make 'default-server' support 'check-send-proxy' keyword.
    - CLEANUP: server: code alignement.
    - MINOR: server: Make 'default-server' support 'non-stick' keyword.
    - MINOR: server: Make 'default-server' support 'send-proxy' and 'send-proxy-v2 keywords.
    - MINOR: server: Make 'default-server' support 'check-ssl' keyword.
    - MINOR: server: Make 'default-server' support 'force-sslv3' and 'force-tlsv1[0-2]' keywords.
    - CLEANUP: server: code alignement.
    - MINOR: server: Make 'default-server' support 'no-ssl*' and 'no-tlsv*' keywords.
    - MINOR: server: Make 'default-server' support 'ssl' keyword.
    - MINOR: server: Make 'default-server' support 'send-proxy-v2-ssl*' keywords.
    - CLEANUP: server: code alignement.
    - MINOR: server: Make 'default-server' support 'verify' keyword.
    - MINOR: server: Make 'default-server' support 'verifyhost' setting.
    - MINOR: server: Make 'default-server' support 'check' keyword.
    - MINOR: server: Make 'default-server' support 'track' setting.
    - MINOR: server: Make 'default-server' support 'ca-file', 'crl-file' and 'crt' settings.
    - MINOR: server: Make 'default-server' support 'redir' keyword.
    - MINOR: server: Make 'default-server' support 'observe' keyword.
    - MINOR: server: Make 'default-server' support 'cookie' keyword.
    - MINOR: server: Make 'default-server' support 'ciphers' keyword.
    - MINOR: server: Make 'default-server' support 'tcp-ut' keyword.
    - MINOR: server: Make 'default-server' support 'namespace' keyword.
    - MINOR: server: Make 'default-server' support 'source' keyword.
    - MINOR: server: Make 'default-server' support 'sni' keyword.
    - MINOR: server: Make 'default-server' support 'addr' keyword.
    - MINOR: server: Make 'default-server' support 'disabled' keyword.
    - MINOR: server: Add 'no-agent-check' server keyword.
    - DOC: server: Add docs for "server" and "default-server" new "no-*" and other settings.
    - MINOR: doc: fix use-server example (imap vs mail)
    - BUG/MEDIUM: tcp: don't require privileges to bind to device
    - BUILD: make the release script use shortlog for the final changelog
    - BUILD: scripts: fix typo in announce-release error message
    - CLEANUP: time: curr_sec_ms doesn't need to be exported
    - BUG/MEDIUM: server: Wrong server default CRT filenames initialization.
    - BUG/MEDIUM: peers: fix buffer overflow control in intdecode.
    - BUG/MEDIUM: buffers: Fix how input/output data are injected into buffers
    - BUG/MINOR: http: Fix conditions to clean up a txn and to handle the next request
    - CLEANUP: http: Remove channel_congested function
    - CLEANUP: buffers: Remove buffer_bounce_realign function
    - CLEANUP: buffers: Remove buffer_contig_area and buffer_work_area functions
    - MINOR: http: remove useless check on HTTP_MSGF_XFER_LEN for the request
    - MINOR: http: Add debug messages when HTTP body analyzers are called
    - BUG/MEDIUM: http: Fix blocked HTTP/1.0 responses when compression is enabled
    - BUG/MINOR: filters: Don't force the stream's wakeup when we wait in flt_end_analyze
    - DOC: fix parenthesis and add missing "Example" tags
    - DOC: update the contributing file
    - DOC: log-format/tcplog/httplog update
    - MINOR: config parsing: add warning when log-format/tcplog/httplog is overriden in "defaults" sections

8 years agoMINOR: config parsing: add warning when log-format/tcplog/httplog is overriden in...
Guillaume de Lafond [Fri, 31 Mar 2017 17:54:09 +0000 (19:54 +0200)] 
MINOR: config parsing: add warning when log-format/tcplog/httplog is overriden in "defaults" sections

Add a warning when "log-format" or "tcplog" or "httplog" is overriden in "defaults" sections.

8 years agoDOC: log-format/tcplog/httplog update
Guillaume de Lafond [Fri, 31 Mar 2017 17:52:15 +0000 (19:52 +0200)] 
DOC: log-format/tcplog/httplog update

"log-format"/"tcplog"/"httplog" overrides any previous "log-format"/"tcplog"/"httplog" config variables.

8 years agoDOC: update the contributing file
Willy Tarreau [Fri, 31 Mar 2017 14:24:44 +0000 (16:24 +0200)] 
DOC: update the contributing file

Bring more details, examples of good/bad messages, and avoid confusion
between commit message and message subject.

8 years agoDOC: fix parenthesis and add missing "Example" tags
Jarno Huuskonen [Thu, 30 Mar 2017 06:19:45 +0000 (09:19 +0300)] 
DOC: fix parenthesis and add missing "Example" tags

- urlp_val had unbalanced parenthesis / square brackets
- src_clr_gpc0,src_inc_gpc0,sc2_clr_gpc0,sc2_inc_gpc0,ssl_c_sha1 had
  examples not tagged as such.

8 years agoBUG/MINOR: filters: Don't force the stream's wakeup when we wait in flt_end_analyze
Christopher Faulet [Thu, 30 Mar 2017 09:13:22 +0000 (11:13 +0200)] 
BUG/MINOR: filters: Don't force the stream's wakeup when we wait in flt_end_analyze

In flt_end_analyze, we wait that the anlayze is finished for both the request
and the response. In this case, because of a task_wakeup, some streams can
consume too much CPU to do nothing. So now, this is the filter's responsibility
to know if this wakeup is needed.

This fix should be backported in 1.7.

8 years agoBUG/MEDIUM: http: Fix blocked HTTP/1.0 responses when compression is enabled
Christopher Faulet [Thu, 30 Mar 2017 08:54:35 +0000 (10:54 +0200)] 
BUG/MEDIUM: http: Fix blocked HTTP/1.0 responses when compression is enabled

When the compression filter is enabled, if a HTTP/1.0 response is received (no
content-length and no transfer-encoding), no data are forwarded to the client
because of a bug and the transaction is blocked indefinitly.

The bug comes from the fact we need to synchronize the end of the request and
the response because of the compression filter. This inhibits the infinite
forwarding of data. But for these responses, the compression is not
activated. So the response body is not analyzed. This leads to a deadlock.

The solution is to enable the analyze of the response body in all cases and
handle this one to enable the infinite forwarding. All other cases should
already by handled.

This fix should be backported to 1.7.

8 years agoMINOR: http: Add debug messages when HTTP body analyzers are called
Christopher Faulet [Thu, 30 Mar 2017 09:33:44 +0000 (11:33 +0200)] 
MINOR: http: Add debug messages when HTTP body analyzers are called

Only DPRINTF() for developers.

8 years agoMINOR: http: remove useless check on HTTP_MSGF_XFER_LEN for the request
Christopher Faulet [Thu, 30 Mar 2017 09:21:53 +0000 (11:21 +0200)] 
MINOR: http: remove useless check on HTTP_MSGF_XFER_LEN for the request

The flag HTTP_MSGF_XFER_LEN is always set for an HTTP request because we always
now the body length. So there is no need to do check on it.

8 years agoCLEANUP: buffers: Remove buffer_contig_area and buffer_work_area functions
Christopher Faulet [Wed, 29 Mar 2017 08:49:49 +0000 (10:49 +0200)] 
CLEANUP: buffers: Remove buffer_contig_area and buffer_work_area functions

Not used anymore since last commit.

8 years agoCLEANUP: buffers: Remove buffer_bounce_realign function
Christopher Faulet [Tue, 28 Mar 2017 09:53:34 +0000 (11:53 +0200)] 
CLEANUP: buffers: Remove buffer_bounce_realign function

Not used anymore since last commit.

8 years agoCLEANUP: http: Remove channel_congested function
Christopher Faulet [Tue, 28 Mar 2017 09:52:37 +0000 (11:52 +0200)] 
CLEANUP: http: Remove channel_congested function

Not used anymore since last commit.

8 years agoBUG/MINOR: http: Fix conditions to clean up a txn and to handle the next request
Christopher Faulet [Tue, 28 Mar 2017 09:51:33 +0000 (11:51 +0200)] 
BUG/MINOR: http: Fix conditions to clean up a txn and to handle the next request

To finish a HTTP transaction and to start the new one, we check, among other
things, that there is enough space in the reponse buffer to eventually inject a
message during the parsing of the next request. Because these messages can reach
the maximum buffers size, it is mandatory to have an empty response
buffer. Remaining input data are trimmed during the txn cleanup (in
http_reset_txn), so we just need to check that the output data were flushed.

The current implementation depends on channel_congested, which does check the
reserved area is available. That's not of course good enough. There are other
tests on the reponse buffer is http_wait_for_request. But conditions to move on
are almost the same. So, we can imagine some scenarii where some output data
remaining in the reponse buffer during the request parsing prevent any messages
injection.

To fix this bug, we just wait that output data were flushed before cleaning up
the HTTP txn (ie. s->res.buf->o == 0). In addition, in http_reset_txn we realign
the response buffer (note the buffer is empty at this step).

Thanks to this changes, there is no more need to set CF_EXPECT_MORE on the
response channel in http_end_txn_clean_session. And more important, there is no
more need to check the response buffer state in http_wait_for_request. This
remove a workaround on response analysers to handle HTTP pipelining.

This patch can be backported in 1.7, 1.6 and 1.5.

8 years agoBUG/MEDIUM: buffers: Fix how input/output data are injected into buffers
Christopher Faulet [Wed, 29 Mar 2017 09:58:28 +0000 (11:58 +0200)] 
BUG/MEDIUM: buffers: Fix how input/output data are injected into buffers

The function buffer_contig_space is buggy and could lead to pernicious bugs
(never hitted until now, AFAIK). This function should return the number of bytes
that can be written into the buffer at once (without wrapping).

First, this function is used to inject input data (bi_putblk) and to inject
output data (bo_putblk and bo_inject). But there is no context. So it cannot
decide where contiguous space should placed. For input data, it should be after
bi_end(buf) (ie, buf->p + buf->i modulo wrapping calculation). For output data,
it should be after bo_end(buf) (ie, buf->p) and input data are assumed to not
exist (else there is no space at all).

Then, considering we need to inject input data, this function does not always
returns the right value. And when we need to inject output data, we must be sure
to have no input data at all (buf->i == 0), else the result can also be wrong
(but this is the caller responsibility, so everything should be fine here).

The buffer can be in 3 different states:

 1) no wrapping

              <---- o ----><----- i ----->
 +------------+------------+-------------+------------+
 |            |oooooooooooo|iiiiiiiiiiiii|xxxxxxxxxxxx|
 +------------+------------+-------------+------------+
                           ^             <contig_space>
                           p             ^            ^
                 l            r

 2) input wrapping

 ...--->            <---- o ----><-------- i -------...
 +-----+------------+------------+--------------------+
 |iiiii|xxxxxxxxxxxx|oooooooooooo|iiiiiiiiiiiiiiiiiiii|
 +-----+------------+------------+--------------------+
       <contig_space>            ^
       ^            ^            p
       l            r

 3) output wrapping

 ...------ o ------><----- i ----->            <----...
 +------------------+-------------+------------+------+
 |oooooooooooooooooo|iiiiiiiiiiiii|xxxxxxxxxxxx|oooooo|
 +------------------+-------------+------------+------+
                    ^             <contig_space>
                    p             ^            ^
                  l            r

buffer_contig_space returns (l - r). The cases 1 and 3 are correctly
handled. But for the second case, r is wrong. It points on the buffer's end
(buf->data + buf->size). It should be bo_end(buf) (ie, buf->p - buf->o).

To fix the bug, the function has been splitted. Now, bi_contig_space and
bo_contig_space should be used to know the contiguous space available to insert,
respectively, input data and output data. For bo_contig_space, input data are
assumed to not exist. And the right version is used, depending what we want to
do.

In addition, to clarify the buffer's API, buffer_realign does not return value
anymore. So it has the same API than buffer_slow_realign.

This patch can be backported in 1.7, 1.6 and 1.5.

8 years agoBUG/MEDIUM: peers: fix buffer overflow control in intdecode.
Emeric Brun [Wed, 29 Mar 2017 14:32:53 +0000 (16:32 +0200)] 
BUG/MEDIUM: peers: fix buffer overflow control in intdecode.

A buffer overflow could happen if an integer is badly encoded in
the data part of a msg received from a peer. It should not happen
with authenticated peers (the handshake do not use this function).

This patch makes the code of the 'intdecode' function more robust.

It also adds some comments about the intencode function.

This bug affects versions >= 1.6.

8 years agoBUG/MEDIUM: server: Wrong server default CRT filenames initialization.
Frédéric Lécaille [Wed, 29 Mar 2017 12:58:09 +0000 (14:58 +0200)] 
BUG/MEDIUM: server: Wrong server default CRT filenames initialization.

This patch fixes a bug which came with 5e57643 commit where server
default CRT filenames were initialized to the same value as server
default CRL filenames.

8 years agoCLEANUP: time: curr_sec_ms doesn't need to be exported
Willy Tarreau [Wed, 29 Mar 2017 13:24:33 +0000 (15:24 +0200)] 
CLEANUP: time: curr_sec_ms doesn't need to be exported

It's not used anywhere outside of tv_update_date().

8 years agoBUILD: scripts: fix typo in announce-release error message
Willy Tarreau [Mon, 27 Mar 2017 17:36:45 +0000 (19:36 +0200)] 
BUILD: scripts: fix typo in announce-release error message

It used to say the tag already existed instead of the opposite.

8 years agoBUILD: make the release script use shortlog for the final changelog
Willy Tarreau [Mon, 27 Mar 2017 17:32:24 +0000 (19:32 +0200)] 
BUILD: make the release script use shortlog for the final changelog

It used to reuse the same command producting the list for the changelog,
requiring to run shortlog manually.

8 years agoBUG/MEDIUM: tcp: don't require privileges to bind to device
Willy Tarreau [Mon, 27 Mar 2017 14:22:59 +0000 (16:22 +0200)] 
BUG/MEDIUM: tcp: don't require privileges to bind to device

Ankit Malp reported a bug that we've had since binding to devices was
implemented. Haproxy wrongly checks that the process stays privileged
after startup when a binding to a device is specified via the bind
keyword "interface". This is wrong, because after startup we're not
binding any socket anymore, and during startup if there's a permission
issue it will be immediately reported ("permission denied"). More
importantly there's no way around it as the process exits on startup
when facing such an option.

This fix should be backported to 1.7, 1.6 and 1.5.

8 years agoMINOR: doc: fix use-server example (imap vs mail)
Lukas Tribus [Sun, 26 Mar 2017 12:55:35 +0000 (12:55 +0000)] 
MINOR: doc: fix use-server example (imap vs mail)

Another minor doc issue in the use-server example, use-server refers
to server "imap", but the server below is actually called "mail".

Renames the server from "mail" to "imap".

8 years agoDOC: server: Add docs for "server" and "default-server" new "no-*" and other settings.
Frédéric Lécaille [Tue, 21 Mar 2017 17:52:12 +0000 (18:52 +0100)] 
DOC: server: Add docs for "server" and "default-server" new "no-*" and other settings.

New boolean settings have been added to disable others. Most of them have "no-" as prefix.

"enabled" disables "disabled" setting,
"no-agent-check" disables "agent-check",
"no-backup" disables "backup",
"no-check" disables "check",
"no-check-ssl" disables "check-ssl",
"no-force-sslv3" disables "force-sslv3",
"no-force-tlsv10" disables "force-tlsv10",
"no-force-tlsv11" disables "force-tlsv11",
"no-force-tlsv12" disables "force-tlsv12,
"no-send-proxy" disables "send-proxy",
"no-send-proxy-v2" disables "send-proxy-v2",
"no-send-proxy-v2-ssl" disables "send-proxy-v2-ssl",
"no-send-proxy-v2-ssl-cn" disables "send-proxy-v2-ssl-cn",
"no-ssl" disables "ssl",
"no-verifyhost" disables "verifyhost",
"sslv3" disables "no-sslv3",
"ssl-reuse" disables "no-ssl-reuse",
"stick" disables "non-stick",
"tlsv10" disables "no-tlsv10",
"tlsv11" disables "no-tlsv11",
"tlsv12" disables "no-tlsv12",
"tls-tickets" disables "no-tls-tickets".

Settings with arguments are now supported on "default-server" lines:

"addr", "ca-file", "ciphers", "crl-file", "crt", "cookie", "namespace", "observe",
"redir", "sni", "source", "tcp-ut" and "track".

From now on, all server "settings" including the new ones above are supported by
"default-server" except "id" which is only supported on "server" lines.

8 years agoMINOR: server: Add 'no-agent-check' server keyword.
Frédéric Lécaille [Tue, 21 Mar 2017 15:39:15 +0000 (16:39 +0100)] 
MINOR: server: Add 'no-agent-check' server keyword.

This patch adds 'no-agent-check' setting supported both by 'default-server'
and 'server' directives to disable an agent check for a specific server which would
have 'agent-check' set as default value (inherited from 'default-server'
'agent-check' setting), or, on 'default-server' lines, to disable 'agent-check' setting
as default value for any further 'server' declarations.

For instance, provided this configuration:

    default-server agent-check
    server srv1
    server srv2 no-agent-check
    server srv3
    default-server no-agent-check
    server srv4

srv1 and srv3 would have an agent check enabled contrary to srv2 and srv4.

We do not allocate anymore anything when parsing 'default-server' 'agent-check'
setting.

8 years agoMINOR: server: Make 'default-server' support 'disabled' keyword.
Frédéric Lécaille [Tue, 21 Mar 2017 10:53:54 +0000 (11:53 +0100)] 
MINOR: server: Make 'default-server' support 'disabled' keyword.

Before this patch, only 'server' directives could support 'disabled' setting.
This patch makes also 'default-server' directives support this setting.
It is used to disable a list of servers declared after a 'defaut-server' directive.
'enabled' new keyword has been added, both supported as 'default-server' and
'server' setting, to enable again a list of servers (so, declared after a
'default-server enabled' directive) or to explicitly enable a specific server declared
after a 'default-server disabled' directive.

For instance provided this configuration:

    default-server disabled
    server srv1...
    server srv2...
    server srv3... enabled
    server srv4... enabled

srv1 and srv2 are disabled and srv3 and srv4 enabled.

This is equivalent to this configuration:

    default-server disabled
    server srv1...
    server srv2...
    default-server enabled
    server srv3...
    server srv4...

even if it would have been preferable/shorter to declare:

    server srv3...
    server srv4...
    default-server disabled
    server srv1...
    server srv2...

as 'enabled' is the default server state.

8 years agoMINOR: server: Make 'default-server' support 'addr' keyword.
Frédéric Lécaille [Mon, 20 Mar 2017 15:30:18 +0000 (16:30 +0100)] 
MINOR: server: Make 'default-server' support 'addr' keyword.

This patch makes 'default-server' support 'addr' setting.
The code which was responsible of parsing 'server' 'addr' setting
has moved from parse_server() to implement a new parser
callable both as 'default-server' and 'server' 'addr' setting parser.

Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'sni' keyword.
Frédéric Lécaille [Mon, 20 Mar 2017 13:54:41 +0000 (14:54 +0100)] 
MINOR: server: Make 'default-server' support 'sni' keyword.

This patch makes 'default-server' directives support 'sni' settings.
A field 'sni_expr' has been added to 'struct server' to temporary
stores SNI expressions as strings during both 'default-server' and 'server'
lines parsing. So, to duplicate SNI expressions from 'default-server' 'sni' setting
for new 'server' instances we only have to "strdup" these strings as this is
often done for most of the 'server' settings.
Then, sample expressions are computed calling sample_parse_expr() (only for 'server'
instances).
A new function has been added to produce the same error output as before in case
of any error during 'sni' settings parsing (display_parser_err()).
Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'source' keyword.
Frédéric Lécaille [Fri, 17 Mar 2017 14:33:50 +0000 (15:33 +0100)] 
MINOR: server: Make 'default-server' support 'source' keyword.

Before this patch, only 'server' directives could support 'source' setting.
This patch makes also 'default-server' directives support this setting.

To do so, we had to extract the code responsible of parsing 'source' setting
arguments from parse_server() function and make it callable both
as 'default-server' and 'server' 'source' setting parser. So, the code is mostly
the same as before except that before allocating anything for 'struct conn_src'
members, we must free the memory previously allocated.

Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'namespace' keyword.
Frédéric Lécaille [Thu, 16 Mar 2017 16:17:36 +0000 (17:17 +0100)] 
MINOR: server: Make 'default-server' support 'namespace' keyword.

Before this patch, 'namespace' setting was only supported by 'server' directive.
This patch makes 'default-server' directive support this setting.

8 years agoMINOR: server: Make 'default-server' support 'tcp-ut' keyword.
Frédéric Lécaille [Wed, 15 Mar 2017 15:36:09 +0000 (16:36 +0100)] 
MINOR: server: Make 'default-server' support 'tcp-ut' keyword.

This patch makes 'default-server' directive support 'tcp-ut' keyword.

8 years agoMINOR: server: Make 'default-server' support 'ciphers' keyword.
Frédéric Lécaille [Wed, 15 Mar 2017 15:20:02 +0000 (16:20 +0100)] 
MINOR: server: Make 'default-server' support 'ciphers' keyword.

This patch makes 'default-server' directive support 'ciphers' setting.

8 years agoMINOR: server: Make 'default-server' support 'cookie' keyword.
Frédéric Lécaille [Wed, 15 Mar 2017 08:13:33 +0000 (09:13 +0100)] 
MINOR: server: Make 'default-server' support 'cookie' keyword.

Before this patch, 'cookie' setting was only supported by 'server' directives.
This patch makes 'default-server' directive also support 'cookie' setting.
Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'observe' keyword.
Frédéric Lécaille [Wed, 15 Mar 2017 07:55:39 +0000 (08:55 +0100)] 
MINOR: server: Make 'default-server' support 'observe' keyword.

Before this path, 'observe' setting was only supported by 'server' directives.
This patch makes 'default-server' directives also support 'observe' setting.
Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'redir' keyword.
Frédéric Lécaille [Tue, 14 Mar 2017 15:42:49 +0000 (16:42 +0100)] 
MINOR: server: Make 'default-server' support 'redir' keyword.

Before this patch only 'server' directives could support 'redir' setting.
This patch makes also 'default-server' directives support 'redir' setting.
Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'ca-file', 'crl-file' and 'crt' settings.
Frédéric Lécaille [Tue, 14 Mar 2017 14:52:04 +0000 (15:52 +0100)] 
MINOR: server: Make 'default-server' support 'ca-file', 'crl-file' and 'crt' settings.

This patch makes 'default-server' directives support 'ca-file', 'crl-file' and
'crt' settings.

8 years agoMINOR: server: Make 'default-server' support 'track' setting.
Frédéric Lécaille [Tue, 14 Mar 2017 14:21:31 +0000 (15:21 +0100)] 
MINOR: server: Make 'default-server' support 'track' setting.

Before this patch only 'server' directives could support 'track' setting.
This patch makes 'default-server' directives also support this setting.
Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'check' keyword.
Frédéric Lécaille [Tue, 14 Mar 2017 10:20:13 +0000 (11:20 +0100)] 
MINOR: server: Make 'default-server' support 'check' keyword.

Before this patch 'check' setting was only supported by 'server' directives.
This patch makes also 'default-server' directives support this setting.
A new 'no-check' keyword parser has been implemented to disable this setting both
in 'default-server' and 'server' directives.
Should not break anything.

8 years agoMINOR: server: Make 'default-server' support 'verifyhost' setting.
Frédéric Lécaille [Mon, 13 Mar 2017 14:52:01 +0000 (15:52 +0100)] 
MINOR: server: Make 'default-server' support 'verifyhost' setting.

This patch makes 'default-server' directive support 'verifyhost' setting.
Note: there was a little memory leak when several 'verifyhost' arguments were
supplied on the same 'server' line.

8 years agoMINOR: server: Make 'default-server' support 'verify' keyword.
Frédéric Lécaille [Mon, 13 Mar 2017 12:41:16 +0000 (13:41 +0100)] 
MINOR: server: Make 'default-server' support 'verify' keyword.

This patch makes 'default-server' directive support 'verify' keyword.

8 years agoCLEANUP: server: code alignement.
Frédéric Lécaille [Mon, 13 Mar 2017 12:10:59 +0000 (13:10 +0100)] 
CLEANUP: server: code alignement.

Code alignement again.

8 years agoMINOR: server: Make 'default-server' support 'send-proxy-v2-ssl*' keywords.
Frédéric Lécaille [Mon, 13 Mar 2017 11:08:01 +0000 (12:08 +0100)] 
MINOR: server: Make 'default-server' support 'send-proxy-v2-ssl*' keywords.

This patch makes 'default-server' directive support 'send-proxy-v2-ssl'
(resp. 'send-proxy-v2-ssl-cn') setting.
A new keyword 'no-send-proxy-v2-ssl' (resp. 'no-send-proxy-v2-ssl-cn') has been
added to disable 'send-proxy-v2-ssl' (resp. 'send-proxy-v2-ssl-cn') setting both
in 'server' and 'default-server' directives.

8 years agoMINOR: server: Make 'default-server' support 'ssl' keyword.
Frédéric Lécaille [Mon, 13 Mar 2017 10:54:17 +0000 (11:54 +0100)] 
MINOR: server: Make 'default-server' support 'ssl' keyword.

 This patch makes 'default-server' directive support 'ssl' setting.
 A new keyword 'no-ssl' has been added to disable this setting both
 in 'server' and 'default-server' directives.

8 years agoMINOR: server: Make 'default-server' support 'no-ssl*' and 'no-tlsv*' keywords.
Frédéric Lécaille [Mon, 13 Mar 2017 10:32:20 +0000 (11:32 +0100)] 
MINOR: server: Make 'default-server' support 'no-ssl*' and 'no-tlsv*' keywords.

This patch makes 'default-server' directive support 'no-sslv3' (resp. 'no-ssl-reuse',
'no-tlsv10', 'no-tlsv11', 'no-tlsv12', and 'no-tls-tickets') setting.
New keywords 'sslv3' (resp. 'ssl-reuse', 'tlsv10', 'tlsv11', 'tlsv12', and
'tls-no-tickets') have been added to disable these settings both in 'server' and
'default-server' directives.

8 years agoCLEANUP: server: code alignement.
Frédéric Lécaille [Mon, 13 Mar 2017 10:02:01 +0000 (11:02 +0100)] 
CLEANUP: server: code alignement.

Code alignement.

8 years agoMINOR: server: Make 'default-server' support 'force-sslv3' and 'force-tlsv1[0-2]...
Frédéric Lécaille [Mon, 13 Mar 2017 09:54:52 +0000 (10:54 +0100)] 
MINOR: server: Make 'default-server' support 'force-sslv3' and 'force-tlsv1[0-2]' keywords.

This patch makes 'default-server' directive support 'force-sslv3'
and 'force-tlsv1[0-2]' settings.
New keywords 'no-force-sslv3' (resp. 'no-tlsv1[0-2]') have been added
to disable 'force-sslv3' (resp. 'force-tlsv1[0-2]') setting both in 'server' and
'default-server' directives.

8 years agoMINOR: server: Make 'default-server' support 'check-ssl' keyword.
Frédéric Lécaille [Mon, 13 Mar 2017 09:38:04 +0000 (10:38 +0100)] 
MINOR: server: Make 'default-server' support 'check-ssl' keyword.

This patch makes 'default-server' directive support 'check-ssl' setting
to enable SSL for health checks.
A new keyword 'no-check-ssl' has been added to disable this setting both in
'server' and 'default-server' directives.

8 years agoMINOR: server: Make 'default-server' support 'send-proxy' and 'send-proxy-v2 keywords.
Frédéric Lécaille [Fri, 10 Mar 2017 15:40:00 +0000 (16:40 +0100)] 
MINOR: server: Make 'default-server' support 'send-proxy' and 'send-proxy-v2 keywords.

This patch makes 'default-server' directive support 'send-proxy'
(resp. 'send-proxy-v2') setting.
A new keyword 'no-send-proxy' (resp. 'no-send-proxy-v2') has been added
to disable 'send-proxy' (resp. 'send-proxy-v2') setting both in 'server' and
'default-server' directives.

8 years agoMINOR: server: Make 'default-server' support 'non-stick' keyword.
Frédéric Lécaille [Fri, 10 Mar 2017 14:50:49 +0000 (15:50 +0100)] 
MINOR: server: Make 'default-server' support 'non-stick' keyword.

This patch makes 'default-server' directive support 'non-stick' setting.
A new keyword 'stick' has been added so that to disable
'non-stick' setting both in 'server' and 'default-server' directives.

8 years agoCLEANUP: server: code alignement.
Frédéric Lécaille [Fri, 10 Mar 2017 14:36:14 +0000 (15:36 +0100)] 
CLEANUP: server: code alignement.

Code alignement.

8 years agoMINOR: server: Make 'default-server' support 'check-send-proxy' keyword.
Frédéric Lécaille [Fri, 10 Mar 2017 13:04:31 +0000 (14:04 +0100)] 
MINOR: server: Make 'default-server' support 'check-send-proxy' keyword.

This patch makes 'default-server' directive support 'check-send-proxy' setting.
A new keyword 'no-check-send-proxy' has been added so that to disable
'check-send-proxy' setting both in 'server' and 'default-server' directives.

8 years agoMINOR: server: Make 'default-server' support 'backup' keyword.
Frédéric Lécaille [Fri, 10 Mar 2017 10:51:05 +0000 (11:51 +0100)] 
MINOR: server: Make 'default-server' support 'backup' keyword.

At this time, only 'server' supported 'backup' keyword.
This patch makes also 'default-server' directive support this keyword.
A new keyword 'no-backup' has been added so that to disable 'backup' setting
both in 'server' and 'default-server' directives.

For instance, provided the following sequence of directives:

default-server backup
server srv1
server srv2 no-backup

default-server no-backup
server srv3
server srv4 backup

srv1 and srv4 are declared as backup servers,
srv2 and srv3 are declared as non-backup servers.

8 years agoMINOR: server: irrelevant error message with 'default-server' config file keyword.
Frédéric Lécaille [Thu, 9 Mar 2017 13:01:02 +0000 (14:01 +0100)] 
MINOR: server: irrelevant error message with 'default-server' config file keyword.

There is no reason to emit such an error message:
"'default-server' expects <name> and <addr>[:<port>] as arguments."
if less than two arguments are provided on 'default-server' lines.
This is a 'server' specific error message.

8 years agoBUG/MINOR: cfgparse: loop in tracked servers lists not detected by check_config_valid...
Frédéric Lécaille [Tue, 14 Mar 2017 13:32:17 +0000 (14:32 +0100)] 
BUG/MINOR: cfgparse: loop in tracked servers lists not detected by check_config_validity().

There is a silly case where a loop is not detected in tracked servers lists:
when a server tracks itself.

Ex:
   server srv1 127.0.0.1:8000 track srv1

Well, this never happens and this does not prevent haproxy from working.

But with this next following configuration:

   server srv1 127.0.0.1:8000 track srv2
   server srv2 127.0.0.1:8000 track srv2
   server srv3 127.0.0.1:8000 track srv2

the code in charge of detecting such loops never returns (without any error message).
haproxy becomes stuck in an infinite loop because of this statement found
in check_config_validity():

for (loop = srv->track; loop && loop != newsrv; loop = loop->track);

Again, such a configuration is never accidentally used I guess.
This latter example seems silly, but as several 'default-server' directives may be used
in the same proxy section, and as 'default-server' settings are not resetted each a
new 'default-server' line is created, it will match the following configuration, in the future,
when 'track' setting will be supported by 'default-server':

   default-server track srv3
   server srv1 127.0.0.1:8000
   server srv2 127.0.0.1:8000
   .
   .
   .
   default-server check
   server srv3 127.0.0.1:8000
(cherry picked from commit 6528fc93d3c065fdac841f24e55cfe9674a67414)

8 years agoMINOR: dns: improve DNS response parsing to use as many available records as possible
Baptiste [Mon, 26 Dec 2016 22:21:08 +0000 (23:21 +0100)] 
MINOR: dns: improve DNS response parsing to use as many available records as possible

A "weakness" exist in the first implementation of the parsing of the DNS
responses: HAProxy always choses the first IP available matching family
preference, or as a failover, the first IP.

It should be good enough, since most DNS servers do round robin on the
records they send back to clients.
That said, some servers does not do proper round robin, or we may be
unlucky too and deliver the same IP to all the servers sharing the same
hostname.

Let's take the simple configuration below:

  backend bk
    srv s1 www:80 check resolvers R
    srv s2 www:80 check resolvers R

The DNS server configured with 2 IPs for 'www'.
If you're unlucky, then HAProxy may apply the same IP to both servers.

Current patch improves this situation by weighting the decision
algorithm to ensure we'll prefer use first an IP found in the response
which is not already affected to any server.

The new algorithm does not guarantee that the chosen IP is healthy,
neither a fair distribution of IPs amongst the servers in the farm,
etc...
It only guarantees that if the DNS server returns many records for a
hostname and that this hostname is being resolved by multiple servers in
the same backend, then we'll use as many records as possible.
If a server fails, HAProxy won't pick up an other record from the
response.

8 years agoMEDIUM: global: add a 'hard-stop-after' option to cap the soft-stop time
Cyril Bonté [Thu, 23 Mar 2017 21:44:13 +0000 (22:44 +0100)] 
MEDIUM: global: add a 'hard-stop-after' option to cap the soft-stop time

When SIGUSR1 is received, haproxy enters in soft-stop and quits when no
connection remains.
It can happen that the instance remains alive for a long time, depending
on timeouts and traffic. This option ensures that soft-stop won't run
for too long.

Example:
  global
    hard-stop-after 30s  # Once in soft-stop, the instance will remain
                         # alive for at most 30 seconds.

8 years agoDOC: Protocol doc: add noop TLV
Andriy Palamarchuk [Thu, 23 Mar 2017 20:30:24 +0000 (16:30 -0400)] 
DOC: Protocol doc: add noop TLV

Add definition of the PP2_TYPE_NOOP TLV which can be used for data
padding and alignment.

8 years agoDOC: Protocol doc: add SSL TLVs, rename CHECKSUM
Andriy Palamarchuk [Tue, 14 Mar 2017 22:59:09 +0000 (18:59 -0400)] 
DOC: Protocol doc: add SSL TLVs, rename CHECKSUM

Add SSL-related TLV types PP2_SUBTYPE_SSL_CIPHER,
PP2_SUBTYPE_SSL_SIG_ALG and PP2_SUBTYPE_SSL_KEY_ALG. Rename
PP2_TYPE_CHECKSUM to PP2_TYPE_CRC32C to make it easier to add checksums
using other algorithms. Clarified encoding of the string fields.
Renamed ASCII to US-ASCII as recommended by
https://www.iana.org/assignments/character-sets/character-sets.xhtml.

8 years agoDOC: Protocol doc: add checksum, TLV type ranges
Andriy Palamarchuk [Tue, 24 Jan 2017 18:48:27 +0000 (13:48 -0500)] 
DOC: Protocol doc: add checksum, TLV type ranges

Add the CRC32c checksum TLV PP2_TYPE_CHECKSUM. Reserve TLV type ranges
CUSTOM, EXPERIMENT and FUTURE. Clarify that only UNSPEC protocol byte is
mandatory to implement on the receiver.

8 years agoDOC/MINOR: Fix typos in proxy protocol doc
Andriy Palamarchuk [Tue, 24 Jan 2017 18:34:08 +0000 (13:34 -0500)] 
DOC/MINOR: Fix typos in proxy protocol doc

8 years agoMEDIUM: kqueue: only set FD_POLL_IN when there are pending data
Willy Tarreau [Mon, 13 Mar 2017 19:49:56 +0000 (20:49 +0100)] 
MEDIUM: kqueue: only set FD_POLL_IN when there are pending data

Let's avoid setting FD_POLL_IN when there's no pending data. It will
save a useless recv() syscall on pure closes.

8 years agoMEDIUM: kqueue: take care of EV_EOF to improve polling status accuracy
Willy Tarreau [Mon, 13 Mar 2017 19:36:48 +0000 (20:36 +0100)] 
MEDIUM: kqueue: take care of EV_EOF to improve polling status accuracy

kevent() always sets EV_EOF with EVFILT_READ to notify of a read shutdown
and EV_EOF with EVFILT_WRITE to notify of a write error. Let's check this
flag to properly update the FD's polled status (FD_POLL_HUP and FD_POLL_ERR
respectively).

It's worth noting that this one can be coupled with a regular read event
to notify about a pending read followed by a shutdown, but for now we only
use this to set the relevant flags (HUP and ERR).

The poller now exhibits the flag HAP_POLL_F_RDHUP to indicate this new
capability.

An improvement may consist in not setting FD_POLL_IN when the "data"
field is null since it normally only reflects the amount of pending
data.

8 years agoMINOR: kqueue: exclusively rely on the kqueue returned status
Willy Tarreau [Mon, 13 Mar 2017 19:30:12 +0000 (20:30 +0100)] 
MINOR: kqueue: exclusively rely on the kqueue returned status

After commit e852545 ("MEDIUM: polling: centralize polled events processing")
all pollers stopped to explicitly check the FD's polled status, except the
kqueue poller which is constructed a bit differently. It doesn't seem possible
to cause any issue such as missing an event however, but anyway it's better to
definitely get rid of this since the event filter already provides the event
direction.

8 years agoOPTIM: poll: enable support for POLLRDHUP
Willy Tarreau [Mon, 13 Mar 2017 16:14:51 +0000 (17:14 +0100)] 
OPTIM: poll: enable support for POLLRDHUP

On Linux since 2.6.17 poll() supports POLLRDHUP to notify of an upcoming
hangup after pending data. Making use of it allows us to avoid a useless
recv() after short responses on keep-alive connections. Note that we
automatically enable the feature once this flag has been met first in a
poll() status. Till now it was only enabled on epoll.

8 years agoBUG/MINOR: raw_sock: always perfom the last recv if RDHUP is not available
Willy Tarreau [Mon, 13 Mar 2017 11:04:34 +0000 (12:04 +0100)] 
BUG/MINOR: raw_sock: always perfom the last recv if RDHUP is not available

Curu Wong reported a case where haproxy used to send RST to a server
after receiving its FIN. The problem is caused by the fact that being
a server connection, its fd is marked with linger_risk=1, and that the
poller didn't report POLLRDHUP, making haproxy unaware of a pending
shutdown that came after the data, so it used to resort to nolinger
for closing.

However when pollers support RDHUP we're pretty certain whether or not
a shutdown comes after the data and we don't need to perform that extra
recv() call.

Similarly when we're dealing with an inbound connection we don't care
and don't want to perform this extra recv after a request for a very
unlikely case, as in any case we'll have to deal with the client-facing
TIME_WAIT socket.

So this patch ensures that only when it's known that there's no risk with
lingering data, as well as in cases where it's known that the poller would
have detected a pending RDHUP, we perform the fd_done_recv() otherwise we
continue, trying a subsequent recv() to try to detect a pending shutdown.

This effectively results in an extra recv() call for keep-alive sockets
connected to a server when POLLRDHUP isn't known to be supported, but
it's the only way to know whether they're still alive or closed.

This fix should be backported to 1.7, 1.6 and 1.5. It relies on the
previous patch bringing support for the HAP_POLL_F_RDHUP flag.

8 years agoMINOR: fd: add a new flag HAP_POLL_F_RDHUP to struct poller
Willy Tarreau [Mon, 13 Mar 2017 10:38:28 +0000 (11:38 +0100)] 
MINOR: fd: add a new flag HAP_POLL_F_RDHUP to struct poller

We'll need to differenciate between pollers which can report hangup at
the same time as read (POLL_RDHUP) from the other ones, because only
these ones may benefit from the fd_done_recv() optimization. Epoll has
had support for EPOLLRDHUP since Linux 2.6.17 and has always been used
this way in haproxy, so now we only set the flag once we've observed it
once in a response. It means that some initial requests may try to
perform a second recv() call, but after the first closed connection it
will be enough to know that the second call is not needed anymore.

Later we may extend these flags to designate event-triggered pollers.

8 years agoBUG/MEDIUM: stream: fix client-fin/server-fin handling
Hongbo Long [Fri, 10 Mar 2017 17:41:51 +0000 (18:41 +0100)] 
BUG/MEDIUM: stream: fix client-fin/server-fin handling

A tcp half connection can cause 100% CPU on expiration.

First reproduced with this haproxy configuration :

  global
      tune.bufsize 10485760
  defaults
      timeout server-fin 90s
      timeout client-fin 90s
  backend node2
      mode tcp
      timeout server 900s
      timeout connect 10s
      server def 127.0.0.1:3333
  frontend fe_api
      mode  tcp
      timeout client 900s
      bind :1990
      use_backend node2

Ie timeout server-fin shorter than timeout server, the backend server
sends data, this package is left in the cache of haproxy, the backend
server continue sending fin package, haproxy recv fin package. this
time the session information is as follows:

  time the session information is as follows:
      0x2373470: proto=tcpv4 src=127.0.0.1:39513 fe=fe_api be=node2
      srv=def ts=08 age=1s calls=3 rq[f=848000h,i=0,an=00h,rx=14m58s,wx=,ax=]
      rp[f=8004c020h,i=0,an=00h,rx=,wx=14m58s,ax=] s0=[7,0h,fd=6,ex=]
      s1=[7,18h,fd=7,ex=] exp=14m58s

  rp has set the CF_SHUTR state, next, the client sends the fin package,

  session information is as follows:
      0x2373470: proto=tcpv4 src=127.0.0.1:39513 fe=fe_api be=node2
      srv=def ts=08 age=38s calls=4 rq[f=84a020h,i=0,an=00h,rx=,wx=,ax=]
      rp[f=8004c020h,i=0,an=00h,rx=1m11s,wx=14m21s,ax=] s0=[7,0h,fd=6,ex=]
      s1=[9,10h,fd=7,ex=] exp=1m11s

  After waiting 90s, session information is as follows:
      0x2373470: proto=tcpv4 src=127.0.0.1:39513 fe=fe_api be=node2
      srv=def ts=04 age=4m11s calls=718074391 rq[f=84a020h,i=0,an=00h,rx=,wx=,ax=]
      rp[f=8004c020h,i=0,an=00h,rx=?,wx=10m49s,ax=] s0=[7,0h,fd=6,ex=]
      s1=[9,10h,fd=7,ex=] exp=? run(nice=0)

  cpu information:
      6899 root      20   0  112224  21408   4260 R 100.0  0.7   3:04.96 haproxy

Buffering is set to ensure that there is data in the haproxy buffer, and haproxy
can receive the fin package, set the CF_SHUTR flag, If the CF_SHUTR flag has been
set, The following code does not clear the timeout message, causing cpu 100%:

stream.c:process_stream:

        if (unlikely((res->flags & (CF_SHUTR|CF_READ_TIMEOUT)) == CF_READ_TIMEOUT)) {
            if (si_b->flags & SI_FL_NOHALF)
            si_b->flags |= SI_FL_NOLINGER;
            si_shutr(si_b);
        }

If you have closed the read, set the read timeout does not make sense.
With or without cf_shutr, read timeout is set:

       if (tick_isset(s->be->timeout.serverfin)) {
           res->rto = s->be->timeout.serverfin;
           res->rex = tick_add(now_ms, res->rto);
       }

After discussion on the mailing list, setting half-closed timeouts the
hard way here doesn't make sense. They should be set only at the moment
the shutdown() is performed. It will also solve a special case which was
already reported of some half-closed timeouts not working when the shutw()
is performed directly at the stream-interface layer (no analyser involved).
Since the stream interface layer cannot know the timeout values, we'll have
to store them directly in the stream interface so that they are used upon
shutw(). This patch does this, fixing the problem.

An easier reproducer to validate the fix is to keep the huge buffer and
shorten all timeouts, then call it under tcploop server and client, and
wait 3 seconds to see haproxy run at 100% CPU :

  global
      tune.bufsize 10485760

  listen px
      bind :1990
      timeout client 90s
      timeout server 90s
      timeout connect 1s
      timeout server-fin 3s
      timeout client-fin 3s
      server def 127.0.0.1:3333

  $ tcploop 3333 L W N20 A P100 F P10000 &
  $ tcploop 127.0.0.1:1990 C S10000000 F

8 years agoMINOR: doc: 2.4. Examples should be 2.5. Examples
Lukas Tribus [Tue, 21 Mar 2017 09:25:09 +0000 (09:25 +0000)] 
MINOR: doc: 2.4. Examples should be 2.5. Examples

Guillaume Michaud reported against Cyril's haproxy-dconv project
that the index for the Examples section should be 2.5 instead of
2.4.

Should be backported to 1.7 and 1.6, so that the example section
can be linked to:
https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#2.5

8 years agoBUG/MAJOR: http: fix typo in http_apply_redirect_rule
Christopher Faulet [Fri, 10 Mar 2017 12:52:30 +0000 (13:52 +0100)] 
BUG/MAJOR: http: fix typo in http_apply_redirect_rule

Because of this typo, AN_RES_FLT_END was never called when a redirect rule is
applied on a keep-alive connection. In almost all cases, this bug has no
effect. But, it leads to a memory leak if a redirect is done on a http-response
rule when the HTTP compression is enabled.

This patch should be backported in 1.7.

8 years agoBUILD: ssl: fix OPENSSL_NO_SSL_TRACE for boringssl and libressl
Emmanuel Hocdet [Mon, 20 Mar 2017 10:39:57 +0000 (11:39 +0100)] 
BUILD: ssl: fix OPENSSL_NO_SSL_TRACE for boringssl and libressl

"sample-fetch which captures the cipherlist" patch introduce #define
do deal with trace functions only available in openssl > 1.0.2.
Add this #define to libressl and boringssl environment.
Thanks to Piotr Kubaj for postponing and testing with libressl.

8 years agoBUILD: ssl: simplify SSL_CTX_set_ecdh_auto compatibility
Emmanuel Hocdet [Mon, 20 Mar 2017 10:11:49 +0000 (11:11 +0100)] 
BUILD: ssl: simplify SSL_CTX_set_ecdh_auto compatibility

SSL_CTX_set_ecdh_auto is declared (when present) with #define. A simple #ifdef
avoid to list all cases of ssllibs. It's a placebo in new ssllibs. It's ok with
openssl 1.0.1, 1.0.2, 1.1.0, libressl and boringssl.
Thanks to Piotr Kubaj for postponing and testing with libressl.