]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
12 years agoBUG/MINOR: session: ensure that we don't retry connection if some data were sent
Willy Tarreau [Mon, 29 Oct 2012 21:41:31 +0000 (22:41 +0100)] 
BUG/MINOR: session: ensure that we don't retry connection if some data were sent

With extra-large buffers, it is possible that a lot of data are sent upon
connection establishment before the session is notified. The issue is how
to handle a send() error after some data were actually sent.

At the moment, only a connection error is reported, causing a new connection
attempt and send() to restart after the last data. We absolutely don't want
to retry the connect() if at least one byte was sent, because those data are
lost.

The solution consists in reporting exactly what happens, which is :
  - a successful connection attempt
  - a read/write error on the channel

That way we go on with sess_establish(), the response analysers are called
and report the appropriate connection state for the error (typically a server
abort while waiting for a response). This mechanism also guarantees that we
won't retry since it's a success. The logs also report the correct connect
time.

Note that 1.4 is not directly affected because it only attempts one send(),
so it cannot detect a send() failure here and distinguish it form a failed
connection attempt. So no backport is needed. Also, this is just a safe belt
we're taking, since this issue should not happen anymore since previous commit.

12 years agoBUG/MINOR: stream_interface: don't loop over ->snd_buf()
Willy Tarreau [Mon, 29 Oct 2012 22:27:14 +0000 (23:27 +0100)] 
BUG/MINOR: stream_interface: don't loop over ->snd_buf()

It is stupid to loop over ->snd_buf() because the snd_buf() itself already
loops and stops when system buffers are full. But looping again onto it,
we lose the information of the full buffers and perform one useless syscall.

Furthermore, this causes issues when dealing with large uploads while waiting
for a connection to establish, as it can report a server reject of some data
as a connection abort, which is wrong.

1.4 does not have this issue as it loops maximum twice (once for each buffer
half) and exists as soon as system buffers are full. So no backport is needed.

12 years agoMINOR: compression: Enable compression for IE6 w/SP2, IE7 and IE8
Finn Arne Gangstad [Mon, 29 Oct 2012 20:43:01 +0000 (21:43 +0100)] 
MINOR: compression: Enable compression for IE6 w/SP2, IE7 and IE8

Some old browsers that have a user-agent starting with "Mozilla/4" do
not support compressison correctly, so disable compression for those.

Internet explorer 6 after Windows XP service pack 2, IE 7, and IE 8,
do however support compression and still have a user agent starting
with Mozilla/4, so we try to enable compression for those.

MSIE has a user-agent on this form:
Mozilla/4.0 (compatible; MSIE <version>; ...)

98% of MSIE 6 SP2 user agents start with
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1
The remaining 2% have additional flags before "SV1".

This simplified matching looking for MSIE at exactly position 25
and SV1 at exacly position 51 gives a few false negatives, so sometimes
a compression opportunity is lost.

A test against 3 hours of traffic to around 3000 news sites worldwide
gives less than 0.007% (70ppm) missed compression opportunities.

12 years agoMEDIUM: stick-table: allocate the table key of size buffer size
Willy Tarreau [Mon, 29 Oct 2012 20:56:59 +0000 (21:56 +0100)] 
MEDIUM: stick-table: allocate the table key of size buffer size

Keys are copied from samples to stick_table_key. If a key is larger
than the stick_table_key, we have an overflow. In pratice it does not
happen because it requires :
   1) a configuration with tune.bufsize larger than BUFSIZE (common)
   2) a stick-table configured with keys strictly larger than buffers
   3) extraction of data larger than BUFSIZE (eg: using payload())

Points 2 and 3 don't make any sense for a real world configuration. That
said the issue needs be fixed. The solution consists in allocating it the
same size as the global buffer size, just like the samples. This fixes the
issue.

12 years agoMEDIUM: remove remains of BUFSIZE in HTTP auth and sample conversions
Willy Tarreau [Mon, 29 Oct 2012 19:44:36 +0000 (20:44 +0100)] 
MEDIUM: remove remains of BUFSIZE in HTTP auth and sample conversions

Sample conversions rely on two alternative buffers which were previously
allocated as static bufs of size BUFSIZE. Now they're initialized to the
global buffer size. It was the same for HTTP authentication. Note that it
seems that none of them was prone to any mistake when dealing with the
buffer size, but better stay on the safe side by maintaining the old
assumption that a trash buffer is always "large enough".

12 years agoMEDIUM: make the trash be a chunk instead of a char *
Willy Tarreau [Mon, 29 Oct 2012 15:51:55 +0000 (16:51 +0100)] 
MEDIUM: make the trash be a chunk instead of a char *

The trash is used everywhere to store the results of temporary strings
built out of s(n)printf, or as a storage for a chunk when chunks are
needed.

Using global.tune.bufsize is not the most convenient thing either.

So let's replace trash with a chunk and directly use it as such. We can
then use trash.size as the natural way to get its size, and get rid of
many intermediary chunks that were previously used.

The patch is huge because it touches many areas but it makes the code
a lot more clear and even outlines places where trash was used without
being that obvious.

12 years agoCLEANUP: replace chunk_printf() with chunk_appendf()
Willy Tarreau [Mon, 29 Oct 2012 15:14:26 +0000 (16:14 +0100)] 
CLEANUP: replace chunk_printf() with chunk_appendf()

This function's naming was misleading as it is used to append data
at the end of a string, causing some surprizes when used for the
first time!

Add a chunk_printf() function which does what its name suggests.

12 years agoMINOR: chunk: add a function to reset a chunk
Willy Tarreau [Mon, 29 Oct 2012 12:23:11 +0000 (13:23 +0100)] 
MINOR: chunk: add a function to reset a chunk

This is a first step in avoiding to constantly reinitialize chunks.
It replaces the old chunk_reset() which was not properly named as it
used to drop everything and was only used by chunk_destroy(). It has
been renamed chunk_drop().

12 years agoCLEANUP: completely remove trashlen
Willy Tarreau [Mon, 29 Oct 2012 12:27:23 +0000 (13:27 +0100)] 
CLEANUP: completely remove trashlen

