Willy Tarreau [Tue, 2 Oct 2012 23:39:48 +0000 (01:39 +0200)]
MEDIUM: connection: use a generic data-layer init() callback
The generic data-layer init callback is now used after the transport
layer is complete and before calling the data layer recv/send callbacks.
This allows the session to switch from the embryonic session data layer
to the complete stream interface data layer, by making conn_session_complete()
the data layer's init callback.
It sill looks awkwards that the init() callback must be used opon error,
but except by adding yet another one, it does not seem to be mergeable
into another function (eg: it should probably not be merged with ->wake
to avoid unneeded calls during the handshake, though semantically that
would make sense).
Willy Tarreau [Tue, 2 Oct 2012 19:21:20 +0000 (21:21 +0200)]
MEDIUM: session: use a specific data_cb for embryonic sessions
We don't want to have the recv or send callbacks in embryonic
sessions, and we want the stream interface to be referenced as
the connection owner only once the session is instanciated. So
let's first have the embryonic session be the owner, then replaced
later by the stream interface once the transport layer is ready.
Willy Tarreau [Tue, 2 Oct 2012 23:12:30 +0000 (01:12 +0200)]
MINOR: connection: add an init callback to the data_cb struct
This callback is used to initialize the data layer.
Willy Tarreau [Tue, 2 Oct 2012 18:57:19 +0000 (20:57 +0200)]
MINOR: connection: split conn_prepare() in two functions
We'll also need a function to takeover an existing connection without
reinitializing it. The same will be needed at the stream interface level.
Willy Tarreau [Tue, 2 Oct 2012 18:07:22 +0000 (20:07 +0200)]
MINOR: connection: provide a generic data layer wakeup callback
Instead of calling conn_notify_si() from the connection handler, we
now call data->wake(), which will allow us to use a different callback
with health checks.
Note that we still rely on a flag in order to decide whether or not
to call this function. The reason is that with embryonic sessions,
the callback is already initialized to si_conn_cb without the flag,
and we can't call the SI notify function in the leave path before
the stream interface is initialized.
This issue should be addressed by involving a different data_cb for
embryonic sessions and for stream interfaces, that would be changed
during session_complete() for the final data_cb.
Willy Tarreau [Tue, 2 Oct 2012 22:41:04 +0000 (00:41 +0200)]
REORG: connection: rename app_cb "data"
Now conn->data will designate the data layer which is the client for
the transport layer. In practice it's the stream interface and will
soon also be the health checks.
Willy Tarreau [Tue, 2 Oct 2012 22:19:48 +0000 (00:19 +0200)]
REORG: connection: rename the data layer the "transport layer"
While working on the changes required to make the health checks use the
new connections, it started to become obvious that some naming was not
logical at all in the connections. Specifically, it is not logical to
call the "data layer" the layer which is in charge for all the handshake
and which does not yet provide a data layer once established until a
session has allocated all the required buffers.
In fact, it's more a transport layer, which makes much more sense. The
transport layer offers a medium on which data can transit, and it offers
the functions to move these data when the upper layer requests this. And
it is the upper layer which iterates over the transport layer's functions
to move data which should be called the data layer.
The use case where it's obvious is with embryonic sessions : an incoming
SSL connection is accepted. Only the connection is allocated, not the
buffers nor stream interface, etc... The connection handles the SSL
handshake by itself. Once this handshake is complete, we can't use the
data functions because the buffers and stream interface are not there
yet. Hence we have to first call a specific function to complete the
session initialization, after which we'll be able to use the data
functions. This clearly proves that SSL here is only a transport layer
and that the stream interface constitutes the data layer.
A similar change will be performed to rename app_cb => data, but the
two could not be in the same commit for obvious reasons.
Willy Tarreau [Thu, 4 Oct 2012 18:38:49 +0000 (20:38 +0200)]
MEDIUM: raw_sock: improve connection error reporting
When a connection setup is pending and we receive an error without a
POLL_IN flag, we're certain there will be nothing to read from it and
we can safely report an error without attempting a recv() call. This
will be significantly better for health checks which will avoid a useless
recv() on all failed checks.
Willy Tarreau [Thu, 4 Oct 2012 18:17:13 +0000 (20:17 +0200)]
MINOR: raw_sock: always report asynchronous connection errors
Depending on the pollers used, a connection error may be notified
with POLLOUT|POLLERR|POLLHUP. POLLHUP by itself is enough for the
connection handler to call the read actor, which would only consider
this flag as a good indication of a hangup, without considering the
POLLERR flag.
In order to address this, we directly jump to the read0 label if
POLLERR was not set.
This will be important with health checks as we don't want to believe
a connection was properly established when it's not the case !
Willy Tarreau [Fri, 28 Sep 2012 14:02:48 +0000 (16:02 +0200)]
MINOR: buffers: add a few functions to write chars, strings and blocks
bo_put{chr,blk,str,chk} are used to write data on the output of a buffer.
Output is truncated if the buffer is not large enough.
Willy Tarreau [Thu, 4 Oct 2012 17:19:36 +0000 (19:19 +0200)]
MINOR: signal: really ignore signals configured with no handler
Until now, signals configured with no handler were still enabled and
ignored upon signal reception. Until now it was not an issue but with
SSL causing many EPIPE all the time, it becomes obvious that signal
processing comes with a cost. So set the handler to SIG_IGN when the
function is NULL.
Willy Tarreau [Thu, 4 Oct 2012 19:54:41 +0000 (21:54 +0200)]
BUG/MINOR: epoll: correctly disable FD polling in fd_rem()
When calling fd_rem(), the polling was not correctly disabled because the
->prev state was set to zero instead of the previous value. fd_rem() is
very rarely used, only just before closing a socket.
The effect is that upon an error reported at the connection level, if the
task assigned to the connection was too slow to be woken up because of too
many other tasks in the run queue, the FD was still not disabled and caused
the connection handler to be called again with the same event until the task
was finally executed to close the fd.
This issue only affects the epoll poller, not the sepoll variant nor any of
the other ones.
It was already present in 1.4 and even 1.3 with the same almost unnoticeable
effects. The bug can in fact only be discovered during development where it
emphasizes other bugs.
It should be backported anyway.
Willy Tarreau [Thu, 4 Oct 2012 06:47:34 +0000 (08:47 +0200)]
MEDIUM: proxy: add the global frontend to the list of normal proxies
Since recent changes on the global frontend, it was not possible anymore
to soft-reload a process which had a stats socket because the socket would
not be disabled upon reload. The only solution to this endless madness is
to have the global frontend part of normal proxies.
Since we don't want to get an ID that shifts all other proxies and causes
trouble in deployed environments, we assign it ID #0 which other proxies
can't grab, and we don't report it in the stats pages.
Willy Tarreau [Thu, 4 Oct 2012 06:56:31 +0000 (08:56 +0200)]
BUG/MEDIUM: listener: don't pause protocols that do not support it
Pausing a UNIX_STREAM socket results in a major pain because the socket
does not correctly resume, it wakes poll() but return EAGAIN on accept(),
resulting in a busy loop. So let's only pause protocols that support it.
This issues has existed since UNIX sockets were introduced on bind lines.
Willy Tarreau [Thu, 4 Oct 2012 06:01:43 +0000 (08:01 +0200)]
BUG/MINOR: config: use a copy of the file name in proxy configurations
Each proxy contains a reference to the original config file and line
number where it was declared. The pointer used is just a reference to
the one passed to the function instead of being duplicated. The effect
is that it is not valid anymore at the end of the parsing and that all
proxies will be enumerated as coming from the same file on some late
configuration errors. This may happen for exmaple when reporting SSL
certificate issues.
By copying using strdup(), we avoid this issue.
1.4 has the same issue, though no report of the proxy file name is done
out of the config section. Anyway a backport is recommended to ease
post-mortem analysis.
Willy Tarreau [Wed, 3 Oct 2012 22:14:33 +0000 (00:14 +0200)]
BUG/MEDIUM: proxy: must not try to stop disabled proxies upon reload
Hervé Commowick reported an issue : haproxy dies in a segfault during a
soft restart if it tries to pause a disabled proxy. This is because disabled
proxies have no management task so we must not wake the task up. This could
easily remain unnoticed since the old process was expected to go away, so
having it go away faster was not really troubling. However, with sync peers,
it is obvious that there is no peer sync during this reload.
This issue has been introduced in 1.5-dev7 with the removal of the
maintain_proxies() function. No backport is needed.
Willy Tarreau [Fri, 28 Sep 2012 18:22:13 +0000 (20:22 +0200)]
BUG/MINOR: ssl: report the L4 connection as established when possible
If we get an SSL error during the handshake, we at least try to see
if a syscall reported an error or not. In case of an error, it generally
means that the connection failed. If there is no error, then the connection
established successfully.
The difference is important for health checks which report the precise cause
to the logs and to the stats.
Emeric Brun [Tue, 2 Oct 2012 17:25:50 +0000 (19:25 +0200)]
BUG/MINOR: build: Fix compilation issue on openssl 0.9.6 due to missing CRL feature.
Emeric Brun [Tue, 2 Oct 2012 13:20:55 +0000 (15:20 +0200)]
BUG/MINOR: ssl: Fix CRL check was not enabled when crlfile was specified.
Emeric Brun [Tue, 2 Oct 2012 12:00:59 +0000 (14:00 +0200)]
DOC: ssl: add 'no-tls-tickets' statement documentation.
Disables the stateless session resumption (RFC 5077 TLS Ticket
extension) and force to use stateful session resumption. Stateless
session resumption is more expensive in CPU usage.
Emeric Brun [Tue, 2 Oct 2012 11:45:20 +0000 (13:45 +0200)]
MINOR: ssl: add statement 'no-tls-tickets' on bind to disable stateless session resumption
Disables the stateless session resumption (RFC 5077 TLS Ticket extension)
and force to use stateful session resumption.
Stateless session resumption is more expensive in CPU usage.
Emeric Brun [Mon, 1 Oct 2012 15:10:30 +0000 (17:10 +0200)]
MEDIUM: config: authorize frontend and listen without bind.
This allows to easily add/remove "bind" entries to a frontend without
being forced to remove it when the last entry is temporarily removed.
While "disabled" may sometimes work in a frontend, it becomes trickier
on "listen" sections which can also hold servers and be referenced by
other frontends.
Note that a "listen" section with no "bind" is equivalent to a "backend"
section.
Configs without any listeners are still reported as invalid and refuse
to load.
Emeric Brun [Fri, 28 Sep 2012 17:42:54 +0000 (19:42 +0200)]
DOC: ssl : add statements 'notlsv11' and 'notlsv12' and rename 'notlsv1' to 'notlsv10'.
This applies both to "bind" and "server" statements.
Emeric Brun [Fri, 28 Sep 2012 17:37:02 +0000 (19:37 +0200)]
MINOR: ssl : add statements 'notlsv11' and 'notlsv12' and rename 'notlsv1' to 'notlsv10'.
This is because "notlsv1" used to disable TLSv1.0 only and had no effect
on v1.1/v1.2. so better have an option for each version. This applies both
to "bind" and "server" statements.
Emeric Brun [Tue, 25 Sep 2012 09:11:16 +0000 (11:11 +0200)]
MINOR: ssl: add build param USE_PRIVATE_CACHE to build cache without shared memory
It removes dependencies with futex or mutex but ssl performances decrease
using nbproc > 1 because switching process force session renegotiation.
This can be useful on small systems which never intend to run in multi-process
mode.
Emeric Brun [Mon, 24 Sep 2012 13:48:52 +0000 (15:48 +0200)]
MINOR: ssl: disable shared memory and locks on session cache if nbproc == 1
We don't needa to lock the memory when there is a single process. This can
make a difference on small systems where locking is much more expensive than
just a test.
Emeric Brun [Fri, 28 Sep 2012 16:35:15 +0000 (18:35 +0200)]
DOC: ssl: add fetches and ACLs 'ssl_verify_crterr', 'ssl_verify_caerr', and 'ssl_verify_crterr_depth'
Emeric Brun [Fri, 21 Sep 2012 13:27:54 +0000 (15:27 +0200)]
MINOR: ssl: add fetches and ACLs to return verify errors
Add fetch 'ssl_verify_caerr':
returns the first ssl verify error at depth > 0 (CA chain).
Add fetch 'ssl_verify_caerr_depth':
returns the first ssl verify error depth (max returns is 15 if depth > 15).
Add fetch 'ssl_verify_crterr':
returns the fist ssl verify error at depth == 0.
Emeric Brun [Fri, 28 Sep 2012 16:14:24 +0000 (18:14 +0200)]
DOC: ssl: add fetch and ACL 'ssl_verify_result'
Emeric Brun [Fri, 21 Sep 2012 13:27:20 +0000 (15:27 +0200)]
MINOR: ssl: add fetch and ACL 'ssl_verify_result'
This fetch returns the final ssl verify error.
Emeric Brun [Fri, 28 Sep 2012 15:55:37 +0000 (17:55 +0200)]
DOC: ssl: add 'ca-ignore-err' and 'crt-ignore-err' statements on 'bind'
Emeric Brun [Fri, 21 Sep 2012 12:31:21 +0000 (14:31 +0200)]
MINOR: ssl: add ignore verify errors options
Allow to ignore some verify errors and to let them pass the handshake.
Add option 'crt-ignore-err <list>'
Ignore verify errors at depth == 0 (client certificate)
<list> is string 'all' or a comma separated list of verify error IDs
(see http://www.openssl.org/docs/apps/verify.html)
Add option 'ca-ignore-err <list>'
Same as 'crt-ignore-err' for all depths > 0 (CA chain certs)
Ex ignore all errors on CA and expired or not-yet-valid errors
on client certificate:
bind 0.0.0.0:443 ssl crt crt.pem verify required
cafile ca.pem ca-ignore-err all crt-ignore-err 10,9
Emeric Brun [Fri, 28 Sep 2012 15:28:03 +0000 (17:28 +0200)]
DOC: ssl: add fetch and ACL 'client_cert'
Emeric Brun [Fri, 21 Sep 2012 11:15:06 +0000 (13:15 +0200)]
MINOR: ssl: add fetch and ACL 'client_crt' to test a client cert is present
Useful in case of 'verify optional' to know if the client sent a certificate.
Emeric Brun [Fri, 28 Sep 2012 15:07:34 +0000 (17:07 +0200)]
DOC: ssl: add 'verify', 'cafile' and 'crlfile' statements on 'bind'
Emeric Brun [Thu, 20 Sep 2012 16:23:56 +0000 (18:23 +0200)]
MEDIUM: ssl: add client certificate authentication support
Add keyword 'verify' on bind:
'verify none': authentication disabled (default)
'verify optional': accept connection without certificate
and process a verify if the client sent a certificate
'verify required': reject connection without certificate
and process a verify if the client send a certificate
Add keyword 'cafile' on bind:
'cafile <path>' path to a client CA file used to verify.
'crlfile <path>' path to a client CRL file used to verify.
Emeric Brun [Fri, 28 Sep 2012 13:26:15 +0000 (15:26 +0200)]
DOC: ssl: add 'ecdhe' statement on 'bind'
Emeric Brun [Thu, 20 Sep 2012 15:10:03 +0000 (17:10 +0200)]
MINOR: ssl: add elliptic curve Diffie-Hellman support for ssl key generation
Add 'ecdhe' on 'bind' statement: to set named curve used to generate ECDHE keys
(ex: ecdhe secp521r1)
Emeric Brun [Fri, 28 Sep 2012 11:01:45 +0000 (13:01 +0200)]
DOC: ssl: update 'crt' statement on 'bind' about Diffie-Hellman parameters loading
Emeric Brun [Thu, 20 Sep 2012 14:19:02 +0000 (16:19 +0200)]
MINOR: ssl: try to load Diffie-Hellman parameters from cert file
Feature is disabled if openssl compiled with OPENSSL_NO_DH.
Willy Tarreau [Thu, 27 Sep 2012 20:20:41 +0000 (22:20 +0200)]
MEDIUM: connection: make use of the owner instead of container_of
This way the connection can become independant on the stream interface.
Willy Tarreau [Thu, 27 Sep 2012 20:14:33 +0000 (22:14 +0200)]
MINOR: connection: add a pointer to the connection owner
This will be needed to find the stream interface from the connection
once they're detached, but in the more immediate term, we'll need this
for health checks since they don't use a stream interface.
Willy Tarreau [Thu, 27 Sep 2012 21:48:56 +0000 (23:48 +0200)]
MEDIUM: monitor: simplify handling of monitor-net and mode health
We were having several different behaviours with monitor-net and
"mode health" :
- monitor-net on TCP connections was evaluated just after accept(),
did not count a connection on the frontend and were not subject
to tcp-request connection rules, and caused an immediate close().
- monitor-net in HTTP mode was evaluated once the session was
accepted (eg: on top of SSL), returned "HTTP/1.0 200 OK\r\n\r\n"
over the connection's data layer and instanciated a session which
was responsible for closing this connection. A connection AND a
session were counted for the frontend ;
- "mode health" with "option httpchk" would do exactly the same as
monitor-net in HTTP mode ;
- "mode health" without "option httpchk" would do the same as above
except that "OK" was returned instead of "HTTP/1.0 200 OK\r\n\r\n".
None of them took care of cleaning the input buffer, sometimes resulting
in a TCP reset to be emitted after the last packet if a request was received
over the connection.
Given the inconsistencies and the complexity in keeping all these features
handled at the right position, we now slightly changed the way they are
handled :
- all of them are handled just after the "tcp-request connection" rules,
so that all of them may be blocked using such rules, offering more
flexibility and consistency ;
- no connection handshake is performed anymore for non-TCP modes
- all of them send the response as raw data over the socket, there is no
more difference between TCP and HTTP mode for example (these rules were
never meant to be served over SSL connections and were never documented
as able to do that).
- any possible pending data on the incoming socket is drained before the
response is sent, in order to avoid the risk of a reset.
- none of them exactly did what was documented !
This results in more consistent, more flexible and more accurate handling of
monitor rules, with smaller and more robust code.
Willy Tarreau [Thu, 27 Sep 2012 13:08:56 +0000 (15:08 +0200)]
BUG/MAJOR: http: chunk parser was broken with buffer changes
Since at least commit
a458b679, msg->sov could become negative in
http_parse_chunk_size() if a chunk size wrapped around the buffer.
The effect is that at some point channel_forward() was called with
a negative size, causing all data to be transferred without being
analyzed anymore.
Since haproxy does not support keep-alive with the server yet, this
issue is not really noticeable, as the server closes the connection
in response. Still, when tunnel mode is used or when pretent-keepalive
is used, it is possible to see the problem.
This issue was reported and diagnosed by William Lallemand at
Exceliance.
Willy Tarreau [Wed, 26 Sep 2012 19:07:15 +0000 (21:07 +0200)]
MINOR: cli: allow to set frontend maxconn to zero
It is sometimes useful to completely disable accepting new connections
on a frontend during maintenance operations. By setting a frontend's
maxconn to zero, connections are not accepted anymore until the limit
is increased again.
Willy Tarreau [Wed, 26 Sep 2012 19:03:11 +0000 (21:03 +0200)]
BUG: stats: fix regression introduced by commit
4348fad1
Recent commit
4348fad1 (listeners: use dual-linked lists to chain listeners
with frontends) broke frontend lookup in stats sockets by using the wrong
iterator in the listeners.
Willy Tarreau [Tue, 25 Sep 2012 14:31:00 +0000 (16:31 +0200)]
CLEANUP: config: fix typo inteface => interface
This was in an error message.
Willy Tarreau [Mon, 24 Sep 2012 15:15:42 +0000 (17:15 +0200)]
CLEANUP: connection: offer conn_prepare() to set up a connection
This will be used by checks as well as stream interfaces.
Willy Tarreau [Mon, 24 Sep 2012 20:47:39 +0000 (22:47 +0200)]
BUG/MINOR: config: check the proper pointer to report unknown protocol
Check the protocol pointer and not the socket to report an unknown family
in servers or peers. This can never happen anyway, it's just to be completely
clean.
Willy Tarreau [Mon, 24 Sep 2012 19:13:39 +0000 (21:13 +0200)]
BUG: http: do not print garbage on invalid requests in debug mode
Cyril Bonté reported a mangled debug output when an invalid request
was sent with a faulty request line. The reason was the use of the
msg->sl.rq.l offset which was not yet initialized in this case. So
we change the way to report such an error so that first we initialize
it to zero before parsing a message, then we use that to know whether
we can trust it or not. If it's still zero, then we display the whole
buffer, truncated by debug_hdr() to the first CR or LF character, which
results in the first line only.
The same operation was performed for the response, which was wrong too.
Cyril Bonté [Sun, 23 Sep 2012 12:19:12 +0000 (14:19 +0200)]
BUILD: fix compilation error with DEBUG_FULL
Recent changes in structures broke the compilation when using DEBUG_FULL.
Let's update apply the changes also to the variables used in DPRINTF calls.
Willy Tarreau [Mon, 24 Sep 2012 18:34:51 +0000 (20:34 +0200)]
DOC: fix index to reference bind and server options
Last commit forgot to update the index.
Willy Tarreau [Mon, 24 Sep 2012 10:43:26 +0000 (12:43 +0200)]
DOC: stats: refer to "bind" section for "stats socket" settings
They're all shared now, so let's have them described at one single
place.
Willy Tarreau [Mon, 24 Sep 2012 10:27:33 +0000 (12:27 +0200)]
DOC: move bind options to their own section
There are now too many bind options to still have them in the middle
of the keyword matrix, so let's move them with the server options in
section 5. No new option was documented yet at this point.
Willy Tarreau [Sat, 22 Sep 2012 17:32:35 +0000 (19:32 +0200)]
MEDIUM: stats: make use of the standard "bind" parsers to parse global socket
The global stats socket statement now makes use of the standard bind parsers.
This results in all UNIX socket options being set by proto_uxst and in all
TCP and SSL options being inherited and usable. For example it is now possible
to enable a stats socket over SSL/TCP by appending the "ssl" keyword and a
certificate after "crt".
The code is simplified since we don't have a special case to parse this config
keyword anymore.
Willy Tarreau [Sat, 22 Sep 2012 17:11:47 +0000 (19:11 +0200)]
MINOR: ssl: set the listeners' data layer to ssl during parsing
It's better to set all listeners to ssl_sock when seeing the "ssl"
keyword that to loop on all of them afterwards just for this. This
also removes some #ifdefs.
Willy Tarreau [Thu, 20 Sep 2012 18:19:28 +0000 (20:19 +0200)]
MEDIUM: stats: remove the stats_sock struct from the global struct
Now the stats socket is allocated when the 'stats socket' line is parsed,
and assigned using the standard str2listener(). This has two effects :
- more than one stats socket can now be declared
- stats socket now support protocols other than UNIX
The next step is to remove the duplicate bind config parsing.
Willy Tarreau [Thu, 20 Sep 2012 18:01:39 +0000 (20:01 +0200)]
MINOR: config: make str2listener() use memprintf() to report errors.
This will make it possible to use the function for other listening
sockets.
Willy Tarreau [Thu, 20 Sep 2012 17:43:14 +0000 (19:43 +0200)]
MINOR: standard: make memprintf() support a NULL destination
Doing so removes many checks that were systematically made because
the callees don't know if the caller passed a valid pointer.
Willy Tarreau [Sat, 22 Sep 2012 16:36:29 +0000 (18:36 +0200)]
BUG: backend: balance hdr was broken since 1.5-dev11
Alex Markham reported and diagnosed a bug appearing on 1.5-dev11,
causing a crash on x86_64 when header hashing is used. The cause is
a missing (int) cast causing a negative offset to appear positive
and the resulting pointer to go out of bounds.
The crash is not possible anymore since 1.5-dev12 because a second
bug caused the negative sign to disappear so the pointer is always
within range but always wrong, so balance hdr() never works anymore.
This fix restores the correct behaviour and ensures the sign is
correct.
Willy Tarreau [Thu, 20 Sep 2012 16:07:14 +0000 (18:07 +0200)]
REORG: listener: move unix perms from the listener to the bind_conf
Unix permissions are per-bind configuration line and not per listener,
so let's concretize this in the way the config is stored. This avoids
some unneeded loops to set permissions on all listeners.
The access level is not part of the unix perms so it has been moved
away. Once we can use str2listener() to set all listener addresses,
we'll have a bind keyword parser for this one.
Willy Tarreau [Thu, 20 Sep 2012 14:48:07 +0000 (16:48 +0200)]
MAJOR: listeners: use dual-linked lists to chain listeners with frontends
Navigating through listeners was very inconvenient and error-prone. Not to
mention that listeners were linked in reverse order and reverted afterwards.
In order to definitely get rid of these issues, we now do the following :
- frontends have a dual-linked list of bind_conf
- frontends have a dual-linked list of listeners
- bind_conf have a dual-linked list of listeners
- listeners have a pointer to their bind_conf
This way we can now navigate from anywhere to anywhere and always find the
proper bind_conf for a given listener, as well as find the list of listeners
for a current bind_conf.
Willy Tarreau [Tue, 18 Sep 2012 18:52:35 +0000 (20:52 +0200)]
MINOR: config: set the bind_conf entry on listeners created from a "listen" line.
Otherwise we would risk a segfault when checking the config's validity
(eg: when looking for conflicts on ID assignments).
Note that the same issue exists with peers_fe and the global stats_fe. All
listeners should be reviewed and simplified to use a compatible declaration
mode.
Willy Tarreau [Tue, 18 Sep 2012 18:05:00 +0000 (20:05 +0200)]
MINOR: stats: fill the file and line numbers in the stats frontend
The stats frontend struct has config file and line which were not set.
They're not used right now but better fill them correctly anyway.
Willy Tarreau [Tue, 18 Sep 2012 18:02:48 +0000 (20:02 +0200)]
MINOR: config: pass the file and line to config keyword parsers
This will be needed when we need to create bind config settings.
Willy Tarreau [Tue, 18 Sep 2012 16:24:39 +0000 (18:24 +0200)]
MINOR: listener: add a scope field in the bind keyword lists
This scope is used to report what the keywords are used for (eg: TCP,
UNIX, ...). It is now reported by bind_dump_kws().
Willy Tarreau [Tue, 18 Sep 2012 16:01:17 +0000 (18:01 +0200)]
MEDIUM: config: enumerate full list of registered "bind" keywords upon error
When an unknown "bind" keyword is detected, dump the list of all
registered keywords. Unsupported default alternatives are also reported
as "not supported".
Willy Tarreau [Tue, 18 Sep 2012 15:40:35 +0000 (17:40 +0200)]
MEDIUM: config: move all unix-specific bind keywords to proto_uxst.c
The "mode", "uid", "gid", "user" and "group" bind options were moved to
proto_uxst as they are unix-specific.
Note that previous versions had a bug here, only the last listener was
updated with the specified settings. However, it almost never happens
that bind lines contain multiple UNIX socket paths so this is not that
much of a problem anyway.
Willy Tarreau [Tue, 18 Sep 2012 15:17:28 +0000 (17:17 +0200)]
MEDIUM: config: move the common "bind" settings to listener.c
These ones are better placed in listener.c than in cfgparse.c, by relying
on the bind keyword registration subsystem.
Willy Tarreau [Tue, 18 Sep 2012 14:34:09 +0000 (16:34 +0200)]
MINOR: config: improve error reporting for "bind" lines
We now report the bind argument, which was missing in all error reports. It
is now much more convenient to spot configuration mistakes.
Willy Tarreau [Fri, 14 Sep 2012 05:53:05 +0000 (07:53 +0200)]
MEDIUM: move bind SSL parsing to ssl_sock
Registering new SSL bind keywords was not particularly handy as it required
many #ifdef in cfgparse.c. Now the code has moved to ssl_sock.c which calls
a register function for all the keywords.
Error reporting was also improved by this move, because the called functions
build an error message using memprintf(), which can span multiple lines if
needed, and each of these errors will be displayed indented in the context of
the bind line being processed. This is important when dealing with certificate
directories which can report multiple errors.
Willy Tarreau [Wed, 12 Sep 2012 21:27:21 +0000 (23:27 +0200)]
MEDIUM: config: move the "bind" TCP parameters to proto_tcp
Now proto_tcp.c is responsible for the 4 settings it handles :
- defer-accept
- interface
- mss
- transparent
These ones do not need to be handled in cfgparse anymore. If support for a
setting is disabled by a missing build option, then cfgparse correctly
reports :
[ALERT] 255/232700 (2701) : parsing [echo.cfg:114] : 'bind' : 'transparent' option is not implemented in this version (check build options).
Willy Tarreau [Wed, 12 Sep 2012 21:17:10 +0000 (23:17 +0200)]
MEDIUM: listener: add a minimal framework to register "bind" keyword options
With the arrival of SSL, the "bind" keyword has received even more options,
all of which are processed in cfgparse in a cumbersome way. So it's time to
let modules register their own bind options. This is done very similarly to
the ACLs with a small difference in that we make the difference between an
unknown option and a known, unimplemented option.
Willy Tarreau [Thu, 13 Sep 2012 17:34:38 +0000 (19:34 +0200)]
CLEANUP: listener: remove unused conf->file and conf->line
These ones are already in bind_conf.
Willy Tarreau [Thu, 13 Sep 2012 15:54:29 +0000 (17:54 +0200)]
MEDIUM: config: replace ssl_conf by bind_conf
Some settings need to be merged per-bind config line and are not necessarily
SSL-specific. It becomes quite inconvenient to have this ssl_conf SSL-specific,
so let's replace it with something more generic.
Willy Tarreau [Wed, 12 Sep 2012 20:58:11 +0000 (22:58 +0200)]
REORG: split "protocols" files into protocol and listener
It was becoming confusing to have protocols and listeners in the same
files, split them.
Willy Tarreau [Fri, 14 Sep 2012 09:40:36 +0000 (11:40 +0200)]
MINOR: config: add a function to indent error messages
Bind parsers may return multiple errors, so let's make use of a new function
to re-indent multi-line error messages so that they're all reported in their
context.
Willy Tarreau [Fri, 14 Sep 2012 21:56:58 +0000 (23:56 +0200)]
BUG/MAJOR: ssl: missing tests in ACL fetch functions
Baptiste Assmann observed a crash of 1.5-dev12 occuring when the ssl_sni
fetch was used with no SNI on the input connection and without a prior
has_sni check. A code review revealed several issues :
1) it was possible to call the has_sni and ssl_sni fetch functions with
a NULL data_ctx if the handshake fails or if the connection is aborted
during the handshake.
2) when no SNI is present, strlen() was called with a NULL parameter in
smp_fetch_ssl_sni().
Guillaume Castagnino [Thu, 13 Sep 2012 13:02:53 +0000 (15:02 +0200)]
DOC: duplicate ssl_sni section
I noticed that the ssl_sni section is duplicated in configuration. Here
is the (very) small fix.
Willy Tarreau [Wed, 12 Sep 2012 06:43:15 +0000 (08:43 +0200)]
MEDIUM: http: add "redirect scheme" to ease HTTP to HTTPS redirection
For instance :
redirect scheme https if !{ is_ssl }
Willy Tarreau [Mon, 10 Sep 2012 07:46:55 +0000 (09:46 +0200)]
[RELEASE] Released version 1.5-dev12
Released version 1.5-dev12 with the following main changes :
- CONTRIB: halog: sort URLs by avg bytes_read or total bytes_read
- MEDIUM: ssl: add support for prefer-server-ciphers option
- MINOR: IPv6 support for transparent proxy
- MINOR: protocol: add SSL context to listeners if USE_OPENSSL is defined
- MINOR: server: add SSL context to servers if USE_OPENSSL is defined
- MEDIUM: connection: add a new handshake flag for SSL (CO_FL_SSL_WAIT_HS).
- MEDIUM: ssl: add new files ssl_sock.[ch] to provide the SSL data layer
- MEDIUM: config: add the 'ssl' keyword on 'bind' lines
- MEDIUM: config: add support for the 'ssl' option on 'server' lines
- MEDIUM: ssl: protect against client-initiated renegociation
- BUILD: add optional support for SSL via the USE_OPENSSL flag
- MEDIUM: ssl: add shared memory session cache implementation.
- MEDIUM: ssl: replace OpenSSL's session cache with the shared cache
- MINOR: ssl add global setting tune.sslcachesize to set SSL session cache size.
- MEDIUM: ssl: add support for SNI and wildcard certificates
- DOC: Typos cleanup
- DOC: fix name for "option independant-streams"
- DOC: specify the default value for maxconn in the context of a proxy
- BUG/MINOR: to_log erased with unique-id-format
- LICENSE: add licence exception for OpenSSL
- BUG/MAJOR: cookie prefix doesn't support cookie-less servers
- BUILD: add an AIX 5.2 (and later) target.
- MEDIUM: fd/si: move peeraddr from struct fdinfo to struct connection
- MINOR: halog: use the more recent dual-mode fgets2 implementation
- BUG/MEDIUM: ebtree: ebmb_insert() must not call cmp_bits on full-length matches
- CLEANUP: halog: make clean should also remove .o files
- OPTIM: halog: make use of memchr() on platforms which provide a fast one
- OPTIM: halog: improve cold-cache behaviour when loading a file
- BUG/MINOR: ACL implicit arguments must be created with unresolved flag
- MINOR: replace acl_fetch_{path,url}* with smp_fetch_*
- MEDIUM: pattern: add the "base" sample fetch method
- OPTIM: i386: make use of kernel-mode-linux when available
- BUG/MINOR: tarpit: fix condition to return the HTTP 500 message
- BUG/MINOR: polling: some events were not set in various pollers
- MINOR: http: add the urlp_val ACL match
- BUG: stktable: tcp_src_to_stktable_key() must return NULL on invalid families
- MINOR: stats/cli: add plans to support more stick-table actions
- MEDIUM: stats/cli: add support for "set table key" to enter values
- REORG/MEDIUM: fd: remove FD_STCLOSE from struct fdtab
- REORG/MEDIUM: fd: remove checks for FD_STERROR in ev_sepoll
- REORG/MEDIUM: fd: get rid of FD_STLISTEN
- REORG/MINOR: connection: move declaration to its own include file
- REORG/MINOR: checks: put a struct connection into the server
- MINOR: connection: add flags to the connection struct
- MAJOR: get rid of fdtab[].state and use connection->flags instead
- MINOR: fd: add a new I/O handler to fdtab
- MEDIUM: polling: prepare to call the iocb() function when defined.
- MEDIUM: checks: make use of fdtab->iocb instead of cb[]
- MEDIUM: protocols: use the generic I/O callback for accept callbacks
- MINOR: connection: add a handler for fd-based connections
- MAJOR: connection: replace direct I/O callbacks with the connection callback
- MINOR: fd: make fdtab->owner a connection and not a stream_interface anymore
- MEDIUM: connection: remove the FD_POLL_* flags only once
- MEDIUM: connection: extract the send_proxy callback from proto_tcp
- MAJOR: tcp: remove the specific I/O callbacks for TCP connection probes
- CLEANUP: remove the now unused fdtab direct I/O callbacks
- MAJOR: remove the stream interface and task management code from sock_*
- MEDIUM: stream_interface: pass connection instead of fd in sock_ops
- MEDIUM: stream_interface: centralize the SI_FL_ERR management
- MAJOR: connection: add a new CO_FL_CONNECTED flag
- MINOR: rearrange tcp_connect_probe() and fix wrong return codes
- MAJOR: connection: call data layer handshakes from the handler
- MEDIUM: fd: remove the EV_FD_COND_* primitives
- MINOR: sock_raw: move calls to si_data_close upper
- REORG: connection: replace si_data_close() with conn_data_close()
- MEDIUM: sock_raw: introduce a read0 callback that is different from shutr
- MAJOR: stream_int: use a common stream_int_shut*() functions regardless of the data layer
- MAJOR: fd: replace all EV_FD_* macros with new fd_*_* inline calls
- MEDIUM: fd: add fd_poll_{recv,send} for use when explicit polling is required
- MEDIUM: connection: add definitions for dual polling mechanisms
- MEDIUM: connection: make use of the new polling functions
- MAJOR: make use of conn_{data|sock}_{poll|stop|want}* in connection handlers
- MEDIUM: checks: don't use FD_WAIT_* anymore
- MINOR: fd: get rid of FD_WAIT_*
- MEDIUM: stream_interface: offer a generic function for connection updates
- MEDIUM: stream-interface: offer a generic chk_rcv function for connections
- MEDIUM: stream-interface: add a snd_buf() callback to sock_ops
- MEDIUM: stream-interface: provide a generic stream_int_chk_snd_conn() function
- MEDIUM: stream-interface: provide a generic si_conn_send_cb callback
- MEDIUM: stream-interface: provide a generic stream_sock_read0() function
- REORG/MAJOR: use "struct channel" instead of "struct buffer"
- REORG/MAJOR: extract "struct buffer" from "struct channel"
- MINOR: connection: provide conn_{data|sock}_{read0|shutw} functions
- REORG: sock_raw: rename the files raw_sock*
- MAJOR: raw_sock: extract raw_sock_to_buf() from raw_sock_read()
- MAJOR: raw_sock: temporarily disable splicing
- MINOR: stream-interface: add an rcv_buf callback to sock_ops
- REORG: stream-interface: move sock_raw_read() to si_conn_recv_cb()
- MAJOR: connection: split the send call into connection and stream interface
- MAJOR: stream-interface: restore splicing mechanism
- MAJOR: stream-interface: make conn_notify_si() more robust
- MEDIUM: proxy-proto: don't use buffer flags in conn_si_send_proxy()
- MAJOR: stream-interface: don't commit polling changes in every callback
- MAJOR: stream-interface: fix splice not to call chk_snd by itself
- MEDIUM: stream-interface: don't remove WAIT_DATA when a handshake is in progress
- CLEANUP: connection: split sock_ops into data_ops, app_cp and si_ops
- REORG: buffers: split buffers into chunk,buffer,channel
- MAJOR: channel: remove the BF_OUT_EMPTY flag
- REORG: buffer: move buffer_flush, b_adv and b_rew to buffer.h
- MINOR: channel: rename bi_full to channel_full as it checks the whole channel
- MINOR: buffer: provide a new buffer_full() function
- MAJOR: channel: stop relying on BF_FULL to take action
- MAJOR: channel: remove the BF_FULL flag
- REORG: channel: move buffer_{replace,insert_line}* to buffer.{c,h}
- CLEANUP: channel: usr CF_/CHN_ prefixes instead of BF_/BUF_
- CLEANUP: channel: use "channel" instead of "buffer" in function names
- REORG: connection: move the target pointer from si to connection
- MAJOR: connection: move the addr field from the stream_interface
- MEDIUM: stream_interface: remove CAP_SPLTCP/CAP_SPLICE flags
- MEDIUM: proto_tcp: remove any dependence on stream_interface
- MINOR: tcp: replace tcp_src_to_stktable_key with addr_to_stktable_key
- MEDIUM: connection: add an ->init function to data layer
- MAJOR: session: introduce embryonic sessions
- MAJOR: connection: make the PROXY decoder a handshake handler
- CLEANUP: frontend: remove the old proxy protocol decoder
- MAJOR: connection: rearrange the polling flags.
- MEDIUM: connection: only call tcp_connect_probe when nothing was attempted yet
- MEDIUM: connection: complete the polling cleanups
- MEDIUM: connection: avoid calling handshakes when polling is required
- MAJOR: stream_interface: continue to update data polling flags during handshakes
- CLEANUP: fd: remove fdtab->flags
- CLEANUP: fdtab: flatten the struct and merge the spec struct with the rest
- CLEANUP: includes: fix includes for a number of users of fd.h
- MINOR: ssl: disable TCP quick-ack by default on SSL listeners
- MEDIUM: config: add a "ciphers" keyword to set SSL cipher suites
- MEDIUM: config: add "nosslv3" and "notlsv1" on bind and server lines
- BUG: ssl: mark the connection as waiting for an SSL connection during the handshake
- BUILD: http: rename error_message http_error_message to fix conflicts on RHEL
- BUILD: ssl: fix shctx build on RHEL with futex
- BUILD: include sys/socket.h to fix build failure on FreeBSD
- BUILD: fix build error without SSL (ssl_cert)
- BUILD: ssl: use MAP_ANON instead of MAP_ANONYMOUS
- BUG/MEDIUM: workaround an eglibc bug which truncates the pidfiles when nbproc > 1
- MEDIUM: config: support per-listener backlog and maxconn
- MINOR: session: do not send an HTTP/500 error on SSL sockets
- MEDIUM: config: implement maxsslconn in the global section
- BUG: tcp: close socket fd upon connect error
- MEDIUM: connection: improve error handling around the data layer
- MINOR: config: make the tasks "nice" value configurable on "bind" lines.
- BUILD: shut a gcc warning introduced by commit 269ab31
- MEDIUM: config: centralize handling of SSL config per bind line
- BUILD: makefile: report USE_OPENSSL status in build options
- BUILD: report openssl build settings in haproxy -vv
- MEDIUM: ssl: add sample fetches for is_ssl, ssl_has_sni, ssl_sni_*
- DOC: add a special acknowledgement for the stud project
- DOC: add missing SSL options for servers and listeners
- BUILD: automatically add -lcrypto for SSL
- DOC: add some info about openssl build in the README
Willy Tarreau [Mon, 10 Sep 2012 07:07:41 +0000 (09:07 +0200)]
DOC: add some info about openssl build in the README
Willy Tarreau [Mon, 10 Sep 2012 07:11:22 +0000 (09:11 +0200)]
BUILD: automatically add -lcrypto for SSL
Some platforms need it. Libz is still not enabled by default because there is
no reason to add this dependency everywhere by default.
Willy Tarreau [Mon, 10 Sep 2012 07:01:23 +0000 (09:01 +0200)]
DOC: add missing SSL options for servers and listeners
Willy Tarreau [Mon, 10 Sep 2012 07:43:09 +0000 (09:43 +0200)]
DOC: add a special acknowledgement for the stud project
Really, the quality of their code deserves it, it would have been much
harder to figure how to get all the things right at once without looking
there from time to time !
Willy Tarreau [Mon, 10 Sep 2012 06:20:03 +0000 (08:20 +0200)]
MEDIUM: ssl: add sample fetches for is_ssl, ssl_has_sni, ssl_sni_*
This allows SNI presence and value to be checked on incoming SSL connections.
It is usable both for ACLs and stick tables.
Willy Tarreau [Mon, 10 Sep 2012 05:16:05 +0000 (07:16 +0200)]
BUILD: report openssl build settings in haproxy -vv
Since it's common enough to discover that some config options are not
supported due to some openssl version or build options, we report the
relevant ones in "haproxy -vv".
Emeric Brun [Fri, 7 Sep 2012 15:30:07 +0000 (17:30 +0200)]
MEDIUM: ssl: add support for SNI and wildcard certificates
A side effect of this change is that the "ssl" keyword on "bind" lines is now
just a boolean and that "crt" is needed to designate certificate files or
directories.
Note that much refcounting was needed to have the free() work correctly due to
the number of cert aliases which can make a context be shared by multiple names.
Baptiste [Sat, 8 Sep 2012 21:10:03 +0000 (23:10 +0200)]
CONTRIB: halog: sort URLs by avg bytes_read or total bytes_read
The patch attached to this mail brings ability to sort URLs by
averaged bytes read and total bytes read in HALog tool.
In most cases, bytes read is also the object size.
The purpose of this patch is to know which URL consume the most
bandwith, in average or in total.
It may be interesting as well to know the standard deviation (ecart
type in french) for some counters (like bytes_read).
The results:
- Sorting by average bytes read per URL:
./halog -uba <~/tmp/haproxy.log | column -t | head
2246 lines in, 302 lines out, 194 parsing errors
18 0 5101 283 5101 283 126573 2278327 /lib/exe/js.php
1 0 1 1 1 1 106734 106734 /wp-admin/images/screenshots/theme-customizer.png
2 0 2 1 2 1 106511 213022 /wp-admin/css/wp-admin.css
1 0 1 1 1 1 96698 96698 /wp-admin/images/screenshots/captions-1.png
1 0 1 1 1 1 73165 73165 /wp-admin/images/screenshots/flex-header-1.png
4 0 0 0 0 0 64832 259328 /cuisine/wp-content/plugins/stats/open-flash-chart.swf
1 0 0 0 0 0 48647 48647 /wp-admin/images/screenshots/flex-header-3.png
1 0 0 0 0 0 44046 44046 /wp-admin/images/screenshots/captions-2.png
1 0 1 1 1 1 38830 38830 /wp-admin/images/screenshots/flex-header-2.png
- Sorting by total bytes read per URL:
./halog -ubt <~/tmp/haproxy.log | column -t | head
2246 lines in, 302 lines out, 194 parsing errors
18 0 5101 283 5101 283 126573 2278327 /lib/exe/js.php
60 0 14387 239 14387 239 10081 604865 /lib/exe/css.php
64 2 8820 137 8819 142 7742 495524 /doku.php
14 0 250 17 250 17 24045 336632 /wp-admin/load-scripts.php
71 0 6422 90 6422 90 4048 287419 /wp-admin/
4 0 0 0 0 0 64832 259328 /cuisine/wp-content/plugins/stats/open-flash-chart.swf
2 0 2 1 2 1 106511 213022 /wp-admin/css/wp-admin.css
31 3 5423 174 5040 180 6804 210931 /index
10 0 429 42 429 42 18009 180093 /cuisine/files/2011/10/tarte_figue_amande-
e1318281546905-225x300.jpg
Willy Tarreau [Sat, 8 Sep 2012 09:28:56 +0000 (11:28 +0200)]
BUILD: makefile: report USE_OPENSSL status in build options
Willy Tarreau [Fri, 7 Sep 2012 14:58:00 +0000 (16:58 +0200)]
MEDIUM: config: centralize handling of SSL config per bind line
SSL config holds many parameters which are per bind line and not per
listener. Let's use a per-bind line config instead of having it
replicated for each listener.
At the moment we only do this for the SSL part but this should probably
evolved to handle more of the configuration and maybe even the state per
bind line.
Willy Tarreau [Fri, 7 Sep 2012 20:18:59 +0000 (22:18 +0200)]
BUILD: shut a gcc warning introduced by commit 269ab31
Usual warning on unchecked write() on which no operation is possible.
William Lallemand [Fri, 7 Sep 2012 08:48:59 +0000 (10:48 +0200)]
LICENSE: add licence exception for OpenSSL
According to OpenSSL FAQ, GPL programs need an exception to use OpenSSL.
http://openssl.org/support/faq.html#LEGAL2
Willy Tarreau [Thu, 6 Sep 2012 12:26:36 +0000 (14:26 +0200)]
MINOR: config: make the tasks "nice" value configurable on "bind" lines.
This is very convenient to reduce SSL processing priority compared to
other traffic. This applies to CPU usage only, but has a direct impact
on latency under congestion.
Willy Tarreau [Thu, 6 Sep 2012 12:12:03 +0000 (14:12 +0200)]
MEDIUM: connection: improve error handling around the data layer
Better avoid calling the data functions upon error or handshake than
having to put conditions everywhere, which are too easy to forget (one
check for CO_FL_ERROR was missing, but this was harmless).
Willy Tarreau [Thu, 6 Sep 2012 12:04:41 +0000 (14:04 +0200)]
BUG: tcp: close socket fd upon connect error
When the data layer fails to initialize (eg: out of memory for SSL), we
must close the socket fd we just allocated.
Willy Tarreau [Thu, 6 Sep 2012 09:58:37 +0000 (11:58 +0200)]
MEDIUM: config: implement maxsslconn in the global section
SSL connections take a huge amount of memory, and unfortunately openssl
does not check malloc() returns and easily segfaults when too many
connections are used.
The only solution against this is to provide a global maxsslconn setting
to reject SSL connections above the limit in order to avoid reaching
unsafe limits.
Willy Tarreau [Thu, 6 Sep 2012 09:32:07 +0000 (11:32 +0200)]
MINOR: session: do not send an HTTP/500 error on SSL sockets
If a session fails its initialization, we don't want to send HTTP/500
over the socket if it's not a raw data layer.
Willy Tarreau [Thu, 6 Sep 2012 09:10:55 +0000 (11:10 +0200)]
MEDIUM: config: support per-listener backlog and maxconn
With SSL, connections are much more expensive, so it is important to be
able to limit concurrent connections per listener in order to limit the
memory usage.
Willy Tarreau [Wed, 5 Sep 2012 06:02:48 +0000 (08:02 +0200)]
BUG/MEDIUM: workaround an eglibc bug which truncates the pidfiles when nbproc > 1
Thomas Heil reported that when using nbproc > 1, his pidfiles were
regularly truncated. The issue could be tracked down to the presence
of a call to lseek(pidfile, 0, SEEK_SET) just before the close() call
in the children, resulting in the file being truncated by the children
while the parent was feeding it. This unexpected lseek() is transparently
performed by fclose().
Since there is no way to have the file automatically closed during the
fork, the only solution is to bypass the libc and use open/write/close
instead of fprintf() and fclose().
The issue was observed on eglibc 2.15.