Commit c919dc66 did not remove the trashlen assigment.

12 years agoMINOR: log: add '%Tl' to log-format
Yuxans Yao [Fri, 19 Oct 2012 02:36:09 +0000 (10:36 +0800)] 
MINOR: log: add '%Tl' to log-format

The '%Tl' is similar to '%T', but using local timezone.

12 years agoBUG: compression: disable auto-close and enable MSG_MORE during transfer
Willy Tarreau [Fri, 26 Oct 2012 23:36:34 +0000 (01:36 +0200)] 
BUG: compression: disable auto-close and enable MSG_MORE during transfer

We don't want the lower layer to forward a close while we're compressing,
and we want the system to fuse outgoing TCP segments using MSG_MORE as
much as possible to save round trips that can emerge from sending short
packets with a PUSH flag.

A test on a remote busy DSL line consisting in compressing a 100MB file
on the fly full of zeroes only showed a transfer rate of a few kB/s due
to these round trips.

12 years agoMINOR: compression: add an offload option to remove the Accept-Encoding header
Willy Tarreau [Fri, 26 Oct 2012 22:34:28 +0000 (00:34 +0200)] 
MINOR: compression: add an offload option to remove the Accept-Encoding header

This is used when it is desired that backend servers don't compress
(eg: because of buggy implementations).

12 years agoBUILD: make it possible to specify ZLIB path
Willy Tarreau [Fri, 10 Feb 2012 19:37:26 +0000 (20:37 +0100)] 
BUILD: make it possible to specify ZLIB path

12 years agoDOC: update document describing relations between internal entities
Willy Tarreau [Fri, 26 Oct 2012 18:40:13 +0000 (20:40 +0200)] 
DOC: update document describing relations between internal entities

Connections have left the stream interface. fdtab[] has been represented.

12 years agoMAJOR: session: detach the connections from the stream interfaces
Willy Tarreau [Fri, 26 Oct 2012 18:10:28 +0000 (20:10 +0200)] 
MAJOR: session: detach the connections from the stream interfaces

We will need to be able to switch server connections on a session and
to keep idle connections. In order to achieve this, the preliminary
requirement is that the connections can survive the session and be
detached from them.

Right now they're still allocated at exactly the same place, so when
there is a session, there are always 2 connections. We could soon
improve on this by allocating the outgoing connection only during a
connect().

This current patch touches a lot of code and intentionally does not
change any functionnality. Performance tests show no regression (even
a very minor improvement). The doc has not yet been updated.

12 years agoCLEANUP: remove trashlen
Willy Tarreau [Fri, 26 Oct 2012 15:35:22 +0000 (17:35 +0200)] 
CLEANUP: remove trashlen

trashlen is a copy of global.tune.bufsize, so let's stop using it as
a duplicate, fall back to the original bufsize, it's less confusing
this way.

12 years agoBUG/MEDIUM: tcp: transparent bind to the source only when address is set
Willy Tarreau [Fri, 26 Oct 2012 17:57:58 +0000 (19:57 +0200)] 
BUG/MEDIUM: tcp: transparent bind to the source only when address is set

Thomas Heil reported that health checks did not work anymore when a backend
or server has "usesrc clientip". This is because the source address is not
set and tcp_bind_socket() tries to bind to that address anyway.

The solution consists in explicitly clearing the source address in the checks
and to make tcp_bind_socket() avoid binding when the address is not set. This
also has an indirect benefit that a useless bind() syscall will be avoided
when using "source 0.0.0.0 usesrc clientip" in health checks.

12 years agoMINOR: tools: add a clear_addr() function to unset an address
Willy Tarreau [Fri, 26 Oct 2012 17:47:23 +0000 (19:47 +0200)] 
MINOR: tools: add a clear_addr() function to unset an address

This will be used to unset a from address.

12 years agoBUG/MEDIUM: command-line option -D must have precedence over "debug"
Willy Tarreau [Fri, 26 Oct 2012 14:04:28 +0000 (16:04 +0200)] 
BUG/MEDIUM: command-line option -D must have precedence over "debug"

From the beginning it has been said that -D must always be used on the
command line from startup scripts so that haproxy does not accidentally
stay in foreground when loaded from init script... Except that this has
not been true for a long time now.

The fix is easy and must be backported to 1.4 too which is affected.

12 years agoMINOR: ssl: checks the consistency of a private key with the corresponding certificate
Emeric Brun [Fri, 26 Oct 2012 11:35:33 +0000 (13:35 +0200)] 
MINOR: ssl: checks the consistency of a private key with the corresponding certificate

12 years agoMINOR: ssl: add 'crt' statement on server.
Emeric Brun [Fri, 26 Oct 2012 10:58:00 +0000 (12:58 +0200)] 
MINOR: ssl: add 'crt' statement on server.

crt: client certificate to send

12 years agoMINOR: ssl: add pattern and ACLs fetches 'ssl_c_notbefore', 'ssl_c_notafter', 'ssl_f_...
Emeric Brun [Mon, 22 Oct 2012 12:11:22 +0000 (14:11 +0200)] 
MINOR: ssl: add pattern and ACLs fetches 'ssl_c_notbefore', 'ssl_c_notafter', 'ssl_f_notbefore' and 'ssl_f_notafter'

ssl_c_notbefore: start date of client cert (string, eg: "121022182230Z" for YYMMDDhhmmss[Z])
ssl_c_notafter: end date of client cert (string, eg: "121022182230Z" for YYMMDDhhmmss[Z])
ssl_f_notbefore: start date of frontend cert (string, eg: "121022182230Z" for YYMMDDhhmmss[Z])
ssl_f_notafter: end date of frontend cert (string, eg: "121022182230Z" for YYMMDDhhmmss[Z])

12 years agoMINOR: ssl: add pattern and ACLs fetches 'ssl_c_key_alg' and 'ssl_f_key_alg'
Emeric Brun [Mon, 22 Oct 2012 10:22:55 +0000 (12:22 +0200)] 
MINOR: ssl: add pattern and ACLs fetches 'ssl_c_key_alg' and 'ssl_f_key_alg'

ssl_c_key_alg: algo used to encrypt the client's cert key (ex: rsaEncryption)
ssl_f_key_alg: algo used to encrypt the frontend's cert key (ex: rsaEncryption)

12 years agoMINOR: ssl: add pattern and ACLs 'ssl_c_sig_alg' and 'ssl_f_sig_alg'
Emeric Brun [Fri, 19 Oct 2012 16:15:40 +0000 (18:15 +0200)] 
MINOR: ssl: add pattern and ACLs 'ssl_c_sig_alg' and 'ssl_f_sig_alg'

ssl_c_sig_alg: client cert signature algo (string). Ex: "RSA-SHA1"
ssl_f_sig_alg: frontend cert signature algo (string). Ex: "RSA-SHA1"

12 years agoMINOR: ssl: add pattern and ACLs fetches 'ssl_c_s_dn', 'ssl_c_i_dn', 'ssl_f_s_dn...
Emeric Brun [Wed, 17 Oct 2012 15:39:35 +0000 (17:39 +0200)] 
MINOR: ssl: add pattern and ACLs fetches 'ssl_c_s_dn', 'ssl_c_i_dn', 'ssl_f_s_dn' and 'ssl_c_i_dn'

ssl_c_s_dn : client cert subject DN (string)
ssl_c_i_dn : client cert issuer DN (string)
ssl_f_s_dn : frontend cert subject DN (string)
ssl_f_i_dn : frontend cert issuer DN (string)

Return either the full DN without params, or just the DN entry (first param) or
its specific occurrence (second param).

12 years agoMINOR: ssl: add pattern and ACLs fetches 'ssl_c_version' and 'ssl_f_version'
Emeric Brun [Wed, 17 Oct 2012 13:03:11 +0000 (15:03 +0200)] 
MINOR: ssl: add pattern and ACLs fetches 'ssl_c_version' and 'ssl_f_version'

ssl_c_version : version of the cert presented by the client  (integer)
ssl_f_version : version of the cert presented by the frontend  (integer)

12 years agoMINOR: ssl: add pattern and ACLs fetches 'ssl_c_serial' and 'ssl_f_serial'
Willy Tarreau [Mon, 22 Oct 2012 15:58:39 +0000 (17:58 +0200)] 
MINOR: ssl: add pattern and ACLs fetches 'ssl_c_serial' and 'ssl_f_serial'

ssl_c_serial: serial of the certificate presented by the client.
ssl_f_serial: serial of the certificate presentend by the frontend.

12 years agoMINOR: ssl: add pattern fetch 'ssl_fc_session_id'
Emeric Brun [Tue, 16 Oct 2012 12:59:28 +0000 (14:59 +0200)] 
MINOR: ssl: add pattern fetch 'ssl_fc_session_id'

This fetch returns the SSL ID of the front connection. Useful to stick
on a given client.

12 years agoMINOR: ssl: add pattern and ACLs fetches 'ssl_fc_protocol', 'ssl_fc_cipher', 'ssl_fc_...
Emeric Brun [Tue, 16 Oct 2012 12:13:26 +0000 (14:13 +0200)] 
MINOR: ssl: add pattern and ACLs fetches 'ssl_fc_protocol', 'ssl_fc_cipher', 'ssl_fc_use_keysize' and 'ssl_fc_alg_keysize'

Some front connection fetches :
- ssl_fc_protocol = protocol name (string)
- ssl_fc_cipher = cipher name (string)
- ssl_fc_use_keysize = symmetric cipher key size used in bits (integer)
- ssl_fc_alg_keysize = symmetric cipher key size supported in bits (integer)

12 years agoMINOR: conf: rename all ssl modules fetches using prefix 'ssl_fc' and 'ssl_c'
Emeric Brun [Thu, 18 Oct 2012 13:59:43 +0000 (15:59 +0200)] 
MINOR: conf: rename all ssl modules fetches using prefix 'ssl_fc' and 'ssl_c'

SSL fetches were renamed :
  ssl_fc_* = Front Connection (attributes of the connection itself)
  ssl_c_*  = Client side certificate

12 years agoBUILD: fix coexistence of openssl and zlib
Willy Tarreau [Fri, 26 Oct 2012 13:05:35 +0000 (15:05 +0200)] 
BUILD: fix coexistence of openssl and zlib

The crappy zlib and openssl libs both define a free_func as a different typedef.
That's a very clever idea to use such a generic name in general purpose libraries,
really... The zlib one is easier to redefine than openssl's, so let's only fix this
one.

12 years agoBUG/MINOR: http: compression should consider all Accept-Encoding header values
Willy Tarreau [Fri, 26 Oct 2012 12:50:26 +0000 (14:50 +0200)] 
BUG/MINOR: http: compression should consider all Accept-Encoding header values

Right now commit 82fe75c1 came with a minor bug limiting the check to the first
accept-encoding header value only.

12 years agoMINOR: compression: optimize memLevel to improve byte rate
Willy Tarreau [Fri, 26 Oct 2012 09:36:40 +0000 (11:36 +0200)] 
MINOR: compression: optimize memLevel to improve byte rate

Decreasing the deflateInit2's memLevel parameter from 9 to 8 does not
affect the compression ratio and increases the compression speed by 12%.
Lower values do not increase transfer speed but decrease the compression
ratio so it looks like 8 is optimal.

12 years agoMINOR: compression: automatically disable compression for older browsers
Willy Tarreau [Fri, 26 Oct 2012 00:11:25 +0000 (02:11 +0200)] 
MINOR: compression: automatically disable compression for older browsers

A number of older browsers have many issues with compressed contents. It
happens that all these older browsers announce themselves as "Mozilla/4"
and that despite not being all broken, the amount of working browsers
announcing themselves this way compared to all other ones is so tiny
that it's not worth wasting cycles trying to adapt to every specific
one.

So let's simply disable compression for these older browsers.

More information on this very detailed article :

   http://zoompf.com/2012/02/lose-the-wait-http-compression

12 years agoMEDIUM: HTTP compression (zlib library support)
William Lallemand [Tue, 23 Oct 2012 08:25:10 +0000 (10:25 +0200)] 
MEDIUM: HTTP compression (zlib library support)

This commit introduces HTTP compression using the zlib library.

http_response_forward_body has been modified to call the compression
functions.

This feature includes 3 algorithms: identity, gzip and deflate:

  * identity: this is mostly for debugging, and it was useful for
  developping the compression feature. With Content-Length in input, it
  is making each chunk with the data available in the current buffer.
  With chunks in input, it is rechunking, the output chunks will be
  bigger or smaller depending of the size of the input chunk and the
  size of the buffer. Identity does not apply any change on data.

  * gzip: same as identity, but applying a gzip compression. The data
  are deflated using the Z_NO_FLUSH flag in zlib. When there is no more
  data in the input buffer, it flushes the data in the output buffer
  (Z_SYNC_FLUSH). At the end of data, when it receives the last chunk in
  input, or when there is no more data to read, it writes the end of
  data with Z_FINISH and the ending chunk.

  * deflate: same as gzip, but with deflate algorithm and zlib format.
  Note that this algorithm has ambiguous support on many browsers and
  no support at all from recent ones. It is strongly recommended not
  to use it for anything else than experimentation.

You can't choose the compression ratio at the moment, it will be set to
Z_BEST_SPEED (1), as tests have shown very little benefit in terms of
compression ration when going above for HTML contents, at the cost of
a massive CPU impact.

Compression will be activated depending of the Accept-Encoding request
header. With identity, it does not take care of that header.

To build HAProxy with zlib support, use USE_ZLIB=1 in the make
parameters.

This work was initially started by David Du Colombier at Exceliance.

12 years agoCLEANUP: http: rename HTTP_MSG_DATA_CRLF state
Willy Tarreau [Thu, 25 Oct 2012 17:04:45 +0000 (19:04 +0200)] 
CLEANUP: http: rename HTTP_MSG_DATA_CRLF state

This state's name is confusing as it is only used with chunked encoding
and makes newcomers think it's also related to the content-length. Let's
call it CHUNK_CRLF to clear any doubt on this.

12 years agoOPTIM: tools: inline hex2i()
Willy Tarreau [Thu, 25 Oct 2012 22:58:22 +0000 (00:58 +0200)] 
OPTIM: tools: inline hex2i()

This tiny function was not inlined because initially not much used.
However it's been used un the chunk parser for a while and it became
one of the most CPU-cycle eater there. By inlining it, the chunk parser
speed was increased by 74 %. We're almost 3 times faster than original
with just the last 4 commits.

12 years agoOPTIM: http: inline http_parse_chunk_size() and http_skip_chunk_crlf()
Willy Tarreau [Thu, 25 Oct 2012 22:49:52 +0000 (00:49 +0200)] 
OPTIM: http: inline http_parse_chunk_size() and http_skip_chunk_crlf()

These functions are not that long and the compiler inlines them well. Doing
so has sped up the chunked encoding parser by 41% !

Note that http_forward_trailers was also declared static because it's not
exported.

12 years agoOPTIM: channel: inline channel_forward's fast path
Willy Tarreau [Thu, 25 Oct 2012 22:21:52 +0000 (00:21 +0200)] 
OPTIM: channel: inline channel_forward's fast path

Most calls to channel_forward() are performed with short byte counts and
are already optimized in channel_forward() taking just a few instructions.
Thus it's a waste of CPU cycles to call a function for this, let's just
inline the short byte count case and fall back to the common one for
remaining situations.

Doing so has increased the chunked encoding parser's performance by 12% !

12 years agoMEDIUM: http: accept IPv6 values with (s)hdr_ip acl
Cyril Bonté [Wed, 24 Oct 2012 22:01:06 +0000 (00:01 +0200)] 
MEDIUM: http: accept IPv6 values with (s)hdr_ip acl

Commit ceb4ac9c states that IPv6 values are accepted by "hdr_ip" acl,
but the code didn't allow it. This patch provides the ability to accept IPv6
values.

12 years agoBUG/MAJOR: fix a segfault on option http_proxy and url_ip acl
Cyril Bonté [Wed, 24 Oct 2012 21:47:47 +0000 (23:47 +0200)] 
BUG/MAJOR: fix a segfault on option http_proxy and url_ip acl

url2sa() mistakenly uses "addr" as a reference. This causes a segfault when
option http_proxy or url_ip are used.

This bug was introduced in haproxy 1.5 and doesn't need to be backported.

12 years agoBUG/MEDIUM: acls using IPv6 subnets patterns incorrectly match IPs
Cyril Bonté [Tue, 23 Oct 2012 19:28:31 +0000 (21:28 +0200)] 
BUG/MEDIUM: acls using IPv6 subnets patterns incorrectly match IPs

Some tests revealed that IPs not in the range of IPv6 subnets incorrectly
matched (for example "acl BUG src 2804::/16" applied to a src IP "127.0.0.1").

This is caused by the acl_match_ip() function applies a mask in host byte
order, whereas it should be in network byte order.

12 years agoMEDIUM: cli: allow the stats socket to be bound to a specific set of processes
Willy Tarreau [Mon, 22 Oct 2012 21:17:18 +0000 (23:17 +0200)] 
MEDIUM: cli: allow the stats socket to be bound to a specific set of processes

Using "stats bind-process", it becomes possible to indicate to haproxy which
process will get the incoming connections to the stats socket. It will also
shut down the warning when nbproc > 1.

12 years agoBUG/MAJOR: connection: risk of crash on certain tricky close scenario
Willy Tarreau [Mon, 22 Oct 2012 20:47:55 +0000 (22:47 +0200)] 
BUG/MAJOR: connection: risk of crash on certain tricky close scenario

In some circumstances, if the connection to the server is aborted while
some data were planned to be sent and the poller reported an ability to
send, then conn_fd_handler() would still call conn->data->send(), causing
the data layer to dereference the now NULL conn->xprt and crash.

So we have to check for conn->xprt validity before calling the data
layer.

This issue was introduced after 1.5-dev12 so it does not need any backport
and does not affect any released version.

Special thanks go to Cristian Ditoiu who once again provided amazing help
to troubleshoot this bug !

12 years agoMEDIUM: listener: provide a fallback for accept4() when not supported
Willy Tarreau [Mon, 22 Oct 2012 17:32:55 +0000 (19:32 +0200)] 
MEDIUM: listener: provide a fallback for accept4() when not supported

It happens that on some systems, the libc is recent enough to permit
building with accept4() but the kernel does not support it. The result
is then a disaster since no connection is accepted. We now detect this
and automatically fall back to accept() and fcntl() when this happens.

12 years agoMINOR: sample: export 'sample_get_trash_chunk(void)'
Emeric Brun [Wed, 17 Oct 2012 13:34:03 +0000 (15:34 +0200)] 
MINOR: sample: export 'sample_get_trash_chunk(void)'

This will be used on external fetch modules.

12 years agoMINOR: acl: add parse and match primitives to use binary type on ACLs
Emeric Brun [Wed, 17 Oct 2012 11:38:19 +0000 (13:38 +0200)] 
MINOR: acl: add parse and match primitives to use binary type on ACLs

Binary ACL match patterns can now be entered as hex digit strings.

12 years agoMINOR: sample: manage binary to string type convertion in stick-table and samples.
Emeric Brun [Wed, 17 Oct 2012 11:36:06 +0000 (13:36 +0200)] 
MINOR: sample: manage binary to string type convertion in stick-table and samples.

Binary type is converted to a null terminated hexa string.

12 years agoDOC: make it clear what the HTTP request size is
Dmitry Sivachenko [Sun, 21 Oct 2012 14:10:25 +0000 (18:10 +0400)] 
DOC: make it clear what the HTTP request size is

Please consider the following patch for configuration.txt to clarify meaning
of bufsize, maxrewrite and the size of HTTP request which can be processed.

12 years agoBUG/MEDIUM: http: set DONTWAIT on data when switching to tunnel mode
Willy Tarreau [Sat, 20 Oct 2012 08:38:09 +0000 (10:38 +0200)] 
BUG/MEDIUM: http: set DONTWAIT on data when switching to tunnel mode

Jaroslaw Bojar diagnosed an issue when haproxy switches to tunnel mode
after a transfer. The response data are sent with the MSG_MORE flag,
causing them to be needlessly queued in the kernel. In order to fix this,
we set the CF_NEVER_WAIT flag on the channels when switching to tunnel
mode.

One issue remained with client-side keep-alive : if the response is sent
before the end of the request, it suffers the same issue for the same
reason. This is easily addressed by setting the CF_SEND_DONTWAIT flag
on the channel when the response has been parsed and we're waiting for
the other side.

The same issue is present in 1.4 so the fix must be backported.

12 years agoMINOR: ssl: improve socket behaviour upon handshake abort.
Willy Tarreau [Fri, 19 Oct 2012 18:52:18 +0000 (20:52 +0200)] 
MINOR: ssl: improve socket behaviour upon handshake abort.

While checking haproxy's SSL stack with www.ssllabs.com, it appeared that
immediately closing upon a failed handshake caused a TCP reset to be emitted.
This is because OpenSSL does not consume pending data in the socket buffers.
One side effect is that if the reset packet is lost, the client might not get
it. So now when a handshake fails, we try to clean the socket buffers before
closing, resulting in a clean FIN instead of an RST.

12 years agoMEDIUM: sample: pass an empty list instead of a null for fetch args
Willy Tarreau [Fri, 19 Oct 2012 17:49:09 +0000 (19:49 +0200)] 
MEDIUM: sample: pass an empty list instead of a null for fetch args

ACL and sample fetches use args list and it is really not convenient to
check for null args everywhere. Now for empty args we pass a constant
list of end of lists. It will allow us to remove many useless checks.

12 years agoMINOR: sample: accept fetch keywords without parenthesis
Willy Tarreau [Fri, 19 Oct 2012 14:47:23 +0000 (16:47 +0200)] 
MINOR: sample: accept fetch keywords without parenthesis

fetch keywords which support arguments do not support being called
without parenthesis even if all arguments are optional. Let's fix
this to allow fetch keywords without parenthesis as is already done
in ACLs.

12 years agoMINOR: chunk: provide string compare functions
Willy Tarreau [Fri, 19 Oct 2012 13:18:06 +0000 (15:18 +0200)] 
MINOR: chunk: provide string compare functions

It's sometimes needed to be able to compare a zero-terminated string with a
chunk, so we now have two functions to do that, one strcmp() equivalent and
one strcasecmp() equivalent.

12 years agoBUG: ssl: fix ssl_sni ACLs to correctly process regular expressions
Willy Tarreau [Fri, 19 Oct 2012 12:34:30 +0000 (14:34 +0200)] 
BUG: ssl: fix ssl_sni ACLs to correctly process regular expressions

ssl_sni_reg was using acl_parse_str which is wrong since we're parsing
a regex. Additionally, neither _end nor _reg may be looked up.

12 years agoMEDIUM: ssl: add support for the "npn" bind keyword
Willy Tarreau [Thu, 18 Oct 2012 16:57:14 +0000 (18:57 +0200)] 
MEDIUM: ssl: add support for the "npn" bind keyword

The ssl_npn match could not work by itself because clients do not use
the NPN extension unless the server advertises the protocols it supports.
Thanks to Simone Bordet for the explanations on how to get it right.

12 years agoBUILD: ssl: fix shctx build on older compilers
Willy Tarreau [Thu, 18 Oct 2012 13:11:52 +0000 (15:11 +0200)] 
BUILD: ssl: fix shctx build on older compilers

gcc < 3 breaks on shctx because of the missing arg in the lock macros.
We don't need the arg at all, it's not used.

12 years agoDOC: fix minor typo on http-send-name-header
Cyril Bonté [Mon, 15 Oct 2012 17:44:24 +0000 (19:44 +0200)] 
DOC: fix minor typo on http-send-name-header

The "server" keyword documentation had a reference on "http-send-server-name"
instead of "http-send-name-header".

12 years agoMINOR: ssl: add 'ssl_npn' sample/acl to extract TLS/NPN information
Willy Tarreau [Mon, 15 Oct 2012 11:19:06 +0000 (13:19 +0200)] 
MINOR: ssl: add 'ssl_npn' sample/acl to extract TLS/NPN information

This may be used to distinguish between SPDY versions for example.

12 years agoDOC: document relations between internal entities
Willy Tarreau [Sun, 14 Oct 2012 12:05:16 +0000 (14:05 +0200)] 
DOC: document relations between internal entities

Links between internal structures have been represented in
entities.fig. The pdf and svg versions were added too.

12 years agoOPTIM: connection: pack the struct target
Willy Tarreau [Sat, 13 Oct 2012 12:33:58 +0000 (14:33 +0200)] 
OPTIM: connection: pack the struct target

The struct target contains one int and one pointer, causing it to be
64-bit aligned on 64-bit platforms. By marking it "packed", we can
save 8 bytes in struct connection and as many in struct session on
such platforms.

12 years agoOPTIM: session: reorder struct session fields
Willy Tarreau [Sat, 13 Oct 2012 09:22:24 +0000 (11:22 +0200)] 
OPTIM: session: reorder struct session fields

A reorering of the struct session fields has increased overall performance
by almost 1% due to better cache usage.

12 years agoCLEANUP: session: remove term_trace which is not used anymore
Willy Tarreau [Sat, 13 Oct 2012 09:09:14 +0000 (11:09 +0200)] 
CLEANUP: session: remove term_trace which is not used anymore

This field was used to trace precisely where a session was terminated
but it did not survive code rearchitecture and was not used at all
anymore. Let's get rid of it.

12 years agoOPTIM: channel: reorganize struct members to improve cache efficiency
Willy Tarreau [Sat, 13 Oct 2012 08:05:56 +0000 (10:05 +0200)] 
OPTIM: channel: reorganize struct members to improve cache efficiency

Now that the buffer is moved out of the channel, it is possible to move
the pointer earlier in the struct and reorder some fields. This new
ordering improves overall performance by 2%, mainly saved in the HTTP
parsers and data transfers.

12 years agoMAJOR: channel: replace the struct buffer with a pointer to a buffer
Willy Tarreau [Fri, 12 Oct 2012 21:49:43 +0000 (23:49 +0200)] 
MAJOR: channel: replace the struct buffer with a pointer to a buffer

With this commit, we now separate the channel from the buffer. This will
allow us to replace buffers on the fly without touching the channel. Since
nobody is supposed to keep a reference to a buffer anymore, doing so is not
a problem and will also permit some copy-less data manipulation.

Interestingly, these changes have shown a 2% performance increase on some
workloads, probably due to a better cache placement of data.

12 years agoCLEANUP: acl: use 'chn' instead of 'b' to name channel pointers
Willy Tarreau [Fri, 12 Oct 2012 21:58:13 +0000 (23:58 +0200)] 
CLEANUP: acl: use 'chn' instead of 'b' to name channel pointers

As with previous patches, this naming is confusing.

12 years agoCLEANUP: stream_interface: use 'chn' instead of 'b' to name channel pointers
Willy Tarreau [Fri, 12 Oct 2012 21:56:57 +0000 (23:56 +0200)] 
CLEANUP: stream_interface: use 'chn' instead of 'b' to name channel pointers

As with previous patches, this naming is confusing.

12 years agoCLEANUP: tcp: use 'chn' instead of 'buf' or 'b' for channel pointer names
Willy Tarreau [Fri, 12 Oct 2012 21:53:39 +0000 (23:53 +0200)] 
CLEANUP: tcp: use 'chn' instead of 'buf' or 'b' for channel pointer names

Same as previous patches, avoid confusion in local variable names.

12 years agoCLEANUP: channel: use 'chn' instead of 'buf' as local variable names
Willy Tarreau [Fri, 12 Oct 2012 21:11:02 +0000 (23:11 +0200)] 
CLEANUP: channel: use 'chn' instead of 'buf' as local variable names

It's too confusing to see buf->buf everywhere where the first buf is
a channel. Let's fix this now.

12 years agoCLEANUP: http: use 'chn' to name channel variables, not 'buf'
Willy Tarreau [Fri, 12 Oct 2012 20:51:15 +0000 (22:51 +0200)] 
CLEANUP: http: use 'chn' to name channel variables, not 'buf'

These "buf" were confusing as they were really refering to channels. At
most places, a buffer was really all what was needed, so a struct buffer
was used instead. It is possible that the performance has slightly increased
by the removal of pointer offset in many pointer operations by directly
using the buffer pointer instead of the channel pointer.

12 years agoREORG: http: rename msg->buf to msg->chn since it's a channel
Willy Tarreau [Fri, 12 Oct 2012 20:40:39 +0000 (22:40 +0200)] 
REORG: http: rename msg->buf to msg->chn since it's a channel

It's extremely confusing to have all those msg->buf->buf everywhere after
the extraction of the buffer from the channel. Let's clean this up.

12 years agoMEDIUM: log: report SSL ciphers and version in logs using logformat %sslc/%sslv
Willy Tarreau [Fri, 12 Oct 2012 18:17:54 +0000 (20:17 +0200)] 
MEDIUM: log: report SSL ciphers and version in logs using logformat %sslc/%sslv

These two new log-format tags report the SSL protocol version (%sslv) and the
SSL ciphers (%sslc) used for the connection with the client. For instance, to
append these information just after the client's IP/port address information
on an HTTP log line, use the following configuration :

    log-format %Ci:%Cp\ %sslv:%sslc\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %st\ %B\ %cc\ \ %cs\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r

It will report a line such as the following one :

    Oct 12 20:47:30 haproxy[9643]: 127.0.0.1:43602 TLSv1:AES-SHA [12/Oct/2012:20:47:30.303] stick2~ stick2/s1 7/0/12/0/19 200 145 - - ---- 0/0/0/0/0 0/0 "GET /?t=0 HTTP/1.0"

12 years agoMINOR: log: make lf_text use a const char *
Willy Tarreau [Fri, 12 Oct 2012 17:48:16 +0000 (19:48 +0200)] 
MINOR: log: make lf_text use a const char *

lf_text() should use a const char * otherwise it makes it more complex
to use data coming from const strings.

12 years agoMEDIUM: log: add a new LW_XPRT flag to pin the transport layer
Willy Tarreau [Fri, 12 Oct 2012 16:01:49 +0000 (18:01 +0200)] 
MEDIUM: log: add a new LW_XPRT flag to pin the transport layer

This flag will have to be set on log tags which require transport layer
information. They will prevent the conn_xprt_close() call from releasing
the transport layer too early.

12 years agoMEDIUM: connection: add a flag to hold the transport layer
Willy Tarreau [Fri, 12 Oct 2012 15:50:05 +0000 (17:50 +0200)] 
MEDIUM: connection: add a flag to hold the transport layer

When we start logging SSL information, we need the SSL struct to be
present even past the conn_xprt_close() call. In order to achieve this,
we should use refcounting on the connection and the transport layer. At
the moment it's not worth using plain refcounting as only the logs require
this, so instead of real refcounting we just use a flag which will be set
by the log subsystem when SSL data need to be logged.

What happens then is that the xprt->close() call is ignored and the
transport layer is closed again during session_free(), after the log
line is emitted.

12 years agoBUG/MEDIUM: session: enable the conn_session_update() callback
Willy Tarreau [Fri, 12 Oct 2012 15:42:13 +0000 (17:42 +0200)] 
BUG/MEDIUM: session: enable the conn_session_update() callback

This callback was introduced by commit 9683e9a0 but never enabled because
the CO_FL_WAKE_DATA flag was not set. The result is that this function is
never called when an SSL handshake fails, so the connection is only closed
on timeout.

12 years agoBUG/MINOR: session: fix some leftover from debug code
Willy Tarreau [Fri, 12 Oct 2012 15:36:40 +0000 (17:36 +0200)] 
BUG/MINOR: session: fix some leftover from debug code

Commit 82569f91 moved the health and monitor-net checks to session.c
but a debug test introduced 0& to disable MSG_DONTWAIT in the recv()
call and this debug code remained there. Since the socket is marked
non-blocking, there should be no effect but it's dangerous to keep
such a thing here.

12 years agoMEDIUM: connection: always unset the transport layer upon close
Willy Tarreau [Fri, 12 Oct 2012 15:00:05 +0000 (17:00 +0200)] 
MEDIUM: connection: always unset the transport layer upon close

When calling conn_xprt_close(), we always clear the transport pointer
so that all transport layers leave the connection in the same state after
a close. This will also make it safer and cheaper to call conn_xprt_close()
multiple times if needed.

12 years agoMEDIUM: log: suffix the frontend's name with '~' when using SSL
Willy Tarreau [Fri, 12 Oct 2012 12:56:11 +0000 (14:56 +0200)] 
MEDIUM: log: suffix the frontend's name with '~' when using SSL

Until now it was not possible to know from the logs whether the incoming
connection was made over SSL or not. In order to address this in the existing
log formats, a new log format %ft was introduced, to log the frontend's name
suffixed with its transport layer. The only transport layer in use right now
is '~' for SSL, so that existing log formats for non-SSL traffic are not
affected at all, and SSL log formats have the frontend's name suffixed with
'~'.

The TCP, HTTP and CLF log format now use %ft instead of %f. This does not
affect existing log formats which still make use of %f however.

12 years agoDOC: Fix rename of options cafile and crlfile to ca-file and crl-file.
Emeric Brun [Thu, 11 Oct 2012 14:28:27 +0000 (16:28 +0200)] 
DOC: Fix rename of options cafile and crlfile to ca-file and crl-file.

12 years agoMINOR: ssl: add statements 'verify', 'ca-file' and 'crl-file' on servers.
Emeric Brun [Thu, 11 Oct 2012 14:11:36 +0000 (16:11 +0200)] 
MINOR: ssl: add statements 'verify', 'ca-file' and 'crl-file' on servers.

It now becomes possible to verify the server's certificate using the "verify"
directive. This one only supports "none" and "required", as it does not make
much sense to also support "optional" here.

12 years agoMINOR: ssl: add statement 'no-tls-tickets' on server side.
Emeric Brun [Thu, 11 Oct 2012 13:28:34 +0000 (15:28 +0200)] 
MINOR: ssl: add statement 'no-tls-tickets' on server side.

12 years agoMEDIUM: ssl: reject ssl server keywords in default-server statement
Emeric Brun [Thu, 11 Oct 2012 13:05:10 +0000 (15:05 +0200)] 
MEDIUM: ssl: reject ssl server keywords in default-server statement

At the moment they are ignored, but they were not rejected so they could
cause confusion in some configurations.

12 years agoMINOR: ssl: move ssl context init for servers from cfgparse.c to ssl_sock.c
Emeric Brun [Thu, 11 Oct 2012 12:00:19 +0000 (14:00 +0200)] 
MINOR: ssl: move ssl context init for servers from cfgparse.c to ssl_sock.c

12 years agoBUG/MINOR: ssl: Fix issue on server statements 'no-tls*' and 'no-sslv3'
Emeric Brun [Thu, 11 Oct 2012 16:36:21 +0000 (18:36 +0200)] 
BUG/MINOR: ssl: Fix issue on server statements 'no-tls*' and 'no-sslv3'

bit field collision with 'force-tlsv*'.

12 years agoMEDIUM: ssl: move "server" keyword SSL options parsing to ssl_sock.c
Willy Tarreau [Wed, 10 Oct 2012 21:04:25 +0000 (23:04 +0200)] 
MEDIUM: ssl: move "server" keyword SSL options parsing to ssl_sock.c

All SSL-specific "server" keywords are now processed in ssl_sock.c. At
the moment, there is no more "not implemented" hint when SSL is disabled,
but keywords could be added in server.c if needed.

12 years agoBUG/MEDIUM: config: check-send-proxy was ignored if SSL was not builtin
Willy Tarreau [Wed, 10 Oct 2012 21:01:14 +0000 (23:01 +0200)] 
BUG/MEDIUM: config: check-send-proxy was ignored if SSL was not builtin

Improper insertion within #if/#endif SSL causes the check-send-proxy state
not to be automatically enabled if SSL is disabled at build time.

12 years agoMEDIUM: server: move parsing of keyword "id" to server.c
Willy Tarreau [Wed, 10 Oct 2012 15:51:05 +0000 (17:51 +0200)] 
MEDIUM: server: move parsing of keyword "id" to server.c

This is the first keyword to be moved to server.c.

12 years agoMEDIUM: server: check for registered keywords when parsing unknown keywords
Willy Tarreau [Wed, 10 Oct 2012 06:57:40 +0000 (08:57 +0200)] 
MEDIUM: server: check for registered keywords when parsing unknown keywords

At this point, no server keyword is registered yet. The help line does
not report supported keywords anymore since it lists the registered ones
only.

12 years agoMINOR: standard: make indent_msg() support empty messages
Willy Tarreau [Wed, 10 Oct 2012 06:56:47 +0000 (08:56 +0200)] 
MINOR: standard: make indent_msg() support empty messages

indent_msg() is called with dynamically generated messages, so these
may be empty (NULL) when an empty list is being dumped. Support this
and return a NULL too.

12 years agoMINOR: server: add minimal infrastructure to parse keywords
Willy Tarreau [Wed, 10 Oct 2012 06:27:36 +0000 (08:27 +0200)] 
MINOR: server: add minimal infrastructure to parse keywords

Just like with the "bind" lines, we'll switch the "server" line
parsing to keyword registration. The code is essentially the same
as for bind keywords, with minor changes such as support for the
default-server keywords and support for variable argument count.

12 years agoBUILD: accept4: move the socketcall declaration outside of accept4()
Willy Tarreau [Wed, 10 Oct 2012 06:26:12 +0000 (08:26 +0200)] 
BUILD: accept4: move the socketcall declaration outside of accept4()

Gcc 4.2.4 breaks on the syscall declared inside the function, move it
outside and declare it static inline.

12 years agoMINOR: halog: add a parameter to limit output line count
Willy Tarreau [Wed, 10 Oct 2012 14:49:28 +0000 (16:49 +0200)] 
MINOR: halog: add a parameter to limit output line count

Sometimes it's useful to limit the output to a number of lines, for
example when output is already sorted (eg: 10 slowest URLs, ...). Now
we can use -m for this.

12 years agoBUG/MINOR: halog: fix help message for -ut/-uto
Willy Tarreau [Wed, 10 Oct 2012 12:57:35 +0000 (14:57 +0200)] 
BUG/MINOR: halog: fix help message for -ut/-uto

Erroneous copy-paste suggesting wrong option.

12 years agoBUG/MINOR: halog: -ad/-ac report the correct number of output lines
Willy Tarreau [Wed, 10 Oct 2012 11:41:52 +0000 (13:41 +0200)] 
BUG/MINOR: halog: -ad/-ac report the correct number of output lines

There was a lines_out++ left from earlier code, causing each input
line to be counted as an output line.

This fix also affects 1.4 and should be backported.

12 years agoMINOR: halog: sort output by cookie code
Willy Tarreau [Wed, 10 Oct 2012 08:26:22 +0000 (10:26 +0200)] 
MINOR: halog: sort output by cookie code

It's sometimes useful to have the output sorted by cookie code to see
the ratios of NI vs VN for example. This is now possible with -cc.

12 years agoDOC: ssl: surround keywords with quotes
Cyril Bonté [Tue, 9 Oct 2012 20:45:34 +0000 (22:45 +0200)] 
DOC: ssl: surround keywords with quotes

In order to make external tools easily detect keywords in the documentation,
let's surround them by quotes as it is done for other keywords.

12 years agoDOC: ssl: remove prefer-server-ciphers documentation
Cyril Bonté [Tue, 9 Oct 2012 20:45:33 +0000 (22:45 +0200)] 
DOC: ssl: remove prefer-server-ciphers documentation

Commit 3c4bc6e1 removed the prefer-server-ciphers statement.
Therefore, the statement should also be removed from the documentation.

12 years agoMEDIUM: listener: add support for linux's accept4() syscall
Willy Tarreau [Mon, 8 Oct 2012 18:11:03 +0000 (20:11 +0200)] 
MEDIUM: listener: add support for linux's accept4() syscall

On Linux, accept4() does the same as accept() except that it allows
the caller to specify some flags to set on the resulting socket. We
use this to set the O_NONBLOCK flag and thus to save one fcntl()
call in each connection. The effect is a small performance gain of
around 1%.

The option is automatically enabled when target linux2628 is set, or
when the USE_ACCEPT4 Makefile variable is set. If the libc is too old
to provide the equivalent function, this is automatically detected and
our own function is used instead. In any case it is possible to force
the use of our implementation with USE_MY_ACCEPT4.

12 years agoBUG/MAJOR: ensure that hdr_idx is always reserved when L7 fetches are used
Willy Tarreau [Fri, 5 Oct 2012 20:41:26 +0000 (22:41 +0200)] 
BUG/MAJOR: ensure that hdr_idx is always reserved when L7 fetches are used

Baptiste Assmann reported a bug causing a crash on recent versions when
sticking rules were set on layer 7 in a TCP proxy. The bug is easier to
reproduce with the "defer-accept" option on the "bind" line in order to
have some contents to parse when the connection is accepted. The issue
is that the acl_prefetch_http() function called from HTTP fetches relies
on hdr_idx to be preinitialized, which is not the case if there is no L7
ACL.

The solution consists in adding a new SMP_CAP_L7 flag to fetches to indicate
that they are expected to work on L7 data, so that the proxy knows that the
hdr_idx has to be initialized. This is already how ACL and HTTP mode are
handled.

The bug was present since 1.5-dev9.